Project Euler/9

From Esolang
Jump to navigation Jump to search

Back to User:ProjectEuler

Project Euler Problem 9 is a problem related to Pythagorean triples. The task is to find out the value of a×b×c where the sum of the natural numbers a, b, and c is equal to 1000 and the three numbers form a Pythagorean triple.

This article is not detailed enough and needs to be expanded. Please help us by adding some more information.

Implementations

Aheui

This program doesn't work out the actual values of a, b, and c. Instead, it uses three medium values x (stores in main stack), m (stored in "n" stack) and n (stored in "nh" stack) acting as a "pythagorean triples generator" where a=x(m2-n2), b=2xmn, c=x(m2+n2). We can easily find out that a+b+c=2mx(m+n) and abc=2x3mn(m+n)(m-n)(m2+n2), and the program uses that shortcut to work out the answer.

발발나반싼빠싾삲빠산빠싾빠반따삲다싼산뚜
뿌썩뿌머투떠떠오뗘벓벌벌벌뻐떠선썬뻐서뻐
쑨뽀섢쏙차빠뱛오발발발따따따주사불다산오
산투두섢썮뻐너벌벌머서뻐머머처모발노
뿌썩빠싼산타우요어어쳐녀뱔별뱔별냐며다셚
따삲빠따싼샨야댜야쌱오사빠따싹삭떠망희

Rockstar

The line marked "See note above" is technically useless[citation needed], but unluckily it couldn't be removed.

The palace is gone.
The stable is gone.
Xenocrates is hardworking
The monk is hard-working
The nun is hardworking
While the palace is gone
Let the stable be the monk with the nun.
Let the stable be of the monk.
Let the stable be with the stable.
If the stable of Xenocrates is 1000
Let my tower be the monk of the monk
Let your tower be the nun of the nun
Let my tower be of my tower
Let your tower be of your tower
Let the palace be my tower without your tower
Let the palace be of the monk
Let the palace be of the nun
Let the palace be of Xenocrates
Let the palace be of Xenocrates
Let the palace be of Xenocrates
Let the palace be with the palace.
Else
If the stable of Xenocrates is higher than 1000
 Xenocrates is hardworking.
 Build the nun up.
 If the monk is the nun
  Build the monk up.
  The nun is hardworking.
 Else
  Xenocrates is hardworking. (See note above)
Else
 Build Xenocrates up.


Say the palace.

External resources

  • Problem 9 on Project Euler Official Website (not available)
  • Problem 9 on Project Euler Mirror