December 1, 2024

December Adventure 2024

While I have enjoyed doing (the first week or two of) Advent of Code the last few years, I think I’m going to not do it this year. I currently have my one-month old son asleep on me, and this is simply not an environment that’s conducive to that kind of problem-solving. I think, instead, I will participate in December Adventure which seems like a much gentler way of having some community and bit of a push to do a bit of coding this month. I have a few plans for what I will work on, but I am deliberately not specifying them up front in case I don’t actually decide to work on them this month. This post will record what I got up to on each day, so I’ll be editing it throughout the month. Read more

August 12, 2024

Who Did Best At The Olympics?

Every four years (give or take a pandemic postponement) debate breaks out about the best way to measure who did best at the olympics. I’m going to look at a couple here. Medals What’s a better measure of success? Gold medals? Total medals? If we look at medal totals, the top ten looks like this: Gold Silver Bronze Medal Totals United States 40 44 42 126 China 40 27 24 91 Great Britain 14 22 29 65 France 16 26 22 64 Australia 18 19 16 53 Japan 20 12 13 45 Italy 12 13 15 40 Netherlands 15 7 12 34 Germany 12 13 8 33 South Korea 13 9 10 32 Whereas if we focus on gold medals only1 a very slightly different picture emerges: Read more

September 26, 2023

How Errors Compound

I was messing around with a project recently, and I thought everything was going swimmingly. My unit tests were passing, the output to stdin looked like I’d expect. And then I made one small change, and instead of the binary number I was expecting, I saw: 1010101001001020 “Ones and zeroes everywhere. And I think I saw a two!”; “It was just a dream, Bender. There’s no such thing as a two.” I added a bunch more unit tests but they didn’t seem to be finding the two. It took me quite a while to figure out what the problem was because there were in fact two problems: one with the function code, and one with the tests. Read more

January 27, 2023

Python's Counter

The problem Python has a Counter object – it’s found in the collections module – and I’ve become convinced that it’s… a bit weird? The basic idea is fine: it’s a dictionary but the keys are things you want to count, and the values are the amount of the thing you have counted. The neat thing is if you initialise a counter with an iterable like a string or a list, it’ll give you the counts for the number of times each element appears. And it gives you convenience methods for finding the most common elements and that sort of thing. It’s pretty neat and I’ve used it a few times. Read more

January 13, 2023

Subclass Like a Boss

I had this idea for a project I could do, but I thought “maybe I should do this other thing first to get to grips with the API”. I was doing something for that project, and got distracted doing a simpler project to learn about the technologies and tools involved. I got distracted from that project by some weird behaviour of a class in the python standard library (I’ll post about that later). And I got distracted from that distraction by trying to find convenient ways to explore the code of python objects so as to make subclassing them easier. And this post is about this distraction to a distraction to a distraction. With any luck, I will eventually post about all of these things, but I’m not naming them in case I never get around to doing them. Read more

© Seamus Bradley 2021–6

Powered by Hugo & Kiss.