Skip to content

# abachman/project_euler

### Subversion checkout URL

You can clone with
or
.

solved 39

• Loading branch information...
commit 19bd992725a61802f5fae44c5109c5a4baf0121c 1 parent a6bf447
Adam Bachman authored
Showing with 61 additions and 0 deletions.
1. +2 −0  notes.txt
2. +43 −0 p038.py
3. +16 −0 p039.py
2  notes.txt
 @@ -1,4 +1,6 @@ unsolved: +039 + 088 108
43 p038.py
 @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# vim: ai ts=4 sts=4 et sw=4 +""" +2009-05-15 + +Take the number 192 and multiply it by each of 1, 2, and 3: + + 192 x 1 = 192 + 192 x 2 = 384 + 192 x 3 = 576 + +By concatenating each product we get the 1 to 9 pandigital, 192384576. We will +call 192384576 the concatenated product of 192 and (1,2,3) + +The same can be achieved by starting with 9 and multiplying by 1, 2, 3, 4, and +5, giving the pandigital, 918273645, which is the concatenated product of 9 and +(1,2,3,4,5). + +What is the largest 1 to 9 pandigital 9-digit number that can be formed as the +concatenated product of an integer with (1,2, ... , n) where n > 1? +""" + +import psyco +psyco.full() + +def has_all(s): + return all(map( lambda i: i in s, '123456789' )) + +def solve(): + for n in range(200000): + out = '' + for x in range(1,12): + out += str(n * x) + if len(out) == 9: + if has_all(out): + print "%i:\t%s\t" % (n, out) + break + +if __name__ == "__main__": + # assert has_all('123456789') + # assert not has_all('1234') + solve() +
16 p039.py
 @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# vim: ai ts=4 sts=4 et sw=4 +""" +2009-05-15 + +If p is the perimeter of a right angle triangle with integral length sides, +{a,b,c}, there are exactly three solutions for p = 120. + +{20,48,52}, {24,45,51}, {30,40,50} + +For which value of p ≤ 1000, is the number of solutions maximised? +""" + +import psyco +psyco.full() +

#### 0 comments on commit `19bd992`

Please sign in to comment.
Something went wrong with that request. Please try again.