File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ from  typing  import  List 
2+ 
3+ 
4+ def  perform_inserts (steps : int , inserts : int ) ->  List [int ]:
5+     circle  =  [0 ]
6+     pos  =  0 
7+     for  i  in  range (1 , inserts  +  1 ):
8+         pos  =  (pos  +  steps ) %  len (circle ) +  1 
9+         circle .insert (pos , i )
10+     return  circle 
11+ 
12+ 
13+ def  part1 (steps : int ) ->  int :
14+     target  =  2017 
15+     circle  =  perform_inserts (steps , target )
16+     index  =  circle .index (target ) +  1 
17+     return  circle [index  %  len (circle )]
18+ 
19+ 
20+ def  part2 (steps : int ) ->  int :
21+     target  =  50000000 
22+     after_zero  =  None 
23+     pos  =  0 
24+     size  =  1 
25+     for  i  in  range (1 , target  +  1 ):
26+         pos  =  (pos  +  steps ) %  size  +  1 
27+         if  pos  ==  1 :
28+             after_zero  =  i 
29+         size  +=  1 
30+     return  after_zero 
31+ 
32+ 
33+ steps  =  324 
34+ print ('Part 1:' , part1 (steps ))
35+ print ('Part 2:' , part2 (steps ))
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments