diff --git a/euler/.gitignore b/euler/.gitignore index 9735f282..fd9a81d9 100644 --- a/euler/.gitignore +++ b/euler/.gitignore @@ -4,4 +4,5 @@ problem03 problem04 problem05 problem06 -problem07 \ No newline at end of file +problem07 +problem09 diff --git a/euler/problem09.porth b/euler/problem09.porth new file mode 100644 index 00000000..ef72a394 --- /dev/null +++ b/euler/problem09.porth @@ -0,0 +1,21 @@ +include "std.porth" + +macro sum 1000 end + +sum +1 while over over >= do + 1 while over over >= do + 2dup over dup * over dup * + + rot rot + + sum swap - + if 2dup dup * = do + swap drop print + 2dup swap print print + 0 exit // can be commented to test that it's the only one solution + else + 2drop + end + 1 + + end drop + 1 + +end 2drop diff --git a/euler/problem09.txt b/euler/problem09.txt new file mode 100644 index 00000000..03c61026 --- /dev/null +++ b/euler/problem09.txt @@ -0,0 +1,11 @@ +:i argc 0 +:b stdin 0 + +:i returncode 0 +:b stdout 12 +425 +375 +200 + +:b stderr 0 +