Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def blockPossible(A, bound, K): | |
s = A[0] | |
blocks = 1; | |
for a in A[1:]: | |
s += a | |
if s>bound: | |
blocks+=1 | |
s=a | |
if blocks > K: | |
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# you can use print for debugging purposes, e.g. | |
# print "this is a debug message" | |
def solution(A): | |
n = len(A) | |
MIN_INT = -n * 20000 | |
v = [A[0]]+(n-1)*[MIN_INT] | |
for i in xrange(1, n): | |
for j in xrange(1, 7): | |
if j <= i: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def solution(A, B): | |
# write your code in Python 2.7 | |
pre = -1 | |
N = len(A) | |
ans=0 | |
for i in xrange(N): | |
if A[i] > pre: | |
ans+=1 | |
pre = B[i] | |
return ans |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def solution(A): | |
# write your code in Python 2.7 | |
A.sort() | |
for i in xrange(len(A)-2): | |
if (((A[i] + A[i+1]) > A[i+2]) and ((A[i+2] + A[i+1]) > A[i]) and ((A[i+2] + A[i]) > A[i+1])): | |
return 1 | |
return 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def solution(A): | |
# write your code in Python 2.7 | |
B = [] | |
for i in xrange(len(A)): | |
B.append((i-A[i],i+A[i])) | |
B = sorted(B, key=lambda x:x[0]) | |
cnt = 0 | |
for i in xrange(len(A)-1): | |
right = B[i][1] | |
start = i+1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def solution(A): | |
# write your code in Python 2.7 | |
n = len(A) | |
if n <=3: | |
return 0 | |
leftMax = [0]*n | |
rightMax = [0]*n | |
for i in xrange(2,n-1): | |
leftMax[i] = max(0,leftMax[i-1]+A[i-1]) | |
for i in xrange(n-3,0,-1): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def solution(A): | |
# write your code in Python 2.7 | |
s = [] | |
tmp = 0 | |
n = len(A) | |
for a in A: | |
tmp = a + tmp | |
s.append(tmp) | |
s.append(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void tryBT() | |
{ | |
delay(20000); | |
led_green_flash(); | |
long baudrates[5] = {9600, 19200, 38400, 57600, 115200}; | |
String inputString=""; | |
for (int i =0; i< 5; i++) | |
{ | |
DebugSerial.begin(baudrates[i]); // debug output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import sqrt | |
def solution(N): | |
# write your code in Python 2.7 | |
minperimeter = 2*(N + 1) | |
if N == 1: | |
return minperimeter | |
denominator = 2 |
OlderNewer