Skip to content

Instantly share code, notes, and snippets.

@pranavgade20
Created April 10, 2022 05:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pranavgade20/dbd6180dbfbc657437ccf5d3d9dd25a1 to your computer and use it in GitHub Desktop.
Save pranavgade20/dbd6180dbfbc657437ccf5d3d9dd25a1 to your computer and use it in GitHub Desktop.
def strategy(opponent_source: str) -> str:
# a very simple strategy - defect if we have the slightest suspicion that the opponent will defect, cooperate otherwise
return 'defect' if 'defect' in opponent_source else 'cooperate'
# you can remove this driver code as long as you make sure that you read the opponent's code from stdin, and write your decision to stdout
def driver():
import sys
opponent_source = ''.join(l for l in sys.stdin)
print(strategy(opponent_source))
driver()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment