####Challenge
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
800000000003600000070090200050007000000045700000100030001000068008500010090000400 |
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| |
###ERb vs. Haml
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} |
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༼つ◕_◕༽つ " |
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<html> | |
<head> | |
<title></title> | |
<link rel="stylesheet" type="text/css" href="style.css" /> | |
<script type="text/javascript" src="http://d3js.org/d3.v3.min.js"></script> | |
<script type="text/javascript" src="http://d3js.org/topojson.v1.min.js"></script> | |
</head> | |
<body> |
I like that this adds a little color to and otherwise dull looking terminal window. From left to right, I'll describe what it includes:
- a fun little alien
- username
- current directory
- Ruby version (via rbenv... you'll have to change this if you use rvm)
- Hearts that deplete throughout the day
This summarizes the things I learned about Sunspot searching while looking throught the source. I included links to specific parts of the source-code. Be sure to check that out if you are curious.
This Job
model will be what the examples below are searching.
class Job < ActiveRecord::Base
searchable do
boolean :requires_expertise
integer :state
time :deadline_at