aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbigail <abigail@abigail.be>2021-03-15 13:14:46 +0100
committerAbigail <abigail@abigail.be>2021-03-15 13:14:46 +0100
commitdbb8361d66d9db35bcc45b88d77792b5f034c187 (patch)
tree04c962787dcded648641dbddefd8d56a8d2d412a
parent65d54d52500028ec5359a7d39619803ade281543 (diff)
downloadperlweeklychallenge-club-dbb8361d66d9db35bcc45b88d77792b5f034c187.tar.gz
perlweeklychallenge-club-dbb8361d66d9db35bcc45b88d77792b5f034c187.tar.bz2
perlweeklychallenge-club-dbb8361d66d9db35bcc45b88d77792b5f034c187.zip
README for week 104
-rw-r--r--challenge-104/abigail/README.md140
1 files changed, 27 insertions, 113 deletions
diff --git a/challenge-104/abigail/README.md b/challenge-104/abigail/README.md
index f8b761268c..3e6ba1fe6b 100644
--- a/challenge-104/abigail/README.md
+++ b/challenge-104/abigail/README.md
@@ -1,137 +1,51 @@
# Solution by Abigail
-## [Chinese Zodiac](https://perlweeklychallenge.org/blog/perl-weekly-challenge-103/#TASK1)
+## [FUSC Sequence](https://perlweeklychallenge.org/blog/perl-weekly-challenge-104/#TASK1)
-You are given a year `$year`.
+Write a script to generate first 50 members of FUSC Sequence. Please
+refer to [OEIS](https://oeis.org/A002487) for more information._
-Write a script to determine the *Chinese Zodiac* for the given year
-$year. Please check out [wikipage](https://en.wikipedia.org/wiki/Chinese_zodiac)
-for more information about it.
+The sequence defined as below:
-The animal cycle:
-* Rat
-* Ox
-* Tiger
-* Rabbit
-* Dragon
-* Snake
-* Horse
-* Goat
-* Monkey
-* Rooster
-* Dog
-* Pig
-
-The element cycle:
-* Wood
-* Fire
-* Earth
-* Metal
-* Water
-
-### Examples
-#### Example 1
-~~~~
-Input: 2017
-Output: Fire Rooster
-~~~~
-
-#### Example 2
~~~~
-Input: 1938
-Output: Earth Tiger
+fusc(0) = 0
+fusc(1) = 1
+for n > 1:
+when n is even: fusc(n) = fusc(n / 2),
+when n is odd: fusc(n) = fusc((n-1)/2) + fusc((n+1)/2)
~~~~
### Notes
-We will actually output a three part string; beside the animal and element
-cycles, we also output the yin/yang cycle.
-
-We will be reading years from standard input, writing results to standard
-output.
+This challenge is beyond simple. Since we're asked to generate a
+fixed number of numbers, we don't need do any calculations, or
+even handle a single if statement. A single print statement is enough.
### Solutions
-* [AWK](awk/ch-1.awk)
-* [Bash](bash/ch-1.sh)
-* [Befunge-93](befunge-93/ch-1.bf93)
-* [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)
### Blog
-[Perl Weekly Challenge 103: Chinese Zodiac](https://wp.me/pcxd30-uS)
-
-## [What's playing?](https://perlweeklychallenge.org/blog/perl-weekly-challenge-103/#TASK2)
-Working from home, you decided that on occasion you wanted some
-background noise while working. You threw together a network streamer
-to continuously loop through the files and launched it in a tmux
-(or screen) session, giving it a directory tree of files to play.
-During the day, you connected an audio player to the stream, listening
-through the workday, closing it when done.
-For weeks you connect to the stream daily, slowly noticing a gradual
-drift of the media. After several weeks, you take vacation. When
-you return, you are pleasantly surprised to find the streamer still
-running. Before connecting, however, if you consider the puzzle of
-determining which track is playing.
+## [NIM Game](https://perlweeklychallenge.org/blog/perl-weekly-challenge-104/#TASK2)
+Write a script to simulate the NIM Game.
-After looking at a few modules to read info regarding the media, a
-quick bit of coding gave you a file list. The file list is in a
-simple CSV format, each line containing two fields: the first the
-number of milliseconds in length, the latter the media's title (this
-example is of several episodes available from the MercuryTheatre.info):
+It is played between 2 players. For the purpose of this task, let
+assume you play against the machine.
+There are 3 simple rules to follow:
~~~~
-1709363,"Les Miserables Episode 1: The Bishop (broadcast date: 1937-07-23)"
-1723781,"Les Miserables Episode 2: Javert (broadcast date: 1937-07-30)"
-1723781,"Les Miserables Episode 3: The Trial (broadcast date: 1937-08-06)"
-1678356,"Les Miserables Episode 4: Cosette (broadcast date: 1937-08-13)"
-1646043,"Les Miserables Episode 5: The Grave (broadcast date: 1937-08-20)"
-1714640,"Les Miserables Episode 6: The Barricade (broadcast date: 1937-08-27)"
-1714640,"Les Miserables Episode 7: Conclusion (broadcast date: 1937-09-03)"
+a) You have 12 tokens
+b) Each player can pick 1, 2 or 3 tokens at a time
+c) The player who picks the last token wins the game
~~~~
-For this script, you can assume to be provided the following information:
-* the value of `$^T` (`$BASETIME`) of the streamer script,
-* the value of `time()`, and
-* a CSV file containing the media to play consisting of the length in
- milliseconds and an identifier for the media (title, filename, or other).
-
-Write a program to output which file is currently playing. For
-purposes of this script, you may assume gapless playback, and format
-the output as you see fit.
-
-Optional: Also display the current position in the media as a time-like value.
-
-### Example
-~~~~
-Input: 3 command line parameters: start time, current time, file name
-
- # Streamer start time: Tue Nov 24 12:22:03 2020
- 1606134123
-
- # Current time: Mon Mar 1 09:34:36 2021
- 1614591276
-
- # filelist.csv
-
-Output:
+### Notes
+This is *not* the NIM game. In the NIM game, you have multiple sets
+of tokens, and on each turn, a player picks a set, and removes any
+non-zero number of of tokens from the set. Typically, the player
+picking the last token loses.
- "Les Miserables Episode 1: The Bishop (broadcast date: 1937-07-23)"
- 00:17:33
-~~~~
+The game as given is a win for the second player, who will win on
+the third move.
### Solutions
-* [GNU AWK](awk/ch-2.awk)
-* [Bash](bash/ch-2.sh)
-* [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 103: What's playing?](https://wp.me/pcxd30-v6)