Example #1
0
def main(limit):
    # trick: want the digits of 2x, 3x, ... to equal
    # if limit > 2 we must have 2x = 3x mod 9 or x = 0 mod 9
    skip = 1 if limit < 3 else 9
    facs = range(2, limit + 1)
    good = lambda n: n > 0 and same(map(digitCountMap, (f * n for f in facs)))
    return next(filter(good, count(0, skip)))
Example #2
0
def main(limit):
	# trick: want the digits of 2x, 3x, ... to equal
	# if limit > 2 we must have 2x = 3x mod 9 or x = 0 mod 9
	skip = 1 if limit < 3 else 9
	facs = range(2, limit + 1)
	good = lambda n: n > 0 and same(map(digitCountMap, (f * n for f in facs)))
	return next(filter(good, count(0, skip)))
Example #3
0
def main(limit):
	# trick: "merge" the sorted lists until a match is found
	gens = (ngonalNums(3), ngonalNums(5), ngonalNums(6))
	nums = list(map(next, gens))
	while nums[0] <= limit or not same(nums):
		i = min(range(3), key=lambda i: nums[i])
		nums[i] = next(gens[i])
	return nums[0]
Example #4
0
def main(limit):
    # trick: "merge" the sorted lists until a match is found
    gens = (ngonalNums(3), ngonalNums(5), ngonalNums(6))
    nums = list(map(next, gens))
    while nums[0] <= limit or not same(nums):
        i = min(range(3), key=lambda i: nums[i])
        nums[i] = next(gens[i])
    return nums[0]