blob: 2722a89443be1a4581946e6e4218f8b31b24bf7e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#!/usr/bin/env perl
use strict;
use warnings;
use feature 'say';
use experimental 'signatures';
sub main ($input_string) {
my $solution = $input_string;
O: while (1) {
foreach my $idx ( 0 .. length($solution) - 2 ) {
my $char = substr( $solution, $idx, 1 );
# If the nex two letters are the same but different case, remove them
if (
(
$char eq uc($char)
and substr( $solution, $idx + 1, 1 ) eq lc($char)
)
or ( $char eq lc($char)
and substr( $solution, $idx + 1, 1 ) eq uc($char) )
)
{
substr( $solution, $idx, 2 ) = '';
next O;
}
}
last;
}
say '"', $solution, '"';
}
main( $ARGV[0] );
|