mscroggs.co.uk
mscroggs.co.uk

subscribe

Blog

A regular expression Christmas puzzle

 2024-12-22 
I showed off and part-solved a prototype version of this puzzle with Katie Steckles in the fifteenth Finite Group livestream. You can watch a recording of this stream, and watch our future streams if you sign up to our Patreon.
I clearly haven't already made enough Christmas puzzles this year, so I've made another one. If you've used regular expressions before, head straight to mscroggs.co.uk/regexmas to try the puzzle. If you've not, read on...

What is a regular expression

Regular expressions are strings of characters that can be used in multiple programming languages to validate text. Regular expressions are usually written between two / characters. Between the slashes, characters have the following meaning:

The puzzle

My regular expression Christmas puzzle is shown below. You can either solve it on this page or at mscroggs.co.uk/regexmas using the buttons or your keyboard, or you can download this PDF of the puzzle.
In the grid below, write r, g, b, c, m, y, k, or w in every square so that:
The squares containing an r will be coloured red, those containing a g will be coloured green, those containing a b will be coloured blue, those containing a c will be coloured cyan, those containing an m will be coloured magenta, those containing a y will be coloured yellow, those containing a k will be coloured black, and those containing a w will be left white.
r g b c m y k w
/^w+yw+$/
/^([kw]+)[^kw]\1$/
/^(g|wwwg|gww)+.$/
/^wy?g*y+w+$/
/^((w|gg)(ww|g)){3}$/
/^[wg](w|g)[gw](.)\2+\1{2}$/
/^.g*[^y]$/
/^([gk][gk][gk])\1\1$/
/^yw+kw+y$/
/^w*b(bb)+w*$/
/^(w+)w?(bb?)\2\2\1$/
/^(www|bbb)+$/
/^w+gyw+$/
/^[wg]*y[wg]*$/
/^.*gwg.*gwb.*$/
/^[^g]+g+[^g]+$/
/^y?g+y?g+k?b+$/
/^[w]+g*w[^w]+$/
/^w+g+wg+[^g]+$/
/^w*yw*g+w*$/
/^w*y?g?y?w*$/
                        
(Click on one of these icons to react to this blog post)

You might also enjoy...

Comments

Comments in green were written by me. Comments in blue were not written by me.
 Add a Comment 


I will only use your email address to reply to your comment (if a reply is needed).

Allowed HTML tags: <br> <a> <small> <b> <i> <s> <sup> <sub> <u> <spoiler> <ul> <ol> <li> <logo>
To prove you are not a spam bot, please type "elbatnuocnu" backwards in the box below (case sensitive):

Archive

Show me a random blog post
 2026 

Feb 2026

Christmas (2025) is over
 2025 
▼ show ▼
 2024 
▼ show ▼
 2023 
▼ show ▼
 2022 
▼ show ▼
 2021 
▼ show ▼
 2020 
▼ show ▼
 2019 
▼ show ▼
 2018 
▼ show ▼
 2017 
▼ show ▼
 2016 
▼ show ▼
 2015 
▼ show ▼
 2014 
▼ show ▼
 2013 
▼ show ▼
 2012 
▼ show ▼

Tags

advent calendar simultaneous equations draughts machine learning triangles christmas curvature matt parker manchester puzzles sorting standard deviation martin gardner estimation approximation royal baby wave scattering talking maths in public fractals matrix of minors mean london underground matrices radio 4 graph theory preconditioning javascript rust phd coventry computational complexity pascal's triangle finite element method video games geogebra cross stitch folding paper crosswords squares a gamut of games alphabets hexapawn boundary element methods data exponential growth numbers geometry coins palindromes oeis games determinants zines world cup dates databet convergence nonograms reddit golden spiral accuracy kenilworth sobolev spaces logo regular expressions platonic solids mathsteroids quadrilaterals signorini conditions royal institution bempp the aperiodical sport map projections trigonometry weak imposition braiding nine men's morris statistics menace tennis newcastle gaussian elimination bots programming bubble bobble chess warwick golden ratio noughts and crosses partridge puzzle christmas card stirling numbers stickers weather station rugby dinosaurs folding tube maps runge's phenomenon latex correlation pac-man rhombicuboctahedron matrix multiplication hannah fry fence posts dataset people maths guest posts crossnumber pi light flexagons kings dragon curves london live stream matrix of cofactors python sound craft cambridge hats european cup ucl reuleaux polygons pizza cutting game of life mathslogicbot pythagoras asteroids php chebyshev datasaurus dozen final fantasy turtles anscombe's quartet chalkdust magazine logic electromagnetic field plastic ratio ternary recursion manchester science festival finite group interpolation wool bodmas probability polynomials books arithmetic crossnumbers crochet tmip frobel gerry anderson error bars gather town graphs realhats fonts big internet math-off misleading statistics numerical analysis mathsjam national lottery thirteen game show probability inverse matrices errors pi approximation day captain scarlet speed football logs countdown binary news 24 hour maths inline code youtube harriss spiral data visualisation friendly squares hyperbolic surfaces propositional calculus raspberry pi go edinburgh

Archive

Show me a random blog post
▼ show ▼
© Matthew Scroggs 2012–2026