aboutsummaryrefslogtreecommitdiff
path: root/challenge-007/duncan-c-white/README
blob: 5fe2b0356b6314e1d7e6c146e9cd5d4d50c19e75 (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
Challenge 1: "Print all the niven numbers from 0 to 50 inclusive, each on
their own line. A niven number is a non-negative number that is divisible
by the sum of its digits.  The first few Niven numbers are 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 12, 18, 20, 21, 24.."

My notes: Cute little problem, let's have a go.


Challenge 2: "A word ladder is a sequence of words [w0, w1, #, wn] such
that each word wi in the sequence is obtained by changing a single
character in the word wi-1. All words in the ladder must be valid
English words.

Given two input words and a file that contains an ordered word list,
implement a routine (e.g., find_shortest_ladder(word1, word2, wordlist))
that finds the shortest ladder between the two input words. For example,
for the words cold and warm, a possible ladder might be:

("cold", "cord", "core", "care", "card", "ward", "warm")

However, there's a several shorter ladders between cold and warm, eg:

("cold", "cord", "card", "ward", "warm").

and we want the shortest which is:


All words in the list have the same length.
All words contain only lowercase alphabetical characters.
There are no duplicates in the word list.
The input words aren't empty and aren't equal but they have
the same length as any word in the word list.

The routine must return a list of the words in the ladder if it
exists. Otherwise, it returns an empty list.

If any of the input words is the wrong length (i.e., its length is
different to a random from the word list) or isn't in the word list,
return an empty list."

My notes: Finally, a well-specified problem:-)