games · MIT License
Overview
A code-breaking logic game: work out a secret code of different digits from Exact and Other clues, with three levels from 3 to 5 digits.
- Owner-tested on a TI calculator
- Version 1.0.0
- 1919 bytes
- Uses random
Tried it? Did this program work on your calculator?
Before you run it
- TI-84 Plus CE Python · No calculator OS or Python App version has been verified.
- TI Connect CE .py transfer to the Python App; the owner's transfer details were not recorded
- The secret code is made of different digits, chosen at random by the calculator for each round.
- Wins and losses are kept only while the program is running.
- A guess must have exactly as many digits as the code, use digits only, and not repeat a digit; anything else asks again without using a try.
Play it here first
Play a full round right here before you download. The screen below runs the same steps as the calculator game: type your answer in the box under it and press Enter, just as you would on the calculator. Each round picks a new secret, and nothing you type is saved.
TI-84 Plus CE Python · screen preview
How to play
How to play Code Breaker
About the game
The calculator makes up a secret code of different digits, and you have a limited number of tries to crack it. It is a number version of the classic code-breaking board game.
After every guess you get two clues. Exact is how many digits are right and in the right spot. Other is how many are in the code but in a different spot. Put the clues together to narrow down the code.
Controls
1, 2, or 3- choose Easy (3 digits, 8 tries), Medium (4 digits, 10 tries), or Hard (5 digits, 12 tries)
4- quit from the level menu
number keys- type a guess, such as 012
enter- submit a guess, or move on from a clue screen
Y- play another round; any other answer ends the game
How to play
- Press enter at the opening screen, then type 1, 2, or 3 to choose a level.
- Read the rules screen and press enter.
- Type a guess with the right number of digits and no digit used twice, then press enter.
- Read Exact and Other, press enter, and guess again.
- Get every digit exact to see CODE CRACKED! on the screen. If the tries run out, the code is shown so you can see how close you were.
Tips
- Exact plus Other is how many of your digits are in the code at all. On Easy, guess 012, then 345, then 678: each total tells you how many code digits are in that group, and if the three totals add up to less than 3, the missing digit is 9.
- Change one or two digits at a time. If Exact goes up or down, you learn which digit moved it.
- A digit that gives Other is in the code, just not where you put it. Try it in a different spot next time.
- A guess with a repeated digit, a letter, or the wrong length does not use up a try. The calculator just asks again.
Good to know
- The win and loss totals start over each time you run the program.
- To stop the game at any time, press the [on] key. The Python App returns to the shell.
Exact reviewed bytes
Source code
# DuckieDai(TM) Code Breaker# TI-84 Plus CE Pythonfrom random import randintdef make_code(n):digits=list('0123456789')code=''for i in range(n):j=randint(0,len(digits)-1)code+=digits.pop(j)return codedef clear():print('\n'*7)def intro():print('DUCKIEDAI(TM)')print('CODE BREAKER')print(' __')print(' ___(o )> quack!')print(' \\ <_. )')print(" `---'")print('by DuckieDai')print('hiddenwordscanner.com')input('Press Enter ')clear()def guess_code(n):while 1:s=input('Your guess? ').strip()if len(s)!=n:print('Enter',n,'digits.')elif not s.isdigit():print('Digits only!')elif len(set(s))!=n:print('No repeated digits!')else:return sdef play():wins=0losses=0while 1:print('CODE BREAKER')print('1 Easy: 3 digits')print('2 Med : 4 digits')print('3 Hard: 5 digits')print('4 Quit')mode=input('Level? ')if mode=='4':breakif mode not in ('1','2','3'):print('Choose 1-4')continuen=int(mode)+2tries=(8,10,12)[int(mode)-1]secret=make_code(n)clear()print('Crack the',n,'digit code!')print('Digits never repeat.')print('Exact = right spot')print('Other = wrong spot')input('Press Enter ')clear()won=Falsefor turn in range(1,tries+1):print('TRY',turn,'OF',tries)s=guess_code(n)exact=sum(s[i]==secret[i] for i in range(n))other=sum(c in secret for c in s)-exactif exact==n:print('CODE CRACKED!')print('QUACK QUACK!')won=Truebreakprint('Exact:',exact)print('Other:',other)if turn<tries:input('Press Enter ')clear()if won:wins+=1else:losses+=1print('OUT OF TRIES!')print('Code was:',secret)print('Wins:',wins,'Losses:',losses)again=input('Again? Y/N ').upper()if again!='Y':breakclear()print('Thanks for playing!')print('DuckieDai(TM)')print('hiddenwordscanner.com')intro()play()
- Filename
CODEBRK.py- Size
- 1919 bytes
- SHA-256
f334ce309cd5c641263519232f63a4cfc2ec0ff1c47432b85117fd596d7610ef
Usage
Inputs
- A level: 1 Easy (3 digits, 8 tries), 2 Medium (4 digits, 10 tries), 3 Hard (5 digits, 12 tries), or 4 Quit
- One guess of the code per try
- Y to play again, anything else to stop
Outputs
- After each guess, Exact (right digit, right spot) and Other (right digit, wrong spot)
- CODE CRACKED on a correct guess, or OUT OF TRIES, and then the secret code
- Running totals of wins and losses
Units: Digits; no units.
Assumptions and limitations
Assumptions
- The secret code is made of different digits, chosen at random by the calculator for each round.
- Wins and losses are kept only while the program is running.
Constraints
- A guess must have exactly as many digits as the code, use digits only, and not repeat a digit; anything else asks again without using a try.
- The level choice must be 1, 2, 3, or 4 exactly.
Known failures
- A guess with a repeated digit, a letter, or the wrong length is rejected with a short message and asked again.
- The win and loss totals reset when the program is started again.
Compatibility and review
- Review status
- Owner-tested on a TI calculator
- Tested on
- Owner reports personally playing this game on a TI-84 Plus CE Python calculator; the test date, OS version, and Python App version were not recorded
- What happened
- Owner reported pass on the calculator. The file is published exactly as provided; this exact file has not yet been rerun on a calculator.
- Dependencies
- random
- Suggested calculator name
CODEBRK— you can give it another valid, unique name when you transfer it- Desktop test cases
- Not available for this interactive-only source
This exact source auto-launches an interactive calculator session, so compatibility evidence comes from the recorded physical-device review rather than an importable desktop fixture.
Transfer and launch
Download the .py file, send it to your calculator with TI Connect CE as CODEBRK or another name, then open the Python App and start a game. Press [on] to stop at any time. This release has no verified calculator OS or Python App version; treat transfer and execution as unverified until independently tested.
Full installation and troubleshooting guide. Check your teacher's or exam's rules before using any program.
Version history
- 1.0.0 — current version, published . Download this reviewed version
Related learning
Enjoying a DuckieDai game? Every game and program here is free. If you would like to say thanks, you can leave a tip on Cash App ($duckiedai214) or read what tips pay for.
Independent compatibility resource: Hidden Word Scanner is independent and is not affiliated with or endorsed by Texas Instruments. TI product names describe compatibility only.
Action-count privacy: Successful downloads, preview starts, and preview completions increment same-origin aggregate counters, and so does a Yes or No answer about whether the program worked. Your browser notes that you answered; that note is never sent to the site. No entered values, source text, IP address, account, cookie, device identifier, or fingerprint is stored with these counts.