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

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

Archive

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