Skip to content

Instantly share code, notes, and snippets.

@Macariom01
Created August 26, 2014 02:58
Show Gist options
  • Save Macariom01/d88cd0780df4f8ea50db to your computer and use it in GitHub Desktop.
Save Macariom01/d88cd0780df4f8ea50db to your computer and use it in GitHub Desktop.
# A simple exercise in Ruby for substituting X for E in the alphabet
# and using nested loops to print each letter.
# Make sure you have Ruby 1.9 or above installed
# then to run simply type ruby then the file name
alpha = ('A'..'Z').to_a
alpha.to_s
i = 0
while i < alpha.length do
count = 0
while count <= i do
if alpha[count] == 'E'
print 'X'
else
print "#{alpha[count]}"
end
count += 1
end
puts
i += 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment