LINUX.ORG.RU

История изменений

Исправление TDrive, (текущая версия) :

#!/usr/bin/env ruby

words = IO.read('words').split("\n")
nums = IO.read('nums').split("\n").map(&:to_i)

full_words = File.open('full_words.txt', 'w')
cuted_words = File.open('cuted_words.txt', 'w')

words.each_with_index do |word, n|
  puts new_word = word[0...nums[n]]
  if new_word == word
    full_words.puts new_word
  else
    cuted_words.puts new_word
  end
end

Исходная версия TDrive, :

#!/usr/bin/env ruby

words = IO.read('words').split("\n")
nums = IO.read('nums').split("\n").map(&:to_i)

full_words = File.open('full_words.txt', 'w')
cuted_words = File.open('cuted_words.txt', 'w')

words.each_with_index do |word, n|
  new_word = word[0...nums[n]]
  if new_word == word
    full_words.puts new_word
  else
    cuted_words.puts new_word
  end
end