0% found this document useful (0 votes)
386 views

Example Test Report - Codility

This document contains an example test report from Codility. It includes details on 3 tasks that were completed, including their scores and time spent. The first task involves writing an SQL query to calculate the sum of elements in a table and scored 100%. The second task finds the leader value in an array and scored 100%. The third task involves calculating equilibriums in a sequence and scored 70%.

Uploaded by

Srikanth
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
386 views

Example Test Report - Codility

This document contains an example test report from Codility. It includes details on 3 tasks that were completed, including their scores and time spent. The first task involves writing an SQL query to calculate the sum of elements in a table and scored 100%. The second task finds the leader value in an array and scored 100%. The third task involves calculating equilibriums in a sequence and scored 70%.

Uploaded by

Srikanth
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

8/10/22, 4:18 PM Example test report - Codility

CodeCheck Report: FNSCDR-VKY


Test Name: Example test

Summary Review (0) Details Timeline

Tasks summary Total score

Task Time spent Score

SqlSum

90%
3 min 100%
SQL (PostgreSQL)

BugfixingLeaderSorted
3 min 100%
Java 8

Equi
8 min 70%
Python

No suspicious activity detected


during the assessment.

Tasks Details

1.
SqlSum
Elementary

Task Score Correctness Performance


Calculate sum of
elements. 100% 100% Not assessed

Task description Solution

Given a table elements with the following structure: Programming language used: SQL (PostgreSQL)

create table elements (

v integer not null


Total time used: 4 minutes
)

write an SQL query that returns the sum of the numbers in Effective time used: 3 minutes
column v.

For example, given:


Task timeline
v

---



10

20
09:24:21 09:37:39
10

your query should return 42. Code: 09:27:41 UTC,


sql- show code in pop-up
postgres,
final,
score: 
100
Copyright 2009–2022 by Codility Limited. All Rights Reserved. Unauthorized
copying, publication or disclosure prohibited.

https://app.codility.com/public-report-detail/ 1/6
8/10/22, 4:18 PM Example test report - Codility

1 -- write your code in PostgreSQL 9.4

2 SELECT sum(v)

3 FROM elements;

Analysis summary

The solution obtained perfect score.

Analysis

expand all Example tests


▶ build.tests.TestBase - ✔ OK
test_000_example

example test

expand all Correctness tests


▶ build.tests.TestBase - ✔ OK
test_010_simple

simple test with values 1..10

▶ build.tests.TestBase - ✔ OK
test_011_simple2

simple test with values [10,20,15]

▶ build.tests.TestBase - ✔ OK
test_012_simple3

simple test with values [1,1,1,1,2,2,2,2]

▶ build.tests.TestBase - ✔ OK
test_020_single

[10]

▶ build.tests.TestBase - ✔ OK
test_021_small

simple correctness test

▶ build.tests.TestBase - ✔ OK
test_022_small2

simple correctness test 2.

▶ build.tests.TestBase - ✔ OK
test_023_small3

simple correctness test 3.

▶ build.tests.TestBase - ✔ OK
test_024_small4

simple correctness test 4.

▶ build.tests.TestBase - ✔ OK
test_030_medium

medium performance test

▶ build.tests.TestBase - ✔ OK
test_040_large

large performance test

2.
BugfixingLeaderSorted
Find and correct bugs in a
Task Score Correctness Performance
Easy

function that finds a value


that occurs in more than 100% 100% Not assessed
half of the elements of an
array.

Task description Solution


https://app.codility.com/public-report-detail/ 2/6
8/10/22, 4:18 PM Example test report - Codility

A non-empty array A consisting of N integers and sorted in a non- Programming language used: Java 8
decreasing order (i.e. A[0] ≤ A[1] ≤ ... ≤ A[N−1]) is given. The
leader of this array is the value that occurs in more than half of Total time used: 10 minutes
the elements of A.

You are given an implementation of a function: Effective time used: 3 minutes


class Solution { public int solution(int[]
A); }
Task timeline
that, given a non-empty array A consisting of N integers, sorted in
a non-decreasing order, returns the leader of array A. The function



should return −1 if array A does not contain a leader.

For example, given array A consisting of ten elements such that:


09:24:21 09:37:39
A[0] = 2
A[1] = 2
A[2] = 2 Code: 09:36:31 UTC,
java,
A[3] = 2 final,
score: 
100
A[4] = 2 1 import java.util.*;
A[5] = 3 2 class Solution {
A[6] = 4 3 int solution(int[] A) {
A[7] = 4 4 int n = A.length;
A[8] = 4 5 int[] L = new int[n + 1];
A[9] = 6 6 L[0] = -1;
7 for (int i = 0; i < n; i++) {
the function should return −1, because the value that occurs most
8 L[i + 1] = A[i];
frequently in the array, 2, occurs five times, and 5 is not more than
9 }
half of 10.
10 int count = 0;
Given array A consisting of five elements such that: 11 int pos = (n + 1) / 2;
12 int candidate = L[pos];
A[0] = 1
13 for (int i = 1; i <= n; i++) {
A[1] = 1
14 if (L[i] == candidate)
A[2] = 1
15 count = count + 1;
A[3] = 1
16 }
A[4] = 50
17 - if (count > pos)
the function should return 1.   + if (2*count > n)
18 return candidate;
The attached code is still incorrect for some inputs. Despite the
19 return (-1);
error(s), the code may produce a correct answer for the example
20 }
test cases. The goal of the exercise is to find and fix the bug(s) in
21 }
the implementation. You can modify at most three lines.

Assume that:

N is an integer within the range [1..100,000]; Analysis summary


each element of array A is an integer within the The solution obtained perfect score.
range [0..2,147,483,647];
array A is sorted in non-decreasing order.

In your solution, focus on correctness. The performance of your Analysis


solution will not be the focus of the assessment.

Copyright 2009–2022 by Codility Limited. All Rights Reserved. Unauthorized


expand all Example tests
copying, publication or disclosure prohibited. ▶ example1
✔ OK
first example test

▶ example2
✔ OK
second example test

expand all Correctness tests


▶ simple1
✔ OK
values from a continuous range

▶ simple2
✔ OK
0s/1s only

▶ single
✔ OK
one element

https://app.codility.com/public-report-detail/ 3/6
8/10/22, 4:18 PM Example test report - Codility
▶ two_values
✔ OK
two different values

▶ extreme_big_values
✔ OK
min/max values only

▶ medium_1
✔ OK
small sequence repeated many times

▶ medium_2
✔ OK
no leader and small sequence with
values from a continuous range

▶ cyclic_sequence
✔ OK
no leader and small sequence
repeated many times

▶ medium_random
✔ OK
random sequences

▶ large
✔ OK
two different values, length = ~100,000

▶ large_range
✔ OK
values from a continuous range, length
= ~100,000

3.
Equi
Task Score Correctness Performance
Medium

Find an index in an array


such that its prefix sum 70% 95% 18%
equals its suffix sum.

Task description Solution

This is a demo task. Programming language used: Python

An array A consisting of N integers is given. An equilibrium index


of this array is any integer P such that 0 ≤ P < N and the sum of Total time used: 9 minutes
elements of lower indices is equal to the sum of elements of
higher indices, i.e.
Effective time used: 8 minutes

A[0] + A[1] + ... + A[P−1] = A[P+1] + ... + A[N−2] +


A[N−1].

Task timeline
Sum of zero elements is assumed to be equal to 0. This can
happen if P = 0 or if P = N−1.



For example, consider the following array A consisting of N = 8


elements:
09:24:21 09:37:39
A[0] = -1

A[1] = 3

Code: 09:37:39 UTC,


py, show code in pop-up
A[2] = -4

final,
score: 
70
A[3] = 5

A[4] = 1

1 # you can write to stdout for debugging purpos


A[5] = -6
2 # print("this is a debug message")

A[6] = 2
3

A[7] = 1 4 def solution(A):

5 n=len(A)

P = 1 is an equilibrium index of this array, because: 6

7 if(n==0):

A[0] = −1 = A[2] + A[3] + A[4] + A[5] + A[6] + A[7] 8 return(-1)

10 for i in range(n):

P = 3 is an equilibrium index of this array, because:


11 sum_left=0

12 sum_right=0

A[0] + A[1] + A[2] = −2 = A[4] + A[5] + A[6] + A[7] 13 mm=0

14 for j in range(n):

https://app.codility.com/public-report-detail/ 4/6
8/10/22, 4:18 PM Example test report - Codility
P = 7 is also an equilibrium index, because: 15 if(mm<A[j]):

16 mm=A[j]

A[0] + A[1] + A[2] + A[3] + A[4] + A[5] + A[6] = 0 17 for j in range(i):

18 sum_left+=A[j]

19 for j in range(i+1,n):

and there are no elements with indices greater than 7.


20 sum_right+=A[j]

P = 8 is not an equilibrium index, because it does not fulfill the 21

22 if(sum_left==sum_right):

condition 0 ≤ P < N.
23 return i

24 return(-1)

Write a function:

def solution(A)

that, given an array A consisting of N integers, returns any of its


equilibrium indices. The function should return −1 if no
equilibrium index exists. Analysis summary

For example, given array A shown above, the function may return The following issues have been detected: timeout errors.
1, 3 or 7, as explained above.

Write an efficient algorithm for the following assumptions:


Analysis
N is an integer within the range [0..100,000];
each element of array A is an integer within the
range [−2,147,483,648..2,147,483,647]. Detected time complexity: O(N**2)
Copyright 2009–2022 by Codility Limited. All Rights Reserved. Unauthorized
copying, publication or disclosure prohibited. expand all Example tests
▶ example
✔ OK
Test from the task description

expand all Correctness tests


▶ simple ✔ OK

▶ extreme_large_numbers
✔ OK
Sequence with extremely large
numbers testing arithmetic overflow.

▶ extreme_negative_numbers
✔ OK
Sequence with extremely large
numbers testing arithmetic overflow.

▶ overflow_tests1
✔ OK
arithmetic overflow tests

▶ overflow_tests2
✔ OK
arithmetic overflow tests

▶ one_large
✔ OK
one large number at the end of the
sequence

▶ sum_0
✔ OK
sequence with sum=0

▶ single_empty
✔ OK
single number or empty array

▶ combinations_of_two
✔ OK
multiple runs, all pairs of values: -1, 0
and 1

▶ combinations_of_three
✔ OK
multiple runs, all triples of values -1, 0
and 1

▶ small_pyramid ✔ OK

expand all Correctness/performance tests


▶ extreme_max
✘ TIMEOUT ERROR

Maximal size test Killed. Hard limit reached:


6.000 sec.

expand all Performance tests


▶ large_long_sequence_of_ones ✘ TIMEOUT ERROR

Killed. Hard limit reached:

https://app.codility.com/public-report-detail/ 5/6
8/10/22, 4:18 PM Example test report - Codility
6.000 sec.

▶ large_long_sequence_of_minu ✘ TIMEOUT ERROR

s_ones Killed. Hard limit reached:


6.000 sec.

▶ medium_pyramid ✔ OK

▶ large_pyramid
✘ TIMEOUT ERROR

Large performance test, O(n^2) running time: 0.320 sec.,


solutions should fail. time limit: 0.192 sec.

▶ huge_pyramid
✘ TIMEOUT ERROR

Large performance test, O(n^2) Killed. Hard limit reached:


solutions should fail. 6.000 sec.

https://app.codility.com/public-report-detail/ 6/6

You might also like