Commits

Shlomi Fish committed 14453ac

Convert the record to an array ref instead of a hash ref.

A small optimisation.

  • Participants
  • Parent commits 99dcadd

Comments (0)

Files changed (1)

File project-euler/126/euler-126-take3.pl

 
 STDOUT->autoflush(1);
 
+use constant DELTA => 0;
+use constant COUNT => 1;
+
 my @C;
 
 # Used to be:
                 ($x*($y+$z)+$z*$y);
 
             # We increase the depth's delta by 8 each time.
-            push @cuboids, { d => ((($x+$y+$z)<<1)-4), n => $new_layer_count};
+            push @cuboids, [((($x+$y+$z)<<1)-4), $new_layer_count];
 
             add_count($new_layer_count);
         }
     # Now add extra layers to the existing cuboids.
     foreach my $rec (@cuboids)
     {
-        while ($rec->{n} < $max_layer_size)
+        while ($rec->[COUNT] < $max_layer_size)
         {
-            add_count($rec->{n} += ($rec->{d} += 4));
+            add_count($rec->[COUNT] += ($rec->[DELTA] += 4));
         }
     }
 }