Tag Archives: Python

Matching braces in a string

I heard recently about an interview problem involving matching braces in a string. Checking to see if all the braces in a string are paired up in the proper order. Seemed like an interesting, and short, challenge.

Examples of strings with proper brace matching: "()", "(){}[]", "([{}])"

Examples of strings without proper brace matching: "(", "[]]", "([)]"

Continue reading Matching braces in a string

Building a reddit bot

It’s spoiler time for the upcoming Magic: the Gathering set. During this time a lot of images get posted to reddit. Unfortunately a lot of people can’t see those images because magic.wizards.com is blocked for them. Imgur however, often is not. I happen to be one of those people. Whenever I would see a post about a new card I would click it only to see that the content is blocked. Then I’d check the comments to see if anybody re-posted it on imgur, most of the time nobody had.

I figured this would be a good opportunity to try to create a bot that does just that!

Continue reading Building a reddit bot

Converting minutes into a readable string

I’d like to start posting some shorter entries. Hopefully that will be more conducive to making posts more often. I’m going to start tagging these as Short Code entries.

For this first one I came across a challenge on reddit about converting a quantity of minutes into a readable string, paraphrasing here:

Write a function that takes in a number of minutes as an integer and returns a string of the format “# years, # months, # days, # hours, #minutes”.

Continue reading Converting minutes into a readable string

Langton’s Ant

langton_good

A little while ago I came across the topic of Cellular Automata. I was fascinated about the idea that complex (and even Turing-complete) behavior can come from a system that follows a few simple rules.

One of the more simple types of cellular automaton is Langton’s ant. This type seemed like a good choice to start with. I’ve been wanting to get into Python for a while now so I figured this would be a good project to get my feet wet.

Continue reading Langton’s Ant