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.
First
My first Adventure is a foray into a little bit of Python. This ended up being quite a long post, but I expect most days will be a lot shorter than this! I am planning to do Advent of Code 2024 over the course of next year. So the idea is that I will do the 25 puzzles from this December over the course of January–November next year. But what deadlines should I set myself in order to complete the puzzles by the end of November? I could split the 333 days of those 11 months into 13-ish day intervals, and do one puzzle per fortnight, more or less. But, the earlier puzzles are easier and the later ones harder, so I kind of want to front load the deadlines so I get the easier ones done earlier to give myself more time for the later puzzles. So how do I calculate how much time to devote to each puzzle? My first thought was maybe this is a job for the fibonacci sequence? (Spoiler alert, it was not).
Essentially what I want to do is split up the time between January 1 and November 30 into 25 intervals
for each of the 25 days of Advent of Code.
The approach I took was to write a function that turns a (increasing) function into a collection of intervals.
If you put $f(x) = x$ in as your function (or lambda x: x in python) then you get a list of equal sized intervals of about 13 point something days each.
But where could you get the right kind of increasing function to give you sensible increasingly long intervals,
given the constraint that there are 25 intervals and the start and end dates are given?
My very naive approach was to take a function, look at the value it returns for input of 25, and then divide our 333 days into that many sections. Then, the deadline for the nth puzzle is just January 1 plus $f(n)$ times the size of the section. So for the case of even sized intervals, the 5th puzzle deadline is 5 times 333/25 days.
from datetime import datetime, timedelta
jan1 = datetime(2025, 1, 1)
dec1 = datetime(2025, 12, 1)
DAYS = (dec1 - jan1).days
PUZZLES = 25
def puzzle_deadlines_totals(fn):
fn_interval = DAYS/fn(PUZZLES)
for i in range(1, PUZZLES+1):
finish = jan1 + timedelta(days=fn_interval * fn(i))
print(f"Puzzle {i}, finish by: {finish}")
Obviously, this is not doing anything to check that you actually pass in an increasing function, and you’d get nonsensical outputs if you did not. This gives you the following output:
>>> puzzle_deadlines_totals(lambda x: x)
Puzzle 1, finish by: 2025-01-14 08:38:24
Puzzle 2, finish by: 2025-01-27 17:16:48
Puzzle 3, finish by: 2025-02-10 01:55:12
Puzzle 4, finish by: 2025-02-23 10:33:36
Puzzle 5, finish by: 2025-03-08 19:12:00
Puzzle 6, finish by: 2025-03-22 03:50:24
Puzzle 7, finish by: 2025-04-04 12:28:48
Puzzle 8, finish by: 2025-04-17 21:07:12
Puzzle 9, finish by: 2025-05-01 05:45:36
Puzzle 10, finish by: 2025-05-14 14:24:00
Puzzle 11, finish by: 2025-05-27 23:02:24
Puzzle 12, finish by: 2025-06-10 07:40:48
Puzzle 13, finish by: 2025-06-23 16:19:12
Puzzle 14, finish by: 2025-07-07 00:57:36
Puzzle 15, finish by: 2025-07-20 09:36:00
Puzzle 16, finish by: 2025-08-02 18:14:24
Puzzle 17, finish by: 2025-08-16 02:52:48
Puzzle 18, finish by: 2025-08-29 11:31:12
Puzzle 19, finish by: 2025-09-11 20:09:36
Puzzle 20, finish by: 2025-09-25 04:48:00
Puzzle 21, finish by: 2025-10-08 13:26:24
Puzzle 22, finish by: 2025-10-21 22:04:48
Puzzle 23, finish by: 2025-11-04 06:43:12
Puzzle 24, finish by: 2025-11-17 15:21:36
Puzzle 25, finish by: 2025-12-01 00:00:00
So now all we need to do is find a function that gives us intervals we like. A function that increases quicker than linear. For some reason, my first thought was “Fibonacci?”.
>>> puzzle_deadlines_totals(fib)
Puzzle 1, finish by: 2025-01-01 00:03:57.720462
Puzzle 2, finish by: 2025-01-01 00:07:55.440923
Puzzle 3, finish by: 2025-01-01 00:11:53.161385
Puzzle 4, finish by: 2025-01-01 00:19:48.602308
Puzzle 5, finish by: 2025-01-01 00:31:41.763693
Puzzle 6, finish by: 2025-01-01 00:51:30.366001
Puzzle 7, finish by: 2025-01-01 01:23:12.129694
Puzzle 8, finish by: 2025-01-01 02:14:42.495696
Puzzle 9, finish by: 2025-01-01 03:37:54.625390
Puzzle 10, finish by: 2025-01-01 05:52:37.121086
Puzzle 11, finish by: 2025-01-01 09:30:31.746476
Puzzle 12, finish by: 2025-01-01 15:23:08.867562
Puzzle 13, finish by: 2025-01-02 00:53:40.614039
Puzzle 14, finish by: 2025-01-02 16:16:49.481601
Puzzle 15, finish by: 2025-01-03 17:10:30.095640
Puzzle 16, finish by: 2025-01-05 09:27:19.577241
Puzzle 17, finish by: 2025-01-08 02:37:49.672881
Puzzle 18, finish by: 2025-01-12 12:05:09.250122
Puzzle 19, finish by: 2025-01-19 14:42:58.923002
Puzzle 20, finish by: 2025-01-31 02:48:08.173124
Puzzle 21, finish by: 2025-02-18 17:31:07.096126
Puzzle 22, finish by: 2025-03-20 20:19:15.269249
Puzzle 23, finish by: 2025-05-08 13:50:22.365375
Puzzle 24, finish by: 2025-07-26 10:09:37.634625
Puzzle 25, finish by: 2025-12-01 00:00:00
This is obviously growing too quickly: fib(25) is over 100,000
so these last couple of values are swamping the earlier smaller values.
Doing the first 12 days of puzzles on Jan 1 seems like a bad idea.
A bit of trial and error and I found this fairly reasonable list of deadlines:
>>> puzzle_deadlines_totals(lambda x: x**1.5)
Puzzle 1, finish by: 2025-01-03 16:07:40.800000
Puzzle 2, finish by: 2025-01-08 13:22:52.948761
Puzzle 3, finish by: 2025-01-14 21:13:07.905228
Puzzle 4, finish by: 2025-01-22 09:01:26.400000
Puzzle 5, finish by: 2025-01-30 20:58:22.210700
Puzzle 6, finish by: 2025-02-09 06:29:06.969664
Puzzle 7, finish by: 2025-02-19 11:40:01.849914
Puzzle 8, finish by: 2025-03-02 11:03:03.590085
Puzzle 9, finish by: 2025-03-14 03:27:21.600000
Puzzle 10, finish by: 2025-03-26 11:54:19.504486
Puzzle 11, finish by: 2025-04-08 11:34:25.176414
Puzzle 12, finish by: 2025-04-22 01:45:03.241824
Puzzle 13, finish by: 2025-05-06 05:49:05.874630
Puzzle 14, finish by: 2025-05-20 23:13:48.246912
Puzzle 15, finish by: 2025-06-05 05:30:00.505382
Puzzle 16, finish by: 2025-06-21 00:11:31.200000
Puzzle 17, finish by: 2025-07-07 06:54:38.874648
Puzzle 18, finish by: 2025-07-24 01:17:49.616536
Puzzle 19, finish by: 2025-08-10 07:01:19.047274
Puzzle 20, finish by: 2025-08-27 23:46:57.685599
Puzzle 21, finish by: 2025-09-15 03:17:58.910959
Puzzle 22, finish by: 2025-10-03 17:18:48.962200
Puzzle 23, finish by: 2025-10-22 17:34:58.549155
Puzzle 24, finish by: 2025-11-11 03:52:55.757315
Puzzle 25, finish by: 2025-12-01 00:00:00
Instead of picking a function that defines the total for each n,
we could instead look at the function that provides the increment between n-1 and n.
On this way of looking at it, to recreate the our “equal intervals” example, we’d need a constant function,
for example lambda x: 1.
We can then translate this into a function for totals by summing the values.
def puzzle_deadlines_intervals(basefn):
def sumfn(n):
return sum([basefn(x) for x in range(1, n+1)])
puzzle_deadlines_totals(sumfn)
What base function might give us nice intervals?
Well, we could just use the linear function lambda x: x.
>>> puzzle_deadlines_intervals(lambda x: x)
Puzzle 1, finish by: 2025-01-02 00:39:52.615385
Puzzle 2, finish by: 2025-01-04 01:59:37.846154
Puzzle 3, finish by: 2025-01-07 03:59:15.692308
Puzzle 4, finish by: 2025-01-11 06:38:46.153846
Puzzle 5, finish by: 2025-01-16 09:58:09.230769
Puzzle 6, finish by: 2025-01-22 13:57:24.923077
Puzzle 7, finish by: 2025-01-29 18:36:33.230769
Puzzle 8, finish by: 2025-02-06 23:55:34.153846
Puzzle 9, finish by: 2025-02-16 05:54:27.692308
Puzzle 10, finish by: 2025-02-26 12:33:13.846154
Puzzle 11, finish by: 2025-03-09 19:51:52.615385
Puzzle 12, finish by: 2025-03-22 03:50:24
Puzzle 13, finish by: 2025-04-04 12:28:48
Puzzle 14, finish by: 2025-04-18 21:47:04.615385
Puzzle 15, finish by: 2025-05-04 07:45:13.846154
Puzzle 16, finish by: 2025-05-20 18:23:15.692308
Puzzle 17, finish by: 2025-06-07 05:41:10.153846
Puzzle 18, finish by: 2025-06-25 17:38:57.230769
Puzzle 19, finish by: 2025-07-15 06:16:36.923077
Puzzle 20, finish by: 2025-08-04 19:34:09.230769
Puzzle 21, finish by: 2025-08-26 09:31:34.153846
Puzzle 22, finish by: 2025-09-18 00:08:51.692308
Puzzle 23, finish by: 2025-10-11 15:26:01.846154
Puzzle 24, finish by: 2025-11-05 07:23:04.615385
Puzzle 25, finish by: 2025-12-01 00:00:00
This would be the same as doing puzzle_deadlines_totals(lambda x: x*(x+1)/2)
but I didn’t realise this until I’d implemented it.
I haven’t actually decided which set of deadlines I will work to yet, but I have time to figure it out.
Tidying this up, I’d want to get rid of the times and just print the date (using finish.date())
and then replace dec1 with dec1 - timedelta(second=1) or something so it’s just before midnight on November 30.
But I’m pretty happy with what I managed in the time I had available.
Second
Today, rather than actually doing any coding, I spent a while setting up a new repo for a project that I’ll probably be playing with during this month. I’m writing a little command line app for rolling dice. The idea is to implement some (but probably not all) of the functionality of this app. But on top of that, the idea is to also include some functionality for drawing cards from a deck. I haven’t figured out what the syntax for that would be yet.
I always get caught out by this issue where, if you have a local git repo, but then you want to set up a remote on, say, codeberg, it’s kind of awkward to get it right. I am fairly sleep deprived, so I went for the simplest, dumbest approach. I nuked the local git repo, cloned the new codeberg repo into a temporary directory, and then moved the repo into the top level. That’s enough for today.
Third
My original plan today was to make some progress on the rust dicr project I mentioned yesterday.
Instead, I installed uiua
and got to the stage of solving the first Project Euler
puzzle with it.
I had this plan at one stage to try solving the Project Euler puzzles in several different languages.
I got to the point of solving the first puzzle in Python, Haskell and J
before…
I don’t remember what happened really?
I got distracted learning rust maybe?
Anyway, that’s a project I might go back to at some stage.
The first puzzle is to find the sum of all the multiples of 3 or 5 less than 1000.
Uiua (pronounced wee-waa) is an array-based programming language like APL or J, but also a stack-based programming language like Forth or Web Assembly. (There might be more obvious examples of stack based programming, but those are the ones I know about). I quite like it so far, although I don’t really like the syntax that requires esoteric symbols aspect. Maybe I just need to get used to it, but I find it hard to read because I don’t find it easy to follow what the symbols mean. Here’s my solution to the first Project Euler problem.
/+×↥ ∩(=0) ⊃(◿ 3) (◿ 5) . ⇡ 1000
(I don’t even know if this will display correctly when I publish, but we’ll see). This is pretty neat, and honestly, I’m much happier with this than I am with my solution in J. I think there must be a better way to do it in J, because my version is horrible. I won’t explain all the uiua syntax here, but I’ll explain roughly how it works, and then you can explore the fairly good docs to follow along more completely.
The strategy is more or less the same as the approach I took in my Haskell solution:
euler :: Int -> Int
euler n = foldl1 (+) $ filter (\x -> (rem x 3 == 0) || (rem x 5 == 0)) [1..n-1]
Reading right to left: get the range of numbers from 1 to n-1
(because Haskell ranges are inclusive, so if we want euler 1000 to give us our result, we need to do n-1);
filter the range to the values divisible by 3 or 5;
sum those values.
The uiua solution is the same, except for a couple of tweaks.
First, I hardcode the value 1000 in the range, because I haven’t got to the part of the tutorial about functions yet.
Second, instead of doing the filter step with a lambda,
I copy the range so I have two copies on the stack (we’ll come back to this), then
I do fork (⊃) to do two different operations on the same data (the two modulus operations)
and then use both (∩) to do the same operation (checking if ==0) on two different arrays (the two modulus-ed arrays).
Uiua doesn’t have explicit AND and OR operators (or a boolean type),
so you just use min and max on arrays of 0s and 1s to do the same thing.
So now I have a boolean array of the positions in the array where the filter condition is true.
Now since I am only interested in the sum of the values,
I don’t need to filter the array per se,
I just need to only keep the values where the condition is true (multiply them by 1) and drop the others (multiply them by 0).
This was why I copied the array at the start.
I multiply the boolean array by the original array, and then reduce with addition to get the sum of the filtered values.
This wasn’t at all what I expected to be adventuring with today, but here we are. I like uiua and might play with it some more.
Fourth
Today I didn’t have a lot of time. I got a little bit further into the Uiua tutorial, but the exercises on the inverses page broke my brain.
Fifth
I actually got back to the dice project I mentioned on the second today.
I didn’t really make any progress because I am prevaricating on some implementation
details, and I am also trying to figure out the best way to do what I want.
I have a very basic dice data model and a very basic parser.
So parsing “3d6” will give you a Dice object, and calling roll()
on that dice object would return a vector of dice rolls.
I now want to add the complexity of modifiers
(like “drop the highest value”) and it’s causing me some
borrow checker headaches.
For various reasons (among them, testability)
I want to change things so that the roll method returns a Result object,
instead of just a list of rolled values.
The Dice and Result structs will then contain a collection of modifiers
that should be applied to the values when you ask the Result object to resolve().
So I want to take the list of rolled values, apply each of a collection of modifiers in turn,
and return the final output.
But how do I do this within Rust’s memory model?
The answer might come to me tomorrow after some sleep.
Sixth
More rust, this evening: specifically my dice project.
I made some changes, and the tests still pass, so I guess I haven’t gone backwards?
I did a lot of messing about trying to figure out a few things,
which meant that in terms of actual functionality, nothing has changed.
I think I understand the memory model a bit better,
and I am confident I’m in a good position to actually make some progress next time.
I think one issue I have at the moment with Rust is that I do a lot of refactoring as I figure out things about
the type system and borrow checker.
For example, I tried to make some variables into array slices,
but then I discovered you can’t collect into an array, because arrays are fixed size and
the compiler can’t know how big an array to reserve to the outcome of collect.
So in the end, all the collections are Vec.
That makes things a little simpler.
Another issue is that the ThreadRng thing, the thing that lets me do random,
needs to be mutable (because it has a state that changes when you get a random number).
The Die struct contains an instance of ThreadRng so that Die.roll() can get its own random numbers.
So any time you create a Die that you want to call roll() on, you have to take it mutably.
This isn’t ideal, and I wonder if I could avoid it by putting the random number generator in a Box.
That’s an issue for another day.
Seventh
I decided to have a go at installing Processing, but there was something screwy about the size of the windows, and where the menu bars were appearing. I decided I didn’t fancy debugging that, so I thought I’d try something else instead.
I did Project Euler problem 2 Python and Haskell.
Both solutions have their nice points.
On the one hand, the haskell solution is just create an infinite list,
map using fibonacci, filter in the even numbers, take while and then fold with +.
On the other hand, it’s pretty slow, because the fibonacci function isn’t memoised.
For python, I can easily memoise the fibonacci function using the @cache decorator
from functools.
On the other hand, the actual algorithm is an unsatisfying while loop.
I had a think about doing the problem in J and decided I didn’t want to.
It has been a while since I’ve played with J,
and I seem to get on better with Uiua than I do with J.
I found some example code for how to build up an array
of fibonacci numbers less than N, and it looked horrible.
I went back to the Uiua tutorial in order to equip me with the tools to tackle Euler problem 2. I haven’t yet got back to doing the problem yet.
Eighth
I have been staring at “eighth” for a good minute and I am still not convince I’ve spelled it right. Anyway. I felt like trying to do some creative coding, or procedural art, or whatever you want to call it. I tried Processing yesterday and it would open the IDE but it was weirdly small – taking up a quarter of my laptop screen only, and I couldn’t see how to make it bigger. The menus were misbehaving, and I basically noped out of trying to get it to work fairly quickly. I suspect that it’s just not been built to work properly on Wayland.
I asked for suggestions for other software to try out on mastodon and got a bunch of answers. So instead of picking one and going through it, I’ve been kind of jumping around trying to see which one is going to be least painful to set up, and what speaks to me. I tried py5 which is, as far as I can tell, a sort of python wrapper on processing. I installed that, but it turns out I don’t have java installed on this machine (so it’s kind of surprising the processing IDE worked at all, what’s going on there?). I could install java, but I decided to see what tools I might be able to use that don’t involve doing that.
I looked at another tool I saw recommended online, but it didn’t have a linux installer so I completely forgot what it was even called. I looked at NodeBox, but that wanted me to install Java 7. And if I’m reluctant to install java, I am doubly reluctant to install a version of java so old it doesn’t appear to be available in the ubuntu package manager.
The two remaining options, the two I will probably actually try to do something with, are Nannou and Reanimate. These are tools in the Rust and Haskell ecosystems respectively. I am kind of drawn to haskell as a language for creative coding, I think it has a kind of creative coding vibe, but Reanimate appears to be mostly geared towards animation, which would not be my main interest. So I’m going to sit down and learn a bit about Nannou first.
At this stage, I remember that uiua can also produce graphics, and I consider trying to make that work for me. So I open up my editor and am reminded that I was trying to understand why my uiua implementation of fibonacci was hitting a recursion depth error for input 8.
This is, I guess, one issue with the December Adventure approach: without a focus on a specific problem, there’s a danger that unfocused types like me will flit about between projects and get nowhere. Well, I guess it’s ok to get nowhere. All that to say, I will probably try to explore Nannou, but later in the month. For now it’s back to solving Euler Project problem 2 in uiua.
So I never actually figured out why my recursive fibonacci definition was hitting recursion depth limits because I realised I actually don’t need to do recursion at all. I rewrote my definition of Fibonacci:
Fib ← ◌ : ⍥(: ⟜+) -1 ⊙(1 1)
So what : ⟜+ does is it adds together the top two values on the stack, but keeps the top argument on the stack, and then flips the two values.
That is, ⟜+ 1 1 adds the two 1s together and puts 2 on the stack, but also puts 1 back on the stack.
So we then flip those two values to put 2 on the top.
We then repeat (⍥) that process a number of times (that number is the parameter for the function).
But before we get that number of repeats, we need to push some initial values onto the stack
(the fibonacci values for inputs 0 and 1).
So we temporarily pop our input parameter off the stack, and then push two 1s onto it with ⊙(1 1).
The -1 is because the number of times we have to repeat : ⟜+ is one less than the input.
For input 1 we need to repeat it 0 times, for example.
Since we’re keeping two values on the stack (the two values we’d need to sum for the next fibonacci number),
when it comes to the end of the function, we need to drop one of them: the second one.
We do ◌ : to just keep the result on the stack:
this flips the two top values on the stack, and then pops and discards one.
Having created this fibonacci function, I realised that we can solve the second Euler Project problem without using it. The full solution works more or less the same, but instead of keeping the values on the stack (and dropping the ones we no longer need) we build up an array of values by prepending the sum of the first two values; repeat that process while the first value is less than 4 million. Then it’s basically filter and reduce. I am now wondering how much effort it would take to refactor my haskell solution to work along the same lines.
Ninth
So it turns out that my alternate version of the Haskell solution for Euler Project
problem 2 is way faster.
And thinking about it, it’s obvious that it should be.
I was basically doing [fib x | x<- [1..]] which calculates the whole sequence for each number.
But of course, getting fib x when you’re generating a sequence of fibonacci numbers is just a matter of
grabbing the last two numbers you generated and adding them together.
So here’s a concrete example of how thinking about a fairly esoteric array programming language solution to
the problem materially improved a solution in a more mainstream language.
OK Haskell isn’t super mainstream, but I could do the same thing in python and dispense with
the recursion there too.
I also did a little bit more of the uiua tutorial, but not much, because I am very tired today.
Tenth
My dice thing now has functionality to keep and drop a number of dice. It’s a hacky mess. I’m sure I could make it way better with a bit of thought, but it works for now. Next up, writing the parser for keeping and dropping…
Eleventh
Today I wrote the parser for keeping and dropping dice. It works, but it will need some more thought when it comes to adding different kinds of modifiers (such as min, max, comparators like “>=4”). I had less trouble with the borrow checker today than previously. I think maybe I’m beginning to have some intuitions about when to borrow versus when to move.
Twelfth
More work on the dice thing today.
I put together the methods and parser for for rolling dice with minimum or maximum value.
So if you do 3d6min2, any values of 1 would be replaced with 2s.
Given the foundations I’d put together over the last couple of days,
this ended up being quite straightforward.
One issue I had with both the parsing from today and yesterday,
was that the rust compiler wasn’t able to recognise that two
functions had the same type.
So I have an enum for the various ways of modifying a roll,
including Min and Max.
Both of these take a number: the minimum or maximum number.
Part of the parser maps the string min to the function Modifier::Min
which is a function that takes a number and returns a value from the Modifier enum.
I do the same thing for Max.
But when I try to do alt(min,max) the parser complained
that the two component parsers have different types.
So I have to write the function as Modifier::Min as fn(usize) -> Modifier
in the map.
It might be easier to see what I mean by looking at the
min_max_mod function
in the code itself.
Thirteenth
I did no adventuring today. I had a bit of a cold and was very tired. I played Talos Principle; that is the closest I got to a computer.
Fourteenth
I am taking a little break from rust to explore replacing my old professional website with something simpler. The current version is built using Hugo and the Wowchemy theme. I’ve had numerous problems with upgrades to hugo and/or wowchemy causing the site to break, and I really don’t need that kind of problem, since the site is basically completely static now. I had a look at the html that hugo generates, and the index has 2200 lines, most of which (1700) are blank. There’s a bunch of mysterious minified javascript included as well. I don’t need any of that. So my plan is to replace it with some basic html. I’m going to take inspiration from readable.css to make something simple, and maintainable.
My main concern is to not break existing urls for my papers. I considered writing some kind of script to extract the urls I need to maintain, and the content that should be there and so on, but honestly, there’s only two dozen papers and I think I’m just going to do it all by hand, like a maniac.
Fifteenth
We had family over today, so it’s got to the evening and I’ve no energy left for adventuring. I thought about trying another Euler Project problem or similar coding challenge, but my brain is fried.
Sixteenth
I realised yesterday that I haven’t actually written CSS and HTML since about 2006, and the landscape has changed a lot in the past almost twenty years. So if I am to remake this website, I am going to need to relearn a lot of what I know about how to build websites. Today’s adventure therefore consisted in playing with Flexbox Froggy and looking at MDN.
Seventeenth
I finished Flexbox Froggy today, and I spent some time reading about CSS. I went to look at the site I was working on and decided I don’t have the energy to actually work on it. December Adventure very much being hampered by newborn-induced sleep deprivation.
Eighteenth
Having got my head around flexbox, I decided that it would be easier to use CSS grid for the site I’m currently making. I have a design I’m somewhat happy with now. I think it’s now going to be a case of combining my layout with the compatible parts of readable.css (i.e. the typography related parts).
This site is supposed to be completely static: once I’ve created it,
it shouldn’t require any modifications.
Because of this, it’s feasible to write the site entirely by hand.
So I want to make sure I get it the layout right, because if I have make a change to the HTML,
I’ll have to make that change in about two dozen places.
This means that I need to decide now on some things like “should the nav element be inside the header or not?”
And once I’ve made that decision, I won’t be able to change it.
I spent a long while being puzzled by why my HTML element that had the property grid-column:1/2
wasn’t spanning across the two columns.
It’s because the grid-column-end (the second number in the grid-column short format)
needs to be the number after the number of the last column you want the element to span across.
Nineteenth
I still don’t really understand how CSS works so I have spent some time today trying to make my layout look alright at different sizes. I think I’m beginning to have more of a mental model of how the components work together, so I hope I’ll get there soon.
I also had a look at removing the conflicting pieces from readable.css. In doing so, I came to the realisation that it’s kind of awkward the way that CSS is used for styling, and also for layout, and those two things are often quite distinct, but they get mixed together in css files. I wonder if it would make sense to keep those two things separate. I don’t know what that would mean, or if there would be any downsides.
Twentieth
Spent some more time figuring out CSS for my website. I got most of the way through putting the actual content into the html pages as well. This ended up being even more manual than I thought, because it turns out I don’t have the markdwon files to hand from my previous version. I thought about extracting the data from the generated html, but it’s a bit of a mess, and doesn’t actually contain all the information I thought it did. So I’m doing it by hand, and doing it properly.
Twenty First
Because of how the previous version of the website I’m building was created,
I have bibTeX files each containing the citation details of one of my papers.
I briefly considered using them to build up the publications page of the site.
It’s definitely something I’d consider if I were expecting to add to the page,
but I am not, so I just wrote it out manually.
The site is nearing completion now.
I need to create a bunch more pages to mimic the existing structure, so as to prevent link rot.
The previous version of the site had a directory for each publication,
and that directory had an index.html, a cite.bib and the pdf of the publication.
So the directory structure and the pdfs have just been copied into the new site already,
and I just need to put up a boilerplatey index.html for each directory and I’m done.
I did not expect to spend so much of my December Adventure rebuilding this website, but it’s actually probably a much more useful thing to be doing than the other things I’ve been doing.
Twenty Second
The overall “Publications” page is now basically done. I am going to just tweak a few things before I create each of the individual publication pages. I want to get it right before I copy and paste two dozen versions of the publication page. Very tired today, so I only did some light CSS prodding. Hopefully one better day tomorrow and the site will be done.
Twenty Third
I wanted to take a break from the website I was building, so I decided to have a look into refreshing the look of waybar, the status bar I use on sway window manager. It turns out that you style the bar with… CSS! So it wasn’t as much of a break as I was hoping for. I actually didn’t do much beyond copy in the example configuration from the docs. This seems to be way nicer than the default configuration. I will probably play with it some more, but I’m happy enough now that it is less distracting.
Twenty Fourth
I did a little python exercise on exercism today just to say I’d done something. I will probably take tomorrow off from my December Adventure because it’s Christmas.
Twenty Fifth
As expected, I took today off from my adventure in order to eat too much.
Twenty Sixth
I think I’ve basically finished my website now.
I will tweak some of the styling and hopefully I can put it online before the year is out.
I’m using a grid layout, so you’d think vertical alignment would be easy,
but padding, margins and line heights mean that it’s not as easy as it seems.
I’m trying to align a side bar (a p element)
with a h2 element.
The heading has more vertical space around it, and it’s kind of unclear what the
“correct” solution would be.
I could put the heading on its own row in the grid layout and align the sidebar with the text
below the heading, I guess.
That feels like a bit of a cheat…
I will also need to change my domain registrar and hosting provider at some point (to move my academic site over to the same provider as this site). In fact, I might put the new site up on the new hosting provider, and change DNS on the old registrar. Then I can change registrar at my leisure.
Twenty Seventh
I downloaded and compiled Zola. Currently this site is built using Hugo, and I’m beginning to get a bit annoyed at it. I am using the snap version of Hugo and it will randomly update itself and throw new deprecation warnings. This means either hoping that the designer of the template I use is keeping it up to date, or learning enough about the hugo templating system to fix it myself. I do not want to do this.
Zola looks like a simpler system (deliberately so, judging by some comments on the github issues) and it’s built in rust, which I prefer to go. So at some point (not during my December Adventure, but maybe next year) I am going to write my own templates for Zola, and move the blog over to a system I am more on top of.
Twenty Eighth
I didn’t have a lot of time for Adventuring today, but I did put a bunch of LEDs, wires and a breadboard in my shopping basket. I have a couple of raspberry pis and accessories knocking around and I am planning to do something with them in the new year. I got a weather station kit for christmas so that’s going to be part of my plans, I also have a compatible e-ink screen.
Twenty Ninth
I went back to what I did on day one of my December Adventure, and tidied the code up a little.
The script will now tell you how many days you get to do each puzzle as well as what day the deadline falls on for each.
I thought about splitting it out into part 1 and part 2 with separate deadlines for each,
but that’s not how the real advent of code works, so I decided against it.
One thing that really caught me out is that I discovered an amusing coincidence that had me convinced I had a bug in my code.
If we use the “interval increases linearly” approach I talked about before,
and we print out the number of days you get per puzzle, puzzle 1 gets 1 day, puzzle 2 gets 2 days,
and so on all the way up to puzzle 25 gets 25 days.
That’s because sum(range(26)) is 325, whereas the number of days from January to November inclusive
is 333.
So, with rounding, it works out to a day per base interval.
I also did a bit more impulse shopping for random hobbyist electronics bits. I’ve got some fun plans for next year!
Thirtieth
I had an idea for a fun little project and I thought I’d put together a little experiment. It’s a simple website reading data from a JSON object and printing some of it onto the page. For now the JSON is hardcoded into the script because reading a separate file turned out to be non-trivial. Or at least, my five minutes of googling yielded only complicated solutions.
Thirty First
No adventuring today as I’m looking after a sick kid (he’s fine). I have enjoyed my december adventure. I don’t see why I should wait until next december to have another adventure.