aboutsummaryrefslogtreecommitdiff
path: root/challenge-108/abigail/README.md
diff options
context:
space:
mode:
authorAbigail <abigail@abigail.be>2021-04-12 13:52:35 +0200
committerAbigail <abigail@abigail.be>2021-04-12 13:52:35 +0200
commit6b444c9324695fe56539797fad50792e6a3dc345 (patch)
treef7bdcebf81f0375a35b81dc382fb0b0a76a584ff /challenge-108/abigail/README.md
parenteeb4cf0caad65ceee5fdddb161be04383ad53428 (diff)
downloadperlweeklychallenge-club-6b444c9324695fe56539797fad50792e6a3dc345.tar.gz
perlweeklychallenge-club-6b444c9324695fe56539797fad50792e6a3dc345.tar.bz2
perlweeklychallenge-club-6b444c9324695fe56539797fad50792e6a3dc345.zip
README for week 108
Diffstat (limited to 'challenge-108/abigail/README.md')
-rw-r--r--challenge-108/abigail/README.md160
1 files changed, 17 insertions, 143 deletions
diff --git a/challenge-108/abigail/README.md b/challenge-108/abigail/README.md
index 67392c9e54..fca58964a2 100644
--- a/challenge-108/abigail/README.md
+++ b/challenge-108/abigail/README.md
@@ -1,157 +1,31 @@
-# Solution by Abigail
-## [Self-descriptive Numbers](https://perlweeklychallenge.org/blog/perl-weekly-challenge-107/#TASK1)
+# Solutions by Abigail
+## [Locate Memory](https://perlweeklychallenge.org/blog/perl-weekly-challenge-108/#TASK1)
-Write a script to display the first three self-descriptive numbers.
-As per [wikipedia](https://en.wikipedia.org/wiki/Self-descriptive_number),
-the definition of Self-descriptive Number is
-
-> In mathematics, a self-descriptive number is an integer `m` that in a
-> given base `b` is `b` digits long in which each digit `d` at position `n`
-> (the most significant digit being at position 0 and the least
-> significant at position `b - 1`) counts how many instances of
-> digit `n` are in `m`.
-
-### Example
-~~~~
- 1210 is a four-digit self-descriptive number:
-
- position 0 has value 1 i.e. there is only one 0 in the number
- position 1 has value 2 i.e. there are two 1 in the number
- position 2 has value 1 i.e. there is only one 2 in the number
- position 3 has value 0 i.e. there is no 3 in the number
-~~~~
-
-### Output
-~~~~
- 1210, 2020, 21200
-~~~~
-
-### Notes
-
-This is a trivial exercise -- as all exercises are which do not
-take any input, and which have a fixed output. Fixed output
-challenges are boring -- unless there's another condition (golf,
-for instance).
-
-This exercise is so trivial, we don't even have to head to the OEIS
-to download the wanted numbers, as the expected output is stated
-in the exercise.
-
-So, all we need to do is print three numbers, separated by commas.
-
-The easiest way would be to just do what the challenge demands
-from us, and print the output as given.
-
-A slightly less easy way would be to head over the given
-[Wikipedia page](https://en.wikipedia.org/wiki/Self-descriptive_number)
-(or the [OEIS](https://oeis.org) for that matter), copy the first
-three numbers, and print those out.
-
-But those solutions no doubt will cause scorn in two weeks,
-when the review comes out. It's all "advice about the code is the thing".
-
-But that raises the question, what is the code which is wanted?
-You could generate all the numbers of length `b` in base `b`, while
-increasing `b`, test them for being self-descriptive, and print
-the first three numbers found.
-
-My advice about brute force code when there is a more efficient way:
-Don't ever do that.
-
-If we just imagine the Wikipedia page didn't list any self-descriptive
-numbers, and Neil Sloane has forgotten to pay the fee for the OEIS
-domain, so it was taken off-line, then it's still easy to determine
-the first three self-descriptive numbers -- no code required.
-
-Given the following observations for a self-descriptive number `N` in base `b`:
-* `N` has `b` digits, and does not start with a `0`.
-* The sum of the digits of `N` is `b`.
-* No digit of `N` equals `b - 1`.
-* The last digit of `N` is `0`.
-* If `b > 4`, then `N` does not start with a `1`.
-* If `b > 4`, then `N` does not start with `b - 2`.
-
-From that, it's easy to determine that:
-* There are no self-descriptive numbers in any base below `4`.
-* A self-descriptive number in base `4` must start with a `1` or `2`. And
- end with a `0`. If it starts with a `1`, the middle digits are `1` and `2`.
- If it starts with a `2`, the middle digits are `0` and `2`. Both `1210`,
- and `2020"`are self-descriptive numbers.
-* A self-descriptive number in base `5` must start with a `2`, and end
- with a `0`. The three middle digits must be `0`, `1`, and `2`. `21200`
- is a self-descriptive number.
-
-(For a more detailed derivation, with all the details filled in, see [the blog
-post](https://abigail.github.io/HTML/Perl-Weekly-Challenge/week-107-1.html))
-
-But this still makes this challenge a glorified `Hello, World!`
-program, as there is no useful code to write to generate the numbers.
+Write a script to declare a variable or constant and print it's
+location in the memory.
### Solutions
-* [AWK](awk/ch-1.awk)
-* [Bash](bash/ch-1.awk)
-* [BASIC](basic/ch-1.bas)
-* [bc](bc/ch-1.bc)
-* [Befunge-93](befunge-93/ch-1.bf93)
-* [C](c/ch-1.c)
-* [Cobol](cobol/ch-1.cb)
-* [Csh](csh/ch-1.csh)
-* [Erlang](erlang/ch-1.erl)
-* [Forth](forth/ch-1.fs)
-* [Fortran](fortran/ch-1.fs)
-* [Go](go/ch-1.go)
-* [Java](java/ch-1.java)
-* [Lua](lua/ch-1.lua)
-* [m4](m4/ch-1.m4)
-* [Node.js](lua/ch-1.js)
-* [OCaml](ocaml/ch-1.ml)
-* [Pascal](pascal/ch-1.pl)
-* [Perl](perl/ch-1.pl)
-* [PHP](php/ch-1.pl)
-* [PostScript](postscript/ch-1.ps)
-* [Python](python/ch-1.py)
-* [R](r/ch-1.r)
-* [Rexx](rexx/ch-1.rexx)
-* [Ruby](ruby/ch-1.rb)
-* [Scheme](scheme/ch-1.scm)
-* [sed](sed/ch-1.sed)
-* [SQL](sql/ch-1.sql)
-* [Tcl](tcl/ch-1.tcl)
### Blog
-[Perl Weekly Challenge 107: Self-descriptive Numbers](https://abigail.github.io/HTML/Perl-Weekly-Challenge/week-107-1.html)
-
-## [List Methods](https://perlweeklychallenge.org/blog/perl-weekly-challenge-107/#TASK2)
-Write a script to list methods of a package/class.
-### Example
-Given the package:
-~~~~
-package Calc;
+## [Bell Numbers](https://perlweeklychallenge.org/blog/perl-weekly-challenge-108/#TASK2)
-use strict;
-use warnings;
+Write a script to display top 10 Bell Numbers. Please refer to
+[wikipedia page](https://en.wikipedia.org/wiki/Bell_number) for
+more informations.
-sub new { bless {}, shift; }
-sub add { }
-sub mul { }
-sub div { }
-
-1;
-~~~~
-Output:
-~~~~
-BEGIN
-mul
-div
-new
-add
-~~~~
+### Example
+* `B_0 = 1`, as you can only have one partition of zero element set
+* `B_1 = 1`, as you can only have one partition of one element set {a}.
+* `B_2 = 2`, `{a}{b}`, `{a,b}`.
+* `B_3 = 5`, `{a}{b}{c}`, `{a,b}{c}`, `{a}{b,c}`, `{a,c}{b}`, `{a,b,c}`.
+* `B_4 = 15`, `{a}{b}{c}{d}`, `{a,b,c,d}`, `{a,b}{c,d}`, `{a,c}{b,d}`,
+ `{a,d}{b,c}`, `{a,b}{c}{d}`, `{a,c}{b}{d}`, `{a,d}{b}{c}`,
+ `{b,c}{a}{d}`, `{b,d}{a}{c}`, `{c,d}{a}{b}`, `{a}{b,c,d}`,
+ `{b}{a,c,d}`, `{c}{a,b,d}`, `{d}{a,b,c}`
### Solutions
-* [Perl](perl/ch-2.pl)
### Blog
-[Perl Weekly Challenge 107: List Methods](https://abigail.github.io/HTML/Perl-Weekly-Challenge/week-107-2.html)