Tasks Details
medium
Calculate the number of elements of an array that are not divisors of each element.
Task Score
77%
Correctness
100%
Performance
50%
You are given an array A consisting of N integers.
For each number A[i] such that 0 ≤ i < N, we want to count the number of elements of the array that are not the divisors of A[i]. We say that these elements are non-divisors.
For example, consider integer N = 5 and array A such that:
A[0] = 3 A[1] = 1 A[2] = 2 A[3] = 3 A[4] = 6For the following elements:
- A[0] = 3, the non-divisors are: 2, 6,
- A[1] = 1, the non-divisors are: 3, 2, 3, 6,
- A[2] = 2, the non-divisors are: 3, 3, 6,
- A[3] = 3, the non-divisors are: 2, 6,
- A[4] = 6, there aren't any non-divisors.
Write a function:
def solution(A)
that, given an array A consisting of N integers, returns a sequence of integers representing the amount of non-divisors.
Result array should be returned as an array of integers.
For example, given:
A[0] = 3 A[1] = 1 A[2] = 2 A[3] = 3 A[4] = 6the function should return [2, 4, 3, 2, 0], as explained above.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [1..50,000];
- each element of array A is an integer within the range [1..2 * N].
Copyright 2009–2025 by Codility Limited. All Rights Reserved. Unauthorized copying, publication or disclosure prohibited.
Solution
Programming language used Python
Time spent on task 17 minutes
Notes
not defined yet
Code: 09:16:10 UTC,
java,
autosave
Code: 09:16:51 UTC,
py,
verify,
result: Failed
Analysis
expand all
Example tests
1.
0.052 s
RUNTIME ERROR,
tested program terminated with exit code 1
stderr:
Invalid result type, array expected, <class 'NoneType'> found.stdout:
6
Code: 09:17:31 UTC,
py,
verify,
result: Failed
Analysis
expand all
Example tests
1.
0.036 s
RUNTIME ERROR,
tested program terminated with exit code 1
stderr:
Invalid result type, array expected, <class 'NoneType'> found.stdout:
6 0
Code: 09:17:47 UTC,
py,
autosave
Code: 09:18:00 UTC,
py,
autosave
Code: 09:19:11 UTC,
py,
verify,
result: Failed
Analysis
expand all
Example tests
1.
0.036 s
RUNTIME ERROR,
tested program terminated with exit code 1
stderr:
Invalid result type, array expected, <class 'NoneType'> found.stdout:
defaultdict(<class 'int'>, {3: 2, 1: 1, 2: 1, 6: 1})
Code: 09:19:49 UTC,
py,
autosave
Code: 09:19:54 UTC,
py,
verify,
result: Failed
Analysis
expand all
Example tests
1.
0.036 s
RUNTIME ERROR,
tested program terminated with exit code 1
stderr:
Invalid result type, array expected, <class 'NoneType'> found.stdout:
3 1 2 3 6
Code: 09:20:03 UTC,
py,
autosave
Code: 09:20:26 UTC,
py,
autosave
Code: 09:20:59 UTC,
py,
autosave
Code: 09:21:30 UTC,
py,
autosave
Code: 09:22:01 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
for num in A:
num_hash[num] += 1
#print(num_hash)
answer = []
for num in A:
for measure in range(1, math.)
Code: 09:22:21 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
for num in A:
num_hash[num] += 1
#print(num_hash)
answer = []
for num in A:
for measure in range(1, num ** (1/2))
Code: 09:22:49 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
for num in A:
num_hash[num] += 1
#print(num_hash)
answer = []
for num in A:
for measure in range(1, math.floor(num ** (1/2))
Code: 09:23:00 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
for num in A:
num_hash[num] += 1
#print(num_hash)
answer = []
for num in A:
for measure in range(1, math.floor(num ** (1/2))
Code: 09:23:10 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
for num in A:
num_hash[num] += 1
#print(num_hash)
answer = []
for num in A:
for measure in range(1, math.floor(num ** (1/2)))
Code: 09:23:27 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
for num in A:
num_hash[num] += 1
#print(num_hash)
answer = []
for num in A:
for measure in range(1, math.floor(num ** (1/2)) + 1):
Code: 09:23:44 UTC,
py,
verify,
result: Failed
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
for num in A:
num_hash[num] += 1
#print(num_hash)
answer = []
for num in A:
print("num ::: " + str(num))
for measure in range(1, math.floor(num ** (1/2)) + 1):
print(measure)
Analysis
expand all
Example tests
1.
0.036 s
RUNTIME ERROR,
tested program terminated with exit code 1
stderr:
Invalid result type, array expected, <class 'NoneType'> found.stdout:
num ::: 3 1 num ::: 1 1 num ::: 2 1 num ::: 3 1 num ::: 6 1 2
Code: 09:23:58 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
for num in A:
num_hash[num] += 1
#print(num_hash)
answer = []
for num in A:
print("num ::: " + str(num))
for measure in range(1, math.floor(num ** (1/2)) + 1):
print(measure)
if
Code: 09:24:10 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
for num in A:
num_hash[num] += 1
#print(num_hash)
answer = []
for num in A:
print("num ::: " + str(num))
for measure in range(1, math.floor(num ** (1/2)) + 1):
print(measure)
if num % measure == 0:
Code: 09:24:40 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
for num in A:
num_hash[num] += 1
#print(num_hash)
answer = []
for num in A:
print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
print(measure)
if num % measure == 0:
count += 1
if
Code: 09:25:10 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
for num in A:
num_hash[num] += 1
#print(num_hash)
answer = []
for num in A:
print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
print(measure)
if num % measure != 0:
continue
if num //
Code: 09:25:41 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
for num in A:
num_hash[num] += 1
#print(num_hash)
answer = []
for num in A:
print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
print(measure)
if num % measure != 0:
continue
count += 1
if measure * measure == num:
Code: 09:25:55 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
for num in A:
num_hash[num] += 1
#print(num_hash)
answer = []
for num in A:
print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
print(measure)
if num % measure != 0:
continue
if measure * measure == num:
Code: 09:26:07 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
for num in A:
num_hash[num] += 1
#print(num_hash)
answer = []
for num in A:
print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
print(measure)
if num % measure != 0:
continue
count
if measure * measure == num:
Code: 09:26:29 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
for num in A:
num_hash[num] += 1
#print(num_hash)
answer = []
for num in A:
print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
print(measure)
if num % measure != 0:
continue
count += num_hash[measure]
if measure * measure == num:
continue
Code: 09:26:40 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
for num in A:
num_hash[num] += 1
#print(num_hash)
answer = []
for num in A:
print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
print(measure)
if num % measure != 0:
continue
count += num_hash[measure]
if measure * measure == num:
continue
cont +=
Code: 09:26:55 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
for num in A:
num_hash[num] += 1
#print(num_hash)
answer = []
for num in A:
print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
print(measure)
if num % measure != 0:
continue
count += num_hash[measure]
if measure * measure == num:
continue
cont += num_hash[num // measure]
Code: 09:27:07 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
for num in A:
num_hash[num] += 1
#print(num_hash)
answer = []
for num in A:
print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
print(measure)
if num % measure != 0:
continue
count += num_hash[measure]
if measure * measure == num:
continue
count += num_hash[num / measure]
Code: 09:27:17 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
for num in A:
num_hash[num] += 1
#print(num_hash)
answer = []
for num in A:
print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
print(measure)
if num % measure != 0:
continue
count += num_hash[measure]
if measure * measure == num:
continue
count += num_hash[num // measure]
Code: 09:27:32 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
for num in A:
num_hash[num] += 1
#print(num_hash)
answer = []
for num in A:
print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
print(measure)
if num % measure != 0:
continue
count += num_hash[measure]
if measure * measure == num:
continue
print("num // measure ::: " + str(nun // measure))
count += num_hash[num // measure]
Code: 09:27:42 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
for num in A:
num_hash[num] += 1
#print(num_hash)
answer = []
for num in A:
print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
print(measure)
if num % measure != 0:
continue
count += num_hash[measure]
if measure * measure == num:
continue
print("num // measure ::: " + str(num // measure))
count += num_hash[num // measure]
Code: 09:27:55 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
for num in A:
num_hash[num] += 1
#print(num_hash)
answer = []
for num in A:
print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
print("measure " + str(measure)
if num % measure != 0:
continue
count += num_hash[measure]
if measure * measure == num:
continue
print("num // measure ::: " + str(num // measure))
count += num_hash[num // measure]
Code: 09:28:02 UTC,
py,
verify,
result: Failed
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
for num in A:
num_hash[num] += 1
#print(num_hash)
answer = []
for num in A:
print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
print("measure ::: " + str(measure))
if num % measure != 0:
continue
count += num_hash[measure]
if measure * measure == num:
continue
print("num // measure ::: " + str(num // measure))
count += num_hash[num // measure]
Analysis
expand all
Example tests
1.
0.036 s
RUNTIME ERROR,
tested program terminated with exit code 1
stderr:
Invalid result type, array expected, <class 'NoneType'> found.stdout:
num ::: 3 measure ::: 1 num // measure ::: 3 num ::: 1 measure ::: 1 num ::: 2 measure ::: 1 num // measure ::: 2 num ::: 3 measure ::: 1 num // measure ::: 3 num ::: 6 measure ::: 1 num // measure ::: 6 measure ::: 2 num // measure ::: 3
Code: 09:28:26 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
for num in A:
num_hash[num] += 1
#print(num_hash)
answer = []
for num in A:
print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
print("measure ::: " + str(measure))
if num % measure != 0:
continue
count += num_hash[measure]
if measure * measure == num:
continue
print("num // measure ::: " + str(num // measure))
count += num_hash[num // measure]
prin
Code: 09:28:37 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
for num in A:
num_hash[num] += 1
#print(num_hash)
answer = []
for num in A:
print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
print("measure ::: " + str(measure))
if num % measure != 0:
continue
count += num_hash[measure]
if measure * measure == num:
continue
print("num // measure ::: " + str(num // measure))
count += num_hash[num // measure]
Code: 09:28:53 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
for num in A:
num_hash[num] += 1
#print(num_hash)
answer = []
for num in A:
print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
print("measure ::: " + str(measure))
if num % measure != 0:
continue
count += num_hash[measure]
if measure * measure != num:
print("num // measure ::: " + str(num // measure))
count += num_hash[num // measure]
Code: 09:29:03 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
for num in A:
num_hash[num] += 1
#print(num_hash)
answer = []
for num in A:
print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
print("measure ::: " + str(measure))
if num % measure != 0:
continue
count += num_hash[measure]
if measure * measure != num:
count += num_hash[num // measure]
print("num // measure ::: " + str(num // measure))
Code: 09:29:14 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
for num in A:
num_hash[num] += 1
#print(num_hash)
answer = []
for num in A:
print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
print("measure ::: " + str(measure))
if num % measure != 0:
continue
count += num_hash[measure]
if measure * measure != num:
count += num_hash[num // measure]
print()
print("num // measure ::: " + str(num // measure))
Code: 09:29:36 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
for num in A:
num_hash[num] += 1
#print(num_hash)
answer = []
for num in A:
print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
print("measure ::: " + str(measure))
if num % measure != 0:
continue
count += num_hash[measure]
if measure * measure != num:
count += num_hash[num // measure]
print("num // measure ::: " + str(num // measure))
print("count ::: " + str(count))
Code: 09:29:37 UTC,
py,
verify,
result: Failed
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
for num in A:
num_hash[num] += 1
#print(num_hash)
answer = []
for num in A:
print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
print("measure ::: " + str(measure))
if num % measure != 0:
continue
count += num_hash[measure]
if measure * measure != num:
count += num_hash[num // measure]
print("num // measure ::: " + str(num // measure))
print("count ::: " + str(count))
Analysis
expand all
Example tests
1.
0.040 s
RUNTIME ERROR,
tested program terminated with exit code 1
stderr:
Invalid result type, array expected, <class 'NoneType'> found.stdout:
num ::: 3 measure ::: 1 num // measure ::: 3 count ::: 3 num ::: 1 measure ::: 1 count ::: 1 num ::: 2 measure ::: 1 num // measure ::: 2 count ::: 2 num ::: 3 measure ::: 1 num // measure ::: 3 count ::: 3 num ::: 6 measure ::: 1 num // measure ::: 6 count ::: 2 measure ::: 2 num // measure ::: 3 count ::: 5
Code: 09:30:35 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
for num in A:
num_hash[num] += 1
#print(num_hash)
answer = []
for num in A:
print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
print("measure ::: " + str(measure))
if num % measure != 0:
continue
count += num_hash[measure]
if measure * measure != num:
count += num_hash[num // measure]
print("num // measure ::: " + str(num // measure))
print("count ::: " + str(count))
Code: 09:30:38 UTC,
py,
verify,
result: Failed
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
for num in A:
num_hash[num] += 1
#print(num_hash)
answer = []
for num in A:
print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
print("measure ::: " + str(measure))
if num % measure != 0:
continue
count += num_hash[measure]
if measure * measure != num:
count += num_hash[num // measure]
print("num // measure ::: " + str(num // measure))
print("count ::: " + str(count))
Analysis
expand all
Example tests
1.
0.036 s
RUNTIME ERROR,
tested program terminated with exit code 1
stderr:
Invalid result type, array expected, <class 'NoneType'> found.stdout:
num ::: 3 measure ::: 1 num // measure ::: 3 count ::: 3 num ::: 1 measure ::: 1 count ::: 1 num ::: 2 measure ::: 1 num // measure ::: 2 count ::: 2 num ::: 3 measure ::: 1 num // measure ::: 3 count ::: 3 num ::: 6 measure ::: 1 num // measure ::: 6 count ::: 2 measure ::: 2 num // measure ::: 3 count ::: 5
Code: 09:31:01 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
for num in A:
num_hash[num] += 1
#print(num_hash)
answer = []
for num in A:
print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
print("measure ::: " + str(measure))
if num % measure != 0:
continue
count += num_hash[measure]
if measure * measure != num:
count += num_hash[num // measure]
print("num // measure ::: " + str(num // measure))
print("count ::: " + str(count))
Code: 09:31:22 UTC,
py,
verify,
result: Failed
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
length = 0
for num in A:
num_hash[num] += 1
length += 1
print("length ::: " + str(length))
#print(num_hash)
answer = []
for num in A:
print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
print("measure ::: " + str(measure))
if num % measure != 0:
continue
count += num_hash[measure]
if measure * measure != num:
count += num_hash[num // measure]
print("num // measure ::: " + str(num // measure))
print("count ::: " + str(count))
Analysis
expand all
Example tests
1.
0.036 s
RUNTIME ERROR,
tested program terminated with exit code 1
stderr:
Invalid result type, array expected, <class 'NoneType'> found.stdout:
length ::: 5 num ::: 3 measure ::: 1 num // measure ::: 3 count ::: 3 num ::: 1 measure ::: 1 count ::: 1 num ::: 2 measure ::: 1 num // measure ::: 2 count ::: 2 num ::: 3 measure ::: 1 num // measure ::: 3 count ::: 3 num ::: 6 measure ::: 1 num // measure ::: 6 count ::: 2 measure ::: 2 num // measure ::: 3 count ::: 5
Code: 09:31:32 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
length = 0
for num in A:
num_hash[num] += 1
length += 1
print("length ::: " + str(length))
#print(num_hash)
answer = []
for num in A:
print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
print("measure ::: " + str(measure))
if num % measure != 0:
continue
count += num_hash[measure]
if measure * measure != num:
count += num_hash[num // measure]
print("num // measure ::: " + str(num // measure))
print("count ::: " + str(count))
Code: 09:31:43 UTC,
py,
verify,
result: Failed
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
length = 0
for num in A:
num_hash[num] += 1
length += 1
print("length ::: " + str(length))
#print(num_hash)
answer = []
for num in A:
print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
print("measure ::: " + str(measure))
if num % measure != 0:
continue
count += num_hash[measure]
if measure * measure != num:
count += num_hash[num // measure]
print("num // measure ::: " + str(num // measure))
print("count ::: " + str(count))
answer.append(length - count)
Analysis
expand all
Example tests
1.
0.036 s
RUNTIME ERROR,
tested program terminated with exit code 1
stderr:
Invalid result type, array expected, <class 'NoneType'> found.stdout:
length ::: 5 num ::: 3 measure ::: 1 num // measure ::: 3 count ::: 3 num ::: 1 measure ::: 1 count ::: 1 num ::: 2 measure ::: 1 num // measure ::: 2 count ::: 2 num ::: 3 measure ::: 1 num // measure ::: 3 count ::: 3 num ::: 6 measure ::: 1 num // measure ::: 6 count ::: 2 measure ::: 2 num // measure ::: 3 count ::: 5
Code: 09:31:52 UTC,
py,
verify,
result: Failed
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
length = 0
for num in A:
num_hash[num] += 1
length += 1
print("length ::: " + str(length))
#print(num_hash)
answer = []
for num in A:
print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
print("measure ::: " + str(measure))
if num % measure != 0:
continue
count += num_hash[measure]
if measure * measure != num:
count += num_hash[num // measure]
print("num // measure ::: " + str(num // measure))
print("count ::: " + str(count))
answer.append(length - count)
print(answer)
Analysis
expand all
Example tests
1.
0.040 s
RUNTIME ERROR,
tested program terminated with exit code 1
stderr:
Invalid result type, array expected, <class 'NoneType'> found.stdout:
length ::: 5 num ::: 3 measure ::: 1 num // measure ::: 3 count ::: 3 num ::: 1 measure ::: 1 count ::: 1 num ::: 2 measure ::: 1 num // measure ::: 2 count ::: 2 num ::: 3 measure ::: 1 num // measure ::: 3 count ::: 3 num ::: 6 measure ::: 1 num // measure ::: 6 count ::: 2 measure ::: 2 num // measure ::: 3 count ::: 5 [2, 4, 3, 2, 3, 0]
Code: 09:32:10 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
length = 0
for num in A:
num_hash[num] += 1
length += 1
print("length ::: " + str(length))
#print(num_hash)
answer = []
for num in A:
print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
print("measure ::: " + str(measure))
if num % measure != 0:
continue
count += num_hash[measure]
if measure * measure != num:
count += num_hash[num // measure]
print("num // measure ::: " + str(num // measure))
print("count ::: " + str(count))
answer.append(length - count)
print(answer)
Code: 09:32:12 UTC,
py,
verify,
result: Failed
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
length = 0
for num in A:
num_hash[num] += 1
length += 1
print("length ::: " + str(length))
#print(num_hash)
answer = []
for num in A:
print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
print("measure ::: " + str(measure))
if num % measure != 0:
continue
count += num_hash[measure]
if measure * measure != num:
count += num_hash[num // measure]
print("num // measure ::: " + str(num // measure))
print("count ::: " + str(count))
answer.append(length - count)
print(answer)
Analysis
expand all
Example tests
1.
0.036 s
RUNTIME ERROR,
tested program terminated with exit code 1
stderr:
Invalid result type, array expected, <class 'NoneType'> found.stdout:
length ::: 5 num ::: 3 measure ::: 1 num // measure ::: 3 count ::: 3 num ::: 1 measure ::: 1 count ::: 1 num ::: 2 measure ::: 1 num // measure ::: 2 count ::: 2 num ::: 3 measure ::: 1 num // measure ::: 3 count ::: 3 num ::: 6 measure ::: 1 num // measure ::: 6 count ::: 2 measure ::: 2 num // measure ::: 3 count ::: 5 [2, 4, 3, 2, 0]
Code: 09:32:37 UTC,
py,
autosave
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
length = 0
for num in A:
num_hash[num] += 1
length += 1
print("length ::: " + str(length))
#print(num_hash)
answer = []
for num in A:
#print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
#print("measure ::: " + str(measure))
if num % measure != 0:
continue
count += num_hash[measure]
if measure * measure != num:
count += num_hash[num // measure]
#print("num // measure ::: " + str(num // measure))
#print("count ::: " + str(count))
answer.append(length - count)
#print(answer)
return answer
Code: 09:32:45 UTC,
py,
verify,
result: Passed
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
length = 0
for num in A:
num_hash[num] += 1
length += 1
#print("length ::: " + str(length))
#print(num_hash)
answer = []
for num in A:
#print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
#print("measure ::: " + str(measure))
if num % measure != 0:
continue
count += num_hash[measure]
if measure * measure != num:
count += num_hash[num // measure]
#print("num // measure ::: " + str(num // measure))
#print("count ::: " + str(count))
answer.append(length - count)
#print(answer)
return answer
Analysis
Code: 09:32:49 UTC,
py,
verify,
result: Passed
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
length = 0
for num in A:
num_hash[num] += 1
length += 1
#print("length ::: " + str(length))
#print(num_hash)
answer = []
for num in A:
#print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
#print("measure ::: " + str(measure))
if num % measure != 0:
continue
count += num_hash[measure]
if measure * measure != num:
count += num_hash[num // measure]
#print("num // measure ::: " + str(num // measure))
#print("count ::: " + str(count))
answer.append(length - count)
#print(answer)
return answer
Analysis
Code: 09:32:52 UTC,
py,
final,
score: 
77
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
import math
def solution(A):
num_hash = collections.defaultdict(int)
length = 0
for num in A:
num_hash[num] += 1
length += 1
#print("length ::: " + str(length))
#print(num_hash)
answer = []
for num in A:
#print("num ::: " + str(num))
count = 0
for measure in range(1, math.floor(num ** (1/2)) + 1):
#print("measure ::: " + str(measure))
if num % measure != 0:
continue
count += num_hash[measure]
if measure * measure != num:
count += num_hash[num // measure]
#print("num // measure ::: " + str(num // measure))
#print("count ::: " + str(count))
answer.append(length - count)
#print(answer)
return answer
Analysis summary
The following issues have been detected: timeout errors.
Analysis
expand all
Correctness tests
1.
0.036 s
OK
2.
0.036 s
OK
1.
0.036 s
OK
2.
0.036 s
OK
3.
0.036 s
OK
1.
0.036 s
OK
1.
0.036 s
OK
1.
0.036 s
OK
2.
0.036 s
OK
expand all
Performance tests
1.
0.076 s
OK
2.
0.060 s
OK
1.
0.216 s
OK
2.
0.172 s
OK
large_random
large, random numbers, length = ~30,000
large, random numbers, length = ~30,000
✘
TIMEOUT ERROR
running time: 0.516 sec., time limit: 0.416 sec.
running time: 0.516 sec., time limit: 0.416 sec.
1.
0.408 s
OK
2.
0.516 s
TIMEOUT ERROR,
running time: 0.516 sec., time limit: 0.416 sec.
large_extreme
large, all the same values, length = 50,000
large, all the same values, length = 50,000
✘
TIMEOUT ERROR
running time: 1.212 sec., time limit: 0.592 sec.
running time: 1.212 sec., time limit: 0.592 sec.
1.
1.212 s
TIMEOUT ERROR,
running time: 1.212 sec., time limit: 0.592 sec.
2.
0.132 s
OK
3.
0.176 s
OK