Skip to content

Instantly share code, notes, and snippets.

def find_movies(flight_length, movie_lengths)
movie_complements = Set.new
movie_lengths.each do |movie_length|
# We have a good movie pair if this length is the complement of a previous movie's length
return true if movie_complements.include? movie_length
# Otherwise, track the complement of this movie's length for checking against succeeding movie lengths
movie_complements << (flight_length - movie_length)
end
@Hamled
Hamled / chair.rb
Created October 13, 2015 21:50
RSpec Example - Chair class
class Chair
def stack(another_chair)
if another_chair.nil?
return [self]
elsif another_chair.is_a? Chair
return [another_chair, self]
else
return another_chair.push(self)
end
end
@Hamled
Hamled / bash_output.txt
Last active October 13, 2015 16:57
RSpec Introduction Examples
$ rspec spec
.
Finished in 0.00121 seconds (files took 0.17275 seconds to load)
1 example, 0 failures
@Hamled
Hamled / advanced_variables.txt
Created October 6, 2015 21:41
Terminal sessions from 10/06/2015 lectures
## Talking about Local Variables and Instance Variables
097 >local_variable = 10
=> 10
098 >@instance_variable = "hi"
=> "hi"
099 >Local_variable = 10
=> 10
100 >Local_variable
=> 10
101 >def bob

Keybase proof

I hereby claim:

  • I am hamled on github.
  • I am hamled (https://keybase.io/hamled) on keybase.
  • I have a public key whose fingerprint is 4F35 1CAF 0D0B 1D00 9CE4 CCF6 4265 F9D0 9BC1 D7EA

To claim this, I am signing this object: