From c5d821dde8d8a8be20f911fa8e6201d80074e1ad Mon Sep 17 00:00:00 2001 From: CY Fung Date: Tue, 30 Aug 2022 00:59:57 +0800 Subject: Week 180 Task 1 --- challenge-180/cheok-yin-fung/perl/ch-1.pl | 12 ++++++++++++ challenge-180/cheok-yin-fung/raku/ch-1.raku | 2 ++ 2 files changed, 14 insertions(+) create mode 100644 challenge-180/cheok-yin-fung/perl/ch-1.pl create mode 100644 challenge-180/cheok-yin-fung/raku/ch-1.raku (limited to 'challenge-180') diff --git a/challenge-180/cheok-yin-fung/perl/ch-1.pl b/challenge-180/cheok-yin-fung/perl/ch-1.pl new file mode 100644 index 0000000000..a7fe2de437 --- /dev/null +++ b/challenge-180/cheok-yin-fung/perl/ch-1.pl @@ -0,0 +1,12 @@ +use v5.30.0; + +my $s = "Long Live Perl"; +my @a = split "", $s; +my %hash; +for (0..$#a) { + $hash{$a[$_]} = 0 if $hash{$a[$_]} == 1; + $hash{$a[$_]} = 1 if !defined($hash{$a[$_]}); +} +my $i = 0; +++$i until $hash{$a[$i]} == 1; +say $i; diff --git a/challenge-180/cheok-yin-fung/raku/ch-1.raku b/challenge-180/cheok-yin-fung/raku/ch-1.raku new file mode 100644 index 0000000000..c744ca86c2 --- /dev/null +++ b/challenge-180/cheok-yin-fung/raku/ch-1.raku @@ -0,0 +1,2 @@ +my $s = "Long Live Perl"; +say index($s, first { $s.indices($_).elems == 1 }, $s.comb ); -- cgit