Challenge 11 – Secret Messages

Challenge 11 – Secret Messages

Complete the programming challenge below and submit your answer below as a word or PDF file file (if you are coding on Repl, add a link to your code in yor document)

Challenge Instructions

It’s time to write some secret messages! Our coders are creating a program that will merge two sentences together to hide them, but they’ve got stuck! Finish the program so the program outputs the merged sentences. For example:

Hello world how are you?
This is a top secret message

= Hello This world is how a are top you? secret message

Extension: Allow the message to merge three sentences together for even better encryption!

Student Solutions - Basic

No Solutions Yet

Student Solutions - Extended

No Solutions Yet

Understanding Logic Gates

Understanding Logic Gates

A variable data type that holds either a True or False value is known as a Boolean. In the same way, logic that we apply in our computers that return either a true or false value is known as Boolean Logic. You have likely already used these statements everyday without realising:

Is the value of x greater then the value of y?
Is the length of my name longer than 3 letters?​
While I haven’t entered by password, don’t let me log in.
logic gates

Logic gates are a diagrammatic way of representing the Boolean logic that takes place within the computer system. Each gate represents the ability to input a true or false value compare them and then an output a single true or false value.

Part of the iGCSE is to recognise the individual logic gates that are used for both simple and complex logic.

To help us understand Boolean Logic, we use a set of symbols to represent each logic statement. These are known as logic gates:

AND Gate
OR Gate
NOT Gate

Notice that only one of these gates has a single input and output. The not gate is a special type of logic gate which inverts the input making it the opposite of what is input . For example, if 1 goes into a not gate then O is output.

Each logic gate can be represented by showing each of the possible inputs and outputs in a table called a truth table. A truth table is an example of all possible inputs (and for more complex circuits all possible combinations of input) and the resulting output.

The truth take prefer not gate has a single input and output as seen in the gate itself.

Truth Table NOT

For other gates the two inputs are identified by naming them. In the example below, one input is identified as input A and another as input B. In some truth tables this may be represented as simply A and B with each representing part of a logical statement. It’s also worth noting at this point that as more inputs are added to a truth table the more rows there will be.

Truth Table AND

Complex Gates

Once he had got to grips with the basic logic gates, another gate that you may need to be familiar with as part of the eye GCSE is the complex gate. These complex gates are actually two logic gates combined in one. You’ll be able to recognise them as they all have an additional feature: both NAND and NOR gates take the nose from the NOT gate and place it at the front of a standard AND or OR gate. The XOR gate takes an OR gate and adds an extra tail to the end.

The NAND Gate is a combination of an and gate and a not gate. This means that the logic statement is NOT AND – the gate will only output a 1 (TRUE) in all instances unless both inputs are one (FALSE).

Truth Table NAND

The NOR gate is a combination of an OR gate and NOT gate. This means that the logic statement is NOT OR so will output 0 (FALSE) unless both inputs are zero (FALSE).

NOR Gate
Truth Table NOR

Finally, the XOR gate is an exclusive OR gate. It is very similar to the logic of an OR gate except that it will not output 1 (TRUE) if both inputs are also 1 (TRUE). This means that the gate will only output 1 (TRUE) if one input is 1 (TRUE) and the other is 0 (FALSE).

XOR Gate
Truth Table XOR