Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
raku-challenges/091/ch-1a.raku
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
20 lines (15 sloc)
489 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env raku | |
# | |
# Task 1 from | |
# https://perlweeklychallenge.org/blog/perl-weekly-challenge-091/ | |
# Comments: https://andrewshitov.com/2020/12/14/raku-challenge-week-91/ | |
unit sub MAIN(Int $n = 1122234); | |
# Cannot process more than 10 repeating digits. | |
# Otherwise use some spelling module. | |
my @spell = <one two three four five six seven eight nine ten>; | |
put gather for $n ~~ m:g/ (\d) $0* / { | |
take @spell[.Str.chars - 1]; | |
take .[0]; | |
} | |
# Output: | |
# two 1 three 2 one 3 one 4 |