mscroggs.co.uk
mscroggs.co.uk

subscribe

Comment

Comments

Comments in green were written by me. Comments in blue were not written by me.
@Oleg: Happy new year!

I just added this:

#if 0
int last_idx_before_mid = 31 - __lzcnt32(off_mask); // 31 - LZCNT ==> index of MSb
#else

// if off_mask can never be zero, no need for check to override BSR result
assert(off_mask);
// a '9' run didn't reveal any 0 [you would know for sure for other sizes]

// need unsigned long result
unsigned long last_idx_before_mid;

// get index of MSb [no need for adjustment if off_mask can never be zero]
_BitScanReverse(&last_idx_before_mid, off_mask);
#endif

a run of '9' now produces the correct result: 1,730,280 :)
Lord Sméagol
on /blog/119
               

Archive

Show me a random blog post
 2026 

May 2026

World Cup stickers 2026

Apr 2026

A new puzzle every day
Mixing Wordle with other games

Feb 2026

Christmas (2025) is over
 2025 

Dec 2025

Christmas card 2025

Nov 2025

Christmas (2025) is coming!

Sep 2025

The partridge puzzle

Aug 2025

TMiP 2025 puzzle hunt

Jun 2025

A nonogram alphabet

Mar 2025

How to write a crossnumber

Jan 2025

Christmas (2024) is over
Friendly squares
 2024 

Dec 2024

A regular expression Christmas puzzle
Christmas card 2024

Nov 2024

Christmas (2024) is coming!

Feb 2024

Zines, pt. 2

Jan 2024

Christmas (2023) is over
 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

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

Archive

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