Skip to content

Instantly share code, notes, and snippets.

View ryanoneill's full-sized avatar

Ryan O'Neill ryanoneill

  • San Francisco, CA
View GitHub Profile

Keybase proof

I hereby claim:

  • I am ryanoneill on github.
  • I am ryanoneill (https://keybase.io/ryanoneill) on keybase.
  • I have a public key whose fingerprint is B8A6 FC7B AAA1 1D67 8B3D 334F E0FE C719 A035 40E1

To claim this, I am signing this object:

@ryanoneill
ryanoneill / minimum_coins_change.py
Created May 22, 2012 01:56
Find Smallest Number of Coins for Exact Change Given Denominations
#!/usr/bin/python
import sys
def minimum_coins_change(denominations, value):
# Find the minimum number of coins necessary to
# provide the exact change. If exact change is
# not possible, return None
result = None
@ryanoneill
ryanoneill / anagrams.py
Created May 16, 2012 17:30
Simple Anagrams Lookup
#!/usr/bin/python
# Converts a word to a hash key
# by taking the word, converting it
# to lowercase, sorting the letters
# and combining the word back as a
# string
def word_to_key(word):
return ''.join(sorted(word.lower()))
@ryanoneill
ryanoneill / Problem05.scala
Created April 25, 2012 20:00
Project Euler - Problem 05 - What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
// http://projecteuler.net/problem=5
// 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
// What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
object Problem05 {
def main(args: Array[String]) {
val numbersToTen = (1 to 10).toList
println("Lowest Common Multiple of 1 to 10: " + lcmList(numbersToTen))
@ryanoneill
ryanoneill / Problem04.scala
Created April 25, 2012 19:59
Project Euler - Problem 04 - Find the largest palindrome made from the product of two 3-digit numbers.
// http://projecteuler.net/problem=4
// A palindromic number reads the same both ways. The largest palindrome made
// from the product of two 2-digit numbers is 9009 = 91 99.
// Find the largest palindrome made from the product of two 3-digit numbers.
object Problem04 {
def main(args: Array[String]) {
@ryanoneill
ryanoneill / Problem03.scala
Created April 25, 2012 19:55
Project Euler - Problem 03 - What is the largest prime factor of the number 600851475143 ?
// http://projecteuler.net/problem=3
//The prime factors of 13195 are 5, 7, 13 and 29.
//What is the largest prime factor of the number 600851475143 ?
object Problem03 {
def main(args: Array[String]) {
//val number = 13195
val number = 600851475143L
@ryanoneill
ryanoneill / Problem02.scala
Created April 25, 2012 19:41
Project Euler - Problem 02 - Find the sum of the even-valued terms.
// http://projecteuler.net/problem=2
// Each new term in the Fibonacci sequence is generated by adding the previous two terms.
// By starting with 1 and 2, the first 10 terms will be:
// 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
// By considering the terms in the Fibonacci sequence whose values do not exceed four million,
// find the sum of the even-valued terms.
@ryanoneill
ryanoneill / Problem01.scala
Created April 25, 2012 02:40
Project Euler Problem 01 - Find the sum of all the multiples of 3 or 5 below 1000.
// http://projecteuler.net/problem=1
// 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.
// Find the sum of all the multiples of 3 or 5 below 1000.
object Problem01 {
def main(args: Array[String]) {
val output = "Sum of [3,5] multiples below %d: "
@ryanoneill
ryanoneill / build.sbt
Created April 9, 2012 04:24
Very Simple Build.sbt File for Lift on Heroku
import com.typesafe.startscript.StartScriptPlugin
name := "Lift Hello World"
seq(StartScriptPlugin.startScriptForClassesSettings: _*)
libraryDependencies ++= {
Seq(
"org.eclipse.jetty" % "jetty-server" % "7.5.4.v20111024" % "compile->default",
"org.eclipse.jetty" % "jetty-servlet" % "7.5.4.v20111024" % "compile->default",
@ryanoneill
ryanoneill / web.xml
Created April 9, 2012 04:14
Very Simple Web Configuration for Lift on Heroku
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<filter>
<filter-name>LiftFilter</filter-name>
<display-name>Lift Filter</display-name>