Skip to content

Commit

Permalink
Distinguish unique oscillators
Browse files Browse the repository at this point in the history
As of this commit only p20, p21 and p690 have been converted this way
  • Loading branch information
Parcly-Taxel committed Jul 26, 2021
1 parent 4d5bca0 commit c6ae93a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 21 deletions.
5 changes: 2 additions & 3 deletions fixedoscs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
16 xp16_0c2w3vz33032988 21
17 xp17_32acy1ca23zy27rszwo8a6y16a8o 36
18 xp18_66625ak8zy177xcc0cczy1g8mwiozx91gp 43
20 xp20_35426ow37bkicz65123 30
21 xp21_5b8b94gszw6520gw6a8ozx332f7zy2121 40
20 xp20_0jhe8gxg8gz122dl56o8ghzy1123cjc32ac 48
21 xp21_y68e13zy0o4ogw315b8oz0gx11z121y6252zc88gy04eiczw32qbzw321 60
22 xp22_178cwggg2y2oo4kozy235433y28111w62sg 36
23 xp23_y1ggy3o8bdzc82u074wo84s8x31560u28czx11y0hi21y411zy5ddx696zgg0s4y1owsi1isx4s0ggz10230f9y3ogjn45303201zyc65 122
24 xp24_2hqz037133zssszx777 24
Expand Down Expand Up @@ -125,4 +125,3 @@
496 xp496_ccy04ajaeweaja4y0cczz66y04apaeweapa4y066zzy2oo0o8i22zy368wov 69
504 xp504_ym356zy364koyh696y6g0s4zyjc871ye11zzy12552yg2bq4y4o8zca6y3oggyp113y3ca6zy823ys8kk8zzy4ggyegs26zy24701y6cicyh354czymcko 111
512 xp512_yr33y166z0ggy033y16426ye33y0ccz011w66yuggz66yz56zzzy2mqyz66zygckgk2a21ya66woozy133y0ccye6426y1cczy566y1cc 100
690 xp690_0ooy9vtvzyc757zok4sxs4kozzzz033y133 40
3 changes: 3 additions & 0 deletions lcm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
20 xp20_35426ow37bkicz65123 30
21 xp21_5b8b94gszw6520gw6a8ozx332f7zy2121 40
690 xp690_0ooy9vtvzyc757zok4sxs4kozzzz033y133 40
48 changes: 30 additions & 18 deletions skopje.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,42 @@
from constructs import *
fixed = {}

def skop(p):
"""Return a list of pairs (Pattern, minimum population) representing
the smallest known oscillators of the specified period."""
if not fixed:
with open("fixedoscs", 'r') as f:
def read_oscfiles(*fns):
"""Read oscillators and their minimum populations from provided files
and return a dictionary."""
res = {}
for fn in fns:
with open(fn, 'r') as f:
for l in f:
period, apgcode, mpop = l.split()
period = int(period)
fixed[period] = fixed.get(period, tuple()) + ((lt.pattern(apgcode), int(mpop)),)
cands = list(fixed.get(p, []))
cands.append(rectifier_loop(p))
cands.append(mold_rectifier_loop(p))
cands.append(p4_bumper_loop(p))
cands.append(p8_loop(p))
cands.append(snark_loop(p))
cands.append(p6_bumper_loop(p))
cands.append(pd_shuttle(p))
cands.append(p6thumb_shuttle(p))
cands.append(p14_shuttle(p))
cands.append(twinbees_shuttle(p))
res[period] = res.get(period, tuple()) + ((lt.pattern(apgcode), int(mpop)),)
return res

def skop(p, unique=False):
"""Return a list of pairs (Pattern, minimum population) representing
the smallest known oscillators of the specified period. Setting unique=True
excludes LCM and adjustable (to infinitely many periods trivially) oscillators."""
if not unique:
fixed = read_oscfiles("fixedoscs", "lcm")
cands = list(fixed.get(p, []))
cands.append(rectifier_loop(p))
cands.append(mold_rectifier_loop(p))
cands.append(p4_bumper_loop(p))
cands.append(p8_loop(p))
cands.append(snark_loop(p))
cands.append(p6_bumper_loop(p))
cands.append(pd_shuttle(p))
cands.append(p6thumb_shuttle(p))
cands.append(p14_shuttle(p))
cands.append(twinbees_shuttle(p))
else:
fixed = read_oscfiles("fixedoscs")
cands = list(fixed.get(p, []))
cands = list(filter(bool, cands))
if not cands:
return []
cands = [pair if pair[1] else (pair[0], minpop(pair[0])) for (i, pair) in enumerate(cands)]
mp = min(pair[1] for pair in cands)
return list(filter(lambda pair: pair[1] == mp, cands))

skuop = lambda p: skop(p, True)

0 comments on commit c6ae93a

Please sign in to comment.