Skip to content

Instantly share code, notes, and snippets.

View girishkvs's full-sized avatar

Venkata Sai Girish Konda girishkvs

View GitHub Profile
@girishkvs
girishkvs / part01.rb
Created August 5, 2012 14:25 — forked from dmalikov/part01.rb
SAAS homework 1
def palindrome? (string)
filtered = string.downcase.gsub(/\W/,'')
filtered.reverse == filtered
end
def count_words (sentence)
words = sentence.downcase.split(/\W/)
result = {}
words.uniq.select{ |w| !w.empty? }.each do |e|
result.store(e, words.count(e))
@girishkvs
girishkvs / cartesian.rb
Created August 5, 2012 13:22 — forked from andrewdavidcostello/cartesian.rb
SaaS-Class: Homework 2
class CartesianProduct
include Enumerable
def initialize(a,b)
@values = []
@values = a.product(b) unless b.empty?
end
def each(&block)
@values.each {|v| yield v}