###ERb vs. Haml
export PS1="\n ࿐࿓ \[\033[4;36m\]\u\[\033[m\] \[\033[2m\]\w\[\033[m\] \[\033[31m\]$(ruby -e 'print RUBY_VERSION')\[\033[m\] $(ruby -e "t=Time.now.hour-12;h=t<0?8+t/6*4:3-t/4;f=h==0?'5;':'';puts\"\033[#{f}31m#{'♥'*h+'♡'*(4-h)}\033[m\"")\[\033[m\]\n༼つ◕_◕༽つ " |
require 'benchmark/ips' | |
def anagram_tony?(str1, str2) | |
str1.chars.sort! == str2.chars.sort! | |
end | |
def anagram_enum?(str1, str2) | |
count = Hash.new {0} | |
str1.each_char {|char| count[char] += 1} | |
str2.each_char {|char| count[char] -= 1} |
def find_uniques | |
(1..9).each do |set_num| | |
map_unique( get_grid(set_num) ) | |
end | |
end | |
def map_unique(set) | |
last_mapping = 'hello' | |
loop do | |
(1..9).each do |value| |
800000000003600000070090200050007000000045700000100030001000068008500010090000400 |
Project Euler is a collection of mathy problems that can be solved with simple algorithms implemented in a program. A lot of these problems can be solved using brute-force techniques while others require clever algorithms. Some of these problems could be solved with application of heavy mathmatical theorems, but I solved the first 25 with simple iternations, recursions, and a bit of cleverness, all using Ruby.
Along the way, I learned a ton about working with arrays, parsing with regex, opening files, writing unit-tests, and even built a little toolbox of frequently used utilities (a module containing methods such as is_prime?
, get_divisors
, and even one for converting numbers to written-out English words).
The best part is the feeling you get when figuring something out on your own. That "Aha!" moment is really, really rewarding!
Anyway, you all should check it out. It might look intimidating at first, but the first 25 can definitely be solved wi
####Challenge