Last active
August 9, 2016 06:46
-
-
Save sobinsunny/efdf98c0c68a31415f04cf94f46bf10e to your computer and use it in GitHub Desktop.
problem no-2
This file contains 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
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 |
This file contains 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
#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