Skip to content

Instantly share code, notes, and snippets.

@inohiro
Created May 27, 2012 13:30
Show Gist options
  • Save inohiro/2814218 to your computer and use it in GitHub Desktop.
Save inohiro/2814218 to your computer and use it in GitHub Desktop.
atcoder3_B
def compare_swap( words )
counter = 0
for i in 0..( words.size - 1 )
break if i == words.size
word = words[i]
puts "word: #{word}"
lastchar = word[word.length - 1].bytes.first
later = []
for j in ( i + 1 )..words.size
compare = words[j]
puts "compare: #{compare}"
comp_lastchar = compare[compare.length - 1].bytes.first
p '==================='
pp lastchar
pp comp_lastchar
if lastchar > comp_lastchar
p '@@@@@@@@@@@@@@@@@'
pp words
words[i], words[j] = words[j], words[i]
pp words
# elsif lastchar == comp_lastchar
# later << words[i]
# later << words[j]
end
pp words
end
end
end
def main
length = gets.to_i
words = []
length.times do
word = gets
words << word.slice( 0..( word.length - 2 ) )
end
require 'pp'
result = []
shortest = 100
words.each do |word|
if shortest > word.length
shortest = word.length
end
end
compare_swap( words )
end
main
@loveybot
Copy link

Yay Ruby!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment