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

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

Archive

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