Skip to content

Instantly share code, notes, and snippets.

def stock_picker(prices)
stock_size = prices.size
results = Array.new(stock_size) { Array.new(3, 0) }
prices.each_with_index do |stock, i|
best_diff = [0, 0, 0]
sub_array = prices[i+1..-1]
sub_array.each do |next_stock|
diff = stock - next_stock
def caesar_cipher(msg, shift)
# ascii codes for alphabet
# A - Z : 65 - 90
# a - z : 97 - 122
asciis = []
msg.each_char { |char| asciis << char.ord }
shifted = asciis.map do |ascii|
if ascii.between?(65, 90)
@remyroo
remyroo / recursion_challenges.rb
Created November 24, 2021 10:07
Exercises from The Odin Project
# Factorial
def factorial(num)
return 1 if num <= 1
num * factorial(num - 1)
end
p factorial(3)
# using enumerable:
def fact(num)
@remyroo
remyroo / collection_challenges.rb
Created November 24, 2021 10:07
Exercises from Turing School
puts 'ANIMALS'
animals = [:dog, :cat, :zebra, :quokka, :unicorn, :bear]
p animals.map(&:to_s)
result = animals.select { |animal| animal.length >= 4 }
p result
nested_animals = [[:dog, :cat, :zebra], [:quokka, :unicorn, :bear]]
p nested_animals.flatten.map(&:to_s)
b = {}
@remyroo
remyroo / pygmaroo.md
Last active June 6, 2020 14:32
A gently tweaked version of the Pygmalion theme for Oh My Zsh

pygmaroo.zsh-theme

I lightly tweaked the Pygmalion theme to better suit my needs.

Features

Includes username, file path, git branch, dirty branch indicator (⚡) and virtualenv name.

Screenshot

Screenshot 2020-06-06 at 16 57 23

Installation