Last active
          September 28, 2019 01:14 
        
      - 
      
- 
        Save colinjfw/f3df25b0b01cdcfe279a8821b821fdfd to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | def move_as_coord(move, head) | |
| case move | |
| when 'up' | |
| return {x: head[:x], y: head[:y]-1} | |
| when 'down' | |
| return {x: head[:x], y: head[:y]+1} | |
| when 'left' | |
| return {x: head[:x]-1, y: head[:y]} | |
| when 'right' | |
| return {x: head[:x]+1, y: head[:y]} | |
| end | |
| end | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment