Ok, so by using
$h=+$r;
where r is something like '05:35'
you get $h = 5, with the '0' and ':35' removed. Is that correct?
# Python test code.
r = "05:35"
h=0+r # oops: "TypeError: unsupported operand type(s) for +: 'int' and 'str'"
h=int(r) # oops: "ValueError: invalid literal for int() with base 10: '05:35'"
h=int(r[:2]) # ... finally, this works :)
<?
list($h,$m)=explode(':',fgets(STDIN));
$h=(int)$h;
$m=floor(((int)$m)/5);
for($x=0;$x<12;$x++)
{
$c[$x]='o';
}
if($h>=12)
$h=$h-12;
if($h==$m)
{$c[$h]='x';}
else
{
$c[$h]='h';$c[$m]='m';
}
$o=<<<EOT
$c[0]
$c[11] $c[1]
$c[10] $c[2]
$c[9] $c[3]
$c[8] $c[4]
$c[7] $c[5]
$c[6]
EOT;
echo $o;
---------
Here it is compressed:
<?list($h,$m)=explode(':',fgets(STDIN)); $h=(int)$h; $m=floor(((int)$m)/5); for($x=0;$x<12;$x++){$c[$x]='o';} if($h>=12)$h=$h-12; if($h==$m){$c[$h]='x';} else{$c[$h]='h';$c[$m]='m';} $o=<<<EOT
$c[0]
$c[11] $c[1]
$c[10] $c[2]
$c[9] $c[3]
$c[8] $c[4]
$c[7] $c[5]
$c[6]
EOT;
echo $o;
Any pointers at all on what i can do to reduce file size will be very much appreciated.