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:

I removed my macros:
#define __tzcnt_u32(v) ((v) ? (_tzcnt_u32(v)) : (32))
#define __lzcnt32(v) ((v) ? (_lzcnt_u32(v)) : (32))
replacing them with simple inline code


Util.h

//#include // not including all
#include // just include what's needed
#include // just include what's needed
#include // just include what's needed

#if 1 // use safe localtime
struct tm buf; // use safe localtime
auto err = localtime_s(&buf, &cur_time); // use safe localtime
return std::put_time(&buf, "%F %T"); // use safe localtime
#else // use safe localtime
return std::put_time(std::localtime(&cur_time), "%F %T");
#endif // use safe localtime


State.h

changed _mm_set_epi8(0x80 to -0x80 to stop warnings

inline replacement:
//int i = __tzcnt_u32(mask); // for no BMI; without zero test, as not needed here
int i = _tzcnt_u32(mask); // for no BMI; without zero test, as not needed here

inline replacement:
//int last_idx_before_mid = 31 - __lzcnt32(off_mask); // for no BMI; without zero test, as not needed here
int last_idx_before_mid = _lzcnt_u32(off_mask); // for no BMI; without zero test, as not needed here


Solver.h

inline replacement:
//return ini.size(); // to stop warning
return (int)ini.size(); // to stop warning

inline replacement:
//const int dim = __tzcnt_u32(mask); // for no BMI; without zero test, as not needed here
const int dim = _tzcnt_u32(mask); // for no BMI; without zero test, as not needed here


I tried '9' runs: with asserts: 10:31, without: 10:18 (saved 2%)
A minute slower than the faulty version, but still not too bad for a 2013 (Q3) CPU :)
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

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

Archive

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