day 6, easy peazy
This commit is contained in:
		
							
								
								
									
										30
									
								
								d06/part1.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								d06/part1.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,30 @@
 | 
			
		||||
 | 
			
		||||
SAMPLE = [
 | 
			
		||||
#Time:	Distance:
 | 
			
		||||
(7,	9),
 | 
			
		||||
(15,	40),
 | 
			
		||||
(30,	200),
 | 
			
		||||
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
INPUT = [
 | 
			
		||||
(40,	219),
 | 
			
		||||
(81,	1012),
 | 
			
		||||
(77,	1365),
 | 
			
		||||
(72,	1089),
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
L = SAMPLE
 | 
			
		||||
L=INPUT
 | 
			
		||||
R = 1
 | 
			
		||||
for (t,r) in L:  # time, record
 | 
			
		||||
	S = 0
 | 
			
		||||
	for i in range(t):  # hold for i
 | 
			
		||||
		v = i # speed in m/s
 | 
			
		||||
		d = v * (t-i)
 | 
			
		||||
		if d > r:
 | 
			
		||||
			S += 1
 | 
			
		||||
	print(S)
 | 
			
		||||
	R *= S
 | 
			
		||||
print(R)
 | 
			
		||||
							
								
								
									
										10
									
								
								d06/part2.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								d06/part2.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
			
		||||
import sys
 | 
			
		||||
 | 
			
		||||
(t,r) = (int(sys.argv[1]), int(sys.argv[2]))
 | 
			
		||||
 | 
			
		||||
print(
 | 
			
		||||
	# i : time of charging, between 0 and t
 | 
			
		||||
	# v = i # speed in m/s
 | 
			
		||||
	# d = v * (t-i)  # distance
 | 
			
		||||
	sum(i*(t-i) > r for i in range(t))
 | 
			
		||||
)
 | 
			
		||||
		Reference in New Issue
	
	Block a user