-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
As of this commit only p20, p21 and p690 have been converted this way
- Loading branch information
1 parent
4d5bca0
commit c6ae93a
Showing
3 changed files
with
35 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |