With the recent passing of a 'symmetrical date' (20:02 20/02 2002) and my inability to find any related posts on here, I present the following code from a co-member of a local linux users' group to produce a list of all symmetrical dates of the form HH:MM DD/MM YYYY
By symmetrical I mean either of the following examples:
I'm simply curious to see the results of a few rounds of golf on this problem.
By symmetrical I mean either of the following examples:
- overall symmetry: 16:12 30/03 2161
- component and overall symmetry: 20:02 20:02 2002
I'm simply curious to see the results of a few rounds of golf on this problem.
#!/usr/bin/perl -w my %symmetrical = (); my $time; my $year; my @months = ('1001', '2002', '3003', '0110', '1111', '2112'); foreach my $i (0 .. 2359) { $i = &fill($i); $i =~ m/(\d\d)(\d\d)/; if (($1 > 23) or ($2 > 59)) { next; } $time = $i; $year = reverse($i); $symmetrical{$year} = $time; } for my $i (sort(keys %symmetrical)) { my $ryear = $i; my $rtime = $symmetrical{$i}; $rtime =~ s/(\d\d)(\d\d)/$1:$2/; for my $rmonth (@months) { $rmonth =~ s/(\d\d)(\d\d)/$1\/$2/; print "$rtime\t$rmonth\t$ryear\n"; } } sub fill { my $i = shift; while (length($i) < 4) { $i = '0' . $i; } return $i; }
|
---|
Replies are listed 'Best First'. | |
---|---|
147 Chars - Re: Symmetrical Date Golf
by metadoktor (Hermit) on Feb 28, 2002 at 14:54 UTC | |
Re: Symmetrical Date Golf
by dragonchild (Archbishop) on Feb 28, 2002 at 15:34 UTC | |
by metadoktor (Hermit) on Feb 28, 2002 at 16:38 UTC | |
Re: Symmetrical Date Golf
by chipmunk (Parson) on Mar 01, 2002 at 03:45 UTC | |
Re: Symmetrical Date Golf
by Anonymous Monk on Mar 01, 2002 at 00:44 UTC | |
by ryan (Pilgrim) on Mar 01, 2002 at 04:48 UTC |
Back to
Meditations