2A2B
2A2B is a shorthand notation used in the Bulls and Cows puzzle and in many programming challenges to describe feedback after a guess. The notation xAyB means that x digits are correct and in the correct position (A), and y digits are correct but in the wrong position (B).
In the common 4-digit version, both the secret and the guess have the same length. A is
Variants vary in length and rules about repeated digits. Some problems allow repeated digits; others require
Example: secret 1234 and guess 1432 yield 2A2B, because digits 1 and 3 are in the correct
Origin and usage: Bulls and Cows is a historical code-breaking game with roots in European puzzles; the
Implementation notes: a typical approach uses two passes—first to count A by direct comparison, then to count