Related to the discussion in this post.

There are multiple ways of executing an R-file. Each of these methods have either challenges in input or output. Which are acceptable to count as "Full program" and how do we score them?

The options are:

  • Using the command line command rscript <filename>. This seems to be the most intuitive way to call a script. However, STDIN needs to be explicitly calls when using scan(), which is one of the most popular methods of reading input in full programs. This would become scan(file("stdin")). Also, this requires explicit printing, using cat or print. Both these limitations would invalidate a lot if not all full program submissions.

  • Calling source in the R console. source is similar to Python's import, it executes a given file. STDIN works properly without modifications, but printing is the same problem as rscript.

  • Calling source with argument echo = TRUE (which can be abbreviated to ec=T). This will print all executed lines of code with their output as if they were executed directly in the console.

If I missed any, please let me know.

The question is two-part: Do we allow source as a way to execute or only rscript? If source is allowed, how do we score its arguments?


1 Answer 1


Allow source, add the arguments to bytecount similar to flags.

Preferably the way of executing the file should be mentioned in the post with the solution.

As for scoring, we can consider the ec=T as a flag and add 4 bytes to the bytecount.

  • 1
    \$\begingroup\$ From what I understand (which is limited) of the requirements of a "full program", this seems right, so +1. I had always just used whatever worked on TIO, without giving it much thought. However, it seems to me that adding in bytes to conform to this doesn't add anything to the spirit of the challenge, and will require extra explanations (at least while everyone gets used to it...) in each answer. I suppose this means that I would be in favour of allowing snippets as answers, but that's a more general debate and one that I'm sure has been thoroughly exhausted. \$\endgroup\$ Commented Aug 25, 2017 at 12:50
  • \$\begingroup\$ I understand this feeling. The one thing I can think of that makes those extra bytes relevant is the decision on whether to use a full program or a function. As it stands, those two are really close together in cost in overhead, which makes them pretty competitive. \$\endgroup\$
    – JAD
    Commented Aug 25, 2017 at 13:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .