Hidden WordScanner
Private scans · No account required

DuckieDai Code Breaker

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.

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

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.

JavaScript is required for the optional browser simulation. Source viewing and downloading remain available without it.

Simulation boundary: This preview uses a reviewed browser adapter. It does not execute the downloaded Python and does not prove TI-Python or calculator compatibility.

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

Tips

Good to know

Exact reviewed bytes

Source code

Download .py

View source below, copy it when JavaScript is available, or download the exact .py bytes.

  1. # DuckieDai(TM) Code Breaker
  2. # TI-84 Plus CE Python
  3. from random import randint
  4. def make_code(n):
  5. digits=list('0123456789')
  6. code=''
  7. for i in range(n):
  8. j=randint(0,len(digits)-1)
  9. code+=digits.pop(j)
  10. return code
  11. def clear():
  12. print('\n'*7)
  13. def intro():
  14. print('DUCKIEDAI(TM)')
  15. print('CODE BREAKER')
  16. print(' __')
  17. print(' ___(o )> quack!')
  18. print(' \\ <_. )')
  19. print(" `---'")
  20. print('by DuckieDai')
  21. print('hiddenwordscanner.com')
  22. input('Press Enter ')
  23. clear()
  24. def guess_code(n):
  25. while 1:
  26. s=input('Your guess? ').strip()
  27. if len(s)!=n:
  28. print('Enter',n,'digits.')
  29. elif not s.isdigit():
  30. print('Digits only!')
  31. elif len(set(s))!=n:
  32. print('No repeated digits!')
  33. else:return s
  34. def play():
  35. wins=0
  36. losses=0
  37. while 1:
  38. print('CODE BREAKER')
  39. print('1 Easy: 3 digits')
  40. print('2 Med : 4 digits')
  41. print('3 Hard: 5 digits')
  42. print('4 Quit')
  43. mode=input('Level? ')
  44. if mode=='4':break
  45. if mode not in ('1','2','3'):
  46. print('Choose 1-4')
  47. continue
  48. n=int(mode)+2
  49. tries=(8,10,12)[int(mode)-1]
  50. secret=make_code(n)
  51. clear()
  52. print('Crack the',n,'digit code!')
  53. print('Digits never repeat.')
  54. print('Exact = right spot')
  55. print('Other = wrong spot')
  56. input('Press Enter ')
  57. clear()
  58. won=False
  59. for turn in range(1,tries+1):
  60. print('TRY',turn,'OF',tries)
  61. s=guess_code(n)
  62. exact=sum(s[i]==secret[i] for i in range(n))
  63. other=sum(c in secret for c in s)-exact
  64. if exact==n:
  65. print('CODE CRACKED!')
  66. print('QUACK QUACK!')
  67. won=True
  68. break
  69. print('Exact:',exact)
  70. print('Other:',other)
  71. if turn<tries:
  72. input('Press Enter ')
  73. clear()
  74. if won:wins+=1
  75. else:
  76. losses+=1
  77. print('OUT OF TRIES!')
  78. print('Code was:',secret)
  79. print('Wins:',wins,'Losses:',losses)
  80. again=input('Again? Y/N ').upper()
  81. if again!='Y':break
  82. clear()
  83. print('Thanks for playing!')
  84. print('DuckieDai(TM)')
  85. print('hiddenwordscanner.com')
  86. intro()
  87. 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

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.