Month: February 2018

Sync to my phone

I originally planned to make a Rust program that would fix the broken encodings in my music files. Luckily, I could solve that without Rust. Luckily, because from what I’ve experienced since then, it would’ve been a horrible pain in the ass to do.

I still wanted to give Rust a try. Contributing Servo is pretty much out of question – it’s just too high level to jump into as a complete beginner. (And honestly, I don’t think I’ll get past “complete beginner” with Rust anytime soon if ever.) It wasn’t hard to find another issue.


Android and UTF-8 ID3 tags

Remember I complained about the Unicode tags in some of my MP3 files would be borked really badly on Android? Well, I solved it. Kind of.

For a while I’ve been trying to figure out what could be causing it. Some of my files were fine, some weren’t. Even innocent stuff like umlaut characters in German could break, while Japanese music would be displayed correctly.


Munching the squares of immortality

Become Immortal is at this point the only 1kyu kata I tried (and solved) on CodeWars. It took me 3-4 days to solve it. It was definitely pretty damn difficult to figure out, but in the end I managed it myself.

Looking at the example tests it was immediately obvious that trying to generate the actual rectangles and xoring everything was out of question. For the heck of it I tried once, but even for the last “basic test” I’d run out of memory (on my desktop) very quick. Sure it works fine if the rectangle is 30-40 rows and columns, but not for scales in the millions. I used it to dump rectangles on the console and double check my solution.


Product of integer partitions

Another CodeWars kata, by the same person who did Twice linear. It was annoying in a different way. Once again, a naive solution was out of question (or so I thought), so I kept trying to figure out a way to shortcut the whole problem with maths.

Generating the integer partitions (and their products) isn’t particularly difficult. There are plenty of resources out there about how to do it – though for some reason mostly in Python.


Talk about linear

There’s a CodeWars kata called Twice linear. It’s one of those problems where a naive solution is just not feasible. Not to mention the first tests aren’t indicative of what’s expected so by the time I hit the wall of very big numbers, I already had a solidified (and naive) mental model. Getting rid of that isn’t an easy task.

Generating the list of numbers isn’t difficult. Keeping it sorted and not adding duplicates makes it a bit more tricky. I tried using Ruby’s SortedSet at first, then Enumerators and plain loops, but everything crapped out at bigger numbers. All tests are supposed to run within 12 seconds on CodeWars, and my code at that point was taking 20+ minutes to run for 60000.


CodeWars

I really like Medium’s weekly digest. It keeps providing me with great articles. A few weeks back there was one with advice from a young girl developer, and (among other pretty solid advice) there was a mention of a certain CodeWars. First time I heard of it. This was Thursday evening.

On Sunday I had 50 or so kata behind me and I was challenging an 1kyu one. It’s really addictive, because I just keep pushing the “next kata” button and can’t rest until I’ve dealt with it. However, this approach doesn’t work if I wanted to solve 5 kata a day as advised, because the algo keeps giving me harder and harder challenges, and even “easier” ones end up taking a few hours.