4
\$\begingroup\$

When I first created Japt I was young and innocent, and I didn't know how to use a command line. So I created the interpreter with HTML and incorporated the JavaScript right into that.

As Japt grew up, I added more features, one of which is a set of flags that slightly change the behavior of the program. Because Japt could only be run in the online interpreter, and Japt parses the input as literals (i.e. strings must be wrapped in quotes, arrays in brackets), I just decided to stick flags in the input box.

This is where the confusion lies. Japt currently can't be run directly from the command line (I'm working on that), so there's no way to include flags as actual arguments; they have to be part of the input. So the question is, how should we score flags in Japt? (Or perhaps they should not be allowed at all in their current state?)


Side note: flags can appear anywhere in the input, up against any of the input types, except it can't be touching a number on the right side. So you can stick any individual flag after the end of the input, adding two bytes. For example:

"abc" 123-P

This is parsed as the string "abc", the number 123, and the -P flag.

Other than this, I believe flags in Japt work the same as in any other language. You can do e.g. -Pg!, which will parse as the -P, -g, and -! flags, and you can do e.g. -g3, which will parse as the -g flag with an argument of 3.

Also, I couldn't manage to find our current consensus on how flags are scored in other languages, though I believe it's just the number of bytes added to the command to invoke the flags.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ IMO, you should just add bytes according to the length of each flag, for -g3, add 3 to your byte count. \$\endgroup\$
    – Mr. Xcoder
    Jun 22, 2017 at 18:13

1 Answer 1

6
\$\begingroup\$

The current rules for counting interpreter flags are hidden in this post. But yes, you add the bytes by which the command-line invocation grows.

For your case, I'd just add the bytes that need to be added to the input (including any spaces that might be necessary to separate the arguments from actual input), but you might just want to make your interpreter support regular command-line flags to avoid confusion in the future.

\$\endgroup\$
2
  • \$\begingroup\$ Should this be retroactively applied to existing solutions that count a flag as 1 byte? \$\endgroup\$
    – Shaggy
    Jun 24, 2017 at 14:35
  • \$\begingroup\$ @Shaggy I'd say yes, but don't make a huge deal out of it--just edit answers as you come across them. \$\endgroup\$ Jun 25, 2017 at 13:25

You must log in to answer this question.

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