Chapter 17. Decoding Communication Systems
My escape companions have given me homework. I think what they’re trying to do is help me keep my mind occupied so I can be a little calmer. Bud is going to access the guards’ communication system and has asked me to help him.
If anyone finds out that we’ve escaped before I can return to prison, the plan will have been a complete failure, at least for me. Everything is well calculated so that doesn’t happen, but if we run into any jailer, we must prevent them from raising the alarm. For this, we’ll create a firewall.

Inside the prison, the situation will be a little different. If a guard discovers us, we’ll have no choice but to subdue and tie them up. As long as they can’t call for reinforcements, the plan will continue.
Bud and Pedro are going to carry the computer with them and, among other things, they’ll use it to monitor and block communications between prison guards. Of course, not all communications, just the ones we’re interested in.
So, taking advantage of having just learned the for-each loop, I’m going to make the five Programs they’ve asked me for using that concept. Of course, before starting the plan, Bud and Pedro will review them to make sure everything is correct.
For the first exercise, I’ll have to intercept some of the messages, specifically those that mention one of the three sectors we’re going to pass through: sector 6, 12, and 14
Program 1. Intercept Messages.
- Initialize an array with three elements:
“Message 12: sector 12”
“Message 6: sector 6”
“Message 14: sector 14”
Use a for-each loop to print the current message to the console preceded by the string “Intercepted message: “.
Solution:
public class Main {
public static void main(String[] args) {
String[] messages = {
"Message 12: sector 12",
"Message 6: sector 6",
"Message 14: sector 14"
};
for (String message : messages) {
System.out.println("Intercepted message: " + message);
}
}
}
In case any message from another sector slips through, we must do something to filter them and avoid false positives. Remember that only messages referring to sectors 6, 12, and 14 are important to us
Ejercicio 2. Filtrar Exercise 2. Filter messages.
- Inicializa un array con catorce elementos:
“Message 1: Alert in sector 1”,
“Message 2: Alert in sector 2”,
“Message 3: Alert in sector 3”,
“Message 4: Alert in sector 4”,
“Message 5: Alert in sector 5”,
“Message 6: Alert in sector 6”,
“Message 7: Alert in sector 7”,
“Message 8: Alert in sector 8”,
“Message 9: Alert in sector 9”,
“Message 10: Alert in sector 10”,
“Message 11: Alert in sector 11”,
“Message 12: Alert in sector 12”,
“Message 13: Alert in sector 13”,
“Message 14: Alert in sector 14”
- Use a for-each loop to filter and display important messages:
Inside the for-each loop, verify if the current message contains the number “6”, “12”, or “14”.
If the condition is met, print the current message to the console preceded by the string “Important message: “.
Solution:
public class Main {
public static void main(String[] args) {
String[] messages = {
"Message 1: Alert in sector 1",
"Message 2: Alert in sector 2",
"Message 3: Alert in sector 3",
"Message 4: Alert in sector 4",
"Message 5: Alert in sector 5",
"Message 6: Alert in sector 6",
"Message 7: Alert in sector 7",
"Message 8: Alert in sector 8",
"Message 9: Alert in sector 9",
"Message 10: Alert in sector 10",
"Message 11: Alert in sector 11",
"Message 12: Alert in sector 12",
"Message 13: Alert in sector 13",
"Message 14: Alert in sector 14"
};
for (String message : messages) {
if (message.contains("6") || message.contains("12") || message.contains("14") ) {
System.out.println("Important message: " + message);
}
}
}
}
Once we’ve identified and filtered the messages that concern us, it’s time to block them. This way we’ll prevent them from spreading and alerting all the prison guards..
Exercise 3. Block Communications
Initialize an array with three elements:
“Message 12: sector 12”
“Message 6: sector 6”
“Message 14: sector 14”
- Use a for-each loop to display blocked messages. Inside the for-each loop, print the current message to the console preceded by the string “Blocking message:”.
Solution:
public class Main {
public static void main(String[] args) {
String[] messages = {
"Message 12: Alert in sector 12",
"Message 6: Alert in sector 6",
"Message 14: Alert in sector 14"
};
for (String message : messages) {
System.out.println("Blocking message: " + message);
}
}
}
In addition to blocking them, we need to redirect them to our main Program. Bud and Pedro use two different computers, and both will need to be alert to know if any guard has raised the alarm.
Exercise 4. Redirect communications.
- Initialize the array with three elements:
- “Message 12: sector 12”
- “Message 6: sector 6”
- “Message 14: sector 14”
- Use a for-each loop to iterate over and display redirected messages:
Inside the for-each loop, print the current message to the console preceded by the string “Redirecting message: ” and followed by the string ” to external system”.
Solution:
public class Main {
public static void main(String[] args) {
String[] messages = {
"Message 12: sector 12",
"Message 6: sector 6",
"Message 14: sector 14"
};
for (String message : messages) {
System.out.println("Redirecting message: " + message + " to external system");
}
}
}
In addition to communications between guards, there is another security measure that concerns us: camera monitoring. The prison uses artificial intelligence software that analyzes images and generates a message every minute. Three of these messages are harmless, but we must create software that detects the one that incriminates us. After that, Bud will complete the software so that these communications are blocked, just as we did with the previous exercises. Below, I show you the four messages generated by the AI software. As you can imagine, the message that says ‘Alert’ is the one we must identify and neutralize.
Exercise 5. Camera Monitoring
- Initialize the array with four elements:
“Image 1: Empty hallway”
“Image 2: Alert”
“Image 3: Open door”
“Image 4: All clear”
- Use a for-each loop to iterate over each element of the images array. Detect Suspicious Activity.
Inside the for-each loop, verify if the current image contains the words “Open door” or “Guard”.
If the condition is met, print the message to the console preceded by the string “Suspicious activity detected: “.
If the condition is not met, print the message to the console preceded by the string “Normal monitoring: “.
Solution:
public class Main {
public static void main(String[] args) {
String[] images = {
"Image 1: Empty hallway",
"Image 2: Alert",
"Image 3: Open door",
"Image 4: All clear"
};
for (String image : images) {
if (image.contains("Open door") || image.contains("Guard")) {
System.out.println("Suspicious activity detected: " + image);
} else {
System.out.println("Normal monitoring: " + image);
}
}
}
}
I’ve done my part. With these Programs, Bud and Pedro have everything they need. From now on, it’s my turn to rest and mentally prepare for the final phase of the escape. So far, everything is going perfectly and there haven’t been any setbacks. I hope the good streak continues.