From f309b17f1652cb9911793d5aad3cf68369769719 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Mon, 29 Jul 2019 01:06:01 +0100 Subject: - Added template for Challenge - 019. --- challenge-019/aaron-sherman/README | 1 + challenge-019/abigail/README | 1 + challenge-019/adam-russell/README | 1 + challenge-019/ailbhe-tweedie/README | 1 + challenge-019/alex-daniel/README | 1 + challenge-019/alexander-karelas/README | 1 + challenge-019/alexey-melezhik/README | 1 + challenge-019/alicia-bielsa/README | 1 + challenge-019/andrezgz/README | 1 + challenge-019/antonio-gamiz/README | 1 + challenge-019/arne-sommer/README | 1 + challenge-019/arpad-toth/README | 1 + challenge-019/athanasius/README | 1 + challenge-019/aubrey-quarcoo/README | 1 + challenge-019/bill-palmer/README | 1 + challenge-019/bob-kleemann/README | 1 + challenge-019/cliveholloway/README | 1 + challenge-019/daniel-mantovani/README | 1 + challenge-019/daniel-mita/README | 1 + challenge-019/dave-cross/README | 1 + challenge-019/dave-jacoby/README | 1 + challenge-019/david-kayal/README | 1 + challenge-019/denis-yurashku/README | 1 + challenge-019/donald-hunter/README | 1 + challenge-019/doug-schrag/README | 1 + challenge-019/duane-powell/README | 1 + challenge-019/duncan-c-white/README | 33 ++++++++++++++++++++++ challenge-019/e-choroba/README | 1 + challenge-019/eddy-hs/README | 1 + challenge-019/feng-chang/README | 1 + challenge-019/finley/README | 1 + challenge-019/fjwhittle/README | 1 + challenge-019/fred-zinn/README | 1 + challenge-019/freddie-b/README | 1 + challenge-019/guillermo-ramos/README | 1 + challenge-019/gustavo-chaves/README | 1 + challenge-019/jacques-guinnebault/README | 1 + challenge-019/jaime/README | 42 ++++++++++++++++++++++++++++ challenge-019/jaldhar-h-vyas/README | 1 + challenge-019/jeff/README | 1 + challenge-019/jeremy-carman/README | 1 + challenge-019/jim-bacon/README | 1 + challenge-019/jj-merelo/README | 1 + challenge-019/jo-christian-oterhals/README | 1 + challenge-019/joe-tym/README | 1 + challenge-019/joelle-maslak/README | 1 + challenge-019/joelle-maslak/perl5/.gitignore | 1 + challenge-019/john-barrett/README | 1 + challenge-019/juan-caballero/README | 1 + challenge-019/kevin-colyer/README | 1 + challenge-019/khalid/README | 1 + challenge-019/kian-meng-ang/README | 1 + challenge-019/kivanc-yazan/README | 1 + challenge-019/lars-balker/README | 1 + challenge-019/laurent-rosenfeld/README | 1 + challenge-019/lubos-kolouch/README | 1 + challenge-019/magnus-woldrich/README | 1 + challenge-019/mano-chandar/README | 1 + challenge-019/mark-anderson/README | 1 + challenge-019/mark-senn/README | 1 + challenge-019/martin-barth/README | 1 + challenge-019/martin-mugeni/README | 1 + challenge-019/matt-latusek/README | 1 + challenge-019/matthew-persico/README | 1 + challenge-019/maxim-kolodyazhny/README | 1 + challenge-019/maxim-nechaev/README | 1 + challenge-019/michael-hamlin/README | 5 ++++ challenge-019/michael-schaap/README | 1 + challenge-019/neil-bowers/README | 1 + challenge-019/nick-logan/README | 1 + challenge-019/nikhil-prasanna/README | 1 + challenge-019/noud/README | 1 + challenge-019/ohmycloud/README | 1 + challenge-019/oleksii-tsvietnov/README | 1 + challenge-019/orestis-zekai/README | 1 + challenge-019/ozzy/README | 1 + challenge-019/pavel-jurca/README | 1 + challenge-019/pavel-starikov/README | 1 + challenge-019/pete-houston/README | 1 + challenge-019/pete-sergeant/README | 1 + challenge-019/philippe-bruhat/README | 1 + challenge-019/prajith-p/README | 1 + challenge-019/randy-lauen/README | 1 + challenge-019/rob-van-dam/README | 1 + challenge-019/rob4t/README | 1 + challenge-019/roger-bell-west/README | 1 + challenge-019/ruben-westerberg/README | 9 ++++++ challenge-019/sean-meininger/README | 1 + challenge-019/sergiotarxz/README | 1 + challenge-019/shardiwal/README | 1 + challenge-019/shaun-pearce/README | 1 + challenge-019/simon-miner/README | 1 + challenge-019/simon-proctor/README | 1 + challenge-019/simon-reinhardt/README | 1 + challenge-019/steve-rogerson/README | 1 + challenge-019/steven-lembark/README | 1 + challenge-019/steven-wilson/README | 1 + challenge-019/tiago-stock/README | 1 + challenge-019/tim-smith/README | 1 + challenge-019/tore-andersson/README | 1 + challenge-019/uzluisf/README | 1 + challenge-019/veesh-goldman/README | 1 + challenge-019/walt-mankowski/README | 1 + challenge-019/william-gilmore/README | 1 + challenge-019/yary-h/README | 1 + challenge-019/yozen-hernandez/README | 1 + 106 files changed, 191 insertions(+) create mode 100644 challenge-019/aaron-sherman/README create mode 100644 challenge-019/abigail/README create mode 100644 challenge-019/adam-russell/README create mode 100644 challenge-019/ailbhe-tweedie/README create mode 100644 challenge-019/alex-daniel/README create mode 100644 challenge-019/alexander-karelas/README create mode 100644 challenge-019/alexey-melezhik/README create mode 100644 challenge-019/alicia-bielsa/README create mode 100644 challenge-019/andrezgz/README create mode 100644 challenge-019/antonio-gamiz/README create mode 100644 challenge-019/arne-sommer/README create mode 100644 challenge-019/arpad-toth/README create mode 100644 challenge-019/athanasius/README create mode 100644 challenge-019/aubrey-quarcoo/README create mode 100644 challenge-019/bill-palmer/README create mode 100644 challenge-019/bob-kleemann/README create mode 100644 challenge-019/cliveholloway/README create mode 100644 challenge-019/daniel-mantovani/README create mode 100644 challenge-019/daniel-mita/README create mode 100644 challenge-019/dave-cross/README create mode 100644 challenge-019/dave-jacoby/README create mode 100644 challenge-019/david-kayal/README create mode 100644 challenge-019/denis-yurashku/README create mode 100644 challenge-019/donald-hunter/README create mode 100644 challenge-019/doug-schrag/README create mode 100644 challenge-019/duane-powell/README create mode 100644 challenge-019/duncan-c-white/README create mode 100644 challenge-019/e-choroba/README create mode 100644 challenge-019/eddy-hs/README create mode 100644 challenge-019/feng-chang/README create mode 100644 challenge-019/finley/README create mode 100644 challenge-019/fjwhittle/README create mode 100644 challenge-019/fred-zinn/README create mode 100644 challenge-019/freddie-b/README create mode 100644 challenge-019/guillermo-ramos/README create mode 100644 challenge-019/gustavo-chaves/README create mode 100644 challenge-019/jacques-guinnebault/README create mode 100644 challenge-019/jaime/README create mode 100644 challenge-019/jaldhar-h-vyas/README create mode 100644 challenge-019/jeff/README create mode 100644 challenge-019/jeremy-carman/README create mode 100644 challenge-019/jim-bacon/README create mode 100644 challenge-019/jj-merelo/README create mode 100644 challenge-019/jo-christian-oterhals/README create mode 100644 challenge-019/joe-tym/README create mode 100644 challenge-019/joelle-maslak/README create mode 100644 challenge-019/joelle-maslak/perl5/.gitignore create mode 100644 challenge-019/john-barrett/README create mode 100644 challenge-019/juan-caballero/README create mode 100644 challenge-019/kevin-colyer/README create mode 100644 challenge-019/khalid/README create mode 100644 challenge-019/kian-meng-ang/README create mode 100644 challenge-019/kivanc-yazan/README create mode 100644 challenge-019/lars-balker/README create mode 100644 challenge-019/laurent-rosenfeld/README create mode 100644 challenge-019/lubos-kolouch/README create mode 100644 challenge-019/magnus-woldrich/README create mode 100644 challenge-019/mano-chandar/README create mode 100644 challenge-019/mark-anderson/README create mode 100644 challenge-019/mark-senn/README create mode 100644 challenge-019/martin-barth/README create mode 100644 challenge-019/martin-mugeni/README create mode 100644 challenge-019/matt-latusek/README create mode 100644 challenge-019/matthew-persico/README create mode 100644 challenge-019/maxim-kolodyazhny/README create mode 100644 challenge-019/maxim-nechaev/README create mode 100644 challenge-019/michael-hamlin/README create mode 100644 challenge-019/michael-schaap/README create mode 100644 challenge-019/neil-bowers/README create mode 100644 challenge-019/nick-logan/README create mode 100644 challenge-019/nikhil-prasanna/README create mode 100644 challenge-019/noud/README create mode 100644 challenge-019/ohmycloud/README create mode 100644 challenge-019/oleksii-tsvietnov/README create mode 100644 challenge-019/orestis-zekai/README create mode 100644 challenge-019/ozzy/README create mode 100644 challenge-019/pavel-jurca/README create mode 100644 challenge-019/pavel-starikov/README create mode 100644 challenge-019/pete-houston/README create mode 100644 challenge-019/pete-sergeant/README create mode 100644 challenge-019/philippe-bruhat/README create mode 100644 challenge-019/prajith-p/README create mode 100644 challenge-019/randy-lauen/README create mode 100644 challenge-019/rob-van-dam/README create mode 100644 challenge-019/rob4t/README create mode 100644 challenge-019/roger-bell-west/README create mode 100644 challenge-019/ruben-westerberg/README create mode 100644 challenge-019/sean-meininger/README create mode 100644 challenge-019/sergiotarxz/README create mode 100644 challenge-019/shardiwal/README create mode 100644 challenge-019/shaun-pearce/README create mode 100644 challenge-019/simon-miner/README create mode 100644 challenge-019/simon-proctor/README create mode 100644 challenge-019/simon-reinhardt/README create mode 100644 challenge-019/steve-rogerson/README create mode 100644 challenge-019/steven-lembark/README create mode 100644 challenge-019/steven-wilson/README create mode 100644 challenge-019/tiago-stock/README create mode 100644 challenge-019/tim-smith/README create mode 100644 challenge-019/tore-andersson/README create mode 100644 challenge-019/uzluisf/README create mode 100644 challenge-019/veesh-goldman/README create mode 100644 challenge-019/walt-mankowski/README create mode 100644 challenge-019/william-gilmore/README create mode 100644 challenge-019/yary-h/README create mode 100644 challenge-019/yozen-hernandez/README (limited to 'challenge-019') diff --git a/challenge-019/aaron-sherman/README b/challenge-019/aaron-sherman/README new file mode 100644 index 0000000000..14ec31f570 --- /dev/null +++ b/challenge-019/aaron-sherman/README @@ -0,0 +1 @@ +Solutions by Aaron Sherman. diff --git a/challenge-019/abigail/README b/challenge-019/abigail/README new file mode 100644 index 0000000000..5f0d73ae16 --- /dev/null +++ b/challenge-019/abigail/README @@ -0,0 +1 @@ +Solution by Abigail diff --git a/challenge-019/adam-russell/README b/challenge-019/adam-russell/README new file mode 100644 index 0000000000..9420c9a781 --- /dev/null +++ b/challenge-019/adam-russell/README @@ -0,0 +1 @@ +Solution by Adam Russell diff --git a/challenge-019/ailbhe-tweedie/README b/challenge-019/ailbhe-tweedie/README new file mode 100644 index 0000000000..36d4034b70 --- /dev/null +++ b/challenge-019/ailbhe-tweedie/README @@ -0,0 +1 @@ +Solution by Ailbhe Tweedie diff --git a/challenge-019/alex-daniel/README b/challenge-019/alex-daniel/README new file mode 100644 index 0000000000..65550789bd --- /dev/null +++ b/challenge-019/alex-daniel/README @@ -0,0 +1 @@ +Solution by Alex Daniel. diff --git a/challenge-019/alexander-karelas/README b/challenge-019/alexander-karelas/README new file mode 100644 index 0000000000..3de9fce8d9 --- /dev/null +++ b/challenge-019/alexander-karelas/README @@ -0,0 +1 @@ +Solution by Alexander Karelas diff --git a/challenge-019/alexey-melezhik/README b/challenge-019/alexey-melezhik/README new file mode 100644 index 0000000000..ca7008f224 --- /dev/null +++ b/challenge-019/alexey-melezhik/README @@ -0,0 +1 @@ +Solution by Alexey Melezhik diff --git a/challenge-019/alicia-bielsa/README b/challenge-019/alicia-bielsa/README new file mode 100644 index 0000000000..c5187874c3 --- /dev/null +++ b/challenge-019/alicia-bielsa/README @@ -0,0 +1 @@ +Solution by Alicia Beilsa. diff --git a/challenge-019/andrezgz/README b/challenge-019/andrezgz/README new file mode 100644 index 0000000000..f4fd0da88e --- /dev/null +++ b/challenge-019/andrezgz/README @@ -0,0 +1 @@ +Solution by Andrezgz diff --git a/challenge-019/antonio-gamiz/README b/challenge-019/antonio-gamiz/README new file mode 100644 index 0000000000..1f5ed5871a --- /dev/null +++ b/challenge-019/antonio-gamiz/README @@ -0,0 +1 @@ +Solution by Antonio Gamiz diff --git a/challenge-019/arne-sommer/README b/challenge-019/arne-sommer/README new file mode 100644 index 0000000000..b5d88e4df4 --- /dev/null +++ b/challenge-019/arne-sommer/README @@ -0,0 +1 @@ +Solution by Arne Sommer. diff --git a/challenge-019/arpad-toth/README b/challenge-019/arpad-toth/README new file mode 100644 index 0000000000..6661dd82c1 --- /dev/null +++ b/challenge-019/arpad-toth/README @@ -0,0 +1 @@ +Solution by Arpad Toth diff --git a/challenge-019/athanasius/README b/challenge-019/athanasius/README new file mode 100644 index 0000000000..cc357fda4a --- /dev/null +++ b/challenge-019/athanasius/README @@ -0,0 +1 @@ +Solution by Athanasius diff --git a/challenge-019/aubrey-quarcoo/README b/challenge-019/aubrey-quarcoo/README new file mode 100644 index 0000000000..8e63a2c1f5 --- /dev/null +++ b/challenge-019/aubrey-quarcoo/README @@ -0,0 +1 @@ +Solution by Aubrey Quarcoo diff --git a/challenge-019/bill-palmer/README b/challenge-019/bill-palmer/README new file mode 100644 index 0000000000..08ec849a41 --- /dev/null +++ b/challenge-019/bill-palmer/README @@ -0,0 +1 @@ +Solution by Bill Palmer. diff --git a/challenge-019/bob-kleemann/README b/challenge-019/bob-kleemann/README new file mode 100644 index 0000000000..78680e4035 --- /dev/null +++ b/challenge-019/bob-kleemann/README @@ -0,0 +1 @@ +Solution by Bob Kleemann diff --git a/challenge-019/cliveholloway/README b/challenge-019/cliveholloway/README new file mode 100644 index 0000000000..b69201296e --- /dev/null +++ b/challenge-019/cliveholloway/README @@ -0,0 +1 @@ +Solution by Clive Holloway diff --git a/challenge-019/daniel-mantovani/README b/challenge-019/daniel-mantovani/README new file mode 100644 index 0000000000..ed538216f2 --- /dev/null +++ b/challenge-019/daniel-mantovani/README @@ -0,0 +1 @@ +Solution by Daniel Mantovani diff --git a/challenge-019/daniel-mita/README b/challenge-019/daniel-mita/README new file mode 100644 index 0000000000..37339f491f --- /dev/null +++ b/challenge-019/daniel-mita/README @@ -0,0 +1 @@ +Solution by Daniel Mita diff --git a/challenge-019/dave-cross/README b/challenge-019/dave-cross/README new file mode 100644 index 0000000000..04b1b0623b --- /dev/null +++ b/challenge-019/dave-cross/README @@ -0,0 +1 @@ +Solution by Dave Cross diff --git a/challenge-019/dave-jacoby/README b/challenge-019/dave-jacoby/README new file mode 100644 index 0000000000..7c06689f16 --- /dev/null +++ b/challenge-019/dave-jacoby/README @@ -0,0 +1 @@ +Solution by Dave Jacoby diff --git a/challenge-019/david-kayal/README b/challenge-019/david-kayal/README new file mode 100644 index 0000000000..66f8615260 --- /dev/null +++ b/challenge-019/david-kayal/README @@ -0,0 +1 @@ +Solution by David Kayal diff --git a/challenge-019/denis-yurashku/README b/challenge-019/denis-yurashku/README new file mode 100644 index 0000000000..2fea994000 --- /dev/null +++ b/challenge-019/denis-yurashku/README @@ -0,0 +1 @@ +Solutions by Denis Yurashku. diff --git a/challenge-019/donald-hunter/README b/challenge-019/donald-hunter/README new file mode 100644 index 0000000000..2eef878f17 --- /dev/null +++ b/challenge-019/donald-hunter/README @@ -0,0 +1 @@ +Solutions by Donald Hunter. diff --git a/challenge-019/doug-schrag/README b/challenge-019/doug-schrag/README new file mode 100644 index 0000000000..bf8a10ffb4 --- /dev/null +++ b/challenge-019/doug-schrag/README @@ -0,0 +1 @@ +Solution by Doug Schrag diff --git a/challenge-019/duane-powell/README b/challenge-019/duane-powell/README new file mode 100644 index 0000000000..3445422743 --- /dev/null +++ b/challenge-019/duane-powell/README @@ -0,0 +1 @@ +Solutions by Duane Powell. diff --git a/challenge-019/duncan-c-white/README b/challenge-019/duncan-c-white/README new file mode 100644 index 0000000000..0220538063 --- /dev/null +++ b/challenge-019/duncan-c-white/README @@ -0,0 +1,33 @@ +Challenge 1: "Write a script that takes 2 or more strings as command +line parameters and print the longest common substring. For example, +the longest common substring of the strings "ABABC", "ABCA" +and "BCBA" is string "BC" of length 3. +" + +My notes: + +Very clearly described. No obvious clever way of solving this, but the +basic method is simple. + + +Challenge 2: "Write a script to implement Priority Queue. It is like +regular queue except each element has a priority associated with it. In a +priority queue, an element with high priority is served before an element +with low priority. It should serve the following operations: + +1) is_empty: check whether the queue has no elements. + +2) insert_with_priority: add an element to the queue with an associated + priority. + +3) pull_highest_priority_element: remove the element from the queue that + has the highest priority, and return it. If two elements have the same + priority, then return element added first. + +" + +My notes: At last, a nicely specified problem to implement a nice data +type. meat and drink to me! I've split out the Priority Queue +implementation into the module PQ.pm, minimally-OO in order to +get free magic PQ printing via interpolation and the magic of +stringification. diff --git a/challenge-019/e-choroba/README b/challenge-019/e-choroba/README new file mode 100644 index 0000000000..efff637bcb --- /dev/null +++ b/challenge-019/e-choroba/README @@ -0,0 +1 @@ +Solutions by E. Choroba. diff --git a/challenge-019/eddy-hs/README b/challenge-019/eddy-hs/README new file mode 100644 index 0000000000..0ed51d222d --- /dev/null +++ b/challenge-019/eddy-hs/README @@ -0,0 +1 @@ +Solution by Eddy HS diff --git a/challenge-019/feng-chang/README b/challenge-019/feng-chang/README new file mode 100644 index 0000000000..74e56de3ed --- /dev/null +++ b/challenge-019/feng-chang/README @@ -0,0 +1 @@ +Solutions by Feng Chang. diff --git a/challenge-019/finley/README b/challenge-019/finley/README new file mode 100644 index 0000000000..f08a121076 --- /dev/null +++ b/challenge-019/finley/README @@ -0,0 +1 @@ +Solution by Finley diff --git a/challenge-019/fjwhittle/README b/challenge-019/fjwhittle/README new file mode 100644 index 0000000000..7dcc95e189 --- /dev/null +++ b/challenge-019/fjwhittle/README @@ -0,0 +1 @@ +Solution by Francis Whittle diff --git a/challenge-019/fred-zinn/README b/challenge-019/fred-zinn/README new file mode 100644 index 0000000000..17bac4f094 --- /dev/null +++ b/challenge-019/fred-zinn/README @@ -0,0 +1 @@ +Solution by Fred Zinn diff --git a/challenge-019/freddie-b/README b/challenge-019/freddie-b/README new file mode 100644 index 0000000000..823d7474b5 --- /dev/null +++ b/challenge-019/freddie-b/README @@ -0,0 +1 @@ +Solution by Freddie B diff --git a/challenge-019/guillermo-ramos/README b/challenge-019/guillermo-ramos/README new file mode 100644 index 0000000000..a39eb01bff --- /dev/null +++ b/challenge-019/guillermo-ramos/README @@ -0,0 +1 @@ +Solution by Guillermo Ramos. diff --git a/challenge-019/gustavo-chaves/README b/challenge-019/gustavo-chaves/README new file mode 100644 index 0000000000..a66bbbf8a3 --- /dev/null +++ b/challenge-019/gustavo-chaves/README @@ -0,0 +1 @@ +Solution by Gustavo Chaves diff --git a/challenge-019/jacques-guinnebault/README b/challenge-019/jacques-guinnebault/README new file mode 100644 index 0000000000..9d3e7c037f --- /dev/null +++ b/challenge-019/jacques-guinnebault/README @@ -0,0 +1 @@ +Solution by Jacques Guinnebault. diff --git a/challenge-019/jaime/README b/challenge-019/jaime/README new file mode 100644 index 0000000000..c1fbac90da --- /dev/null +++ b/challenge-019/jaime/README @@ -0,0 +1,42 @@ +# Challenge #1 + +Write a script that takes 2 or more strings as command line parameters +and print the longest common substring. For example, the longest +common substring of the strings “ABABC”, “BABCA” and “ABCBA” is string +“ABC” of length 3. Other common substrings are “A”, “AB”, “B”, “BA”, +“BC” and “C”. + +## Solution + +Substrings of the first argument are iterated by decreasing length. + +The script finds the `$substring` that is common within the list of +parameters `@ARGV == grep(/$substring/,@ARGV)`. + +# Challenge #2 + +Write a script to implement Priority Queue. It is like regular queue +except each element has a priority associated with it. In a priority +queue, an element with high priority is served before an element with +low priority. Please check this wiki page for more informations. It +should serve the following operations: + +1. `is_empty`: check whether the queue has no elements. + +2. `insert_with_priority`: add an element to the queue with an +associated priority. + +3. `pull_highest_priority_element`: remove the element from the queue +that has the highest priority, and return it. If two elements have the +same priority, then return element added first. + +## Solution + +The solution is a hashmap of priority and anonymous arrays. + +The anonymous array `[]` is accessed with a `$priority`. +`$queue` is the hashmap. `$queue->{$priority}` is an anonymous array. +`@{$queue->{$priority}}` wraps access to the prioritized queues as arrays. + +`pull_highest_priority_element()` parses the `$queue` to find the +nonempty array with the largest priority, then returns the first entry. diff --git a/challenge-019/jaldhar-h-vyas/README b/challenge-019/jaldhar-h-vyas/README new file mode 100644 index 0000000000..7dce927eca --- /dev/null +++ b/challenge-019/jaldhar-h-vyas/README @@ -0,0 +1 @@ +Solution by Jaldhar H. Vyas diff --git a/challenge-019/jeff/README b/challenge-019/jeff/README new file mode 100644 index 0000000000..d5f15f4a8e --- /dev/null +++ b/challenge-019/jeff/README @@ -0,0 +1 @@ +Solution by Jeff diff --git a/challenge-019/jeremy-carman/README b/challenge-019/jeremy-carman/README new file mode 100644 index 0000000000..3d08510e49 --- /dev/null +++ b/challenge-019/jeremy-carman/README @@ -0,0 +1 @@ +Solution by Jeremy Carman diff --git a/challenge-019/jim-bacon/README b/challenge-019/jim-bacon/README new file mode 100644 index 0000000000..8dcfd637a3 --- /dev/null +++ b/challenge-019/jim-bacon/README @@ -0,0 +1 @@ +Solution by Jim Bacon diff --git a/challenge-019/jj-merelo/README b/challenge-019/jj-merelo/README new file mode 100644 index 0000000000..d09838676b --- /dev/null +++ b/challenge-019/jj-merelo/README @@ -0,0 +1 @@ +Solution by JJ Merelo diff --git a/challenge-019/jo-christian-oterhals/README b/challenge-019/jo-christian-oterhals/README new file mode 100644 index 0000000000..eafff999fb --- /dev/null +++ b/challenge-019/jo-christian-oterhals/README @@ -0,0 +1 @@ +Solution by Jo Christian Oterhals diff --git a/challenge-019/joe-tym/README b/challenge-019/joe-tym/README new file mode 100644 index 0000000000..4e2d1b704f --- /dev/null +++ b/challenge-019/joe-tym/README @@ -0,0 +1 @@ +Solutions by Joe Tym. diff --git a/challenge-019/joelle-maslak/README b/challenge-019/joelle-maslak/README new file mode 100644 index 0000000000..d12c7940c3 --- /dev/null +++ b/challenge-019/joelle-maslak/README @@ -0,0 +1 @@ +Solution by Joelle Maslak diff --git a/challenge-019/joelle-maslak/perl5/.gitignore b/challenge-019/joelle-maslak/perl5/.gitignore new file mode 100644 index 0000000000..714f73c541 --- /dev/null +++ b/challenge-019/joelle-maslak/perl5/.gitignore @@ -0,0 +1 @@ +_Inline diff --git a/challenge-019/john-barrett/README b/challenge-019/john-barrett/README new file mode 100644 index 0000000000..a7ff0af641 --- /dev/null +++ b/challenge-019/john-barrett/README @@ -0,0 +1 @@ +Solution by John Barrett diff --git a/challenge-019/juan-caballero/README b/challenge-019/juan-caballero/README new file mode 100644 index 0000000000..bffe4b05c2 --- /dev/null +++ b/challenge-019/juan-caballero/README @@ -0,0 +1 @@ +Solution by Juan Caballero diff --git a/challenge-019/kevin-colyer/README b/challenge-019/kevin-colyer/README new file mode 100644 index 0000000000..32aa940083 --- /dev/null +++ b/challenge-019/kevin-colyer/README @@ -0,0 +1 @@ +Solutions by Kevin Colyer. diff --git a/challenge-019/khalid/README b/challenge-019/khalid/README new file mode 100644 index 0000000000..1ca4211368 --- /dev/null +++ b/challenge-019/khalid/README @@ -0,0 +1 @@ +Solution by Khalid diff --git a/challenge-019/kian-meng-ang/README b/challenge-019/kian-meng-ang/README new file mode 100644 index 0000000000..a5f0359813 --- /dev/null +++ b/challenge-019/kian-meng-ang/README @@ -0,0 +1 @@ +Solution by Kian-Meng Ang diff --git a/challenge-019/kivanc-yazan/README b/challenge-019/kivanc-yazan/README new file mode 100644 index 0000000000..bc7f8ca509 --- /dev/null +++ b/challenge-019/kivanc-yazan/README @@ -0,0 +1 @@ +Solution by Kivanc Yazan diff --git a/challenge-019/lars-balker/README b/challenge-019/lars-balker/README new file mode 100644 index 0000000000..054649c9eb --- /dev/null +++ b/challenge-019/lars-balker/README @@ -0,0 +1 @@ +Solution by Lars Balker diff --git a/challenge-019/laurent-rosenfeld/README b/challenge-019/laurent-rosenfeld/README new file mode 100644 index 0000000000..f9c6e1437e --- /dev/null +++ b/challenge-019/laurent-rosenfeld/README @@ -0,0 +1 @@ +Solution by Laurent Rosenfeld diff --git a/challenge-019/lubos-kolouch/README b/challenge-019/lubos-kolouch/README new file mode 100644 index 0000000000..921b2d9f4a --- /dev/null +++ b/challenge-019/lubos-kolouch/README @@ -0,0 +1 @@ +Solutions by Lubos Kolouch. diff --git a/challenge-019/magnus-woldrich/README b/challenge-019/magnus-woldrich/README new file mode 100644 index 0000000000..79cde2997c --- /dev/null +++ b/challenge-019/magnus-woldrich/README @@ -0,0 +1 @@ +Solution by Magnus Woldrich diff --git a/challenge-019/mano-chandar/README b/challenge-019/mano-chandar/README new file mode 100644 index 0000000000..2ec028460a --- /dev/null +++ b/challenge-019/mano-chandar/README @@ -0,0 +1 @@ +Solutions by Mano Chandar. diff --git a/challenge-019/mark-anderson/README b/challenge-019/mark-anderson/README new file mode 100644 index 0000000000..544858a104 --- /dev/null +++ b/challenge-019/mark-anderson/README @@ -0,0 +1 @@ +Solutions by Mark Anderson. diff --git a/challenge-019/mark-senn/README b/challenge-019/mark-senn/README new file mode 100644 index 0000000000..f37c93431c --- /dev/null +++ b/challenge-019/mark-senn/README @@ -0,0 +1 @@ +Solution by Mark Senn diff --git a/challenge-019/martin-barth/README b/challenge-019/martin-barth/README new file mode 100644 index 0000000000..13c469f3c3 --- /dev/null +++ b/challenge-019/martin-barth/README @@ -0,0 +1 @@ +Solutions by Martin Barth. diff --git a/challenge-019/martin-mugeni/README b/challenge-019/martin-mugeni/README new file mode 100644 index 0000000000..416ca98166 --- /dev/null +++ b/challenge-019/martin-mugeni/README @@ -0,0 +1 @@ +Solution by Martin Mugeni diff --git a/challenge-019/matt-latusek/README b/challenge-019/matt-latusek/README new file mode 100644 index 0000000000..e1dc8b6e16 --- /dev/null +++ b/challenge-019/matt-latusek/README @@ -0,0 +1 @@ +Solution by Matt Latusek. diff --git a/challenge-019/matthew-persico/README b/challenge-019/matthew-persico/README new file mode 100644 index 0000000000..5aa5622296 --- /dev/null +++ b/challenge-019/matthew-persico/README @@ -0,0 +1 @@ +Solutions by Matthew O. Persico. diff --git a/challenge-019/maxim-kolodyazhny/README b/challenge-019/maxim-kolodyazhny/README new file mode 100644 index 0000000000..e5b4df7154 --- /dev/null +++ b/challenge-019/maxim-kolodyazhny/README @@ -0,0 +1 @@ +Solution by Maxim Kolodyazhny diff --git a/challenge-019/maxim-nechaev/README b/challenge-019/maxim-nechaev/README new file mode 100644 index 0000000000..0695cbfa4d --- /dev/null +++ b/challenge-019/maxim-nechaev/README @@ -0,0 +1 @@ +Solutions by Maxim Nechaev. diff --git a/challenge-019/michael-hamlin/README b/challenge-019/michael-hamlin/README new file mode 100644 index 0000000000..3c1a735306 --- /dev/null +++ b/challenge-019/michael-hamlin/README @@ -0,0 +1,5 @@ +Solutions by Michael Hamlin. + +ch-1.pl the Ackermann function grows so rapidly that I dont think I can +test the real hyperness of my code, even with GMP. + diff --git a/challenge-019/michael-schaap/README b/challenge-019/michael-schaap/README new file mode 100644 index 0000000000..db803c5d87 --- /dev/null +++ b/challenge-019/michael-schaap/README @@ -0,0 +1 @@ +Solution by Michael Schaap diff --git a/challenge-019/neil-bowers/README b/challenge-019/neil-bowers/README new file mode 100644 index 0000000000..9d446303df --- /dev/null +++ b/challenge-019/neil-bowers/README @@ -0,0 +1 @@ +Solution by Neil Bowers diff --git a/challenge-019/nick-logan/README b/challenge-019/nick-logan/README new file mode 100644 index 0000000000..86919ac8b8 --- /dev/null +++ b/challenge-019/nick-logan/README @@ -0,0 +1 @@ +Solution by Nick Logan diff --git a/challenge-019/nikhil-prasanna/README b/challenge-019/nikhil-prasanna/README new file mode 100644 index 0000000000..7c28d1a844 --- /dev/null +++ b/challenge-019/nikhil-prasanna/README @@ -0,0 +1 @@ +Solution by Nikhil Prasanna. diff --git a/challenge-019/noud/README b/challenge-019/noud/README new file mode 100644 index 0000000000..0b0970d708 --- /dev/null +++ b/challenge-019/noud/README @@ -0,0 +1 @@ +Solution by Noud diff --git a/challenge-019/ohmycloud/README b/challenge-019/ohmycloud/README new file mode 100644 index 0000000000..e993fafea7 --- /dev/null +++ b/challenge-019/ohmycloud/README @@ -0,0 +1 @@ +Solution by Ohmycloud diff --git a/challenge-019/oleksii-tsvietnov/README b/challenge-019/oleksii-tsvietnov/README new file mode 100644 index 0000000000..113183cc6d --- /dev/null +++ b/challenge-019/oleksii-tsvietnov/README @@ -0,0 +1 @@ +Solution by Oleksii Tsvietnov diff --git a/challenge-019/orestis-zekai/README b/challenge-019/orestis-zekai/README new file mode 100644 index 0000000000..7e89e9dd0f --- /dev/null +++ b/challenge-019/orestis-zekai/README @@ -0,0 +1 @@ +Solutions by Orestis Zekai. diff --git a/challenge-019/ozzy/README b/challenge-019/ozzy/README new file mode 100644 index 0000000000..44e39371ef --- /dev/null +++ b/challenge-019/ozzy/README @@ -0,0 +1 @@ +Solution by Ozzy diff --git a/challenge-019/pavel-jurca/README b/challenge-019/pavel-jurca/README new file mode 100644 index 0000000000..78d131bd34 --- /dev/null +++ b/challenge-019/pavel-jurca/README @@ -0,0 +1 @@ +Solution by Pavel Jurca diff --git a/challenge-019/pavel-starikov/README b/challenge-019/pavel-starikov/README new file mode 100644 index 0000000000..67ed468ff0 --- /dev/null +++ b/challenge-019/pavel-starikov/README @@ -0,0 +1 @@ +Solutions by Pavel Starikov. diff --git a/challenge-019/pete-houston/README b/challenge-019/pete-houston/README new file mode 100644 index 0000000000..15d44fe3a4 --- /dev/null +++ b/challenge-019/pete-houston/README @@ -0,0 +1 @@ +Solution by Pete Houston diff --git a/challenge-019/pete-sergeant/README b/challenge-019/pete-sergeant/README new file mode 100644 index 0000000000..baf8dfe304 --- /dev/null +++ b/challenge-019/pete-sergeant/README @@ -0,0 +1 @@ +Solutions by Pete Sergeant. diff --git a/challenge-019/philippe-bruhat/README b/challenge-019/philippe-bruhat/README new file mode 100644 index 0000000000..0bf3aeed05 --- /dev/null +++ b/challenge-019/philippe-bruhat/README @@ -0,0 +1 @@ +Solution by Philippe Bruhat diff --git a/challenge-019/prajith-p/README b/challenge-019/prajith-p/README new file mode 100644 index 0000000000..20517308f8 --- /dev/null +++ b/challenge-019/prajith-p/README @@ -0,0 +1 @@ +Solution by Prajith P diff --git a/challenge-019/randy-lauen/README b/challenge-019/randy-lauen/README new file mode 100644 index 0000000000..17fac69a1c --- /dev/null +++ b/challenge-019/randy-lauen/README @@ -0,0 +1 @@ +Solution by Randy Lauen diff --git a/challenge-019/rob-van-dam/README b/challenge-019/rob-van-dam/README new file mode 100644 index 0000000000..d0e17767f8 --- /dev/null +++ b/challenge-019/rob-van-dam/README @@ -0,0 +1 @@ +Solution by Rob Van Dam diff --git a/challenge-019/rob4t/README b/challenge-019/rob4t/README new file mode 100644 index 0000000000..787d89fa0a --- /dev/null +++ b/challenge-019/rob4t/README @@ -0,0 +1 @@ +Solution by Robert Gratza diff --git a/challenge-019/roger-bell-west/README b/challenge-019/roger-bell-west/README new file mode 100644 index 0000000000..245784dce5 --- /dev/null +++ b/challenge-019/roger-bell-west/README @@ -0,0 +1 @@ +Solutions by Roger Bell West. diff --git a/challenge-019/ruben-westerberg/README b/challenge-019/ruben-westerberg/README new file mode 100644 index 0000000000..60f1fb8f9a --- /dev/null +++ b/challenge-019/ruben-westerberg/README @@ -0,0 +1,9 @@ +Solution by Ruben Westerberg + +ch-1.pl and ch-1.p6 +=== +Run the program with two arguments to find the longest sub string common to both. alpha numeric characters only. + +ch-2.pl and ch-2.p6 +=== +Run the program to demonstrate a priority queue inserting, listing and pulling data until empty diff --git a/challenge-019/sean-meininger/README b/challenge-019/sean-meininger/README new file mode 100644 index 0000000000..8ca81e00a0 --- /dev/null +++ b/challenge-019/sean-meininger/README @@ -0,0 +1 @@ +Solution by Sean Meininger diff --git a/challenge-019/sergiotarxz/README b/challenge-019/sergiotarxz/README new file mode 100644 index 0000000000..6aac3baa4f --- /dev/null +++ b/challenge-019/sergiotarxz/README @@ -0,0 +1 @@ +Solution by Sergio Iglesias. diff --git a/challenge-019/shardiwal/README b/challenge-019/shardiwal/README new file mode 100644 index 0000000000..c529c63c01 --- /dev/null +++ b/challenge-019/shardiwal/README @@ -0,0 +1 @@ +Solution by Rakesh Kumar Shardiwal diff --git a/challenge-019/shaun-pearce/README b/challenge-019/shaun-pearce/README new file mode 100644 index 0000000000..9b251e6c06 --- /dev/null +++ b/challenge-019/shaun-pearce/README @@ -0,0 +1 @@ +Solutions by Shaun Pearce. diff --git a/challenge-019/simon-miner/README b/challenge-019/simon-miner/README new file mode 100644 index 0000000000..cc433eaa54 --- /dev/null +++ b/challenge-019/simon-miner/README @@ -0,0 +1 @@ +Solutions by Simon Miner. diff --git a/challenge-019/simon-proctor/README b/challenge-019/simon-proctor/README new file mode 100644 index 0000000000..f674742166 --- /dev/null +++ b/challenge-019/simon-proctor/README @@ -0,0 +1 @@ +Solution by Simon Proctor diff --git a/challenge-019/simon-reinhardt/README b/challenge-019/simon-reinhardt/README new file mode 100644 index 0000000000..422afa13b4 --- /dev/null +++ b/challenge-019/simon-reinhardt/README @@ -0,0 +1 @@ +Solution by Simon Reinhardt diff --git a/challenge-019/steve-rogerson/README b/challenge-019/steve-rogerson/README new file mode 100644 index 0000000000..bd91edaf63 --- /dev/null +++ b/challenge-019/steve-rogerson/README @@ -0,0 +1 @@ +Solution by Steve Rogerson diff --git a/challenge-019/steven-lembark/README b/challenge-019/steven-lembark/README new file mode 100644 index 0000000000..74894afa94 --- /dev/null +++ b/challenge-019/steven-lembark/README @@ -0,0 +1 @@ +Solution by Steven Lembark diff --git a/challenge-019/steven-wilson/README b/challenge-019/steven-wilson/README new file mode 100644 index 0000000000..6911e56168 --- /dev/null +++ b/challenge-019/steven-wilson/README @@ -0,0 +1 @@ +Solution by Steven Wilson diff --git a/challenge-019/tiago-stock/README b/challenge-019/tiago-stock/README new file mode 100644 index 0000000000..096a081b30 --- /dev/null +++ b/challenge-019/tiago-stock/README @@ -0,0 +1 @@ +Solution by Tiago Stock diff --git a/challenge-019/tim-smith/README b/challenge-019/tim-smith/README new file mode 100644 index 0000000000..83596de4fd --- /dev/null +++ b/challenge-019/tim-smith/README @@ -0,0 +1 @@ +Solution by Tim Smith diff --git a/challenge-019/tore-andersson/README b/challenge-019/tore-andersson/README new file mode 100644 index 0000000000..6b1b021ce0 --- /dev/null +++ b/challenge-019/tore-andersson/README @@ -0,0 +1 @@ +Solution by Tore Andersson diff --git a/challenge-019/uzluisf/README b/challenge-019/uzluisf/README new file mode 100644 index 0000000000..c668a77e15 --- /dev/null +++ b/challenge-019/uzluisf/README @@ -0,0 +1 @@ +Solution by Luis F. Uceta. diff --git a/challenge-019/veesh-goldman/README b/challenge-019/veesh-goldman/README new file mode 100644 index 0000000000..28a85f6e5c --- /dev/null +++ b/challenge-019/veesh-goldman/README @@ -0,0 +1 @@ +Solution by Veesh Goldman diff --git a/challenge-019/walt-mankowski/README b/challenge-019/walt-mankowski/README new file mode 100644 index 0000000000..cf907b02dd --- /dev/null +++ b/challenge-019/walt-mankowski/README @@ -0,0 +1 @@ +Solutions by Walt Mankowski. diff --git a/challenge-019/william-gilmore/README b/challenge-019/william-gilmore/README new file mode 100644 index 0000000000..e3df40ca2a --- /dev/null +++ b/challenge-019/william-gilmore/README @@ -0,0 +1 @@ +Solution by William Gilmore diff --git a/challenge-019/yary-h/README b/challenge-019/yary-h/README new file mode 100644 index 0000000000..200fbce413 --- /dev/null +++ b/challenge-019/yary-h/README @@ -0,0 +1 @@ +Solution by Yary H diff --git a/challenge-019/yozen-hernandez/README b/challenge-019/yozen-hernandez/README new file mode 100644 index 0000000000..07779f04ee --- /dev/null +++ b/challenge-019/yozen-hernandez/README @@ -0,0 +1 @@ +Solutions by Yozen Hernandez. -- cgit From 5b1a2e347f263c66734b2f8a5cd677d6d4709213 Mon Sep 17 00:00:00 2001 From: Roger Bell_West Date: Mon, 29 Jul 2019 08:56:36 +0100 Subject: Challenge 19 answers --- challenge-019/roger-bell-west/perl5/1.pl | 19 +++++++++++++++ challenge-019/roger-bell-west/perl5/2.pl | 41 ++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100755 challenge-019/roger-bell-west/perl5/1.pl create mode 100755 challenge-019/roger-bell-west/perl5/2.pl (limited to 'challenge-019') diff --git a/challenge-019/roger-bell-west/perl5/1.pl b/challenge-019/roger-bell-west/perl5/1.pl new file mode 100755 index 0000000000..9d5f470d49 --- /dev/null +++ b/challenge-019/roger-bell-west/perl5/1.pl @@ -0,0 +1,19 @@ +#! /usr/bin/perl + +use strict; +use warnings; + +# Write a script to display months from the year 1900 to 2019 where +# you find 5 weekends i.e. 5 Friday, 5 Saturday and 5 Sunday. + +use Time::Local; +use POSIX qw(strftime); + +foreach my $y (1900..2019) { + foreach my $m (1,3,5,7,8,10,12) { + my @d=gmtime(timegm(0,0,0,1,$m-1,$y)); + if ($d[6]==5) { + print strftime('%B %Y',@d),"\n"; + } + } +} diff --git a/challenge-019/roger-bell-west/perl5/2.pl b/challenge-019/roger-bell-west/perl5/2.pl new file mode 100755 index 0000000000..4d1ae70960 --- /dev/null +++ b/challenge-019/roger-bell-west/perl5/2.pl @@ -0,0 +1,41 @@ +#! /usr/bin/perl + +use strict; +use warnings; + +# Write a script that can wrap the given paragraph at a specified +# column using the greedy algorithm. + +use Getopt::Std; + +my %o=(w => 72); +getopts('w:',\%o); + +my $s=$o{w}; +my @w; +while (<>) { + chomp; + if ($_ eq '') { + if (@w) { + print join(' ',@w),"\n"; + @w=(); + $s=$o{w}; + } + print "\n"; + } else { + foreach my $w (split ' ',$_) { + my $lw=length($w); + if ($lw+1 > $s) { + print join(' ',@w),"\n"; + @w=($w); + $s=$o{w}-$lw; + } else { + push @w,$w; + $s-=($lw+1); + } + } + } +} +if (@w) { + print join(' ',@w),"\n"; +} -- cgit From 5890fbc9ce9a9832ec5e55f1c6bd8e871d017991 Mon Sep 17 00:00:00 2001 From: Simon Proctor Date: Mon, 29 Jul 2019 14:23:53 +0100 Subject: Months with 5 weekends in --- challenge-019/simon-proctor/perl6/ch-1.p6 | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 challenge-019/simon-proctor/perl6/ch-1.p6 (limited to 'challenge-019') diff --git a/challenge-019/simon-proctor/perl6/ch-1.p6 b/challenge-019/simon-proctor/perl6/ch-1.p6 new file mode 100644 index 0000000000..d7456d0a97 --- /dev/null +++ b/challenge-019/simon-proctor/perl6/ch-1.p6 @@ -0,0 +1,26 @@ +#!/usr/bin/env perl6 + +use v6; + +#| Given a starting an ending year print all months in the years between (inclusive) with 5 weekends (Friday, Saturday and Sunday) +multi sub MAIN( + Int() $start = 1900, #= Starting year. Defaults to 1900 + Int() $end = Date.today().year() #= Ending year. Default to this year. +) { + say "Months with 5 Fridays between {$start} and {$end}"; + + for $start..$end -> $year { + for 1..12 -> $month { + my $range = Date.new( :$year, :$month, :1day )..Date.new( :$year, :$month, day => Date.new( :$year, :$month ).days-in-month ); + my @weekends = (5..7).map( -> $dow { $range.grep( *.day-of-week == $dow ).elems } ); + say "{$year}-{sprintf("%02d",$month)}" if all( @weekends ) == 5; + } + } +} + +#| Display help text +multi sub MAIN( + Bool :h(:$help) where ?* +) { + say $*USAGE; +} -- cgit From ef7d846c7416907a94b25b28a4642bfb9fbbc361 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Mon, 29 Jul 2019 14:26:20 +0100 Subject: - Added solutions by Lubos Kolouch. --- challenge-019/lubos-kolouch/perl5/ch-1.pl | 68 +++++++++++++++++++++++++++++++ challenge-019/lubos-kolouch/perl5/ch-2.pl | 60 +++++++++++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 challenge-019/lubos-kolouch/perl5/ch-1.pl create mode 100644 challenge-019/lubos-kolouch/perl5/ch-2.pl (limited to 'challenge-019') diff --git a/challenge-019/lubos-kolouch/perl5/ch-1.pl b/challenge-019/lubos-kolouch/perl5/ch-1.pl new file mode 100644 index 0000000000..282033d7ee --- /dev/null +++ b/challenge-019/lubos-kolouch/perl5/ch-1.pl @@ -0,0 +1,68 @@ +#!/usr/bin/perl +#=============================================================================== +# +# FILE: ch-1.pl +# +# USAGE: ./ch-1.pl +# +# DESCRIPTION: Task #1 +# +# Task #1 +# Write a script to display months from the year 1900 to 2019 where you find 5 weekends i.e. 5 Friday, 5 Saturday and 5 Sunday. +# +# +# OPTIONS: --- +# REQUIREMENTS: --- +# BUGS: --- +# NOTES: --- +# AUTHOR: Lubos Kolouch, +# ORGANIZATION: +# VERSION: 1.0 +# CREATED: 07/29/2019 08:48:27 PM +# REVISION: --- +#=============================================================================== + +use strict; +use warnings; +use feature qw{ say }; +use Data::Dumper; +use Date::Calc qw/check_date Day_of_Week Days_in_Month/; + +sub has_5_weekends { + my ( $year, $month ) = @_; + + my $days = Days_in_Month( $year, $month ); + + my %wdays; + + for my $day ( 1 .. $days ) { + $wdays{ Day_of_Week( $year, $month, $day ) }++; + } + + return 1 if ( $wdays{5} == 5 ) and ( $wdays{6} == 5 ) and ( $wdays{7} == 5 ); + + return 0; +} + +###### MAIN ###### + +my $count; + +for my $year ( 1900 .. 2019 ) { + for my $month ( 1 .. 12 ) { + $count++ if has_5_weekends( $year, $month ); + } + +} + +say "There are $count months"; +###### TESTS ###### + +use Test::More; + +say 'TESTS:'; + +is( has_5_weekends( 2019, 7 ), 0, 'Test 2019/07' ); +is( has_5_weekends( 2019, 3 ), 1, 'Test 2019/03' ); + +done_testing; diff --git a/challenge-019/lubos-kolouch/perl5/ch-2.pl b/challenge-019/lubos-kolouch/perl5/ch-2.pl new file mode 100644 index 0000000000..eab51b40b1 --- /dev/null +++ b/challenge-019/lubos-kolouch/perl5/ch-2.pl @@ -0,0 +1,60 @@ +#!/usr/bin/perl +#=============================================================================== +# +# FILE: ch-2.pl +# +# USAGE: ./ch-2.pl +# +# DESCRIPTION: Task #2 +# +# Task #2 +# Write a script that can wrap the given paragraph at a specified column using the [greedy +# algorithm](https://en.wikipedia.org/wiki/Line_wrap_and_word_wrap#Minimum_number_of_lines). +# +# +# OPTIONS: --- +# REQUIREMENTS: --- +# BUGS: --- +# NOTES: --- +# AUTHOR: Lubos Kolouch, +# ORGANIZATION: +# VERSION: 1.0 +# CREATED: 07/29/2019 08:48:27 PM +# REVISION: --- +#=============================================================================== + +use strict; +use warnings; +use feature qw{ say }; + +###### MAIN ###### +my ( $width, @words ) = @ARGV; + +$width or die 'Usage: script width text'; +@words or die 'Usage: script width text'; + +die 'Usage: script width(numeric!) text' unless $width =~ /\d+/msx; + +my $space_left = $width; + +for my $word (@words) { + my $len = length($word); + + if ( $len + 1 > $space_left ) { + print "\n"; + $space_left = $width - $len; + } + else { + $space_left -= $len; + } + + print "$word "; +} + +say qq//; +###### TESTS ###### + +use Test::More; + +say 'NO TESTS THIS TIME'; +done_testing; -- cgit From 23345520201cbefa4097f03300a60ef6780b1cf7 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Mon, 29 Jul 2019 14:36:57 +0100 Subject: - Added solution by Mark Anderson. --- challenge-019/mark-anderson/perl5/ch-1.pl | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 challenge-019/mark-anderson/perl5/ch-1.pl (limited to 'challenge-019') diff --git a/challenge-019/mark-anderson/perl5/ch-1.pl b/challenge-019/mark-anderson/perl5/ch-1.pl new file mode 100644 index 0000000000..db2a2ac1c2 --- /dev/null +++ b/challenge-019/mark-anderson/perl5/ch-1.pl @@ -0,0 +1,23 @@ +#!/usr/bin/env perl + +use Modern::Perl '2018'; +use DateTime; + +for my $year (1900 .. 2019) { + for my $month (1 .. 12) { + my $dt = DateTime->last_day_of_month( + year => $year, + month => $month); + + while($dt->day_name ne 'Sunday') { + $dt->subtract(days => 1); + } + + if($dt->weekday_of_month == 5 and + $dt->subtract(days => 1)->weekday_of_month == 5 and + $dt->subtract(days => 1)->weekday_of_month == 5) { + say "$month/$year"; + } + } +} + -- cgit From c91c189ef04a8a2eaac6a21fe60bd2e1180881a3 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Mon, 29 Jul 2019 14:42:01 +0100 Subject: - Added solutios by Pete Houston. --- challenge-019/pete-houston/perl5/ch-1.pl | 11 +++++++++++ challenge-019/pete-houston/perl5/ch-2.pl | 23 +++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 challenge-019/pete-houston/perl5/ch-1.pl create mode 100644 challenge-019/pete-houston/perl5/ch-2.pl (limited to 'challenge-019') diff --git a/challenge-019/pete-houston/perl5/ch-1.pl b/challenge-019/pete-houston/perl5/ch-1.pl new file mode 100644 index 0000000000..f84ba2829d --- /dev/null +++ b/challenge-019/pete-houston/perl5/ch-1.pl @@ -0,0 +1,11 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Time::Piece; + +my $month = Time::Piece->strptime ('1900-01-01', '%Y-%m-%d'); +while ($month->year < 2020) { + printf "%s %i has 5 weekends\n", $month->fullmonth, $month->year + if $month->month_last_day == 31 && $month->wday == 6; + $month = $month->add_months (1); +} diff --git a/challenge-019/pete-houston/perl5/ch-2.pl b/challenge-019/pete-houston/perl5/ch-2.pl new file mode 100644 index 0000000000..2df3565051 --- /dev/null +++ b/challenge-019/pete-houston/perl5/ch-2.pl @@ -0,0 +1,23 @@ +#!/usr/bin/env perl +#=============================================================================== +# +# USAGE: ./ch-2.pl linewidth +# +# DESCRIPTION: wrap STDIN at the specified linewidth, preserving newlines +# +#=============================================================================== + +use strict; +use warnings; +use Text::Wrap qw/$columns wrap/; + +die "The linewidth is required as the argument\n" + unless defined $ARGV[0]; + +($columns) = $ARGV[0] =~ /^([0-9]+)$/g; +die "The supplied linewidth ($ARGV[0]) isn't a natural number\n" + unless $columns; + +binmode STDIN, ':encoding(UTF-8)'; +binmode STDOUT, ':encoding(UTF-8)'; +print wrap ('', '', ); -- cgit From 2c0f4c13284dee279c6b1eb96fc70676fb648771 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Mon, 29 Jul 2019 14:47:25 +0100 Subject: - Added solutions by Roger Bell West. --- challenge-019/roger-bell-west/perl5/1.pl | 19 ------------- challenge-019/roger-bell-west/perl5/2.pl | 41 ----------------------------- challenge-019/roger-bell-west/perl5/ch-1.pl | 19 +++++++++++++ challenge-019/roger-bell-west/perl5/ch-2.pl | 41 +++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 60 deletions(-) delete mode 100755 challenge-019/roger-bell-west/perl5/1.pl delete mode 100755 challenge-019/roger-bell-west/perl5/2.pl create mode 100755 challenge-019/roger-bell-west/perl5/ch-1.pl create mode 100755 challenge-019/roger-bell-west/perl5/ch-2.pl (limited to 'challenge-019') diff --git a/challenge-019/roger-bell-west/perl5/1.pl b/challenge-019/roger-bell-west/perl5/1.pl deleted file mode 100755 index 9d5f470d49..0000000000 --- a/challenge-019/roger-bell-west/perl5/1.pl +++ /dev/null @@ -1,19 +0,0 @@ -#! /usr/bin/perl - -use strict; -use warnings; - -# Write a script to display months from the year 1900 to 2019 where -# you find 5 weekends i.e. 5 Friday, 5 Saturday and 5 Sunday. - -use Time::Local; -use POSIX qw(strftime); - -foreach my $y (1900..2019) { - foreach my $m (1,3,5,7,8,10,12) { - my @d=gmtime(timegm(0,0,0,1,$m-1,$y)); - if ($d[6]==5) { - print strftime('%B %Y',@d),"\n"; - } - } -} diff --git a/challenge-019/roger-bell-west/perl5/2.pl b/challenge-019/roger-bell-west/perl5/2.pl deleted file mode 100755 index 4d1ae70960..0000000000 --- a/challenge-019/roger-bell-west/perl5/2.pl +++ /dev/null @@ -1,41 +0,0 @@ -#! /usr/bin/perl - -use strict; -use warnings; - -# Write a script that can wrap the given paragraph at a specified -# column using the greedy algorithm. - -use Getopt::Std; - -my %o=(w => 72); -getopts('w:',\%o); - -my $s=$o{w}; -my @w; -while (<>) { - chomp; - if ($_ eq '') { - if (@w) { - print join(' ',@w),"\n"; - @w=(); - $s=$o{w}; - } - print "\n"; - } else { - foreach my $w (split ' ',$_) { - my $lw=length($w); - if ($lw+1 > $s) { - print join(' ',@w),"\n"; - @w=($w); - $s=$o{w}-$lw; - } else { - push @w,$w; - $s-=($lw+1); - } - } - } -} -if (@w) { - print join(' ',@w),"\n"; -} diff --git a/challenge-019/roger-bell-west/perl5/ch-1.pl b/challenge-019/roger-bell-west/perl5/ch-1.pl new file mode 100755 index 0000000000..9d5f470d49 --- /dev/null +++ b/challenge-019/roger-bell-west/perl5/ch-1.pl @@ -0,0 +1,19 @@ +#! /usr/bin/perl + +use strict; +use warnings; + +# Write a script to display months from the year 1900 to 2019 where +# you find 5 weekends i.e. 5 Friday, 5 Saturday and 5 Sunday. + +use Time::Local; +use POSIX qw(strftime); + +foreach my $y (1900..2019) { + foreach my $m (1,3,5,7,8,10,12) { + my @d=gmtime(timegm(0,0,0,1,$m-1,$y)); + if ($d[6]==5) { + print strftime('%B %Y',@d),"\n"; + } + } +} diff --git a/challenge-019/roger-bell-west/perl5/ch-2.pl b/challenge-019/roger-bell-west/perl5/ch-2.pl new file mode 100755 index 0000000000..4d1ae70960 --- /dev/null +++ b/challenge-019/roger-bell-west/perl5/ch-2.pl @@ -0,0 +1,41 @@ +#! /usr/bin/perl + +use strict; +use warnings; + +# Write a script that can wrap the given paragraph at a specified +# column using the greedy algorithm. + +use Getopt::Std; + +my %o=(w => 72); +getopts('w:',\%o); + +my $s=$o{w}; +my @w; +while (<>) { + chomp; + if ($_ eq '') { + if (@w) { + print join(' ',@w),"\n"; + @w=(); + $s=$o{w}; + } + print "\n"; + } else { + foreach my $w (split ' ',$_) { + my $lw=length($w); + if ($lw+1 > $s) { + print join(' ',@w),"\n"; + @w=($w); + $s=$o{w}-$lw; + } else { + push @w,$w; + $s-=($lw+1); + } + } + } +} +if (@w) { + print join(' ',@w),"\n"; +} -- cgit From d868660e9770a750721ea3379ffe860759e70c43 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Mon, 29 Jul 2019 16:07:48 +0100 Subject: - Added solution by Dave Cross. --- challenge-019/dave-cross/perl5/ch-1.pl | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 challenge-019/dave-cross/perl5/ch-1.pl (limited to 'challenge-019') diff --git a/challenge-019/dave-cross/perl5/ch-1.pl b/challenge-019/dave-cross/perl5/ch-1.pl new file mode 100644 index 0000000000..3ed9f078d8 --- /dev/null +++ b/challenge-019/dave-cross/perl5/ch-1.pl @@ -0,0 +1,30 @@ +#!/usr/bin/perl +# +# Perl Weekly Challenge #19 / Task #1 +# +# Write a script to display months from the year 1900 to 2019 where +# you find 5 weekends i.e. 5 Friday, 5 Saturday and 5 Sunday. + +use strict; +use warnings; +use feature 'say'; + +use Time::Piece; + +# A month can only have five weekends if: +# +# * It has 31 days +# * The 1st of the month is a Friday + +# Array of months with 31 days +my @months = (qw[Jan Mar May Jul Aug Oct Dec]); +my $format = '%Y-%b'; + +for my $y (1900 .. 2019) { + for my $m (@months) { + # Get the first day of the month as a Time::Piece object + my $first = Time::Piece->strptime("$y-$m", $format); + # Print the date if the 1st is a Friday + say $first->strftime('%b %Y') if $first->day eq 'Fri'; + } +} -- cgit From 60fcb8183e758e74f7b04480859df34183c2eee3 Mon Sep 17 00:00:00 2001 From: Simon Proctor Date: Mon, 29 Jul 2019 17:26:59 +0100 Subject: Word wrapping --- challenge-019/simon-proctor/perl6/ch-2.p6 | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 challenge-019/simon-proctor/perl6/ch-2.p6 (limited to 'challenge-019') diff --git a/challenge-019/simon-proctor/perl6/ch-2.p6 b/challenge-019/simon-proctor/perl6/ch-2.p6 new file mode 100644 index 0000000000..e0bb089dde --- /dev/null +++ b/challenge-019/simon-proctor/perl6/ch-2.p6 @@ -0,0 +1,27 @@ +#!/usr/bin/env perl6 + +use v6; + + + +#| Read from STDIN and wrap to the given number of characters +multi sub MAIN ( + UInt() $width = 80, #= Width to wrap to (default 80 characters) +) { + my $out = ""; + my $left = $width; + for $*IN.words -> $word { + if $word.codes + 1 > $left { + say $out; + $out = ""; + $left = $width; + } + $out = $out ?? "$out $word" !! $word; + $left = $width - $out.codes; + } + say $out if $out; +} + + +#| Display help +multi sub MAIN( Bool :h(:$help) where ?* ) { say $*USAGE } -- cgit From e398e78726ae1989afd57a882f56692a71de2e66 Mon Sep 17 00:00:00 2001 From: Simon Proctor Date: Mon, 29 Jul 2019 17:28:06 +0100 Subject: Removed extra lines --- challenge-019/simon-proctor/perl6/ch-2.p6 | 2 -- 1 file changed, 2 deletions(-) (limited to 'challenge-019') diff --git a/challenge-019/simon-proctor/perl6/ch-2.p6 b/challenge-019/simon-proctor/perl6/ch-2.p6 index e0bb089dde..1af8bb16f6 100644 --- a/challenge-019/simon-proctor/perl6/ch-2.p6 +++ b/challenge-019/simon-proctor/perl6/ch-2.p6 @@ -2,8 +2,6 @@ use v6; - - #| Read from STDIN and wrap to the given number of characters multi sub MAIN ( UInt() $width = 80, #= Width to wrap to (default 80 characters) -- cgit From b3e324861b111fe7f267cea4ddc0979c75a37e98 Mon Sep 17 00:00:00 2001 From: Dave Jacoby Date: Mon, 29 Jul 2019 12:38:41 -0400 Subject: Challenge 19 --- challenge-019/dave-jacoby/perl5/ch-1.pl | 171 ++++++++++++++++++++++++++++++++ challenge-019/dave-jacoby/perl5/ch-2.pl | 56 +++++++++++ 2 files changed, 227 insertions(+) create mode 100755 challenge-019/dave-jacoby/perl5/ch-1.pl create mode 100755 challenge-019/dave-jacoby/perl5/ch-2.pl (limited to 'challenge-019') diff --git a/challenge-019/dave-jacoby/perl5/ch-1.pl b/challenge-019/dave-jacoby/perl5/ch-1.pl new file mode 100755 index 0000000000..72d5c907c8 --- /dev/null +++ b/challenge-019/dave-jacoby/perl5/ch-1.pl @@ -0,0 +1,171 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use utf8; +use feature qw{ postderef say signatures state switch }; +no warnings + qw{ experimental::postderef experimental::smartmatch experimental::signatures }; + +use DateTime; + +# The Challenge + +# Write a script to display months from the year 1900 to 2019 +# where you find 5 weekends i.e. 5 Friday, 5 Saturday and 5 Sunday. + +# Let's look at an example of such a month. + +# March 2019 +# +# M T W T F S S +# 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 + +# A four-weekend month fits in 28 days, so that could be any month, +# but as we see here, we need 3 more days, so we need a 31 day month, +# and it only works if the month starts on Friday. + +# 30 days have September (9) +# April (4), June (6) and November (11) +# And February (2) is right out + +my @months = (1, 3, 5, 7, 8, 10, 12); + +# We only need one DateTime object. +# We'll set the month, day and year as needed + +my $date = DateTime->now(); +$date->set_day(1); +for my $year ( 1900 .. 2019 ) { + $date->set_year($year); + for my $month ( @months ) { + $date->set_month($month); + say $date->ymd if 5 == $date->day_of_week; + } +} + +__DATA__ + +1901-03-01 +1902-08-01 +1903-05-01 +1904-01-01 +1904-07-01 +1905-12-01 +1907-03-01 +1908-05-01 +1909-01-01 +1909-10-01 +1910-07-01 +1911-12-01 +1912-03-01 +1913-08-01 +1914-05-01 +1915-01-01 +1915-10-01 +1916-12-01 +1918-03-01 +1919-08-01 +1920-10-01 +1921-07-01 +1922-12-01 +1924-08-01 +1925-05-01 +1926-01-01 +1926-10-01 +1927-07-01 +1929-03-01 +1930-08-01 +1931-05-01 +1932-01-01 +1932-07-01 +1933-12-01 +1935-03-01 +1936-05-01 +1937-01-01 +1937-10-01 +1938-07-01 +1939-12-01 +1940-03-01 +1941-08-01 +1942-05-01 +1943-01-01 +1943-10-01 +1944-12-01 +1946-03-01 +1947-08-01 +1948-10-01 +1949-07-01 +1950-12-01 +1952-08-01 +1953-05-01 +1954-01-01 +1954-10-01 +1955-07-01 +1957-03-01 +1958-08-01 +1959-05-01 +1960-01-01 +1960-07-01 +1961-12-01 +1963-03-01 +1964-05-01 +1965-01-01 +1965-10-01 +1966-07-01 +1967-12-01 +1968-03-01 +1969-08-01 +1970-05-01 +1971-01-01 +1971-10-01 +1972-12-01 +1974-03-01 +1975-08-01 +1976-10-01 +1977-07-01 +1978-12-01 +1980-08-01 +1981-05-01 +1982-01-01 +1982-10-01 +1983-07-01 +1985-03-01 +1986-08-01 +1987-05-01 +1988-01-01 +1988-07-01 +1989-12-01 +1991-03-01 +1992-05-01 +1993-01-01 +1993-10-01 +1994-07-01 +1995-12-01 +1996-03-01 +1997-08-01 +1998-05-01 +1999-01-01 +1999-10-01 +2000-12-01 +2002-03-01 +2003-08-01 +2004-10-01 +2005-07-01 +2006-12-01 +2008-08-01 +2009-05-01 +2010-01-01 +2010-10-01 +2011-07-01 +2013-03-01 +2014-08-01 +2015-05-01 +2016-01-01 +2016-07-01 +2017-12-01 +2019-03-01 diff --git a/challenge-019/dave-jacoby/perl5/ch-2.pl b/challenge-019/dave-jacoby/perl5/ch-2.pl new file mode 100755 index 0000000000..bd7d0462ac --- /dev/null +++ b/challenge-019/dave-jacoby/perl5/ch-2.pl @@ -0,0 +1,56 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use utf8; +use feature qw{ postderef say signatures state switch }; +no warnings + qw{ experimental::postderef experimental::smartmatch experimental::signatures }; + +# Write a script that can wrap the given paragraph +# at a specified column using the greedy algorithm. +# https://en.wikipedia.org/wiki/Line_wrap_and_word_wrap#Minimum_number_of_lines + +## SpaceLeft := LineWidth +## for each Word in Text +## if (Width(Word) + SpaceWidth) > SpaceLeft +## insert line break before Word in Text +## SpaceLeft := LineWidth - Width(Word) +## else +## SpaceLeft := SpaceLeft - (Width(Word) + SpaceWidth) + +my $text = q{ + Let me announce the winner of Perl Weekly Challenge - 018 and the + name is E. Choroba. Many congratulations Choroba, you should soon + hear from Perl Careers about your reward. Please do let us know how + you feel about it. For rest of the participants, I would say Good + Luck for next time. Keep sending in your solutions and share your + knowledge with each other. +}; + +say word_wrap( 30, $text ); +say ''; +say word_wrap( 60, $text ); +say ''; +say word_wrap( 80, $text ); +say ''; + +sub word_wrap ( $col, $text ) { + my @text = grep { /\S/ } split /\s+/, $text; + my $output; + my $line = ''; + my $space_left = $col; + for my $word (@text) { + my $width = length $word; + if ( ( $width + 1 ) > $space_left ) { + $output .= "\n" . $word . ' '; + $space_left = $col - ( $width + 1 ); + } + else { + $output .= $word . ' '; + $space_left -= ( $width + 1 ); + } + } + return $output; +} + -- cgit From 832a1316bd92d26750ed4ba81d2611d8ed0291ff Mon Sep 17 00:00:00 2001 From: Walt Mankowski Date: Mon, 29 Jul 2019 15:10:52 -0400 Subject: added perl 5 solutions for week 19 parts 1 and 2 --- challenge-019/walt-mankowski/perl5/ch-1.pl | 41 +++++++++++++++++++++++ challenge-019/walt-mankowski/perl5/ch-2.pl | 52 ++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 challenge-019/walt-mankowski/perl5/ch-1.pl create mode 100644 challenge-019/walt-mankowski/perl5/ch-2.pl (limited to 'challenge-019') diff --git a/challenge-019/walt-mankowski/perl5/ch-1.pl b/challenge-019/walt-mankowski/perl5/ch-1.pl new file mode 100644 index 0000000000..0509d81b26 --- /dev/null +++ b/challenge-019/walt-mankowski/perl5/ch-1.pl @@ -0,0 +1,41 @@ +#!/usr/bin/env perl + +# Perl Weekly Challenge 019-1 +# https://perlweeklychallenge.org/blog/perl-weekly-challenge-019/ +# +# Write a script to display months from the year 1900 to 2019 where +# you find 5 weekends i.e. 5 Friday, 5 Saturday and 5 Sunday. + +use strict; +use warnings; +use feature qw(:5.30); +use experimental qw(signatures); +use Time::Local; + +# Looking at March 2019 it's clear that this can only happen if the +# month has 31 days and starts on a Friday: +# +# March 2019 +# Su Mo Tu We Th Fr Sa +# 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 + +my @months = (0, 2, 4, 6, 7, 9, 11); + +for my $year (1900..2019) { + for my $month (@months) { + if (starts_on_friday($year, $month)) { + printf "%d/%02d\n", $year, $month+1; + } + } +} + +# does the month starts with a Friday? +sub starts_on_friday($year, $month) { + my $time = timelocal(undef, undef, undef, 1, $month, $year); + return (localtime($time))[6] == 5; +} diff --git a/challenge-019/walt-mankowski/perl5/ch-2.pl b/challenge-019/walt-mankowski/perl5/ch-2.pl new file mode 100644 index 0000000000..590ebe5a1f --- /dev/null +++ b/challenge-019/walt-mankowski/perl5/ch-2.pl @@ -0,0 +1,52 @@ +#!/usr/bin/env perl + +# Perl Weekly Challenge 019-2 +# https://perlweeklychallenge.org/blog/perl-weekly-challenge-019/ +# +# Write a script that can wrap the given paragraph at a specified +# column using the greedy algorithm specifed at +# https://en.wikipedia.org/wiki/Line_wrap_and_word_wrap#Minimum_number_of_lines + +use strict; +use warnings; +use feature qw(:5.30); +use experimental qw(signatures); + +my $txt = <