Friday, 31 December 2021

Most likes in instagram

Almost one year posting a photo each day. Quite surprisingly for me, these are the twelve ones which got the most likes (from top left to bottom right).





Sunday, 19 December 2021

Calendar puzzle (ii)

In the end I went for the brute force approach, ie the not so elegant approach. It took me a while to write and debug the code but eventually I got there and found thousands and thousands of solutions (in fact I assume I found them all). Once I somewhat tidy the code up I will post it in github. Today I spent some time figuring out how to plot the calendar, learning about colour maps, grids, etc. As usual, python has you covered! People who have created and contributed to libraries such as numpy and matplotlib definitely deserve a lot of credit.

Since it makes no sense to publish here a daily puzzle I have created a twitter account for the Calendar, so that I can create a bot which tweets a solution every day (or if I feel even more adventurous and I have time, maybe posting a hint and then a few hours later the solution?). I read this great post from Miguel García and so far so good as I already managed to post something from a script after fumbling my way through Twitter´s Development Portal.

Not quite sure yet where to run the bot. One option would be to set up a raspberry pi, another one would be to explore pythonanywhere which I already used to host the tute app. We´ll see.

PS1: It will be in pythonanywhere, whose free tier allows to run one scheduled task per day (!), which is enough for this. It should run each day at 8am. Let´s see.

PS2: It works! :-) Code in a semi tidy state available in GitHub 

PS3 (October 2024): Bot now also available for Bluesky 





Solutions for today, who would have thought that there are so many ways to solve this puzzle?







Monday, 13 December 2021

Calendar puzzle

This year I am participating again on Advent of Code. So far, so good, let´s see how many stars I manage to get in the end. However this post is not about AoC, but about another puzzle I came across.

It´s a calendar with eight pieces that can hide months and days on table below, so the remaining cells show the date. Apparently you can find a combination for each day of the year (rotating and flipping pieces is allowed). However brute forcing won´t work. I calculated the amount of different positions and it´s a lot of combinations. Looking at the pieces below, there are 96 different ways in which you can place piece A, 98 for B, 82 for C, 154 for D, 151 for E, 80 for F, 196 for G and 154 for H (pieces with simmetries have less possible locations).

So brute forcing this problem would require to loop through each of the 98 positions possible for A, for each one then loop over whatever positions are still possible from the original 82 for B, etc, etc. 

I will give it a try but I wonder if there is a more elegant approach. Hints are welcome.