Code Hint
This classic guessing game is about carefully comparing a secret code with a player's guess. Write a function get_hint that counts bulls and cows for the strings secret and guess. A bull is a correct digit in the correct position, and a cow is a correct digit in the wrong position. Return the hint in the format xAyB, where x is the number of bulls and y is the number of cows.
Примеры
Ввод
"1807", "7810"Вывод
"1A3B"Ввод
"1123", "0111"Вывод
"1A1B"Ввод
"1", "1"Вывод
"1A0B"Нужно реализовать
def get_hint(secret: str, guess: str) -> str:
Теги
stringshashmapmath
Prihláste sa, aby ste videli históriu odoslaní
Prihlásiť saPrihláste sa, aby ste mohli používať AI mentora
Prihlásiť saVisible tests
1
Input
"1807", "7810"Expected
"1A3B"2
Input
"1123", "0111"Expected
"1A1B"3
Input
"1", "1"Expected
"1A0B"4
Input
"1", "0"Expected
"0A0B"5
Input
"1122", "1222"Expected
"3A0B"6
Input
"ab", "7810!"Expected
"0A0B"Focus radio
Paused · SomaFM · Fluid