15
\$\begingroup\$

Background

SmileBASIC is a BASIC interpreter for the Nintendo 3DS.

Like most versions of BASIC, there is a PRINT command which displays text in the console. (As well as ? which does the same thing)

By default, PRINT moves the cursor to the next row after printing, and this can be disabled by putting a semicolon after the last argument.

Problem

PRINT without ; does NOT output a trailing newline. This can be tested by comparing it with printing a real newline character:

PRINT "TEST1" 'print + move cursor
PRINT "TEST2"+CHR$(10); 'print + newline

Using CHKCHR, you can see that TEST2 has a newline character after it, while TEST1 does not.

You can also use LOCATE to move the cursor without printing newlines or other special characters.

newlines yes

Many challenges ask you to print lines of text separated by newlines (for example, ASCII art). Is it acceptable to move the cursor in a different way (using PRINT or LOCATE)?

newlines no

Other challenges specifically say that trailing newlines are not allowed. Should extra cursor movements not be allowed at all?

\$\endgroup\$
  • \$\begingroup\$ I'm suspicious that there isn't a newline character there. How does CHKCHR work, and how does the system know to print on the next line? \$\endgroup\$ – Nathan Merrill Oct 27 '17 at 22:06
  • \$\begingroup\$ CHKCHR(x,y) returns the ASCII code of the character at x,y in the console. When a newline is printed, the cursor x position is set to 0, and the y position is set to the current line + 1. I guess PRINT just does the same thing on its own. \$\endgroup\$ – 12Me21 Oct 27 '17 at 22:18
  • 2
    \$\begingroup\$ Ah, so instead of the console being an single-dimensional array of characters, in SmileBASIC, its basically a 2D grid of characters? Out of curiousity, what happens if you call CHKCHR on a character you haven't printed over yet? \$\endgroup\$ – Nathan Merrill Oct 27 '17 at 22:19
  • \$\begingroup\$ Is there any way to pipe a program's output to a file in SmileBASIC? \$\endgroup\$ – Jonathan Frech Oct 27 '17 at 22:58
  • \$\begingroup\$ No, you can't do that. \$\endgroup\$ – 12Me21 Oct 28 '17 at 13:52
  • 3
    \$\begingroup\$ I guess the real question I should've asked is "Can cursor movements be used instead of newlines?" \$\endgroup\$ – 12Me21 Oct 28 '17 at 16:27
  • 4
    \$\begingroup\$ Related. The consensus was that, at least for [ascii-art], creating a certain appearance is more important than outputting the exact byte stream (unless that was required). \$\endgroup\$ – Esolanging Fruit Oct 30 '17 at 5:30
  • \$\begingroup\$ @NathanMerrill The console is filled with NULs by default. \$\endgroup\$ – snail_ Nov 1 '17 at 22:13
8
\$\begingroup\$

Existing consensus supports this

As user Challenger5 mentioned in a comment, a previous question about control characters in ascii-art challenges yielded this consensus, which states that challenges are about displaying an image comprised of ASCII characters, NOT about replicating a byte string. Thus the fact that SmileBASIC does not need to use the newline character to separate lines of output is immaterial: Being able to display the requested image means that portion of the challenge is complete, though it does not necessarily exempt an answer from other rules.

With regards to answers banning a trailing newline, I personally think that falls into a similar category as answers banning built-in solutions and if an asker wishes to include the rule anyway then it is THEIR job to be specific about what they ban. Thus, if your solution does not include the newline character after the last line then it doesn't have a trailing newline.

Exceptions

I stated that is not about replicating a byte string. However, there is an overlapping tag which IS often about replicating a byte string: . As a general rule, I would say that any Kolmogorov complexity challenge does require exactly a newline character in the answer's output where there is a newline character in the requested output. This would include challenges which are both ASCII art and Kolmogorov complexity.

\$\endgroup\$
  • 5
    \$\begingroup\$ I disagree with requiring it on challenges that are both ascii-art and kolmogrov-complexity. In my mind, if an ascii-art challenge wants more output 3 lines down, simply jumping 3 lines is totally fine, even if that 3-line-jump is constant every time (making it a kolmogrov-complexity) \$\endgroup\$ – Nathan Merrill Nov 1 '17 at 22:41

You must log in to answer this question.

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