Skip to content

Instantly share code, notes, and snippets.

@timsegraves
Created October 9, 2012 04:03
Show Gist options
  • Select an option

  • Save timsegraves/3856525 to your computer and use it in GitHub Desktop.

Select an option

Save timsegraves/3856525 to your computer and use it in GitHub Desktop.

Revisions

  1. timsegraves created this gist Oct 9, 2012.
    27 changes: 27 additions & 0 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    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