Done puzzle 47
[project-euler.git] / euler-4-old.rb
1 num = 1
2 dem = 1
3
4 directions = [:left, :back, :down, :forward]
5
6 direction = :left
7
8 10.times do
9 puts "#{num}/#{dem}, dir = #{direction}"
10 case direction
11 when :left
12 num += 1
13 direction = :back
14 when :down
15 dem += 1
16 direction = :forward
17 when :back
18 if num > 1
19 num -= 1
20 else
21 direction = :forward
22 end
23 dem += 1
24 when :forward
25 if dem > 1
26 dem -= 1
27 else
28 direction = :back
29 end
30 num += 1
31 end
32 end
33
34
35
36
37