A first shot though I only generated 7198 variations...I must've done something wrong or misinterpreted something in your problem statement.
#!/usr/bin/perl -w
use strict;
symdate();
sub symdate{
my($h,$n,$d,$m,$y,$r);my@x=qw(1001 2002 3003 0110 1111 2112);for('0000
+10'..'195921'){$r=reverse$_;$h=substr($_,0,2);$n=substr($_,2,2);$d=su
+bstr($_,4,2);$m=substr($r,0,2);$y=substr($r,2,4);for(@x){if($_ eq $d.
+$m){if(($h>=0)&&($h<24)&&($n>=0)&&($n<60)){print "$h:$n $d/$m $y\n";}
+}}}
}
Update:
Fixed the logical error and shortened the code down to 179 chars.
sub symdate
{
my($f,$r);for('000000'..'235930'){$f=$_.reverse;$r='(..)'x6;$f=~s/$r/$
+1:$2 $3\/$4 $5$6/g;for(qw(1001 2002 3003 0110 1111 2112)){if((
$_ eq $3.$4)&&($1<24)&&($2<60)){print"$f\n";}}}
}
Update2:
Shortened it down to 147 chars though still not as good as chipmunk's. Btw, it generates 8,640 solutions.
sub symdate
{
for(qw(01 10 20 30 11 21)){for$h('00'..'23'){for$m('00'..'59'){$s="$h$
+m$_";$r='(..)'x6;$f=$s.reverse$s;$f=~s/$r/$1:$2 $3\/$4 $5$6/;print$f,
+"\n";}}}
}
metadoktor
"The doktor is in."
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.