blob: a5b283e113009a8f8423408ccf727af884527299 (
plain)
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
42
43
44
|
Task 1: "GCD Sum
You are given a positive integer $N.
Write a script to sum GCD of all possible unique pairs between 1 and $N.
Example 1:
Input: 3
Output: 3
gcd(1,2) + gcd(1,3) + gcd(2,3)
Example 2:
Input: 4
Output: 7
gcd(1,2) + gcd(1,3) + gcd(1,4) + gcd(2,3) + gcd(2,4) + gcd(3,4)
"
My notes: very clearly defined. Haven't used GCDs for a while:-)
Task 2: "Magical Matrix
Write a script to display matrix as below with numbers 1 - 9. Please make sure numbers are used once.
[ a b c ]
[ d e f ]
[ g h i ]
So that it satisfies the following:
a + b + c = 15
d + e + f = 15
g + h + i = 15
a + d + g = 15
b + e + h = 15
c + f + i = 15
a + e + i = 15
c + e + g = 15
"
My notes: clearly defined. Constraint problem.
|