Skip to content

Instantly share code, notes, and snippets.

Grandma

Write a Deaf Grandma program.

Whatever you say to grandma (whatever you type in), she should respond with

HUH?! SPEAK UP, SONNY!

unless you shout it (type in all capitals).

@epoch
epoch / calc2.md
Last active February 23, 2016 22:19
calc2

Wordy Arithmetic

Write a program that takes a word problem in the format:

What is 5 plus 13?

What is 7 minus 5?

What is 6 multiplied by 4?

@epoch
epoch / anagram.md
Created June 25, 2014 22:28
Anagram

Anagram Detector

Write a program that, given a word and a list of possible anagrams, selects the correct one(s).

In other words, given: "listen" and %w(enlists google inlets banana) the program should return "inlets".

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after
@epoch
epoch / example.md
Last active August 29, 2015 14:03
Sinatra Generator

SinatraGenerator

generate a simple hello world sinatra app

Installation

Install it yourself as:

$ gem install sinatra_generator
@epoch
epoch / say_magnitudes.md
Created July 7, 2014 23:16
Say Magnitudes

Say Magnitudes

Write a program that will take a number from 0 to 999,999,999,999 and break it into chunks, adding the magnitude.

In other words, if the input to the program is 1234567890 then the output should be '1 billion 234 million 567 thousand 890'

The program must also report any values that are out of range.

Extensions

@epoch
epoch / etl.md
Last active November 1, 2024 03:42

Extract-Transform-Load

We are going to do the Transform step of an Extract-Transform-Load.

This is a fancy way of saying "We have some crufty, legacy data over in this system, and now we need it in this shiny new system over here, so we're going to migrate this".

Typically, this is followed by "We're only going to need to run this once", which is then typically followed by much forehead slapping and moaning about

Binary

Write a program that will convert a binary number, represented as a string (i.e. "101010"), to it's decimal equivalent using first principles (i.e. no, you may not use built-in ruby libraries or gems to accomplish the conversion).

The program should consider strings specifying an invalid binary as the value 0.

This is how computers work:

# "1011001"
# shortform git commands
alias g='git'
# list all files ever added to a git repo
git log --name-status --oneline --all | grep -P "^[A|M|D]\s" | awk '{print $2}' | sort | uniq
# get current branch
git branch | grep "^*" | sed 's/* //g'
# stage manually deleted files

Sum of Multiples

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.

Write a program that, given a number, can find the sum of all the multiples of 3 or 5 up to and including that number.

Allow the program to be configured to find the sum of multiples of numbers other than 3 and 5.

Source

A variation on Problem 1 at Project Euler