1
\$\begingroup\$

Background

Many BASIC dialects idiomatically use DATA and READ commands to store and read input data from the source code. We appear to have a consensus that this form of input is valid in these languages, however we have not formed a consensus on how to score solutions that use this approach.

The Question

Given a snippet of the form shown below, how should it be scored?

Yabasic, ??? bytes

DATA 2
DATA 3
DIM primes(4)
FOR i = 1 TO 4
  READ primes(i)
  PRINT primes(i)
NEXT
DATA 5
DATA 7

Try it online!

\$\endgroup\$

2 Answers 2

0
\$\begingroup\$

All Read Bytes Should Be Scored

Snippets should be split into header, code, and footer sections, with all DATA calls in the header and/or footer. All other code will contribute to byte count.

Example

Yabasic, 68 bytes

Header (not counted)
DATA 2
DATA 3
Code
DIM primes(4)
FOR i = 1 TO 4
  READ primes(i)
  PRINT primes(i)
NEXT
Footer (not counted)
DATA 5
DATA 7

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ I would generally support this approach, as works well with TIO - style online editors, and should be flexible enough to work with most languages in most situations \$\endgroup\$ Apr 8 at 16:53
-1
\$\begingroup\$

All Non-data Bytes Should Be Scored

All Non-data (that is data, not DATA) bytes, including all required DATA calls, as well as all necessary spaces, newlines, etc.

Example

Yabasic, 92 bytes

Note: all # in the below snippet represent points of user input, and do not contribute to the byte count

DATA #
DATA #
DIM primes(4)
FOR i = 1 TO 4
  READ primes(i)
  PRINT primes(i)
NEXT
DATA #
DATA #

Try it online!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ I would recommend against this approach, as it does not work well with TIO style editors, variable input lengths, and leaves a large amount of ambiguity around inputs of the form DATA 1,2,3 - do the commas count? what if commas are not legal in your dialect? how do you handle variable length input? \$\endgroup\$ Apr 8 at 16:57

You must log in to answer this question.

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