Skip to content

Instantly share code, notes, and snippets.

View andersr's full-sized avatar
😅
Focusing

Anders Ramsay andersr

😅
Focusing
View GitHub Profile
@andersr
andersr / detect_anagram.rb
Created October 7, 2013 13:40
Anagram detector
class Anagram
attr_accessor :candidate, :list
def initialize(candidate)
@candidate = candidate
@list = list
end
def match(list)
list.select do |item|
@andersr
andersr / jukebox_spec.rb
Last active December 25, 2015 02:39
jukebox_spec.rb
require 'simplecov'
SimpleCov.start
require 'json'
require 'rspec'
require_relative 'spec_helper'
require_relative 'jukebox'
require_relative 'song'
#use this song data for your tests
songs = [
@andersr
andersr / triangle_check.rb
Created October 11, 2013 14:48
What type of Triangle?
#not posted
@andersr
andersr / convert_to_roman.rb
Created October 11, 2013 14:49
Convert Arab to Roman Numerals
#not posted
@andersr
andersr / binary_handshake.rb
Created October 11, 2013 14:51
Binary Handshake
# not posted yet
@andersr
andersr / tower_of_hanoi.rb
Created October 11, 2013 14:53
Tower of Hanoi
#not posted
@andersr
andersr / pigeon_organizer.rb
Created October 11, 2013 14:54
NYC Pigeon Organizer
#not posted

##Alien Sandwich A numbered list of instructions for making a peanut butter and jelly sandwich.

  1. Hello Alien!
  2. IF you have a left and a right arm AND IF you have something at the end of each arm that can grasp objects AND IF you are able to visually distinguish between different object shapes and colors, continue to the next step, ELSE stop here. No PBJ sandwich for you, sorry!
  3. Henceforth, your Left Hand will be referred to as "LH" and your Right Arm will be referred to as "RH"
  4. Next, we will collect and label all the objects on the table.
  5. Reach out and grasp an object on the table.
  6. IF the object is round and flat, this object is a "Plate" ELSE IF the object is soft to the touch, this object is "Bread Loaf" ELSE IF the object is narrow with one side that is sharp to the touch, this object is a "Knife" ELSE IF the object is hard, has a cylindrical shape and you can see a brown substance inside, this is a "Peanut Butter Jar" ELSE the object is a "Jelly Jar"
  7. Set down the object in an empty s
# Download this file:
# https://gist.github.com/aviflombaum/28534c5d69edd2439a7d/download
# Run it from your terminal with:
# ruby ruby.basics.rb
# (Just make sure you are in the right directory)
# ======================================
# Ignore All This Code
# ======================================
fizz, buzz, fizz_buzz, no_buzz = [], [], [], []
(1..50).each do |n|
if (n % 3 == 0) && (n % 5 == 0)
fizz_buzz.push(n)
elsif n % 3 == 0
fizz.push(n)
elsif n % 5 == 0
buzz.push(n)
else