Implementing BFS in Elixir

After 12 days of adventofcode I think I'm starting to understand Elixir's mindset, or at least I'm starting to write code I wasn't able to read 2 weeks ago. Let's try to use my BFS implementation below to explain some Elixir concepts. Graph Representation Before we can dive into the actual algorithm code for breadth first search we need to figure out a way to store the graph. The original problem input arrived in text format and looked like this: 0 <-> 2 1

Read more

How To: Encrypt Large Files with Python and PyNacl

One limitation of pynacl's concise API is its lack of support for buffered reading. When it comes to large files we can't always load all data to memory in one chunk. This is how I dealt with the problem in a recent project. The Mechanism Pynacl can encrypt and authenticate short blocks (<=16kb is the recommended size). With larger files we'll want to read the file in chunks, encrypt and sign each using pynacl's secret box and then HMAC the entire encrypted data. These are

Read more

Insights from Advent Of Code (Week 1)

My first week solving advent of code has almost ended, which makes it a good time to reflect on the quizzes, my solutions and other solutions I found online. tl;dr Advent of Code is a series of coding quizzes delivered daily during December. Project website is: https://adventofcode.com AOC turned out to be a very nice way to learn a new programming language (I'm learning Elixir). Most puzzles are very easy, as seen in the leaderboard times. Practising a short coding quiz every day

Read more

My Reading List - Dec 2017

Keeping updated on the latest industry trends is an important part of our work. My method is to read new articles briefly as it comes out, and create long readling lists from the ones that look important. I can then read those articles in depth in my own time. It started as a sole project, then I started emailing them locally to friends, and now that I have this blog it seems right to publish it here as well. This is my list of the most

Read more

Solving 24 Puzzle with Elixir

A recent blog post I read reminded me how good computers are at solving puzzles. In the linked post the author solved a game called 24, in which you take 4 digits and need to find an arithmetic combinations of them to reach the number 24. Elixir's strong recursion and pattern matching capabilities are a good match to the challenge. The Gist Let's start with the code. Explanation follows: defmodule Game do def play(ops, [24]) do ops end def play(_ops, [_x]) do false end

Read more