Skip to content

Instantly share code, notes, and snippets.

@showyou
Created April 4, 2020 07:31
Show Gist options
  • Save showyou/3f6ac819bdcff761a0cc6be332ce00bd to your computer and use it in GitHub Desktop.
Save showyou/3f6ac819bdcff761a0cc6be332ce00bd to your computer and use it in GitHub Desktop.
次のデュオトリオの組み合わせを勝手に見つける
import random
aqours = ["千歌", "梨子", "果南", "ダイヤ", "曜", "善子", "花丸", "鞠莉", "ルビィ"]
def check(combi):
if set(combi) == ("千歌", "果南") or \
set(combi) == ("善子", "曜") or \
set(combi) == ("ダイヤ", "ルビィ") or \
set(combi) == ("花丸", "鞠莉", "梨子"):
return False
else:
return True
duo1 = random.sample(aqours, 2)
print("1:", duo1)
rest1 = list(set(aqours) - set(duo1))
duo2 = random.sample(rest1, 2)
print("2:", duo2)
rest2 = list(set(rest1) - set(duo2))
duo3 = random.sample(rest2, 2)
print("3:", duo3)
trio = list(set(rest2) - set(duo3))
print("trio:", trio)
print("既存じゃない?:", "OK" if(check(duo1) and check(duo2) and check(duo3) and check(trio)) else "NG")
@showyou
Copy link
Author

showyou commented Apr 4, 2020

$ python random_duotrio.py
1: ['鞠莉', '果南']
2: ['千歌', 'ルビィ']
3: ['梨子', 'ダイヤ']
trio: ['花丸', '善子', '曜']
既存じゃない?: OK

木探索くらいしろよって話ですよね・・

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment