Last active
April 26, 2022 18:16
-
-
Save Feniksovich/cfbd44c7ffab35b1082e5cae0ed336a3 to your computer and use it in GitHub Desktop.
Programs for IT Unified State Exam (Game Theory)
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
# 1 heap | |
# Prohibition of repetition of the opponent's move | |
def f(s,p,c,m): | |
if s>64: return c%2==m%2 | |
if c==m: return 0 | |
h=[] | |
if p!='+1': h+=[f(s+1,'+1',c+1,m)] | |
if p!='+2': h+=[f(s+1,'+2',c+1,m)] | |
if p!='*2': h+=[f(s+1,'*2',c+1,m)] | |
return any(h) if (c+1)%2==m%2 else all(h) | |
for s in range(1, 65): | |
for m in range(1,10): | |
if f(s,0,m): | |
print(s, m) | |
break |
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
# 1 heap | |
# "With a loss" condition | |
def f(s,c,m): | |
if 32<=s<64: return c%2==m%2 | |
if s>64: return c%2!=m%2 | |
if c==m: return 0 | |
h=[f(s+1,c+1,m), f(s+2,c+1,m), f(s*3,c+1,m)] | |
return any(h) if (c+1)%2==m%2 else all(h) | |
for s in range(1, 65): | |
for m in range(1,10): | |
if f(s,0,m): | |
print(s, m) | |
break |
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
# 1 heap | |
# Without restrictions | |
def f(s,c,m): | |
if s>64: return c%2==m%2 | |
if c==m: return 0 | |
h=[f(s+1,c+1,m), f(s+2,c+1,m), f(s*3,c+1,m)] | |
return any(h) if (c+1)%2==m%2 else all(h) | |
for s in range(1, 65): | |
for m in range(1,10): | |
if f(s,0,m): | |
print(s, m) | |
break |
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
# 2 heaps | |
# Without restrictions | |
def f(a,b,c,m): | |
if s>64: return c%2==m%2 | |
if c==m: return 0 | |
h=[f(a+1,b,c+1,m), f(a,b+1,c+1,m), f(a+2,b,c+1,m), f(a,b+2,c+1,m)] | |
return any(h) if (c+1)%2==m%2 else all(h) | |
for a in range(1, 65): | |
for m in range(1,10): | |
if f(a,10,0,m): | |
print(s, m) | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment