Created
November 22, 2011 11:43
-
-
Save evandrix/1385484 to your computer and use it in GitHub Desktop.
Extreme Startup submission - SWEng tutorial Mon 21Nov11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
require 'logger' | |
log = Logger.new(STDOUT) | |
log.level = Logger::DEBUG | |
get '/' do | |
if params[:q] | |
log.debug(params[:q]) | |
sz_q = params[:q].split(": ")[1] | |
if sz_q =~ /anagram/ | |
sz_word = sz_q.split(" ")[-1].gsub('"','') | |
sum = 0 | |
sz_word.each_byte { |c| sum+=c } | |
words = params[:q].split(": ")[2].split(", ") | |
theWord = "" | |
words.each do |word| | |
sum_word = 0 | |
word.each_byte { |c| sum_word+=c } | |
if sum == sum_word | |
theWord = word | |
break | |
end | |
end | |
return theWord | |
elsif sz_q =~ /^what is (\d+) plus (\d+) plus (\d+)$/ | |
return ($1.to_i + $2.to_i + $3.to_i).to_s | |
elsif sz_q =~ /^what is (\d+) multiplied by (\d+) plus (\d+)$/ | |
return ($1.to_i * $2.to_i + $3.to_i).to_s | |
elsif sz_q =~ /^what is (\d+) plus (\d+) multiplied by (\d+)$/ | |
return (($1.to_i + $2.to_i) * $3.to_i).to_s | |
elsif sz_q =~ /^what is (\d+) plus (\d+)$/ | |
return ($1.to_i + $2.to_i).to_s | |
elsif sz_q =~ /^what is the english scrabble score of (\s+)$/ | |
return $1 | |
end | |
end | |
"lwy08" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment