diff options
| author | Abigail <abigail@abigail.be> | 2021-03-01 10:49:48 +0100 |
|---|---|---|
| committer | Abigail <abigail@abigail.be> | 2021-03-01 10:49:48 +0100 |
| commit | 161b46493925498e77ce338d04e505642ef746ec (patch) | |
| tree | d7b628805011cfc8a71189e3fe3dec22599a1a59 | |
| parent | 2e7bba2423ac520245be83ea15504303968b466b (diff) | |
| download | perlweeklychallenge-club-161b46493925498e77ce338d04e505642ef746ec.tar.gz perlweeklychallenge-club-161b46493925498e77ce338d04e505642ef746ec.tar.bz2 perlweeklychallenge-club-161b46493925498e77ce338d04e505642ef746ec.zip | |
README for week 102
| -rw-r--r-- | challenge-102/abigail/README.md | 127 |
1 files changed, 24 insertions, 103 deletions
diff --git a/challenge-102/abigail/README.md b/challenge-102/abigail/README.md index caf1448381..4fc611621d 100644 --- a/challenge-102/abigail/README.md +++ b/challenge-102/abigail/README.md @@ -1,122 +1,43 @@ # Solution by Abigail -## [Pack a Spiral](https://perlweeklychallenge.org/blog/perl-weekly-challenge-101/#TASK1) +## [Rare Numbers](https://perlweeklychallenge.org/blog/perl-weekly-challenge-102/#TASK1) -You are given an array `@A` of items (integers say, but they can be anything). -Your task is to pack that array into an `MxN` matrix spirally -counterclockwise, as tightly as possible. +You are given a positive integer `$N`. -'Tightly' means the absolute value `|M-N|` of the difference has to be as -small as possible +Write a script to generate all Rare numbers of size `$N` if exists. +Please checkout [the page](http://www.shyamsundergupta.com/rare.htm) +for more information about it. ### Examples -#### Example 1 ~~~~ -Input: @A = (1,2,3,4) - -Output: - - 4 3 - 1 2 +(a) 2 digits: 65 +(b) 6 digits: 621770 +(c) 9 digits: 281089082 ~~~~ -Since the given array is already a `1x4` matrix on its own, but that's -not as tight as possible. Instead, you'd spiral it counterclockwise into - -~~~~ - 4 3 - 1 2 -~~~~ -#### Example 2 -~~~~ -Input: @A = (1..6) -Output: - 6 5 4 - 1 2 3 -~~~~ -or -~~~~ - 5 4 - 6 3 - 1 2 -~~~~ -Either will do as an answer, because they're equally tight. - -#### Example 3 -~~~~ -Input: @A = (1..12) - -Output: - 9 8 7 6 - 10 11 12 5 - 1 2 3 4 -~~~~ -or -~~~~ - 8 7 6 - 9 12 5 - 10 11 4 - 1 2 3 -~~~~ +## [Hash-counting String](https://perlweeklychallenge.org/blog/perl-weekly-challenge-102/#TASK2) -### Solutions -* [AWK](awk/ch-1.awk) -* [Bash](bash/ch-1.sh) -* [C](c/ch-1.c) -* [Lua](lua/ch-1.lua) -* [Node.js](node/ch-1.js) -* [Perl](perl/ch-1.pl) -* [Python](python/ch-1.py) -* [Ruby](ruby/ch-1.rb) +You are given a positive integer `$N`. -### Blog -[Perl Weekly Challenge 101: Pack a Spiral](https://wp.me/pcxd30-r7) +Write a script to produce Hash-counting string of that length. +The definition of a hash-counting string is as follows: +- the string consists only of digits 0-9 and hashes, `'#'`. +- there are no two consecutive hashes: `"##"z does not appear in your string +- the last character is a hash +- the number immediately preceding each hash (if it exists) is the position + of that hash in the string, with the position being counted up from 1 -## [Origin-containing Triangle](https://perlweeklychallenge.org/blog/perl-weekly-challenge-101/#TASK2) - -You are given three points in the plane, as a list of six co-ordinates: -`A=(x1,y1)`, `B=(x2,y2)` and `C=(x3,y3)`. - -Write a script to find out if the triangle formed by the given three -co-ordinates contain origin `(0,0)`. - -Print `1` if found otherwise `0`. +It can be shown that for every positive integer `N` there is exactly one +such length-`N` string. ### Examples -#### Example 1 -~~~~ -Input: A=(0,1), B=(1,0) and C=(2,2) - -Output: 0 because that triangle does not contain (0,0). -~~~~ - -#### Example 2 ~~~~ -Input: A=(1,1), B=(-1,1) and C=(0,-3) - -Output: 1 because that triangle contains (0,0) in its interior. -~~~~ - -#### Example 3 +(a) "#" is the counting string of length 1 +(b) "2#" is the counting string of length 2 +(c) "#3#" is the string of length 3 +(d) "#3#5#7#10#" is the string of length 10 +(e) "2#4#6#8#11#14#" is the string of length 14 ~~~~ -Input: A=(0,1), B=(2,0) and C=(-6,0) - -Output: 1 because (0,0) is on the edge connecting B and C. -~~~~ - -### Solutions -* [AWK](awk/ch-2.awk) -* [Bash](bash/ch-2.sh) -* [Befunge-93](befunge-93/ch-2.bf93) -* [C](c/ch-2.c) -* [Lua](lua/ch-2.lua) -* [Node.js](node/ch-2.js) -* [Perl](perl/ch-2.pl) -* [Python](python/ch-2.py) -* [Ruby](ruby/ch-2.rb) - -### Blog -[Perl Weekly Challenge 101: Origin-containing Triangle](https://wp.me/pcxd30-s8) |
