-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathzad1.simi
More file actions
41 lines (37 loc) · 1.9 KB
/
zad1.simi
File metadata and controls
41 lines (37 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#A = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990, 999999989, 999999988, 999999987, 999999986, 999999985, 999999984, 999999983, 999999982, 999999981, 999999980, 999999979, 999999978, 999999977, 999999976, 999999975, 999999974, 999999973, 999999972, 999999971, 999999970, 999999969, 999999968, 999999967, 999999966, 999999965, 999999964, 999999963, 999999962, 999999961, 999999960, 999999959, 999999958, 999999957, 999999956, 999999955, 999999954, 999999953, 999999952, 999999951, 999999950, 999999949, 999999948, 999999947, 999999946, 999999945, 999999944, 999999943, 999999942, 999999941, 999999940, 999999939, 999999938, 999999937, 999999936, 999999935, 999999934, 999999933, 999999932, 999999931, 999999930, 999999929, 999999928, 999999927, 999999926, 999999925, 999999924, 999999923, 999999922, 999999921, 999999920, 999999919, 999999918, 999999917, 999999916, 999999915, 999999914, 999999913, 999999912, 999999911, 999999910, 999999909, 999999908, 999999907, 999999906, 999999905, 999999904, 999999903, 999999902, 999999901]
import "./Stdlib/File.simi"
def load(case):
file = File("/Users/gordanglavas/Downloads/game_inputs/game_input" + case)
reader = ReadStream(file)
reader.readLine()
input = reader.readLine()
array = input.split(' ').map(def s: s.toNumber())
rescue ex:
if ex:
print ex.message
return nil
end
end
reader.close()
return array
end
def numFactors($n):
$count = 0
while $n % 2 == 0:
$n /= 2
$count += 1
end
for i in Range(3, Math.sqrt($n) + 1, 2):
while $n % i == 0:
$n /= i
$count += 1
end
end
if $n > 2: $count += 1
return $count
end
for i in Range(1, 8):
sum = load(i).map(numFactors).reduce(0, def (a, b): a + b)
print ife(sum % 2, "Mirko", "Slavko")
print sum
end