1 ! Copyright (c) 2007, 2008 Aaron Schaefer, Samuel Tardieu.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: definitions io io.files io.pathnames kernel math math.parser
4 prettyprint project-euler.ave-time sequences vocabs vocabs.loader
5 project-euler.001 project-euler.002 project-euler.003 project-euler.004
6 project-euler.005 project-euler.006 project-euler.007 project-euler.008
7 project-euler.009 project-euler.010 project-euler.011 project-euler.012
8 project-euler.013 project-euler.014 project-euler.015 project-euler.016
9 project-euler.017 project-euler.018 project-euler.019 project-euler.020
10 project-euler.021 project-euler.022 project-euler.023 project-euler.024
11 project-euler.025 project-euler.026 project-euler.027 project-euler.028
12 project-euler.029 project-euler.030 project-euler.031 project-euler.032
13 project-euler.033 project-euler.034 project-euler.035 project-euler.036
14 project-euler.037 project-euler.038 project-euler.039 project-euler.040
15 project-euler.041 project-euler.042 project-euler.043 project-euler.044
16 project-euler.045 project-euler.046 project-euler.047 project-euler.048
17 project-euler.052 project-euler.053 project-euler.055 project-euler.056
18 project-euler.057 project-euler.059 project-euler.067 project-euler.071
19 project-euler.073 project-euler.075 project-euler.076 project-euler.079
20 project-euler.092 project-euler.097 project-euler.099 project-euler.100
21 project-euler.116 project-euler.117 project-euler.134 project-euler.148
22 project-euler.150 project-euler.151 project-euler.164 project-euler.169
23 project-euler.173 project-euler.175 project-euler.186 project-euler.190
24 project-euler.203 project-euler.215 ;
29 : problem-prompt ( -- n )
30 "Which problem number from Project Euler would you like to solve?"
31 print readln string>number ;
33 : number>euler ( n -- str )
34 number>string 3 CHAR: 0 pad-left ;
36 : solution-path ( n -- str/f )
37 number>euler "project-euler." prepend
38 vocab where dup [ first <pathname> ] when ;
42 : problem-solved? ( n -- ? )
45 : run-project-euler ( -- )
46 problem-prompt dup problem-solved? [
47 dup number>euler "project-euler." prepend run
48 "Answer: " write dup number? [ number>string ] when print
49 "Source: " write solution-path .
51 drop "That problem has not been solved yet..." print
54 MAIN: run-project-euler