Last active
June 3, 2021 15:23
-
-
Save shakayami/15f95a2d68d5a45a1bd5035240592c4a to your computer and use it in GitHub Desktop.
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
import random | |
from collections import defaultdict | |
from fractions import Fraction | |
import itertools | |
D=list("おちんまうこ") | |
FACES={"う":500,"ま":500,"ち":500,"ん":50,"こ":100,"お":300} | |
WORDS={"うんち":1000,"うんこ":1000,"まんこ":1000,"おまんこ":5000,"ちんこ":1000,"ちんちん":3000,"おちんちん":10000} | |
TRIPILES={"う":2,"ま":2,"ち":2,"ん":-3,"こ":Fraction(3,2),"お":Fraction(3,2)} | |
def todict(S): | |
SS=defaultdict(int) | |
for x in S:SS[x]+=1 | |
return SS | |
def issubset(SS,TT): | |
#SS in TT:True | |
#SS not in TT:False | |
for x in D: | |
if SS[x]>TT[x]: | |
return False | |
return True | |
def sgn(x): | |
if x<0: | |
return -1 | |
elif x>0: | |
return 1 | |
else: | |
return 0 | |
def ORESEN(x): | |
if x<-4: | |
return -4 | |
elif x>4: | |
return 4 | |
else: | |
return x | |
def evaluate(S): | |
SS=todict(S) | |
ret=0 | |
for x in D: | |
ret+=SS[x]*FACES[x] | |
for st in WORDS: | |
if issubset(todict(st),SS): | |
ret+=WORDS[st] | |
for x in D: | |
if SS[x]>=3: | |
ret*=ORESEN(TRIPILES[x]+(SS[x]-3)*sgn(TRIPILES[x])) | |
if x=="お" and ret<0: | |
ret*=-1 | |
return ret | |
A=0 | |
B=0 | |
for seq in itertools.product(D,repeat=5): | |
A+=evaluate(seq) | |
B+=1 | |
Except=Fraction(A,B)#1812875/648 | |
print(Except,float(Except)) | |
print("----") | |
#以降はおみくじ | |
S="".join([random.choice(D) for i in range(6)]) | |
print(S,evaluate(S)) | |
SS=todict(S) | |
for st in WORDS: | |
if issubset(todict(st),SS): | |
print(st) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment