This file contains hidden or 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
| import glob | |
| import numpy as np | |
| from itertools import combinations | |
| from time import time | |
| t0 = time() | |
| words = [] | |
| for file in glob.glob('wordle*'): | |
| with open(file) as f: | |
| for word in f.read().split(): |
This file contains hidden or 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
| from math import factorial | |
| from re import sub | |
| def calc(expression): | |
| expression = expression.replace('^', '**') | |
| expression = expression.replace('/', '//') | |
| expression = sub(r'(\w+)!', r'factorial(\1)', expression) | |
| return eval(expression) | |
| # Numbers for certain cases (always sideSubsets * variationInsideSolvedsides * variationInRest) |
This file contains hidden or 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
| use v5.10; | |
| sub invertMove { | |
| my ($m) = @_; | |
| return $m if $m =~ /2$/; | |
| return "$m'" if $m !~ /'/; | |
| $m =~ s/'//; | |
| return $m; | |
| } |
This file contains hidden or 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
| def sim(alg): | |
| state = "UF UR UB UL DF DR DB DL FR FL BR BL UFR URB UBL ULF DRF DFL DLB DBR".split() | |
| for move in alg.split(): | |
| perm = "FLBR FRBL FDBU FUBD URDL ULDR".split()['UDLRFB'.index(move[0])] | |
| n = 2 + "2'".find(move[-1]) | |
| table = str.maketrans(perm, perm[n:] + perm[:n]) | |
| state = [p.translate(table) if move[0] in p else p for p in state] | |
| return state | |
| print(sim("D L2 B2 L2 R2 F2 R2 U2 R2 D' U' R' B F L' D R2") == sim("U R B F L D R2")) |
This file contains hidden or 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
| import re | |
| from string import maketrans | |
| from collections import Counter | |
| def rotations(scramble): | |
| ori2alg = {'UDLRFB':''} | |
| for side, wide, angle in re.findall(r'(\w)(w?)(\S?)', scramble): | |
| a = "12'".find(angle) + 1 | |
| next_ori2alg = {} | |
| for ori, alg in ori2alg.items(): |