day 1
This commit is contained in:
		
							
								
								
									
										16
									
								
								d01/d01_1.awk
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								d01/d01_1.awk
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,16 @@
 | 
				
			|||||||
 | 
					NR == 1 {
 | 
				
			||||||
 | 
						A = $1
 | 
				
			||||||
 | 
						next
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					$1 > A {
 | 
				
			||||||
 | 
						N++
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						A = $1
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					END {
 | 
				
			||||||
 | 
						print N
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										8
									
								
								d01/d01_2.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								d01/d01_2.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
				
			|||||||
 | 
					import sys
 | 
				
			||||||
 | 
					L = [ int(l[:-1]) for l in sys.stdin.readlines() ]
 | 
				
			||||||
 | 
					Z = zip(L, L[1:], L[2:])
 | 
				
			||||||
 | 
					M = [ a+b+c for (a,b,c) in Z]
 | 
				
			||||||
 | 
					Y = zip(M, M[1:])
 | 
				
			||||||
 | 
					P = [ [0,1][a<b] for (a,b) in Y ]
 | 
				
			||||||
 | 
					#print([(l,m,p) for (l,m,p) in zip(L,M,P)])
 | 
				
			||||||
 | 
					print(sum(P))
 | 
				
			||||||
							
								
								
									
										10
									
								
								d01/sample
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								d01/sample
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
				
			|||||||
 | 
					199
 | 
				
			||||||
 | 
					200
 | 
				
			||||||
 | 
					208
 | 
				
			||||||
 | 
					210
 | 
				
			||||||
 | 
					200
 | 
				
			||||||
 | 
					207
 | 
				
			||||||
 | 
					240
 | 
				
			||||||
 | 
					269
 | 
				
			||||||
 | 
					260
 | 
				
			||||||
 | 
					263
 | 
				
			||||||
		Reference in New Issue
	
	Block a user