Skip to content

Instantly share code, notes, and snippets.

View hrubantjakub1's full-sized avatar

Jakub Hrubant hrubantjakub1

  • Prague, Czech Republic
View GitHub Profile
@hrubantjakub1
hrubantjakub1 / MaxDoubleSliceSum
Created April 21, 2017 12:46
maxdoubleslicesum one of codility tasks Java + codesays community solution in Python
// my solution is based on iterating all the list comparing all possible sums and find the max sum.
class Solution {
public static int solution(int[] A) {
int length = A.length;
int max = 0;
int sum = 0;
for (int x = 0; x < length - 4; x++) {
for (int y = x + 2; y < length - 2; y++) {
for (int z = y + 2; z < length; z++) {
for (int l = x + 1; l <= (y - 1); l++) {
@hrubantjakub1
hrubantjakub1 / MaxCounters
Last active April 21, 2017 14:09
my solution for MaxCounters codility task in Python + codesays community solution, solved in Python
def solution (N, A):
counters = [0] * N # number_of_counters
for K in A:
if 1 <= K <= N:
counters[K-1] += 1
elif K > N:
max_value = max(counters)
for index in range(len(counters)):
counters[index] = max_value
return counters
@hrubantjakub1
hrubantjakub1 / solution for frog jump java
Created April 20, 2017 12:28
codility solution for frog jump in java
// Task is to find out how many jumps is needed to get from distance X to Y. Length of every jump is D.
it is one of codility tasks
class Solution {
// X = beginning, Y = finish, D = distance
public int solution(int X, int Y, int D) {
int state = X;
int count = 0;
while (state < Y) {
state = state + D;
// find element without pair in array
def solution(A):
A.sort()
for index in range(0,len(A),2):
if A[index] != A[index+1]:
return A[index]
B = [5,6,2,9,2,3,6,7,3,1,7,9,1]
print(solution(B))
@hrubantjakub1
hrubantjakub1 / OddOccurrencesInArray python
Last active April 21, 2017 14:32
my solution for codility task
// find odd element in array
def solution(A):
accessed = [False] * len(A)
randit = len(A)
for a in range(len(A)):
if accessed[a] == False:
for b in range(len(A)):
if a == b:
continue
if accessed[b] == False: