Limited Offer Get 25% off — use code BESTW25
No AI No Plagiarism On-Time Delivery Free Revisions
Claim Now
Prices start at $5 per page · plagiarism-free papers · free revisions for 14 days 24/7 support: support@bestwriters.com
Uncategorized

Python Assignment #1 – Combination Lock Puzzle

  • Posted
  • Authoradmin
  • Length398 words
  • Reading time2 min
Write My Assignment FREE

Python Assignment #1 – Combination Lock Puzzle

There is a popular puzzle where you try to guess the combination to a lock given some clues. For our purposes, the lock has exactly three wheels, each with values 0 through 9. (The answer is 042)

You must provide the clues on the command line and they must be of the form XYZ-R-W where:

XYZ = a possible combination of 3 digits, each 0-9

R = count of wheels that are the right digit in the right place (0-3)

W = count of wheels that are the right digit but in the wrong place (0-3)

The expectation is that you will use a brute form technique to solve this puzzle. Iterate through all 1,000 possible combinations and see which one(s) pass all the clues. Do NOT try to solve this puzzle the way a human would, using logic.

Additional rules:

  1. The number of clues can vary. If no clues are given you must print an error message.
  2. You must use a regular expression to validate the XYZ-R-W syntax.
  3. You do not need to do any additional validation of the XYZ, R, W parameters.
  4. You must print the list of clues given, all on one line.
  5. You must count the number of solutions found and print that count.
  6. If no solutions are found, you must print a message to that effect.

$ python3 lock.py

Need to give some patterns of the form XYZ-R-W

# This is the sample from the picture above

$ python3 lock.py 682-1-0 614-0-1 206-0-2 738-0-0 380-0-1

Trying 682-1-0 614-0-1 206-0-2 738-0-0 380-0-1

*** Solution #1 is … (there is exactly one answer, hidden)

$ python3 lock.py 682-1-0 614-0-1 206-0-2 738-0-0 380-0-1 314-1-0

Trying 682-1-0 614-0-1 206-0-2 738-0-0 380-0-1 314-1-0

No Solutions Found

$ python3 lock.py 682-0-0 614-0-0 206-0-0 738-0-0

Trying 682-0-0 614-0-0 206-0-0 738-0-0

*** Solution #1 is 555

*** Solution #2 is 559

*** Solution #3 is 595

*** Solution #4 is 599

*** Solution #5 is 955

*** Solution #6 is 959

*** Solution #7 is 995

*** Solution #8 is 999

$ python3 lock.py 682-1-0 614-0-1 w06-0-2 738-0-0 380-0-1

Invalid argument: w06-0-2

# The 4 is invalid, must be 0-3

$ python3 lock.py 682-1-0 614-0-1 206-0-2 738-4-0 380-0-1

Invalid argument: 738-4

The post Python Assignment #1 – Combination Lock Puzzle appeared first on My Assignment Online.

Plagiarism Free Assignment Help

Expert Help With This Assignment — On Your Terms

✓ Native UK, USA & Australia writers ✓ Deadline from 3 hours ✓ 100% Plagiarism-Free — Turnitin included ✓ Unlimited free revisions ✓ Free to submit — compare quotes

admin

Academic writer and editor at BestWriters.

Get your paper off your plate tonight

Post your instructions for free. Prices start at $5 per page.

Place an order