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

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

Archive

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