some code compaction
This commit is contained in:
		@@ -1,16 +1,4 @@
 | 
			
		||||
NR == 1 {
 | 
			
		||||
	A = $1
 | 
			
		||||
	next
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
$1 > A {
 | 
			
		||||
	N++
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
	A = $1
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
END {
 | 
			
		||||
	print N
 | 
			
		||||
}
 | 
			
		||||
NR == 1 { A = $1; next }
 | 
			
		||||
$1 > A { N++ }
 | 
			
		||||
{ A = $1 }
 | 
			
		||||
END { print N }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,10 @@
 | 
			
		||||
import sys
 | 
			
		||||
L = [int(l[:-1]) for l in sys.stdin.readlines()]
 | 
			
		||||
print(sum([0,1][a<b] for (a,b) in zip(L, L[3:])))
 | 
			
		||||
print(sum([0,1][a<d] for (a,d) in zip(L, L[3:])))
 | 
			
		||||
 | 
			
		||||
# window1 = [A,B,C] ; window2 = [B,C,D]
 | 
			
		||||
# sum(Window1) <? sum(window2)
 | 
			
		||||
# (A+B+C) <? (B+C+D)
 | 
			
		||||
# (A+B+C)-B-C <? (B+C+D)-B-C
 | 
			
		||||
# A <? D
 | 
			
		||||
# eg: comparing A+B+C and B+C+D is the same as comparing A and D
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user