done 2017.05.1
This commit is contained in:
		
							parent
							
								
									2a8ca5a657
								
							
						
					
					
						commit
						50802d3c8c
					
				
							
								
								
									
										24
									
								
								2017/05/1trampoline-maze.py
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										24
									
								
								2017/05/1trampoline-maze.py
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,24 @@ | ||||
| #!/usr/bin/env python3 | ||||
| 
 | ||||
| # input file has an integer on every line | ||||
| # pointer starts at the first line | ||||
| # each 'jump' moves by the value of the line | ||||
| # positive goes downward, negative goes upward | ||||
| # after the jump, increment the jumping-off line by +1 | ||||
| 
 | ||||
| if __name__ == '__main__': | ||||
|     with open("input", "r", encoding="utf-8") as maze_file: | ||||
|         maze_strings = maze_file.readlines() | ||||
|         maze_size = len(maze_strings) | ||||
|         maze_ints = [] | ||||
|         for i in range(maze_size): | ||||
|             maze_ints.append(int(maze_strings[i])) | ||||
|         pointer = 0 | ||||
|         jumps = 0 | ||||
|         while pointer < maze_size and pointer >= 0: | ||||
|             current_value = maze_ints[pointer] | ||||
|             maze_ints[pointer] = current_value + 1 | ||||
|             jumps += 1 | ||||
|             pointer += current_value | ||||
|         print(f'finally, jumping from {current_value} at {pointer - current_value}, you missed {pointer}!') | ||||
|         print(f'it took {jumps} jumps!') | ||||
							
								
								
									
										1074
									
								
								2017/05/input
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1074
									
								
								2017/05/input
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user