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 | |
diffs = [] | |
sum_a = 0 | |
for i in range(len(A)): | |
sum_a += A[i] | |
sum_b = 0 | |
for i in range(0, len(A)-1): | |
sum_b += A[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
import math | |
def solution(X, Y, D): | |
if D < 0: | |
return 0 | |
steps = math.ceil((abs(Y-X)) / float(D)) | |
print steps | |
steps = int(steps) | |
return steps |
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): | |
m = len(A) + 1 | |
expected_sum = (m * (m+1)) / 2 | |
return expected_sum - sum(A) | |
# https://codility.com/demo/results/demo4C4YQX-MX2/ | |
# O(N) or O(N * log(N)) |
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(X, A): | |
if len(A) <= 0 or X <= 0: | |
return -1 | |
d = dict(zip(range(1, X+1), [0] * (X+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
# you can use print for debugging purposes, e.g. | |
# print "this is a debug message" | |
def solution(A): | |
d = dict(zip(range(1, len(A) + 1), [0] * (len(A) + 1) )) | |
result = 0 | |
for i in A: | |
if i in d: | |
d.pop(i) | |
if not d: | |
result = 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): | |
d = {} | |
result = 0 | |
for i in range(len(A)): | |
if A[i] not in d and A[i] >= 1: | |
d[A[i]] = 0 | |
j = 1 | |
while j <= 100010: | |
if not j in d: | |
result = j |
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
#!/usr/bin/env python | |
def solution(N, A): | |
counters = [0] * N | |
max_counter = 0 | |
all_inc = 0 | |
N1 = N + 1 | |
for i in range(len(A)): |
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
#https://codility.com/demo/results/demoRPXRJY-QA4/ | |
def solution(A, B, K): | |
result = B // K - A // K | |
if A % K == 0: # Additional one | |
result += 1 | |
return result |
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
# https://codility.com/demo/results/demoHUQZ5G-SSR/ | |
def solution(A): | |
if len(A) <= 0: | |
return -1 | |
result = 0 | |
multiplier = 0 | |
for i in range(len(A)): | |
if A[i] == 0: | |
multiplier += 1 | |
else: |
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
### Keybase proof | |
I hereby claim: | |
* I am arastogi19 on github. | |
* I am halite (https://keybase.io/halite) on keybase. | |
* I have a public key ASCLQWEfIXRfxPeuS6LzN6jRO5MSU-BEtV7iCp6nb09fFQo | |
To claim this, I am signing this object: |
OlderNewer