Ejemplo n.º 1
0
def run():
    t = euler_util.triangles()
    for i in range(285):
        t.next()

    p = euler_util.pentagonals()
    curr_p = p.next()

    h = euler_util.hexagonals()
    curr_h = h.next()

    while True:
        curr_t = t.next()

        while curr_p < curr_t:
            curr_p = p.next()

        while curr_h < curr_t:
            curr_h = h.next()

        if curr_t == curr_h and curr_t == curr_p:
            # print curr_t
            return
Ejemplo n.º 2
0
def run():
    fields = [Field(get_field(g)) for g in [eu.triangles(), eu.squares(), eu.pentagonals(), eu.hexagonals(), eu.heptagonals(), eu.octagonals()]]
    solve(fields, [0] * 6)
Ejemplo n.º 3
0
# count triangle words

import euler_util

tgen = euler_util.triangles()
t = [tgen.next() for i in range(1000)]

f = open('words.txt', 'r')
data = f.read()
f.close()

words = [euler_util.word_value(d[1:-1]) for d in data.split(',')]
words = filter(lambda x: euler_util.bsearch(t, x) != -1, words)
print len(words)