Skip to content

Instantly share code, notes, and snippets.

@malandrina
malandrina / gist:3745321
Created September 18, 2012 19:35
Anagram solvers for same-length anagrams, in Ruby

Anagram solvers for same-length, single word anagrams, in Ruby

I wanted to write an anagram solver that would return a list of the anagrams of the same length of a given word/combination of characters, such that:

same_length_anagrams("deify") => "edify"

or

same_length_anagrams("ogb") => "bog", "gob"

@malandrina
malandrina / gist:3744867
Created September 18, 2012 18:26
Implementing a Reverse Polish Notation Calculator in Ruby

Implementing a Reverse Polish notation calculator in Ruby

A couple weeks ago I had a go at implementing an RPN calculator in Ruby. I knew I wanted the calculator to function by popping operands out of an array populated with the values of the input expression, operating upon the operands with the appropriate operator, and pushing the result back into the stack of operands.

I was able to implement this in version 1, but it took forever and the resulting code was not very beautiful. Why?

  • I started coding before I had a thorough understanding of RPN

    Wait, 20 10 5 4 + * - is what now?