aboutsummaryrefslogtreecommitdiff
path: root/challenge-091/duncan-c-white/README
blob: c8483d64bb32a2ccd5a3ecbdd11699e4930e9c62 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Task 1: "Count Number

You are given a positive number $N.  Write a script to count number and display as you read it.

Example 1:

Input: $N = 1122234
Output: 21321314

as we read "two 1 three 2 one 3 one 4"

Example 2:

Input: $N = 2333445
Output: 12332415

as we read "one 2 three 3 two 4 one 5"

Example 3:

Input: $N = 12345
Output: 1112131415

as we read "one 1 one 2 one 3 one 4 one 5"
"

My notes: not brilliantly clearly defined, but simple to do with a freq hash.


Task 2: "Jump Game

You are given an array of positive numbers @N, where value at each index
determines how far you are allowed to jump further.  Write a script to
decide if you can jump to the last index. Print 1 if you are able to
reach the last index otherwise 0.

Example 1:

	Input: @N = (1, 2, 1, 2)
	Output: 1

as we jump one place from index 0 and then twoe places from index 1 to
reach the last index.

Example 2:

	Input: @N = (2,1,1,0,2)
	Output: 0

it is impossible to reach the last index. as we jump two places from index
0 to reach index 2, followed by one place jump from index 2 to reach the
index 3. once you reached the index 3, you can't go any further because
you can only jump 0 position further.
"

My notes: does it mean "decide if you can jump to the last index, starting at index 0"?
all the examples show that, so I'm going to assume that's what it means.  But it
doesn't say that explicitly - reading at first I thought you would have a
free choice of where to start, so would have to search "starting at pos 0",
"starting at pos 1"... etc.  Negative numbers would also make it more interesting.