diff options
| author | Julien Fiegehenn <simbabque@cpan.org> | 2022-04-19 22:38:05 +0100 |
|---|---|---|
| committer | Julien Fiegehenn <simbabque@cpan.org> | 2022-04-19 22:38:47 +0100 |
| commit | d3a10cb72385a2cce5c541e6899ea40a7eaec4fe (patch) | |
| tree | 9a5e173387091eda3fbc35d70405cd51be50999f | |
| parent | ccb9e0b8e0008e5fa71768a88620ec0478a8ffaf (diff) | |
| download | perlweeklychallenge-club-d3a10cb72385a2cce5c541e6899ea40a7eaec4fe.tar.gz perlweeklychallenge-club-d3a10cb72385a2cce5c541e6899ea40a7eaec4fe.tar.bz2 perlweeklychallenge-club-d3a10cb72385a2cce5c541e6899ea40a7eaec4fe.zip | |
perl 161 solution 1
| -rw-r--r-- | challenge-161/julien-fiegehenn/perl/ch-1.pl | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/challenge-161/julien-fiegehenn/perl/ch-1.pl b/challenge-161/julien-fiegehenn/perl/ch-1.pl new file mode 100644 index 0000000000..ce487004a6 --- /dev/null +++ b/challenge-161/julien-fiegehenn/perl/ch-1.pl @@ -0,0 +1,19 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +use feature 'say'; + +my @dictionary + = do { open my $fh, '<', 'data/dictionary.txt' or die $!; <$fh>; }; +chomp @dictionary; + +WORD: for my $word (@dictionary) { + + # say $word if join(q{}, sort split //, $word) eq $word; ## this seems like the obvious solution + my @letters = split //, $word; + for my $i (0 .. $#letters - 1) { + next WORD unless ord($letters[$i]) <= ord($letters[$i + 1]); + } + say $word; +} |
