Created
August 16, 2025 13:18
-
-
Save Shikugawa/16eb08c36708ba41e373f53f1b244e30 to your computer and use it in GitHub Desktop.
装甲悪鬼村正 パズルソルバー
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
| cand = [62, 9, 41, 49, 105, 96, 8, 22, 101, 55, 35, 46, 84, 60, 99, 24, 74, 124] | |
| import copy | |
| obj = 315 | |
| targets = [obj-(51+15), obj-(78+54), obj-(36+110), obj-(103+3), obj-(113+57), obj-(56+120)] | |
| aaaaa = [] | |
| def get_cands(level, arr, seen): | |
| if level == 6 and len(arr) == len(targets): | |
| return copy.copy(arr) | |
| for i in range(len(cand)): | |
| if i in seen: | |
| continue | |
| for j in range(i+1, len(cand)): | |
| if j in seen: | |
| continue | |
| for k in range(j+1, len(cand)): | |
| if k in seen: | |
| continue | |
| if cand[i]+cand[j]+cand[k] == targets[level]: | |
| arr.append((cand[i], cand[j], cand[k])) | |
| seen.add(i) | |
| seen.add(j) | |
| seen.add(k) | |
| op = get_cands(level+1, arr, seen) | |
| if len(op) != 0: | |
| aaaaa.append(op) | |
| arr.pop() | |
| seen.remove(i) | |
| seen.remove(j) | |
| seen.remove(k) | |
| return [] | |
| get_cands(0, [], set()) | |
| import itertools | |
| bbbbb = [] | |
| def eval(level, arr, s): | |
| if level == 6: | |
| if arr[0][0]+arr[1][0]+arr[2][0]+7+122 == obj and\ | |
| arr[0][1]+arr[1][1]+arr[2][1]+20+125 == obj and\ | |
| arr[0][2]+arr[1][2]+arr[2][2]+59+11 == obj and\ | |
| arr[3][0]+arr[4][0]+arr[5][0]+112+34 == obj and\ | |
| arr[3][1]+arr[4][1]+arr[5][1]+109+87 == obj and\ | |
| arr[3][2]+arr[4][2]+arr[5][2]+10+100 == obj: | |
| return arr | |
| else: | |
| return [] | |
| for n in itertools.permutations(s[level]): | |
| res = eval(level+1, arr + [n], s) | |
| if len(res) != 0: | |
| bbbbb.append(res) | |
| return [] | |
| for s in aaaaa: | |
| eval(0, [], s) | |
| print(bbbbb) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment