Created
October 9, 2012 04:03
-
-
Save timsegraves/3856525 to your computer and use it in GitHub Desktop.
Cube for Austin
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
str = "JAYHAWK" | |
i = 0 | |
j = 0 | |
builder = "" | |
# Each item in this loop will be a new line in your cube | |
while i < str.length do | |
# Reset the variables (won't need to do this in java for loops) | |
builder = "" | |
j = i | |
k = 0 | |
# This loop starts at the current position of i (so for the second line it would print AYHAWK) | |
while j < str.length do | |
# This is the same thing as builder = builder + userInput.charAt(j) | |
builder << str[j] | |
j = j + 1 | |
end | |
# This loops starts at position 0 and goes to the number of lines we're on (for the second line it would print J) | |
while k < i do | |
builder << str[k] | |
k = k + 1 | |
end | |
i = i + 1 | |
puts builder | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment