Professional Documents
Culture Documents
Hexahexaflexagon Booklet
Hexahexaflexagon Booklet
Computational
Thinking:
HexaHexaFlexagon
Automata FL
AP
b 1
3
Explore a strange c
7 4
paper puzzle 0
4
Code it by drawing 1 8 25
a ‘map’ 7
5
2 a 0 3 6 a
8
c
b
6
3 a 7 1 4 a
0
b a 4
1 c 8 2 5a a
7
a 5
2 c
0 3 6 a
8
6
3 7 1 4 a
0
c b
4
1 a 8 2 5
7
b c
b
5
2 c 0 3 6
8
a 6
1 FL
AP
2
2 www.cs4fn.org
From paper
puzzles to
saving lives
You make a red and yellow Using the same idea you can quickly
hexahexaflexagon by folding and create early prototypes of the user
interfaces for any program you are
gluing a multicoloured paper strip
developing, to check your ideas work. You
in a special way. Once made you can show it to the people who will use it.
start to explore it. As you fold and That way you can check they find it easy
unfold it, you magically reveal to use, don’t make mistakes and never get
new sides as the flexagon changes confused about what to do next. It helps
colour. you make sure that your design works.
You create a map as you explore it. It’s By quickly creating an early finite state
like a tube map. Circles are places you machine version of a user interface you
find. Lines show the places you can move can also check other things about it, like
between by folding and unfolding the whether you can always get back to the
flexagon. main home screen in one button press,
or WON’T get stuck with no way out.
This special kind of map is called a finite
state machine. Even though the map is just This really matters if people’s lives depend
a sketch of circles and lines it is also a kind on the program you are creating - if it
of program. It describes the computations is a heart monitor to keep people alive
involved in flexing the flexagon. perhaps, or controls a roller coaster, or
even if it is the shutdown system of a
By drawing the map in a special finite state nuclear power plant.
machine simulator, you have created a
virtual version of the hexahexaflexagon. Finite state machines are powerful tools
You can now explore it using the simulation in the computational thinking toolbox.
you have created.
www.cs4fn.org 3
FLAP 1
4
b 7 4
c
3
0
2 5
8 5
a
1
7
3 6
0 6
2 a a
8c b
1 4
7 4
a
3 a
0 a
a
2 5
b 8 5
c
1
7 a
a
c 3 6
0 6
2
8 a
1 4
7 4
3
0c b
2 5
8 5
1 a
7c b
3 6
b 0 6
2 c
4 www.cs4fn.org
Making a
Flexagon
Making a hexahexaflexagon:
the algorithm Download a copy of the
1. Download a copy of the coloured multicoloured hexahexaflexagon
hexahexaflexagon template from template from www.cs4fn.org/
www.cs4fn.org/hexahexaflexagon/
hexahexaflexagon/
2. Print an enlarged, coloured version
on to A3 paper.
www.cs4fn.org 5
Making a
Flexagon
6. Starting from the FLAP 1 end, fold the 7. Do a similar thing with the result.
first purple triangle against its adjacent Starting at the FLAP1 end, fold the
purple one, then green against green, first blue triangle against the adjacent
orange against orange, and so on blue triangle. This brings three yellow
down the strip. Make sure you fold as triangles together as below.
precisely as you can along the lines,
so that triangles fold exactly over each
FLAP 1
other. You should end up with a shorter
folded strip that looks like the one below.
FLAP 1
6 www.cs4fn.org
8. Now fold the next two blue triangles 9. Fold the final two blue triangles together,
together, back-to-back in the same tucking FLAP 2 in, so it is under the
way. You should now have five yellow hexagon you have made, leaving a
triangles together in a hexagon shape hexagon with FLAP 1 sticking out.
with the next blue triangle.
FLAP 1
FLAP 1
www.cs4fn.org 7
Making a
Flexagon
8 www.cs4fn.org
Flexing your 2. Opposite them are two yellow triangles
hexahexaflexagon with ‘b’ marked on them. While still
pinching the ‘a’ s, flatten the ‘b’ sides
Your flexagon has a yellow side and a
towards them so the flexagon makes a
red side. You can reveal new, different
Y shape from above as in diagram.
coloured sides by ‘flexing’ it: folding it up
and unfolding it again. Here’s how. 3. Open the flexagon up from the middle of
the Y, like a flower bud opening. A new
Flexing a hexahexaflexagon: blue side will be revealed. The yellow
the algorithm side has flipped to the back and the
1. Start with the yellow side up. Two of the original red side has disappeared.
yellow triangles have a letter ‘a’ on them.
Pinch those two triangles together. 4. Keep doing this – pinching two sides
together, flattening the opposite side and
opening up from the middle and you will
reveal more coloured sides. Explore!
pinch
a
b a b
flatten
b a b
a
pinch
www.cs4fn.org 9
10 www.cs4fn.org
Using Graphs
to Explore
www.cs4fn.org 11
Using Graphs
to Explore
a
3 2
12 www.cs4fn.org
Graphs that and the edges show how you can move
are maps between those nodes. An underground
or rail network map is a graph, where the
As you flex the flexagon, moving from
stations are the nodes and the railway lines
side to side, draw new circles for each
connecting them the edges. A railway map
new side. Put arrows between them
ignores (abstracts away from) the exact
showing how you got there. If you return
positions and distances between stations
to a side you’ve already seen, then the
to focus on how they are connected.
arrow should point back to the original
circle. Don’t draw a new one. For a flexagon the places you can visit –
the nodes - are the different numbered
Computer scientists have a special name
sides of the flexagon. The edges show how
for this kind of map: a graph. It’s a different
you can get from side to side. We’ve used
thing to the graphs mathematicians draw.
arrows as edges of the graph to show the
To a computer scientist a graph is just
direction you can travel along them. This
a series of circles, called nodes, and a
is called a directed graph.
series of lines connecting them called
edges. The nodes represent places to visit
www.cs4fn.org 13
Using Graphs
to Explore
14 www.cs4fn.org
Exploring with There are two possibilities. If our to-do list
a ‘To Do’ list is empty then we have finished. We have
fully explored the flexagon from that start
We need a way to keep track of which
point. The other possibility is that there is
parts of the graph are unexplored. We can
something still on our to-do list. We then
do that by keeping a to-do list of nodes
need to use the graph we’ve created to
with unexplored edges. As we explore the
navigate to one of those unexplored nodes
flexagon, adding new nodes and edges to
and carry on.
our graph, we can update our list.
This will work as long as there are no dead-
We start at any side of the flexagon,
end sections of the graph where the only
drawing it as the first node of our graph.
way to return to the start is to go back the
It has as yet unexplored places to flex so
way you came. Is that true for the graph of
we add that node to our to-do list too along
a flexagon? If so you would need to either
with which actions (flexing at a, b or c) we
flex the flexagon backwards to undo the
have yet to explore. We pick any and try
moves made, or dismantle and re-glue it
it, crossing it off the list for that node. We
back to the start. That is the equivalent of
update the graph with the new edge. We
being teleported out of a maze back to the
are now at a new side of the flexagon, so
entrance to try again!
we do the same from there adding each
node to our list if it isn’t already there. Once you have drawn the full graph for the
flexagon, draw a tidied version of it, so the
Eventually we will get to a node where
lines don’t cross and the nodes are nicely
we have crossed off all the actions. That
spread out. A full graph for the flexagon is
means it is fully explored. What then?
given overleaf.
www.cs4fn.org 15
a
4 8
b c
3
a a
c b
0 1 2 6
a
a b c a
5 7
16 www.cs4fn.org
Finite State
Machines
www.cs4fn.org 17
Finite State
Machines
b c
transition to take.
18 www.cs4fn.org
The finite state machine simulator, We can check these and other properties
pvsioweb, (www.cs4fn.org/pvsioweb/) by executing the simulation. For a large
is an example of a research toolset that machine that may take an impractically
does this. Created to help design medical long time. A better way is to use some
devices, it allows finite state machines to logical thinking to check properties of
be drawn like this and then quickly turns the model. We don’t have to do this by
them in to working simulations. It allows hand. We can devise algorithms and
much more, as it is linked to powerful write programs that check the properties
mathematical tools too… we are interested in automatically. If we
write them to work on finite state machine
Checking Properties models and build them in to our finite
Once we have created the finite state state machine simulator, then they can
machine simulation of our flexagon, we be used to check these kind of properties
can ignore the flexagon itself and explore automatically for any machine we create.
it further using its model. We can do a This allows us to check the properties of
similar thing with all sorts of phenomena the finite state machine in a really rigorous
we want to investigate – it is an alternative way (as we did to explore and create it in
way to do science. Create a model of the first place).
the phenomenon (like our finite state
For our flexagon, the finite state machine
machine) then explore it. Computational
is small. So once we have the complete
models are a useful way to understand
graph we can easily see why we kept
the world, from how our flexagon works
returning to sides 1, 2 and 3, for example.
to the way cancer spreads through cells.
Those states form a central triangle with
Using the model, we can answer the other states branching off but always
questions like: what is the quickest returning. Whichever way you go, you
sequence of actions from the start state always end up at one of those three sides
that will get us to state 4, or how many within at most three flexes. Sides 7, 8 and
steps does it take to get from state 5 to 0 on the other hand are harder to get to.
state 1? We can also check more general
By creating the finite state machine
properties like whether there are any
version – the computational model –
dead ends where we would get stuck, or
we are able to better understand the
whether we can always get back to the
flexagon.
start. We already saw how important the
last property is if we are trying to visit
every state of the finite state machine.
www.cs4fn.org 19
20 www.cs4fn.org
Graphs for real
22 www.cs4fn.org
Life and death the next patient arrives, that whatever state
it is in you can always get back to the start
Of course all of this applies to any program
state quickly. Ideally this should involve
we might want to create, and to anything we
doing exactly the same thing, whatever
can represent with a finite state machine.
state the machine has been left in. It
That includes gadgets that people’s lives
should be easy and obvious without special
depend on.
training. A designer can check important
Suppose you were designing a machine properties like that at the outset based on
for accident and emergency staff to use the finite state machine model of the device.
when patients arrive at the hospital – a Similarly, regulators, those charged with
resuscitator perhaps or a machine to making sure new machines are safe, could
quickly give them painkillers or lost blood. check the same properties before they allow
You want to be sure it is easy to use. You the machine to be sold in a similar way.
want the instruction manual to be correct.
That is exactly how finite state machines are
You want to be sure that certain properties
now being used…helping ensure machines
hold. For example, often the machine
are safe, saving lives.
will be left in a random state during an
emergency. It would be good to know, when
www.cs4fn.org 23
24 www.cs4fn.org
Computational
Thinking
www.cs4fn.org 25
Computational
Thinking
26 www.cs4fn.org
More to do All in all, graphs and
Flexagon Birthday Cards finite state machines
You can have lots of fun with flexagons if
you are creative. Add pictures to the sides are incredibly useful…
and you can create a puzzle that involves
finding a hidden picture. You could even
there is a lot of
create a hexahexaflexagon birthday card computational thinking
with hidden messages to find.
in a hexahexaflexagon!
The other side of the flexagon…
We have completely ignored the other
side of the flexagon! Turn it over and some
sides have no numbers in the centre!
There is a whole new world to explore
by flexing it with that side up. Do any of
the states of that side overlap with those
we already know about? If they do how
do we tell them apart? Perhaps we will
need a different abstraction once we start
drawing the graph? If so what to use? Is
it possible to pass through all the sides
without turning the flexagon over? It’s time
to create a finite state machine for the
flexagon as a whole.
www.cs4fn.org 27
Teaching London Computing:
www.teachinglondoncomputing.org
This booklet was written by Paul Curzon, June 2015, with support from the CHI+MED and Teaching London
Computing Teams. It was funded by Queen Mary University of London (QMUL), CHI+MED (EPSRC EP/
240_15
G058063/1) involving QMUL, Swansea, UCL and City Universities, the Mayor of London and Department for
Education. cs4fn is a partner on the BBC’s Make it Digital campaign.