This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RSpec.describe Stack do | |
before :each do | |
@node3 = Node.new(57, nil) | |
@node2 = Node.new(21, @node3) | |
@node1 = Node.new(34, @node2) | |
@stack = Stack.new | |
end | |
describe "initialize a stack" do | |
it "stack.top should eq nil" do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module StringReverser | |
def self.reverse(input) | |
return nil if input == nil | |
output = [] | |
input.split("").each_with_index do |n,i| | |
output << input[-i-1] | |
end | |
output.join("").to_s | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LargestPrimeFactor | |
def largest_prime_of(number) | |
return nil if number == nil | |
arr = [] | |
(2..number).each do |n| | |
if prime?(n) | |
arr << n | |
end | |
end | |
arr.reject!{|n| number % n != 0} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Uniques | |
def self.cleanup(array) | |
arr = Hash.new(0) | |
array.reject{ |item| (arr[item] += 1) > 1 } | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Factorial | |
def self.of(number) | |
return nil if number == nil | |
arr = [] | |
(1..number).each do |n| | |
arr << n | |
end | |
arr.inject(:*) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class String | |
def rot13 | |
self.tr!("A-Za-z", "N-ZA-Mn-za-m") | |
self | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#... | |
gem 'devise' | |
gem 'omniauth-twitter' | |
gem 'omniauth-facebook' | |
gem "omniauth-google-oauth2" | |
gem "figaro" | |
#... |