Created
August 26, 2014 02:58
-
-
Save Macariom01/d88cd0780df4f8ea50db to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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