Copy

Permutations With and Without Repetition in Elixir

Hey <<First Name>>,

Another week, another letter.

I spent more time this past week pouring hours into my ongoing Chord project. During one of my hacking sessions, I noticed that a piece of my chord generation code was completely wrong.

If I want to find all possible C major chords on guitar, I need to play at least C, E, and G on three of the strings of my guitar. The remaining strings can be used to play any permutation of those same notes (with repetitions). To implement this, I needed a permutation generator that support both k-length permutations, and the generation of permutations with repetitions.



I couldn’t find one, so I took it as an opportunity to flex my Elixir muscles and build one myself!

Later on, a Redditor suggested that I refactor my solution to use Elixir streams to combat the combinatoric explosion that results from generating long sequences of permutations with repetitions. While I don’t need this for my current project, the idea of encoding my recursive algorithm into a stream’s accumulator is tickling my brain. I might have to revisit this in a future post.

I also dusted off my Secure Meteor project this week. I’ve been sitting on it for quite some time, but I’m motivated to get it released early this coming year.

Away from the computer, I finished reading Mary Doria Russell’s The Sparrow this past week. It’s a fantastic book that reminded me quite a bit of The Left Hand of Darkness. Highly recommended, if you’re into that kind of thing.

What have you been reading lately?

Pete
Copyright © 2018 East5th, All rights reserved.

Want to change how you receive these emails?
You can update your preferences or unsubscribe from this list