2025
Learning project
Bulls & Cows
A small code-breaking game in Kotlin, used to keep input, rules and results in separate, testable pieces.
RoleEverything
Year2025
SourcePrivate repository
Overview
The player guesses a hidden code; the game answers with how many digits are right and in the right place. Small enough to finish, big enough to contain a whole system: generate, validate, compare, report.
Problem
Written as one procedural script it works and is impossible to change. The rules, the console input, and the scoring end up in the same function, so a fix to one of them risks the other two.
Solution
Input, game rules, and result calculation live in separate types. The comparison that produces bulls and cows is a deterministic function of the secret and the guess, which means it can be tested without running the game.
My role
Wrote it end to end in Kotlin on the JVM.
Architecture
Technologies
- LanguageKotlin
- RuntimeJVM
- DesignObject-oriented
- VerificationUnit tests
Challenges
Edge cases in generating a valid secret — repeated symbols change what a correct answer even means.
Rejecting bad input before any state changes, so a malformed guess cannot half-advance the game.
What I learned
Testability is a layout decision. The moment the comparison stopped reading from the console, it became a function I could check in a second — and every rule I moved out of the I/O got easier to reason about.
Next