Skip to content

Instantly share code, notes, and snippets.

View gavinmcgimpsey's full-sized avatar

Gavin McGimpsey gavinmcgimpsey

View GitHub Profile
class DNA
def initialize( str )
@strand = str.chars
end
def hamming_distance( str )
other_strand = str.chars
distance = 0
@gavinmcgimpsey
gavinmcgimpsey / crypto_square.rb
Last active May 6, 2016 05:46
Launch School challenge - crypto square
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
@gavinmcgimpsey
gavinmcgimpsey / html5_stub.html
Last active May 7, 2016 13:05 — forked from awrowse/html5_stub.html
HTML5 Page Stub
<!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
@gavinmcgimpsey
gavinmcgimpsey / protein_translation.rb
Created January 14, 2016 21:46
RNA Translation Exercise
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}