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
|
Challenge 1: "Write a script to accept a string from command line and
split it on change of character. For example, if the string is "ABBCDEEF",
then it should split like 'A', 'BB', 'C', 'D', 'EE', 'F'."
My notes: Clearly defined, sounds like a job for regexes.
Challenge 2: "Write a script to print the smallest pair of Amicable Numbers."
Amicable numbers are two different numbers so related that the sum of the
proper divisors of each is equal to the other number. (A proper divisor
of a number is a positive factor of that number other than the number
itself. For example, the proper divisors of 6 are 1, 2, and 3.)
The smallest pair of amicable numbers is (220, 284). They are amicable
because the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44,
55 and 110, of which the sum is 284; and the proper divisors of 284 are 1,
2, 4, 71 and 142, of which the sum is 220.
The first ten amicable pairs are: (220, 284), (1184, 1210), (2620,
2924), (5020, 5564), (6232, 6368), (10744, 10856), (12285, 14595),
(17296, 18416), (63020, 76084), and (66928, 66992)
My notes: Another clearly described problem. Obvious method involves
a bit of caching.
|