Skip to content

Instantly share code, notes, and snippets.

@twilson90
Last active October 12, 2018 22:17
Show Gist options
  • Save twilson90/7f838a6b1ac4a7896a1ac63585595c6a to your computer and use it in GitHub Desktop.
Save twilson90/7f838a6b1ac4a7896a1ac63585595c6a to your computer and use it in GitHub Desktop.
import sys
ans = sys.stdin.readline().split(" ")
guess = sys.stdin.readline().split(" ")
def count_white(ans, guess):
temp_ans = ans[:]
pegs = 0
for i in guess:
if i in temp_ans:
temp_ans.remove(i)
pegs += 1
return pegs
def count_black(ans, guess):
return sum([ans[i] == guess[i] for i in range(len(ans))])
def check(ans, guess):
white = count_white(ans, guess)
black = count_black(ans, guess)
white -= black
return str(white)+" "+str(black)
sys.stdout.write(check(ans, guess))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment