aboutsummaryrefslogtreecommitdiff
path: root/challenge-035/daniel-mita
diff options
context:
space:
mode:
authorDaniel Mita <mienaikage@gmail.com>2019-11-22 13:41:32 +0000
committerDaniel Mita <mienaikage@gmail.com>2019-11-22 13:44:16 +0000
commitc19bf149e5457a3b2d658b44ee0107bf58dc4984 (patch)
tree75d272d51809f6e8c035d3f9f58dae8e61088935 /challenge-035/daniel-mita
parent96c7b5de514604382234a5c23470fe0cd1591a12 (diff)
downloadperlweeklychallenge-club-c19bf149e5457a3b2d658b44ee0107bf58dc4984.tar.gz
perlweeklychallenge-club-c19bf149e5457a3b2d658b44ee0107bf58dc4984.tar.bz2
perlweeklychallenge-club-c19bf149e5457a3b2d658b44ee0107bf58dc4984.zip
Ignore whitespace in decoder
Diffstat (limited to 'challenge-035/daniel-mita')
-rw-r--r--challenge-035/daniel-mita/perl6/Morse.pm67
1 files changed, 5 insertions, 2 deletions
diff --git a/challenge-035/daniel-mita/perl6/Morse.pm6 b/challenge-035/daniel-mita/perl6/Morse.pm6
index 106d7b8846..b387cd9904 100644
--- a/challenge-035/daniel-mita/perl6/Morse.pm6
+++ b/challenge-035/daniel-mita/perl6/Morse.pm6
@@ -88,10 +88,13 @@ module Morse {
#| Decode binary morse code
sub decode (
- Str $bits where *.trim.comb.all eq 1|0, #= A string containing a sequence of 1s and 0s
+ Str $bits where *.comb(/\S/).all eq 1|0, #= A string containing a sequence of 1s and 0s
--> Str
) is export {
- .return with Decode.parse( $bits.trim, :actions(Decoder.new) ).made;
+ .return with Decode.parse(
+ $bits.trans( /\s+/ => '' ),
+ :actions(Decoder.new)
+ ).made;
X::Morse::InvalidSequence.new.throw;
}