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

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

Archive

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