Last active
June 23, 2019 14:45
-
-
Save miyataka/3f9dc3af254f4b9a482a4a49757a81a5 to your computer and use it in GitHub Desktop.
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
2.3.3 |
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
array = gets.chomp.split(' ') | |
N = array[0].to_i | |
L = array[1].to_i | |
flavor_list = [] | |
N.times do |i| | |
flavor_list.push(L + i) | |
end | |
bite = if N.abs > -L | |
flavor_list.map(&:abs).min | |
else | |
- flavor_list.map(&:abs).min | |
end | |
print flavor_list.inject(:+) - bite |
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
i = gets.chomp | |
prev = '' | |
result = '' | |
i.split('').each do |k| | |
if k == prev | |
result = 'Bad' | |
break | |
else | |
result = 'Good' | |
end | |
prev = k | |
end | |
print result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment