1

I found this ruby problem on RubyQuiz, which states besides the problem itself, the following:

"The script should be a standard Unix filter, reading from files specified on the command-line or STDIN and writing to STDOUT. Each line of input will contain one integer (between 1 and 3999) expressed as an Arabic or Roman numeral"

I have no idea how to do a Unix Filter using Ruby.. to read files in this case,

Could somebody please enlighten me on how to accomplish this task in the best way possible.

Thanks as always!

jlstr
  • 2,986
  • 6
  • 43
  • 60

1 Answers1

3

The best way to read files from STDIN is using ARGF, as explained in this answer: Best practices with STDIN in Ruby?

You can write to STDOUT using puts or printf.

For more detailed info about IO in Ruby, read the Ruby Doc: http://www.ruby-doc.org/core/classes/IO.html

Community
  • 1
  • 1
Sam Grossberg
  • 1,306
  • 1
  • 13
  • 28