]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/project-euler/100/100.factor
Harmonize spelling
[factor.git] / extra / project-euler / 100 / 100.factor
index 72584d833ec842bc4eca1d5e7ea344ba224e2981..0ea04961819bb8984777de0b6f3467f39a43498d 100644 (file)
@@ -1,23 +1,22 @@
 ! Copyright (c) 2008 Eric Mertens.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel math math.functions sequences project-euler.common ;
+USING: kernel math math.functions project-euler.common ;
 IN: project-euler.100
 
 ! http://projecteuler.net/index.php?section=problems&id=100
 
-! DESCRIPTION
-! -----------
+! DESCRIPTION ! -----------
 
-! If a box contains twenty-one coloured discs, composed of fifteen blue discs
-! and six red discs, and two discs were taken at random, it can be seen that
-! the probability of taking two blue discs, P(BB) = (15/21)*(14/20) = 1/2.
+! If a box contains twenty-one colored discs, composed of fifteen blue discs
+!  and six red discs, and two discs were taken at random, it can be seen that
+!  the probability of taking two blue discs, P(BB) = (15/21)*(14/20) = 1/2.
 
 ! The next such arrangement, for which there is exactly 50% chance of taking
-! two blue discs at random, is a box containing eighty-five blue discs and
-! thirty-five red discs.
+!  two blue discs at random, is a box containing eighty-five blue discs and
+!  thirty-five red discs.
 
 ! By finding the first arrangement to contain over 10^12 = 1,000,000,000,000
-! discs in total, determine the number of blue discs that the box would contain.
+!  discs in total, determine the number of blue discs that the box would contain.
 
 
 ! SOLUTION
@@ -26,7 +25,7 @@ IN: project-euler.100
 : euler100 ( -- answer )
     1 1
     [ dup dup 1 - * 2 * 10 24 ^ <= ]
-    [ tuck 6 * swap - 2 - ] while nip ;
+    [ [ 6 * swap - 2 - ] keep swap ] while nip ;
 
 ! TODO: solution needs generalization