Skip to content

Instantly share code, notes, and snippets.

View gbazilio's full-sized avatar

Guilherme Bazilio gbazilio

View GitHub Profile
@gbazilio
gbazilio / max-counter.py
Created January 22, 2017 14:56
Codility - Max Counter
def solution(N, A):
max_counter = last_max_counter = 0
counters = [0] * N
for k in xrange(len(A)):
current_counter = A[k]
if current_counter == N+1:
last_max_counter = max_counter
else:
@gbazilio
gbazilio / passing-cars.py
Created January 29, 2017 13:34
Codility - Passing cars
def solution(A):
passing_cars = 0
east_cars = 0
for index in xrange(len(A)):
if A[index] == 1:
passing_cars += east_cars
else:
east_cars += 1
@gbazilio
gbazilio / genomic-query.py
Created January 29, 2017 16:25
Codility - Genomic range query
def solution(S, P, Q):
m_size = len(P)
count_size = len(S) + 1
A = [0] * count_size
C = [0] * count_size
G = [0] * count_size
for i in xrange(len(S)):
nucleotide = S[i]
A[i + 1] += A[i] + (1 if nucleotide == 'A' else 0)