def main(): """ challenge043 """ source = "0123456789" return sum([int(n) for n in permutate(source) if int(n) >= 1000000000 and int(n[7:10]) % 17 == 0 and int(n[6:9]) % 13 == 0 and int(n[5:8]) % 11 == 0 and int(n[4:7]) % 7 == 0 and int(n[3:6]) % 5 == 0 and int(n[2:5]) % 3 == 0 and int(n[1:4]) % 2 == 0])
def main(): """ challenge041 """ # loop through number of digits highest = 0 for number_size in [4, 7]: chars = "".join([str(c) for c in range(1, number_size + 1)]) for potential in [int(p) for p in permutate(chars) if is_prime(int(p))]: # if potential > highest: # Potential is always higher in this scenario. highest = potential return highest
def main(): """ challenge032 """ source = "123456789" products = [] for potential in [int(p) for p in permutate(source)]: # * can be after 1, 2, 3, 4 # = can only be between 5 and 6 third = potential % 10**4 for i in range(1, 3): first = potential // 10**(9 - i) second = (potential // 10**(4)) % 10**(5 - i) product = first * second if product == third: products.append(third) return sum(set(products))
def test_permutate(input, expected): actual = set(permutate(input)) expect(actual).to.eq(expected)
def main(): """ challenge024 """ number = "0123456789" return int(list(islice(permutate(number), 999999, 1000000))[0])