Skip to content

Instantly share code, notes, and snippets.

View jjuliano's full-sized avatar

Joel Bryan Juliano jjuliano

View GitHub Profile
@jjuliano
jjuliano / my_application_controller.rb
Created July 11, 2012 20:37
[Rubymotion] UITableView and UITableViewCell using SimpleView (https://github.com/seanho/SimpleView) taken from Teacup example by Colinta (http://colinta.com/thoughts/aw_hell_its_a_table_cell.html). [refactor to use more SimpleView convention for tagging,
class MyApplicationController < UIViewController
def viewDidLoad
@data = [
{ icon: 'niftywow',
project: 'NiftyWow',
description: "Oh you just can't imagine.",
logos: ['apple', 'github']
},
{ icon: 'amazingwhizbang',
@jjuliano
jjuliano / euler-001.rb
Created December 9, 2012 01:37
Add all the natural numbers below one thousand that are multiples of 3 or 5.
#!/usr/bin/env ruby
# Problem: Add all the natural numbers below one thousand that are multiples of 3 or 5.
# Description: 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.
sum = 0
limit = 1000 - 1
@jjuliano
jjuliano / euler-002.rb
Created December 10, 2012 01:34
Find the sum of all the even-valued terms in the Fibonacci sequence which do not exceed four million.
#!/usr/bin/env ruby
#
# Problem: Find the sum of all the even-valued terms in the Fibonacci sequence which do not exceed four million.
# Description: 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, ...
#
# Find the sum of all the even-valued terms in the sequence which do not exceed four million.
#
# Solution:
@jjuliano
jjuliano / euler-003.rb
Created December 12, 2012 08:17
Find the largest prime factor of a composite number.
#!/usr/bin/env ruby
# Problem: Find the largest prime factor of a composite number.
# Description: The prime factors of 13195 are 5, 7, 13 and 29.
#
# What is the largest prime factor of the number 600851475143?
# Solution:
number = 600851475143
@jjuliano
jjuliano / euler-004.rb
Created December 12, 2012 08:24
Find the largest palindrome made from the product of two 3-digit numbers
#!/usr/bin/env ruby
# 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 palin-
# drome made from the product of two 3-digit numbers.
# Solution:
palindromes = []
(100..999).each do |x|
(100..999).each do |y|
@jjuliano
jjuliano / euler-005.rb
Created December 12, 2012 08:26
What is the difference between the sum of the squares and the square of sums?
#!/usr/bin/env ruby
# The sum of the squares of the first ten natural numbers is,
# 12 + 22 + ... + 102 = 385
# The square of the sum of the first ten natural numbers is,
# (1 + 2 + ... + 10)2 = 552 = 3025
# Hence the difference between the sum of the squares of the first ten natural
# numbers and the square of the sum is 3025 385 = 2640.
# Find the difference between the sum of the squares of the first one hundred natu-
# ral numbers and the square of the sum.
@jjuliano
jjuliano / euler-006.rb
Created December 12, 2012 08:35
Find the 10001st prime.
#!/usr/bin/env ruby
# By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
# What is the 10001st prime number?
# Solution:
primes, remainder = [], []
limit = 10001
rangemax = limit/10
n = 2

Keybase proof

I hereby claim:

  • I am jjuliano on github.
  • I am joelbryan (https://keybase.io/joelbryan) on keybase.
  • I have a public key whose fingerprint is 84BA 318B DD8B E94F 94E5 3A6E E6D7 F776 CE6D E3A7

To claim this, I am signing this object:

class Dog
def initialize(breed)
@breed = breed
end
def kind
@breed
end
end
package main
import "fmt"
type dog struct {
breed string
}
func main() {
kind := dog{