Skip to content

Instantly share code, notes, and snippets.

@iagox86
Created July 29, 2014 22:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iagox86/eee470b683a347dcdd4b to your computer and use it in GitHub Desktop.
Save iagox86/eee470b683a347dcdd4b to your computer and use it in GitHub Desktop.
require 'pp'
CIPHER = ["",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
""]
i = 10
j = 9
dir = :right
length = 1
current_length = 0
puts(CIPHER[i][j])
word = ""
loop do
word += CIPHER[i][j]
puts(word)
if(dir == :right)
j += 1
elsif(dir == :left)
j -= 1
elsif(dir == :up)
i -= 1
else
i += 1
end
if(j < 0 || j > 20 || i < 0 || i > 20)
break
end
current_length += 1
if(current_length == length.floor)
length += 0.5
current_length = 0
if(dir == :right)
dir = :up
elsif(dir == :left)
dir = :down
elsif(dir == :up)
dir = :left
else
dir = :right
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment