Commits

Shlomi Fish committed 8dc89be

Cleanup.

Thanks to some people on #perl6.

  • Participants
  • Parent commits da60448

Comments (0)

Files changed (1)

File project-euler/189/euler_189-2.p6

 sub my_find(Int $wanted_h) returns Int
 {
     # The start_data for $h == 1
-    my %data = (
-        seq => {'0' => 1, '1' => 1, '2' => 1,},
-        derived =>
+    my $this_seqs = {'0' => 1, '1' => 1, '2' => 1,};
+    my $prev_deriveds =
+    {
+        '' =>
         {
-            '' =>
-            {
-                '0' => 1,
-                '1' => 1,
-                '2' => 1,
-            }
-        },
-        count => 3,
-    );
-    for (1 .. $wanted_h - 1) -> $h
+            '0' => 1,
+            '1' => 1,
+            '2' => 1,
+        }
+    };
+
+    my $total_count;
+
+    for (1 ..^ $wanted_h) -> $h
     {
-        my $this_seqs = %data{'seq'};
-        my $prev_deriveds = %data{'derived'};
-
-        my $total_count = 0;
+        $total_count = 0;
         my $next_deriveds = {};
         my $next_seqs = {};
 
         }
 
         # Fill the next data.
-        %data =
-        (
-            seq => $next_seqs,
-            derived => $next_deriveds,
-            count => $total_count,
-        );
+        ($this_seqs, $prev_deriveds) = ($next_seqs, $next_deriveds);
         say "Count[{$h+1}] = $total_count";
     }
 
-    return %data{'count'};
+    return $total_count;
 }
 
 # Test