No tags yet

No tag edit access

Time limit per test: 0.25 second(s)

Memory limit: 262144 kilobytes

Memory limit: 262144 kilobytes

input: standard

output: standard

output: standard

You probably know the game "bulls and cows". Just in case, we explain the rules. The first player picks a four-digit number with all digits distinct (leading zero is allowed) and keeps it secret. The second player tries to guess the secret number. For each guess, the first player issues a response in the form "

For example, if the first player picked 5071, and the second guessed 6012, the response would be "one bull, one cow". Here the "bull" is the digit 0, as it is in the second position in both numbers, and the "cow" is the digit 1, as it is in the fourth position in the secret, but in the third position in the guess.

Write a program to count the number of cows and bulls for the given the secret and guess.

sample input | sample output |

5071 6012 | 1 1 |

sample input | sample output |

4321 4321 | 4 0 |

sample input | sample output |

1980 0879 | 0 3 |

sample input | sample output |

1234 5678 | 0 0 |

Codeforces (c) Copyright 2010-2019 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Apr/20/2019 16:28:01 (f2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|