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

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

Archive

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