Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- secret_number = input()
- top_secret_number = secret_number
- numb_of_bulls = int(input())
- numb_of_cows = int(input())
- current_number = ''
- current_bulls = 0
- current_cows = 0
- flag_found = False
- for digit_1 in range(1, 10):
- for digit_2 in range(1, 10):
- for digit_3 in range(1, 10):
- for digit_4 in range(1, 10):
- current_number = str(digit_1) + str(digit_2) + str(digit_3) + str(digit_4)
- for i in range(0, 4):
- for j in range(0, 4):
- if current_number[j] == top_secret_number[j]:
- current_bulls += 1
- symb = list(top_secret_number)
- symb[j] = '0'
- top_secret_number = "".join(symb)
- symb_cur = list(current_number)
- symb_cur[j] = 'z'
- current_number = "".join(symb_cur)
- for l in range(0, 4):
- if current_number[l] == top_secret_number[i]:
- current_cows += 1
- symb = list(top_secret_number)
- symb[i] = '0'
- top_secret_number = "".join(symb)
- symb_cur = list(current_number)
- symb_cur[l] = 'z'
- current_number = "".join(symb_cur)
- if current_bulls == numb_of_bulls and current_cows == numb_of_cows:
- flag_found = True
- print((str(digit_1) + str(digit_2) + str(digit_3) + str(digit_4)), end=' ')
- current_cows = 0
- current_bulls = 0
- top_secret_number = secret_number
- if not flag_found:
- print('No')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement