Advertisement
Guest User

Untitled

a guest
Jul 10th, 2012
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.67 KB | None | 0 0
  1. @height = 6
  2. @jmp_size = 3
  3. @walls = {0=>{0=>0, 1=>0, 2=>0, 3=>1, 4=>0, 5=>0, 6=>1},
  4.          1=>{0=>0, 1=>1, 2=>0, 3=>0, 4=>1, 5=>1, 6=>0}}
  5. @position = 0
  6. @current_wall = 0
  7.  
  8. def progress
  9.   while (@position < @height) do
  10.     (@walls[@current_wall][@position+1] == 0) ? @position++ : jump //No idea why this isnt working
  11.   end
  12. end
  13.  
  14. def alternate
  15.   if @current_wall == 0
  16.     @current_wall = 1
  17.   else
  18.     @current_wall = 0
  19.   end
  20. end
  21.  
  22. def jump
  23.   alternate
  24.  
  25.   @position+=@jmp_size
  26.   if @walls[@current_wall][@position] == 1
  27.     @position-(@jmp_size+1) and alternate
  28.     jump
  29.   elsif @position > @height
  30.     puts 'YES'
  31.   else
  32.     progress
  33.   end
  34. end
  35.  
  36. progress
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement