Skip to content

Instantly share code, notes, and snippets.

View tonyta's full-sized avatar

Tony Ta tonyta

View GitHub Profile
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༼つ◕_◕༽つ "
@tonyta
tonyta / anne_gram.rb
Created May 15, 2014 16:56
Anagrams with Anne
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}
@tonyta
tonyta / find_unique.rb
Created February 25, 2014 02:59
sudoku find unique
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|
@tonyta
tonyta / gist:9164378
Created February 23, 2014 00:00
800000000003600000070090200050007000000045700000100030001000068008500010090000400
800000000003600000070090200050007000000045700000100030001000068008500010090000400
@tonyta
tonyta / challenge.md
Last active August 29, 2015 13:55
Project Euler Challenge

Project Euler 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

@tonyta
tonyta / DBC Phase 0 Week 4 - Creating a BoggleBoard Class.md
Last active January 1, 2016 08:49 — forked from dbc-challenges/0.2.1-boggle_class_from_methods.rb
DBC Phase 0 Week 4 - Creating a BoggleBoard Class