Skip to content

Commit

Permalink
variable name change
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown authored and unknown committed Feb 12, 2015
1 parent a83cac3 commit d66a0ad
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/diamond_generator.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
class DiamondGenerator
def generate(letter)
result = []
topDiamond = []
letter_distance = letter.ord - 'A'.ord
(0..letter_distance).each do |index|
current_letter = ('A'.ord + index).chr
if index == 0
result << ' '*letter_distance + current_letter + ' '*letter_distance
topDiamond << ' '*letter_distance + current_letter + ' '*letter_distance
else
result << ' '*(letter_distance-index) + current_letter + ' '*(2*index-1) + current_letter + ' '*(letter_distance-index)
topDiamond << ' '*(letter_distance-index) + current_letter + ' '*(2*index-1) + current_letter + ' '*(letter_distance-index)
end
end
result = result + (letter=='A' ? [] : result[0..result.length-2].reverse)
topDiamond + (letter=='A' ? [] : topDiamond[0...topDiamond.length-1].reverse)
end
end

0 comments on commit d66a0ad

Please sign in to comment.