diff options
| author | Markus "Holli" Holzer <holli.holzer@gmail.com> | 2020-02-22 17:10:14 +0100 |
|---|---|---|
| committer | Markus "Holli" Holzer <holli.holzer@gmail.com> | 2020-02-22 17:10:14 +0100 |
| commit | b496f4ddc37a2b8d3c3aba3449e8eec4646e0204 (patch) | |
| tree | c64af5640056b4a0bf939125ea0eacde77b94f44 /challenge-048 | |
| parent | e29acf35011a292db357580662a9ce8f40bf6799 (diff) | |
| parent | 21446a2dca5cea394700e161dd0e33a8005cb4dc (diff) | |
| download | perlweeklychallenge-club-b496f4ddc37a2b8d3c3aba3449e8eec4646e0204.tar.gz perlweeklychallenge-club-b496f4ddc37a2b8d3c3aba3449e8eec4646e0204.tar.bz2 perlweeklychallenge-club-b496f4ddc37a2b8d3c3aba3449e8eec4646e0204.zip | |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-048')
43 files changed, 988 insertions, 5 deletions
diff --git a/challenge-048/alicia-bielsa/perl/ch-1.pl b/challenge-048/alicia-bielsa/perl/ch-1.pl new file mode 100644 index 0000000000..9cb3395bc4 --- /dev/null +++ b/challenge-048/alicia-bielsa/perl/ch-1.pl @@ -0,0 +1,28 @@ +#Survivor +#There are 50 people standing in a circle in position 1 to 50. The person standing at position 1 has a sword. He kills the next person i.e. standing at position 2 and pass on the sword to the immediate next i.e. person standing at position 3. Now the person at position 3 does the same and it goes on until only one survives. +# +#Write a script to find out the survivor. +use strict; +use warnings; + +my $numberPeople = 50; +my $numberPeopleAlive = $numberPeople; +my @aPeople = (); +foreach my $position (1..$numberPeople){ + my $nextPosition = $position == $numberPeople ? 1 : $position +1; + my %hTmp = ( 'nextPosition' => $nextPosition); + push (@aPeople, \%hTmp); +} + + +my $swordPosition = 1; +while ($numberPeopleAlive > 1){ + + my $killPosition = $aPeople[ $swordPosition - 1 ]->{'nextPosition'}; + $aPeople[ $swordPosition - 1 ]->{'nextPosition'} = $aPeople[ $killPosition - 1 ]->{'nextPosition'}; + $swordPosition = $aPeople[ $killPosition - 1 ]->{'nextPosition'}; + $numberPeopleAlive--; + +} + +print "Last Position Alive : $swordPosition\n";
\ No newline at end of file diff --git a/challenge-048/alicia-bielsa/perl/ch-2.pl b/challenge-048/alicia-bielsa/perl/ch-2.pl new file mode 100644 index 0000000000..4b0596a8d8 --- /dev/null +++ b/challenge-048/alicia-bielsa/perl/ch-2.pl @@ -0,0 +1,33 @@ +#Palindrome Dates +#Write a script to print all Palindrome Dates between 2000 and 2999. +#The format of date is mmddyyyy. For example, the first one was on October 2, 2001 as it is represented as 10022001. + +use strict; +use warnings; +use DateTime; +use Try::Tiny; +use English; + + +foreach my $date (2000..2999){ + my $palindromeDate = reverse($date).$date; + if (isValidDate ($palindromeDate )){ + print "Palindrome Date $palindromeDate \n"; + } +} + +sub isValidDate { + my $dateToValidate = shift; + my $validDate = 1; + my $dt = try { + DateTime->new( + year => substr($dateToValidate, 4,4), + month => substr($dateToValidate, 0,2), + day => substr($dateToValidate, 2,2)); + } catch { + if ($ARG){ + $validDate = 0; + } + }; + return $validDate; +} diff --git a/challenge-048/alicia-bielsa/raku/ch-1.p6 b/challenge-048/alicia-bielsa/raku/ch-1.p6 new file mode 100644 index 0000000000..3bedb89438 --- /dev/null +++ b/challenge-048/alicia-bielsa/raku/ch-1.p6 @@ -0,0 +1,22 @@ +use v6; + + + +my $numberPeople = 50; +my $numberPeopleAlive = $numberPeople; +my @aPeople; +for 1..$numberPeople { + my $nextPosition = $_ == $numberPeople ?? 1 !! $_ +1; + @aPeople.push({'nextPosition' => $nextPosition}); +} + +my $swordPosition = 1; +while $numberPeopleAlive > 1 { + my $killPosition = @aPeople[ $swordPosition-1 ]<nextPosition>; + @aPeople[ $swordPosition-1 ]<nextPosition> = @aPeople[ $killPosition-1 ]<nextPosition>; + $swordPosition = @aPeople[ $killPosition-1 ]<nextPosition>; + $numberPeopleAlive--; + +} + +print "Last Position Alive : $swordPosition\n";
\ No newline at end of file diff --git a/challenge-048/alicia-bielsa/raku/ch-2.p6 b/challenge-048/alicia-bielsa/raku/ch-2.p6 new file mode 100644 index 0000000000..8319c34c7f --- /dev/null +++ b/challenge-048/alicia-bielsa/raku/ch-2.p6 @@ -0,0 +1,14 @@ +#Palindrome Dates +#Write a script to print all Palindrome Dates between 2000 and 2999. +#The format of date is mmddyyyy. For example, the first one was on October 2, 2001 as it is represented as 10022001. + +use v6; + +for 2000..2999 { + my $mmdd = $_.flip; + my $date = Date.new($_, $mmdd.substr(0,2), $mmdd.substr(2,2)); + CATCH { + default { } + } + say $mmdd ~ $_; +}
\ No newline at end of file diff --git a/challenge-048/andrezgz/perl/ch-1.pl b/challenge-048/andrezgz/perl/ch-1.pl new file mode 100644 index 0000000000..2f88382970 --- /dev/null +++ b/challenge-048/andrezgz/perl/ch-1.pl @@ -0,0 +1,84 @@ +#!/usr/bin/perl + +# https://perlweeklychallenge.org/blog/perl-weekly-challenge-048/ +# Task #1 +# +# Survivor +# There are 50 people standing in a circle in position 1 to 50. +# The person standing at position 1 has a sword. +# He kills the next person i.e. standing at position 2 and +# pass on the sword to the immediate next i.e. person standing at position 3. +# Now the person at position 3 does the same and it goes on until only one survives. +# Write a script to find out the survivor. + +use strict; +use warnings; + +my @people = (1..50); +my $killed = 0; + +while (@people > 1) { + # determine who will be killed within the circle + $killed -= @people if ++$killed > $#people; + # declare who kills who + printf '%2d kills %-2d'.$/, $people[$killed-1], $people[$killed]; + # remove killed one from people + splice @people, $killed, 1; +} + +# The Highlander, there can be only one +printf $/.'%d is the survivor',@people; + +__END__ +./ch-1.pl + 1 kills 2 + 3 kills 4 + 5 kills 6 + 7 kills 8 + 9 kills 10 +11 kills 12 +13 kills 14 +15 kills 16 +17 kills 18 +19 kills 20 +21 kills 22 +23 kills 24 +25 kills 26 +27 kills 28 +29 kills 30 +31 kills 32 +33 kills 34 +35 kills 36 +37 kills 38 +39 kills 40 +41 kills 42 +43 kills 44 +45 kills 46 +47 kills 48 +49 kills 50 + 1 kills 3 + 5 kills 7 + 9 kills 11 +13 kills 15 +17 kills 19 +21 kills 23 +25 kills 27 +29 kills 31 +33 kills 35 +37 kills 39 +41 kills 43 +45 kills 47 +49 kills 1 + 5 kills 9 +13 kills 17 +21 kills 25 +29 kills 33 +37 kills 41 +45 kills 49 + 5 kills 13 +21 kills 29 +37 kills 45 + 5 kills 21 +37 kills 5 + +37 is the survivor diff --git a/challenge-048/andrezgz/perl/ch-2.pl b/challenge-048/andrezgz/perl/ch-2.pl new file mode 100644 index 0000000000..4af91e854d --- /dev/null +++ b/challenge-048/andrezgz/perl/ch-2.pl @@ -0,0 +1,72 @@ +#!/usr/bin/perl + +# https://perlweeklychallenge.org/blog/perl-weekly-challenge-048/ +# Task #2 +# +# Palindrome Dates +# Write a script to print all Palindrome Dates between 2000 and 2999. +# The format of date is mmddyyyy. +# For example, the first one was on October 2, 2001 as it is represented as 10022001. + +use strict; +use warnings; + +my $y = 1999; + +my @months = qw/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/; + +while ( ++$y < 3000 ) { + # year is inverted and divided to get month and day + my ($m, $d) = scalar(reverse $y) =~ m/../g ; + next unless is_valid_dom($y, $m, $d); + print $months[$m-1] . ' ' . $d . ', ' . $y .$/; +} + +sub is_valid_dom { + my ($y, $m, $d) = @_; + return if $d < 1 || $d > 31 || $m < 1 || $m > 12; # impossible days/months + return if $d > 30 && grep {$m == $_} (4,6,9,11); # 30-day months + return if $d > 29 && $m == 2; # 28-day February + return if $d == 29 && $m == 2 # 29-day February + && ! ($y % 4 == 0 && ($y % 100 != 0 || $y % 400 == 0) ); # not a leap year + return 1; # valid day for the month and year +} + +__END__ +./ch-2.pl +Oct 02, 2001 +Jan 02, 2010 +Nov 02, 2011 +Feb 02, 2020 +Dec 02, 2021 +Mar 02, 2030 +Apr 02, 2040 +May 02, 2050 +Jun 02, 2060 +Jul 02, 2070 +Aug 02, 2080 +Sep 02, 2090 +Oct 12, 2101 +Jan 12, 2110 +Nov 12, 2111 +Feb 12, 2120 +Dec 12, 2121 +Mar 12, 2130 +Apr 12, 2140 +May 12, 2150 +Jun 12, 2160 +Jul 12, 2170 +Aug 12, 2180 +Sep 12, 2190 +Oct 22, 2201 +Jan 22, 2210 +Nov 22, 2211 +Feb 22, 2220 +Dec 22, 2221 +Mar 22, 2230 +Apr 22, 2240 +May 22, 2250 +Jun 22, 2260 +Jul 22, 2270 +Aug 22, 2280 +Sep 22, 2290 diff --git a/challenge-048/arne-sommer/blog.txt b/challenge-048/arne-sommer/blog.txt new file mode 100644 index 0000000000..97abe3101f --- /dev/null +++ b/challenge-048/arne-sommer/blog.txt @@ -0,0 +1 @@ +https://raku-musings.com/surviving-dates.html diff --git a/challenge-048/arne-sommer/raku/ch-1.p6 b/challenge-048/arne-sommer/raku/ch-1.p6 new file mode 100755 index 0000000000..ca9519eaf1 --- /dev/null +++ b/challenge-048/arne-sommer/raku/ch-1.p6 @@ -0,0 +1,21 @@ +#! /usr/bin/env raku + +unit sub MAIN (:$verbose); + +my @people = 1 .. 50; + +my $next = 1; + +say ": @people[] [Index: $next]" if $verbose; + +while @people.elems > 1 +{ + my $killed = @people.splice($next, 1); + + $next++; + $next = 0 if $next > @people.end; + + say ": @people[] [K:$killed] [Next:$next]" if $verbose; +} + +say "Living: @people[]";
\ No newline at end of file diff --git a/challenge-048/arne-sommer/raku/ch-2.p6 b/challenge-048/arne-sommer/raku/ch-2.p6 new file mode 100755 index 0000000000..fe3f3a7547 --- /dev/null +++ b/challenge-048/arne-sommer/raku/ch-2.p6 @@ -0,0 +1,25 @@ +#! /usr/bin/env raku + +for 0..2 -> $y2 +{ + for 0..9 -> $y3 + { + for 0..1 -> $y4 + { + for 0..1 -> $m1 + { + for 0..9 -> $m2 + { + for 0..2 -> $d1 + { + next unless $m1 == $y4 && $m2 == $y3 && $d1 == $y2; + next if $m1 == 0 == $m2; + next if $m1 == 1 && $m2 > 2; + + say $m1 ~ $m2 ~ $d1 ~ '22' ~ $y2 ~ $y3 ~ $y4; + } + } + } + } + } +} diff --git a/challenge-048/arne-sommer/raku/palindrome-date-loop b/challenge-048/arne-sommer/raku/palindrome-date-loop new file mode 100755 index 0000000000..fe3f3a7547 --- /dev/null +++ b/challenge-048/arne-sommer/raku/palindrome-date-loop @@ -0,0 +1,25 @@ +#! /usr/bin/env raku + +for 0..2 -> $y2 +{ + for 0..9 -> $y3 + { + for 0..1 -> $y4 + { + for 0..1 -> $m1 + { + for 0..9 -> $m2 + { + for 0..2 -> $d1 + { + next unless $m1 == $y4 && $m2 == $y3 && $d1 == $y2; + next if $m1 == 0 == $m2; + next if $m1 == 1 && $m2 > 2; + + say $m1 ~ $m2 ~ $d1 ~ '22' ~ $y2 ~ $y3 ~ $y4; + } + } + } + } + } +} diff --git a/challenge-048/arne-sommer/raku/palindrome-date-object b/challenge-048/arne-sommer/raku/palindrome-date-object new file mode 100755 index 0000000000..ed0171be7f --- /dev/null +++ b/challenge-048/arne-sommer/raku/palindrome-date-object @@ -0,0 +1,11 @@ +#! /usr/bin/env raku + +my $date = Date.new('2000-01-01', + formatter => { sprintf "%02d%02d%04d", .month, .day, .year }); + +while $date.year < 3000 +{ + say $date if $date.Str eq $date.Str.flip; + + $date .= succ; +} diff --git a/challenge-048/arne-sommer/raku/palindrome-date-object2 b/challenge-048/arne-sommer/raku/palindrome-date-object2 new file mode 100755 index 0000000000..c8a2765db4 --- /dev/null +++ b/challenge-048/arne-sommer/raku/palindrome-date-object2 @@ -0,0 +1,12 @@ +#! /usr/bin/env raku + +my $date = Date.new('2000-01-01', + formatter => { sprintf "%02d%02d%04d", .month, .day, .year }); + +while $date.year < 3000 +{ + my $date-str = $date.Str; + say $date-str if $date-str eq $date-str.flip; + + $date .= succ; +} diff --git a/challenge-048/arne-sommer/raku/survivor b/challenge-048/arne-sommer/raku/survivor new file mode 100755 index 0000000000..ca9519eaf1 --- /dev/null +++ b/challenge-048/arne-sommer/raku/survivor @@ -0,0 +1,21 @@ +#! /usr/bin/env raku + +unit sub MAIN (:$verbose); + +my @people = 1 .. 50; + +my $next = 1; + +say ": @people[] [Index: $next]" if $verbose; + +while @people.elems > 1 +{ + my $killed = @people.splice($next, 1); + + $next++; + $next = 0 if $next > @people.end; + + say ": @people[] [K:$killed] [Next:$next]" if $verbose; +} + +say "Living: @people[]";
\ No newline at end of file diff --git a/challenge-048/e-choroba/blog.txt b/challenge-048/e-choroba/blog.txt new file mode 100644 index 0000000000..f517d615f4 --- /dev/null +++ b/challenge-048/e-choroba/blog.txt @@ -0,0 +1 @@ +http://blogs.perl.org/users/e_choroba/2020/02/perl-weekly-challenge-048-survivor-and-palindrome-dates.html diff --git a/challenge-048/e-choroba/perl/ch-1a.pl b/challenge-048/e-choroba/perl/ch-1a.pl index 59edc5fed9..71802c3fd6 100755 --- a/challenge-048/e-choroba/perl/ch-1a.pl +++ b/challenge-048/e-choroba/perl/ch-1a.pl @@ -5,17 +5,17 @@ use feature qw{ say }; my @people = (1) x 50; my $sword = 0; -my $next = sub { +sub following { do { $sword = (1 + $sword) % @people } until $people[$sword]; -}; +} while (1 < (my $living = grep $_, @people)) { # print 1 + $sword, ' kills '; - $next->(); + following(); # print 1 + $sword, $living == 2 # ? ' and the survivor is ' # : ' and passes the sword to '; $people[$sword] = 0; - $next->(); + following(); # say 1 + $sword; } say 1 + $sword; diff --git a/challenge-048/laurent-rosenfeld/blog.txt b/challenge-048/laurent-rosenfeld/blog.txt new file mode 100644 index 0000000000..f847368aec --- /dev/null +++ b/challenge-048/laurent-rosenfeld/blog.txt @@ -0,0 +1 @@ +http://blogs.perl.org/users/laurent_r/2020/02/perl-weekly-challenge-48-survivor-and-palindrome-dates.html diff --git a/challenge-048/laurent-rosenfeld/perl/ch-1.pl b/challenge-048/laurent-rosenfeld/perl/ch-1.pl new file mode 100644 index 0000000000..6bd4420d7d --- /dev/null +++ b/challenge-048/laurent-rosenfeld/perl/ch-1.pl @@ -0,0 +1,12 @@ +use strict; +use warnings; +use feature "say"; + +my $number = shift // 50; + +my @persons = 1 .. $number; +for (1.. $number - 1) { + push @persons, shift @persons; + shift @persons; +} +say "Person @persons is the survivor.\n"; diff --git a/challenge-048/laurent-rosenfeld/perl/ch-1a.pl b/challenge-048/laurent-rosenfeld/perl/ch-1a.pl new file mode 100644 index 0000000000..72dd67386f --- /dev/null +++ b/challenge-048/laurent-rosenfeld/perl/ch-1a.pl @@ -0,0 +1,13 @@ +use strict; +use warnings; +use feature "say"; + +my $number = shift // 50; +my @persons = 1 .. $number; # we can do that because + # we don't use the array indices +do { + push @persons, shift @persons; + shift @persons; + say "@persons"; +} until @persons == 1; +say "Person @persons is the survivor.\n"; diff --git a/challenge-048/laurent-rosenfeld/perl/ch-2.pl b/challenge-048/laurent-rosenfeld/perl/ch-2.pl new file mode 100644 index 0000000000..33b9027682 --- /dev/null +++ b/challenge-048/laurent-rosenfeld/perl/ch-2.pl @@ -0,0 +1,9 @@ +use strict; +use warnings; +use feature "say"; + +for my $year (2000 .. 2300) { + my ($month, $day) = (reverse $year) =~ /(\d\d)(\d\d)/; + next if $month > 12 or $month < 1 or $day > 31 or $day < 1; + say "$month/$day/$year is a palindromic date."; +} diff --git a/challenge-048/laurent-rosenfeld/raku/ch-1.p6 b/challenge-048/laurent-rosenfeld/raku/ch-1.p6 new file mode 100644 index 0000000000..da6781883b --- /dev/null +++ b/challenge-048/laurent-rosenfeld/raku/ch-1.p6 @@ -0,0 +1,12 @@ +use v6; + +my $number = @*ARGS ?? @*ARGS[0] !! 50; + +my $number = 50; +my @persons = 1 .. $number; + +for (1.. $number - 1) { + push @persons, shift @persons; + shift @persons; +} +say "Person @persons[] is the survivor.\n"; diff --git a/challenge-048/laurent-rosenfeld/raku/ch-2.p6 b/challenge-048/laurent-rosenfeld/raku/ch-2.p6 new file mode 100644 index 0000000000..d3ec9c6e23 --- /dev/null +++ b/challenge-048/laurent-rosenfeld/raku/ch-2.p6 @@ -0,0 +1,7 @@ +use v6; + +for 2000 .. 2300 -> $year { + my ($month, $day) = ($year.flip ~~ /(\d\d)(\d\d)/)[0, 1]; + next if $month > 12 or $month < 1 or $day > 31 or $day < 1; + say "$month/$day/$year is a palindromic date."; +} diff --git a/challenge-048/mohammad-anwar/blog.txt b/challenge-048/mohammad-anwar/blog.txt new file mode 100644 index 0000000000..e7b9f167f0 --- /dev/null +++ b/challenge-048/mohammad-anwar/blog.txt @@ -0,0 +1 @@ +https://perlweeklychallenge.org/blog/my-first-date-with-raku diff --git a/challenge-048/mohammad-anwar/perl/ch-1.pl b/challenge-048/mohammad-anwar/perl/ch-1.pl new file mode 100644 index 0000000000..fb66076660 --- /dev/null +++ b/challenge-048/mohammad-anwar/perl/ch-1.pl @@ -0,0 +1,13 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +my @people = (1 ..50); +while (scalar(@people) > 1) { + my $sword = shift @people; + shift @people; + push @people, $sword; +} + +print "Survivor is at position $people[0]\n"; diff --git a/challenge-048/mohammad-anwar/perl/ch-2.pl b/challenge-048/mohammad-anwar/perl/ch-2.pl index 22e71b25e3..5cc5cc7bdf 100644 --- a/challenge-048/mohammad-anwar/perl/ch-2.pl +++ b/challenge-048/mohammad-anwar/perl/ch-2.pl @@ -6,7 +6,7 @@ use Date::Tiny; my $date = Date::Tiny->new(year => 2000, month => 1, day => 1); -while ($date->year <= 2999) { +while ($date->year <= 2299) { my $date_as_str = sprintf("%02d%02d%04d", $date->month, $date->day, $date->year); if ($date_as_str eq reverse($date_as_str)) { print "$date_as_str is a Palindrome date.\n"; diff --git a/challenge-048/mohammad-anwar/raku/ch-1.p6 b/challenge-048/mohammad-anwar/raku/ch-1.p6 new file mode 100644 index 0000000000..df6efab00a --- /dev/null +++ b/challenge-048/mohammad-anwar/raku/ch-1.p6 @@ -0,0 +1,14 @@ +#!/usr/bin/env perl6 + +use v6; + +sub MAIN() { + my @people = 1..50; + while @people.elems > 1 { + my $sword = @people.shift; + @people.shift; + @people.push($sword); + } + + say "Survivor is at position @people[0]"; +} diff --git a/challenge-048/mohammad-anwar/raku/ch-2.p6 b/challenge-048/mohammad-anwar/raku/ch-2.p6 new file mode 100644 index 0000000000..ad2c46ef2b --- /dev/null +++ b/challenge-048/mohammad-anwar/raku/ch-2.p6 @@ -0,0 +1,15 @@ +#!/usr/bin/env perl6 + +use v6; + +sub MAIN() { + my $fmt = { sprintf "%02d%02d%04d", .month, .day, .year }; + my $date = Date.new(2000, 1, 1, formatter => $fmt); + while $date.year <= 2299 { + my $date-as-str = $date.Str; + if $date-as-str eq $date-as-str.flip { + say "$date-as-str is a Palindrome date."; + } + ++$date; + } +} diff --git a/challenge-048/noud/raku/ch-1.p6 b/challenge-048/noud/raku/ch-1.p6 new file mode 100644 index 0000000000..6afe800033 --- /dev/null +++ b/challenge-048/noud/raku/ch-1.p6 @@ -0,0 +1,34 @@ +# Survivor +# +# There are 50 people standing in a circle in position 1 to 50. The person +# standing at position 1 has a sword. He kills the next person i.e. standing at +# position 2 and pass on the sword to the immediate next i.e. person standing +# at position 3. Now the person at position 3 does the same and it goes on +# until only one survives. +# +# Write a script to find out the survivor. + +# This is a special case of the Josephus problem: +# +# https://en.wikipedia.org/wiki/Josephus_problem +# and +# +# https://oeis.org/A006257 +# +# Let n be the total number of people in the circle and k be the step to the +# next person. I.e. k - 2 people are skipped, person k is killed and person +# k will get the sword. Let f(n, k) denote the position of the survivor. If +# person k is killed, we're left with a circle of n - 1 and the next person who +# gets the sword is (k mod n) + 1. The survivor person in the remaining circle +# is f(n - 1, k) if we start counting at 1. Shifting the numbers the survivor +# person is (f(n - 1, k) + k - 1) mod n + 1. Hence we have the recurrence +# relation: +# +# f(n, k) = (f(n - 1, k) + k - 1) mod n + 1. +# +# For this problem we have n = 50 and k = 2. + +multi sub f(1, $k) { 1; } +multi sub f($n, $k) { (f($n - 1, $k) + $k - 1) % $n + 1; } + +say "Survivor: ", f(50, 2); diff --git a/challenge-048/noud/raku/ch-2.p6 b/challenge-048/noud/raku/ch-2.p6 new file mode 100644 index 0000000000..9affb72031 --- /dev/null +++ b/challenge-048/noud/raku/ch-2.p6 @@ -0,0 +1,22 @@ +# Palindrome Dates +# +# Write a script to print all Palindrome Dates between 2000 and 2999. The +# format of date is mmddyyyy. For example, the first one was on October 2, 2001 +# as it is represented as 10022001. + +# It's possible to compute directly all possibilities. Let +# "m1 m2 d1 d2 y1 y2 y3 y4" be the palindrome, because we look between years 2000 +# and 2999, y1 = 2. Because we have a palindrome: +# +# "m1 m2 d1 d2 2 y2 y3 y4" = "y4 y3 y2 2 d2 d1 m2 m1" +# |
