2
\$\begingroup\$

...or I guess more specifically, can I require that input from STDIN (or closest alternative, e.g. TIO) be newline terminated?

Utilising apps like TIO this isn't added, but if using a terminal with <<< a newline is appended, it can only be omitted using something like echo -n ... | script. I've definitely used either as it suits me, but I don't know if that's appropriate or not.

A specific example of this is my answer to this question which could save two bytes assuming a newline exists on the input, but would necessitate TIO having an explicit terminating newline.


This has an answer in the I/O defaults

Thanks to @Bubbler for clarifying.

My read on this is that you may specify either way as your answer requires.

\$\endgroup\$
3
  • 2
    \$\begingroup\$ I think this case is covered by this default I/O. In the challenge, newlines are guaranteed to not appear in the input string, so you can use it as the "sentinel" (which means the input will always be <input string><newline> for your program). \$\endgroup\$
    – Bubbler
    Aug 2, 2022 at 22:59
  • \$\begingroup\$ Ok great, so I could just specify in answers for clarity that newline is either required or must be omitted. \$\endgroup\$ Aug 3, 2022 at 12:15
  • 1
    \$\begingroup\$ Possible duplicate of Default for Code Golf: Input/Output methods \$\endgroup\$ Aug 18, 2022 at 3:29

1 Answer 1

2
\$\begingroup\$

Use either, specify what's required

This fits with flexible I/O but could be contentious, it's what I feel is the most forgiving and I don't see how this could be abused for any meaningful score reduction, but I could be missing something!

\$\endgroup\$

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