|  |  | @ -29,17 +29,17 @@ let read_cell map x y = (* return Some char at these coordinates, or None if bel | 
			
		
	
		
		
			
				
					
					|  |  |  |   then Some (List.nth (List.nth map x) (wrapped_y y map)) |  |  |  |   then Some (List.nth (List.nth map x) (wrapped_y y map)) | 
			
		
	
		
		
			
				
					
					|  |  |  |   else None |  |  |  |   else None | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | let rec go map position slope count = (* move across the map, counting trees *) |  |  |  | let rec go map position slope = (* move across the map, counting trees *) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |   let (x, y) = position in |  |  |  |   let (x, y) = position in | 
			
		
	
		
		
			
				
					
					|  |  |  |   let (dy, dx) = slope in (* suddenly regretting having x be the vertical axis.. *) |  |  |  |   let (dy, dx) = slope in (* suddenly regretting having x be the vertical axis.. *) | 
			
		
	
		
		
			
				
					
					|  |  |  |   match read_cell map x y with |  |  |  |   match read_cell map x y with | 
			
		
	
		
		
			
				
					
					|  |  |  |   | None -> count (* off the map. stop counting *) |  |  |  |   | None -> 0 (* off the map! stop counting *) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   | Some '#' -> go map (x+dx, y+dy) slope (count+1) |  |  |  |   | Some '#' -> 1 + go map (x+dx, y+dy) slope | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   | Some a -> go map (x+dx, y+dy) slope count |  |  |  |   | Some a -> go map (x+dx, y+dy) slope | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | let map = read_file "day3.txt" |> List.map explode |  |  |  | let map = read_file "day3.txt" |> List.map explode | 
			
		
	
		
		
			
				
					
					|  |  |  | let slopes = [(1, 1); (3, 1); (5, 1); (7, 1); (1, 2)] |  |  |  | let slopes = [(1, 1); (3, 1); (5, 1); (7, 1); (1, 2)] | 
			
		
	
		
		
			
				
					
					|  |  |  | let tree_counts = slopes |> List.map (fun slope -> go map (0, 0) slope 0);; |  |  |  | let tree_counts = slopes |> List.map (fun slope -> go map (0, 0) slope);; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | List.iter (fun count -> Printf.printf "Number of trees: %i\n" count) tree_counts;; |  |  |  | List.iter (fun count -> Printf.printf "Number of trees: %i\n" count) tree_counts;; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | 
 |