Code breaking using Trace Tables

In the following set of challenges, you will use a trace table to workout the secret code of the following six padlocks. Before attempting this challenge, you may want to find out mode about the use of trace tables when testing or predicting the output of an algorithm.

Padlock #1Padlock #2Padlock #3Padlock #4Padlock #5Padlock #6

Padlock #1:


The following code will help you work out the combination (code) to open padlock #1 (see below)

code = ""
FOR i FROM 1 TO 3
   digit = i * 2
   code = code + STR(digit)
NEXT i
OUTPUT(code)

Trace Table

 Line NumberidigitcodeOUTPUT
1“”
21
32
4“2”
22
34
4“24”
23
36
4“246”
6246

Padlock


Input the combination on the padlock below and click on “Unlock?” to test your combination.

Padlock #2:


The following code will help you work out the combination (code) to open padlock #2 (see below)

code = ""
code = code + "9" 
code = code + "7"
code = code + "1"
OUTPUT(code)

Trace Table


Complete the following trace table to work out the 3-digit padlock code:
 Line NumbercodeOUTPUT
1

Padlock


Input the combination on the padlock below and click on “Unlock?” to test your combination.

Padlock #3:


The following code will help you work out the combination (code) to open padlock #3 (see below)

code = ""
code = code + "7" 
code = "4" + code
code = code + "3"
OUTPUT(code)

Trace Table


Complete the following trace table to work out the 3-digit padlock code:
 Line NumbercodeOUTPUT
1

Padlock


Input the combination on the padlock below and click on “Unlock?” to test your combination.

Padlock #4:


The following code will help you work out the combination (code) to open padlock #4 (see below)

code = 61 
IF code MOD 2 == 0 THEN
   code = code * 3
ELSE
   code = code * 2
END IF
OUTPUT(code)

Trace Table


Complete the following trace table to work out the 3-digit padlock code:
 Line Numbercodecode MOD 2 == 0 ?OUTPUT
1

Padlock


Input the combination on the padlock below and click on “Unlock?” to test your combination.

Padlock #5:


The following code will help you work out the combination (code) to open padlock #5 (see below)

code = 24 
IF code > 20 AND code <= 10 THEN
   code = code * 3
ELSE IF code > 20 OR code <= 10 THEN 
   code = code * 10
ELSE 
   code = code * 4
END IF
OUTPUT(code)

Trace Table


Complete the following trace table to work out the 3-digit padlock code:
 Line Numbercodecode>20 ?code<=10 ?OUTPUT
1

Padlock


Input the combination on the padlock below and click on “Unlock?” to test your combination.

Padlock #6:


The following code will help you work out the combination (code) to open padlock #6 (see below)

code = 245 
WHILE code < 1000
   code = code + 200
END WHILE
code = code - 200
OUTPUT(code)

Trace Table


Complete the following trace table to work out the 3-digit padlock code:
 Line Numbercodecode<1000 ?OUTPUT
1

Padlock


Input the combination on the padlock below and click on “Unlock?” to test your combination.

Did you like this challenge?

Click on a star to rate it!

Average rating 2.7 / 5. Vote count: 158

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!