aboutsummaryrefslogtreecommitdiff
path: root/challenge-080/duncan-c-white/README
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2020-09-28 05:21:39 +0100
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2020-09-28 05:21:39 +0100
commit112e460c3f67b1d7c0a8c3cb31d26f113645eeb2 (patch)
treede9f63affba8e9dc891b20c5520b83c2331e2b29 /challenge-080/duncan-c-white/README
parent1e95beb93e91a87f7490daef571e2320d763da08 (diff)
downloadperlweeklychallenge-club-112e460c3f67b1d7c0a8c3cb31d26f113645eeb2.tar.gz
perlweeklychallenge-club-112e460c3f67b1d7c0a8c3cb31d26f113645eeb2.tar.bz2
perlweeklychallenge-club-112e460c3f67b1d7c0a8c3cb31d26f113645eeb2.zip
- Added template for Challenge 080.
Diffstat (limited to 'challenge-080/duncan-c-white/README')
-rw-r--r--challenge-080/duncan-c-white/README67
1 files changed, 67 insertions, 0 deletions
diff --git a/challenge-080/duncan-c-white/README b/challenge-080/duncan-c-white/README
new file mode 100644
index 0000000000..f173adcc40
--- /dev/null
+++ b/challenge-080/duncan-c-white/README
@@ -0,0 +1,67 @@
+Task 1: "Fibonacci Sum
+
+You are given a positive integer $N.
+
+Write a script to find out all possible combination of Fibonacci Numbers
+required to get $N on addition.
+
+You are NOT allowed to repeat a number. Print 0 if none found.
+
+Example 1:
+
+Input: $N = 6
+
+Output:
+ 1 + 2 + 3 = 6
+ 1 + 5 = 6
+
+Example 2:
+
+Input: $N = 9
+
+Output:
+ 1 + 8 = 9
+ 1 + 3 + 5 = 9
+"
+
+My notes: ok. pretty straightforward, especially after last weeks' first task.
+Not quite so trivial to do efficiently, my solution generates a lot of
+duplicate solutions (hence the dedup() function), and is very slow for large N.
+(See also ch-1a.pl for a tabulation of number of Fibonacci sums for i=1..N)
+
+
+Task 2: "Lonely X
+
+You are given m x n character matrix consists of O and X only.
+
+Write a script to count the total number of X surrounded by O only. Print
+0 if none found.
+
+Example 1:
+
+Input: [ O O X ]
+ [ X O O ]
+ [ X O O ]
+
+Output: 1 as there is only one X at the first row last column surrounded
+by only O.
+
+Example 2:
+
+Input: [ O O X O ]
+ [ X O O O ]
+ [ X O O X ]
+ [ O X O O ]
+
+Output: 2
+
+ a) First X found at Row 1 Col 3.
+
+ b) Second X found at Row 3 Col 4.
+"
+
+My notes: interesting question, sounds simple but perhaps not quite
+as simple as it sounds. Especially (obviously) "surrounded by only O"..
+Note that I counted rows and columns from 0, not 1. So the output I
+generate for the second grid (file grid2) is:
+"2 lonely Xs in grid: [0, 2],[2, 3]"