Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @height = 6
- @jmp_size = 3
- @walls = {0=>{0=>0, 1=>0, 2=>0, 3=>1, 4=>0, 5=>0, 6=>1},
- 1=>{0=>0, 1=>1, 2=>0, 3=>0, 4=>1, 5=>1, 6=>0}}
- @position = 0
- @current_wall = 0
- def progress
- while (@position < @height) do
- (@walls[@current_wall][@position+1] == 0) ? @position++ : jump //No idea why this isnt working
- end
- end
- def alternate
- if @current_wall == 0
- @current_wall = 1
- else
- @current_wall = 0
- end
- end
- def jump
- alternate
- @position+=@jmp_size
- if @walls[@current_wall][@position] == 1
- @position-(@jmp_size+1) and alternate
- jump
- elsif @position > @height
- puts 'YES'
- else
- progress
- end
- end
- progress
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement