Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,17 @@
from collections import defaultdict
from itertools import product
from pprint import pprint as pp
cube2n = {x**3:x for x in range(1, 1201)}
sum2cubes = defaultdict(set)
for c1, c2 in product(cube2n, cube2n):
if c1 >= c2: sum2cubes[c1 + c2].add((cube2n[c1], cube2n[c2]))
taxied = sorted((k, v) for k,v in sum2cubes.items() if len(v) >= 2)
#pp(len(taxied)) # 2068
for t in enumerate(taxied[:25], 1):
pp(t)
print('...')
for t in enumerate(taxied[2000-1:2000+6], 2000):
pp(t)

View file

@ -0,0 +1,20 @@
cubes, crev = [x**3 for x in range(1,1200)], {}
# for cube root lookup
for x,x3 in enumerate(cubes): crev[x3] = x + 1
sums = sorted(x+y for x in cubes for y in cubes if y < x)
idx = 0
for i in range(1, len(sums)-1):
if sums[i-1] != sums[i] and sums[i] == sums[i+1]:
idx += 1
if idx > 25 and idx < 2000 or idx > 2006: continue
n,p = sums[i],[]
for x in cubes:
if n-x < x: break
if n-x in crev:
p.append((crev[x], crev[n-x]))
print "%4d: %10d"%(idx,n),
for x in p: print " = %4d^3 + %4d^3"%x,
print

View file

@ -0,0 +1,30 @@
from heapq import heappush, heappop
def cubesum():
h,n = [],1
while True:
while not h or h[0][0] > n**3: # could also pre-calculate cubes
heappush(h, (n**3 + 1, n, 1))
n += 1
(s, x, y) = heappop(h)
yield((s, x, y))
y += 1
if y < x: # should be y <= x?
heappush(h, (x**3 + y**3, x, y))
def taxis():
out = [(0,0,0)]
for s in cubesum():
if s[0] == out[-1][0]:
out.append(s)
else:
if len(out) > 1: yield(out)
out = [s]
n = 0
for x in taxis():
n += 1
if n >= 2006: break
if n <= 25 or n >= 2000:
print(n, x)