This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| class DNA | |
| def initialize( str ) | |
| @strand = str.chars | |
| end | |
| def hamming_distance( str ) | |
| other_strand = str.chars | |
| distance = 0 |
| class Crypto | |
| def initialize(str) | |
| @input = str.downcase | |
| .chars | |
| .keep_if { |c| c =~ /[0-9a-z]/ } | |
| end | |
| def size | |
| Math.sqrt(@input.length).ceil | |
| end |
| <!doctype html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>Page Title</title> | |
| <link rel="stylesheet" href="main.css"> | |
| <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script> | |
| <script src="handlebars.js"></script> | |
| <script src="script.js"></script> | |
| </head> |
| class School | |
| def initialize | |
| @school = {} | |
| end | |
| def add(name, grade) | |
| ( @school[grade] &. << name ) || @school[grade] = [name] # Yay 2.3.0! | |
| end | |
| def grade(grade) |
| class CircularBuffer | |
| def initialize(length) | |
| @buffer = [] | |
| @length = length | |
| end | |
| def read | |
| fail BufferEmptyException.new if @buffer.empty? | |
| @buffer.shift | |
| end |
| class InvalidCodonError < ArgumentError; end | |
| module Translation | |
| def self.of_rna(string) | |
| result = [] | |
| tris = string.chars | |
| .each_slice(3) | |
| .to_a | |
| .map(&:join) |
| class Octal | |
| def initialize(str) | |
| @digits = str.chars | |
| end | |
| def to_decimal | |
| return 0 if @digits.any? { |digit| digit =~ /[^0-7]/ } | |
| @digits | |
| .map(&:to_i) | |
| .reverse |
| module Bed | |
| @bed = [] | |
| def load_bed(obj) | |
| @bed << obj | |
| end | |
| def display_bed_contents | |
| @bed.each {|thing| puts thing} |
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer