Skip to content

Instantly share code, notes, and snippets.

View romerobrjp's full-sized avatar
🏠
Working from home

Romero Medeiros romerobrjp

🏠
Working from home
View GitHub Profile
@romerobrjp
romerobrjp / fibonacci_memoization.js
Created September 12, 2020 22:55
Solution for fibonacci using the memoization technique
fibonacci function(n, cache) {
cache = cache || {};
if (n === 0) return 0;
if (n === 1) return 1;
if (cache[n]) return cache[n];
return cache[n] = this.fibonacci(n - 1, cache) + this.fibonacci(n - 2, cache);
};
@romerobrjp
romerobrjp / fun_with_anagrams.js
Created August 2, 2020 13:00
Fun with Anagrams
/**
*
*** Fun with Anagrams ***
*
* Given an array of strings, remove each string that is an anagram of an earlier string, then return the remaining array in sorted order.
* Example
* str = ['code', 'doce', 'ecod', 'framer', 'frame']
*
* 'code' and 'doce' are anagrams. Remove 'doce' from the array and keep the first occurrence 'code' in the array.
@romerobrjp
romerobrjp / History\-136f3a9a\entries.json
Last active November 29, 2022 14:22
React Material Table Localization translations PT-BR
{"version":1,"resource":"file:///c%3A/Repos/my-angular-specs/src/app/app.component.ts","entries":[{"id":"OAmg.ts","timestamp":1664325909752},{"id":"xq9U.ts","timestamp":1664326221371},{"id":"IUeI.ts","timestamp":1664326232490},{"id":"7mYA.ts","timestamp":1669679768382},{"id":"ZAqs.ts","source":"undoRedo.source","timestamp":1669679774107}]}
@romerobrjp
romerobrjp / shopcruit.rb
Created January 24, 2017 19:50
Shopify challenge
# You've discovered the Shopify Store 'Shopicruit'.
# Since you're obsessed with lamps and wallets, you want to buy every single lamp
# and wallet variant they have to offer.
# By inspecting the Javascript calls on the store you discovered that the shop lists products
# at http://shopicruit.myshopify.com/products.json.
# Write a program that calculates how much all lamps and wallets would cost you.
# Attach your program (any language) and answer in your reply.
require 'net/http'
require 'json'
@romerobrjp
romerobrjp / multiples_challenge.rb
Last active January 24, 2017 04:31
# 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.
class Challenges
# www.projecteuler.net
# 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.
def multiples_of_3_and_5
(1...1000).select { |n| n if (n % 3 == 0) || (n % 5 == 0) }.inject(:+)
end
end
puts "challenge 1: #{Challenges.new.multiples_of_3_and_5}"
def rot13(secret_messages)
alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz '.split('')
rot13 = 'NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm '.split('')
lookup_hash = {}
alphabet.zip(rot13) do |key, value|
lookup_hash[key] = value
end