Skip to content

Instantly share code, notes, and snippets.

@stormsweeper
Created March 11, 2019 19:22
Show Gist options
  • Save stormsweeper/569420a55acaa0c64f1738fc8dcbe7f7 to your computer and use it in GitHub Desktop.
Save stormsweeper/569420a55acaa0c64f1738fc8dcbe7f7 to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=569420a55acaa0c64f1738fc8dcbe7f7

Break the code!

You've been given a box with a secret number lock. If you put the correct numbers in, the secret message will be revealed.

You'll need to write 7 conditional statements to help figure out the correct numbers.

OUTPUT 1:

  • If input1 is equal to 8, set the text of output1 to Y

OUTPUT 2:

  • If input2 is equal to or less than 5, set the text of output2 to O
  • else set the text of output2 to A

OUTPUT 3:

  • If input3 is equal to 6, set the text of output3 to U
  • else if input3 is greater than 5, set the text of output3 to G
  • else set the text of output3 to N

OUTPUT 4:

  • If input4 is greater that 3 and less than 7, set the text of output4 to O

OUTPUT 5:

  • If input2 is less than 7 and input5 is less than 4, set the text of output5 to T

OUTPUT 6:

  • If input3 is less than or equal to 6 or input6 is not equal to 0, set the text of output6 to R
  • else set the text of output6 to I

OUTPUT 7:

  • If input4 is greater than 5 and input7 is less than or equal to 5, set the text of output7 to Y
  • else if input7 is greater than 8 and input4 is greater than 4, set the text of output7 to T
  • else set the text of output7 to E
<!DOCTYPE html>
<html>
<head>
<title>Break the Code</title>
</head>
<body>
<table>
<tr>
<th></th>
<th>(1)</th>
<th>(2)</th>
<th>(3)</th>
<th>(4)</th>
<th>(5)</th>
<th>(6)</th>
<th>(7)</th>
</tr>
<tr>
<th>INPUT:</th>
<td><input id="input1" type="number" min="0" max="9" value="0"></td>
<td><input id="input2" type="number" min="0" max="9" value="0"></td>
<td><input id="input3" type="number" min="0" max="9" value="0"></td>
<td><input id="input4" type="number" min="0" max="9" value="0"></td>
<td><input id="input5" type="number" min="0" max="9" value="0"></td>
<td><input id="input6" type="number" min="0" max="9" value="0"></td>
<td><input id="input7" type="number" min="0" max="9" value="0"></td>
</tr>
<tr>
<th>OUTPUT:</th>
<td class="output" id="output1">&nbsp;</td>
<td class="output" id="output2">&nbsp;</td>
<td class="output" id="output3">&nbsp;</td>
<td class="output" id="output4">&nbsp;</td>
<td class="output" id="output5">&nbsp;</td>
<td class="output" id="output6">&nbsp;</td>
<td class="output" id="output7">&nbsp;</td>
</tr>
</table>
<button id="check-code">CHECK CODE</button>
<div id="message">
</div>
</body>
</html>
{"enabledLibraries":["jquery"],"hiddenUIComponents":["editor.css","editor.html","console"]}
$("#check-code").click(function(){
// YOUR CODE STARTS ON LINE 11
var input1 = parseInt($("#input1").val());
var input2 = parseInt($("#input2").val());
var input3 = parseInt($("#input3").val());
var input4 = parseInt($("#input4").val());
var input5 = parseInt($("#input5").val());
var input6 = parseInt($("#input6").val());
var input7 = parseInt($("#input7").val());
// OUTPUT 1:
// If input1 is equal to 8, set the text of output1 to Y
// OUTPUT 2:
// If input2 is equal to or less than 5, set the text of output2 to O
//
// else set the text of output2 to A
// OUTPUT 3:
// If input3 is equal to 6, set the text of output3 to U
//
// else if input3 is greater than 5, set the text of output3 to G
//
// else set the text of output3 to N
// OUTPUT 4:
// If input4 is greater that 3 and less than 7, set the text of output4 to O
// OUTPUT 5:
// If input2 is less than 7
// and input5 is less than 4, set the text of output5 to T
// OUTPUT 6:
// If input3 is less than or equal to 6
// or input6 is not equal to 0, set the text of output6 to R
//
// else set the text of output6 to I
// OUTPUT 7:
// If input4 is greater than 5
// and input7 is less than or equal to 5, set the text of output7 to Y
//
// else if input7 is greater than 8
// and input4 is greater than 4, set the text of output7 to T
//
// else set the text of output7 to E
// DON'T CHANGE THE CODE BELOW THIS LINE!
if (
input1^input2^input3 === 0b1001
&&
input4^input5^input6^input7 === 0b1111
&&
input1^input2^input3^input4^input5^input6^input7 === 0b0110
) {
$("#message").text("CORRECT!").css("color", "green");
} else {
$("#message").text("INCORRECT!").css("color", "red");
}
});
body {
font-family: sans-serif;
}
input[type=number] {
width: 2.125em;
text-align: center;
}
.output {
text-align: center;
border: 1px solid grey;
font-family: monospace;
color: purple;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment