HackSoc, the computer science society
Hello, HackSoc!
 
 
 
 

This week, we have our first talk of the term! Our talks are currently streamed live using YouTube Premiere on Thursday evenings. The list of this term's talks is now also live, so take a look over on the Talks page of our website!

There is also another Film Night on Friday! See you there.

Below are the solutions to "The Cursed C" puzzles from last time - how did you do? Make sure you also check out the graph puzzle below, and let us know if you solve it!

The Calendar
 
 
 
 

Talk - "Mapping with Robots" by Jacob Allen - 19:00, Thu 22/10

We'll post a YouTube Premiere link in Slack (and on our calendar) shortly before the talk is scheduled to begin. Once the talk livestream has finished, join us in Discord for questions with the speaker!

Navigation is one of the core challenges of any form of robotics (at least any form which requires movement). There are several problems which must be solved for navigation, two of the core problems being localisation and mapping, that is, knowing where the robot is in a landscape and knowing that landscape. While they are simple tasks for most humans, they are relatively complex and computationally expensive tasks for robots, particularly those with limited sensors or limited computational power.

In this talk I will introduce the concepts behind mapping in robotics, and by extension some of the concepts behind localisation. I will discuss the state of the art, with particular focus on novel approaches using swarm robotics and sparse data which each pose unique problems for localisation and mapping. Finally, I will show an example and talk about the practical complexities of actually implementing mapping in robotics.


Film Night - 19:00, Fri 23/10 - HackSoc Discord (The Pod)

We gather together to watch a film (or sometimes several). Apparently some of these might have a link to Computer Science, but we haven't spotted one yet.

Vote for the film you'd like to watch using our Film Night Portal!

We'll use our very own live-streaming platform to watch the film together. Keep an eye on our Slack and Discord just before 7pm for a link!

"The Cursed C" Puzzle Solution
 
 
 
 

1.

C, unlike many modern languages, offers no memory protection itself. The OS running it may enforce some, but it does not enforce it within the program as it can’t know what is and isn’t valid to write/read. This first program falls afoul of this issue because of the following line:

while (counter <= 10)

Because our counter here is being compared to 10 using the “equal to or less than” operator, it will index our messy array by 0 to 10 inclusive. This means that it sets each entry to zero and then sets the index 10 to zero, but this is out of bounds of the array (it is the 11th item of a 10 item array) so we instead zero the next thing in memory. What’s next in memory? Our counter variable (it’s even next in the file)! So the program loops forever as just as it reaches 10 it gets set back to zero again.

while (counter < 10)

Using the above (just plain “less than”) will fix it.

2.

The second one is not an issue with C, as such, but instead an issue caused by the C preprocessor. The C preprocessor is typically run on C files before they are compiled and performs textural replacement of terms and some limited logic. The below 2 lines tell the preprocessor to replace all occurrences of “MAGIC_NUMBER” with “10;”, and all occurrences of “NUMBER_THREE” with “3;”:

#define MAGIC_NUMBER 10;
#define NUMBER_THREE 3;

You may already be able to tell what the issue is just from the above explanation, but here’s the full code with the preprocessor run:

#include <stdio.h>
 
void main(void)
{
  int count = 0;
  for (size_t i = 0; i < 6; i++)
  {
    count += 10; - 3;;
  }
  printf("Count is %d.", count);
}

So now the problem line can be identified:

    count += 10; - 3;;

At first glance this looks like entirely invalid code, but it is actually valid and will compile. It can be parsed as three statements:

count += 10;

Which is entirely valid.

- 3;

Which is unary negation and also entirely valid. And:

;

Which is an empty statement and also valid.

This is all caused by the fact that preprocessor defines should not have semicolons on the end unless you want them placed in the output code. And, while the output code has two pointless statements in it, it is still valid, so the code compiles successfully (it just doesn’t do what we wanted it to)!

Your New Puzzle - "The Crystal Maze"
 
 
 
 

TODO TODO TODO PASTE THE IMAGE HERE IN GMAIL

This puzzle was named after the TV show in which it appeared, The Crystal Maze.

You are given the above graph. You must label each node in the graph with a letter of the alphabet from A to H (inclusive).

You must also follow these constraints:

  • Each letter must label only one node, e.g. only one node can be labeled “F”.
  • Nodes that are connected by an edge must not be consecutive, for instance a node labeled A cannot be connected to a node labeled B.

Using these rules we can see that the trivial alphabetical labelling, as shown below is invalid.

TODO TODO TODO PASTE THE IMAGE HERE IN GMAIL

Bonus: Once you have found a labeling of the graph which works, design and implement a program which can label any such graph, with any number and arrangement of nodes and edges.

And Finally...
 
 
 
 

Make sure you're in HackSoc's Slack workspace! We have over 200 members, and it's free to join the conversation, so sign up now!

If you're joining us for any of our virtual events, make sure you're also in our Discord server.

Have a great week,

Aaron 🤖

Facebook Twitter HackSoc website Slack