diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2021-03-07 09:31:46 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-07 09:31:46 +0000 |
| commit | 71883efdfc974b2f02f21f90325aaf6ca657d665 (patch) | |
| tree | 871be941e446e22fca111b0cf3731537d5439444 | |
| parent | 37cc975709ca3b6f95c9ef6fb0d335ce297c0c30 (diff) | |
| parent | adcfa6385a72794942e18744e867333b06e462d1 (diff) | |
| download | perlweeklychallenge-club-71883efdfc974b2f02f21f90325aaf6ca657d665.tar.gz perlweeklychallenge-club-71883efdfc974b2f02f21f90325aaf6ca657d665.tar.bz2 perlweeklychallenge-club-71883efdfc974b2f02f21f90325aaf6ca657d665.zip | |
Merge pull request #3670 from wambash/challenge-week-102
solutions week 102
| -rw-r--r-- | challenge-102/wambash/raku/ch-1.raku | 148 | ||||
| -rw-r--r-- | challenge-102/wambash/raku/ch-2.raku | 22 |
2 files changed, 170 insertions, 0 deletions
diff --git a/challenge-102/wambash/raku/ch-1.raku b/challenge-102/wambash/raku/ch-1.raku new file mode 100644 index 0000000000..8e696ebba6 --- /dev/null +++ b/challenge-102/wambash/raku/ch-1.raku @@ -0,0 +1,148 @@ +#!/usr/bin/env raku + +constant RARE := < +65 +621770 +281089082 +2022652202 +2042832002 +868591084757 +872546974178 +872568754178 +6979302951885 +20313693904202 +20313839704202 +20331657922202 +20331875722202 +20333875702202 +40313893704200 +40351893720200 +200142385731002 +204238494066002 +221462345754122 +244062891224042 +245518996076442 +248359494187442 +403058392434500 +441054594034340 +816984566129618 +2078311262161202 +2133786945766212 +2135568943984212 +2135764587964212 +2135786765764212 +4135786945764210 +6157577986646405 +6889765708183410 +8052956026592517 +8052956206592517 +8191154686620818 +8191156864620818 +8191376864400818 +8650327689541457 +8650349867341457 +22542040692914522 +67725910561765640 +86965750494756968 +225342456863243522 +225342458663243522 +225342478643243522 +284684666566486482 +284684868364486482 +297128548234950692 +297128722852950692 +297148324656930692 +297148546434930692 +497168548234910690 +619431353040136925 +619631153042134925 +631688638047992345 +633288858025996145 +633488632647994145 +653488856225994125 +811865096390477018 +865721270017296468 +871975098681469178 +898907259301737498 +2042401829204402402 +2060303819041450202 +2420424089100600242 +2551755006254571552 +2702373360882732072 +2825378427312735282 +6531727101458000045 +6988066446726832640 +8066308349502036608 +8197906905009010818 +8200756128308135597 +8320411466598809138 +22134434735752443122 +22134434753752443122 +22134436953532443122 +22136414517954423122 +22136414971554423122 +22136456771730423122 +61952807156239928885 +61999171315484316965 +65459144877856561700 +208393425242000083802 +219518549668074815912 +257661195832219326752 +286694688797362186682 +837982875780054779738 +2414924301133245383042 +2414924323311045383042 +2414946523311023183042 +2576494891793995836752 +2576494893971995836752 +2620937863931054483162 +2620937863931054483162 +2620955641393276283162 +2622935621573476481162 +2622935643751276481162 +2622937641933274481162 +2622955841933256281162 +2622957843751254281162 +2727651947516658327272 +2747736918335953517072 +2788047668617596408872 +2788047848617776408872 +2788047868437576408872 +2788047888617376408872 +2939501759705522349392 +2939503375709360349392 +2939503537707740349392 +2939521359525562149392 +2939521557527542149392 +2939523577527340149392 +2939523779525320149392 +2959503377707360349192 +6344828989519887483525 +8045841652464561594308 +8045841654642561594308 +8655059576513659814468 +8655059772157639814468 +8655079374155679614468 +8655079574515659614468 +8888070771864228883913 +20006212343920163220002 +20404210361902143200402 +21544373975964337344512 +22781275420027357218722 +80618209916486890281608 +81313065142333312588218 +84247683299691574674248 +89650295750128200205698 +>.classify: *.chars; + +multi MAIN (Int $digit) { + put RARE{+$digit} // '' +} + +multi MAIN (Bool :$test!) { + use Test; + is RARE{2}, 65; + is RARE{6}, 621770; + is RARE{9}, 281089082; + done-testing; +} diff --git a/challenge-102/wambash/raku/ch-2.raku b/challenge-102/wambash/raku/ch-2.raku new file mode 100644 index 0000000000..ba91e2bf7d --- /dev/null +++ b/challenge-102/wambash/raku/ch-2.raku @@ -0,0 +1,22 @@ +#!/usr/bin/env raku + +sub hash-counting-string ($n) { + "$n#", { $n - .chars ~ "#" ~ $_ } ... *.chars ≥ $n + andthen .tail + andthen .subst: /^1 <?before '#' > /, :d; +} + +multi MAIN (Bool :$test!) { + use Test; + is hash-counting-string(12).chars, 12; + is hash-counting-string( 1), '#'; + is hash-counting-string( 2), '2#'; + is hash-counting-string( 3), '#3#'; + is hash-counting-string(10), '#3#5#7#10#'; + is hash-counting-string(14), '2#4#6#8#11#14#'; + done-testing; +} + +multi MAIN (Int $n) { + say hash-counting-string( $n ) +} |
