Skip to content

Instantly share code, notes, and snippets.

@sobinsunny
Last active August 9, 2016 06:46
Show Gist options
  • Save sobinsunny/efdf98c0c68a31415f04cf94f46bf10e to your computer and use it in GitHub Desktop.
Save sobinsunny/efdf98c0c68a31415f04cf94f46bf10e to your computer and use it in GitHub Desktop.
problem no-2
module AreAnagrams
def self.are_anagrams?(string_a, string_b)
raise NotImplementedError, 'Not implemented' if string_b.strip.empty? || string_b.strip.empty?
string_a.chars.sort == string_b.chars.sort
end
end
#call object.tests(n), n is the number of tests
class SuperScore
def initialize
@rows = []
end
def tests(number_of_tests)
(1..number_of_tests).each do |test|
puts "Enter #{test} test mark."
value = gets.chomp
@rows.push(value.split(' '))
end
calculate
end
def calculate
output = []
(0..2).each do |i|
output << @rows.max_by { |row| row[i] }[i].to_i
end
"#{output.join(',')} \n #{output.reduce(:+)}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment