Background: Methods in Vitsy are defined by specific indices of lines of code. For example, if I wanted to call the second line of a program, I would call 1m to specify the first index of the methods.

In a recent challenge, I was also asked to count the preceding newline, which sort of made sense, since you needed the newline to even make it a method and the newline was perceived to be the only thing separating it from being a snippet. But then again, how Vitsy does methods in the first place is totally floating; I could put the function 30 or 40 lines down and still call it, but with a different index number.

Should I count this newline, or no?


3 Answers 3


No, do not count it.

This may seem counter-intuitive at first glance, but it is in fact consistent with how we count bytes.

  • We don't count separators in other languages.

    def f(x):return 2*x

    is counted as 19 bytes in Python,

    f()(echo $[2*$1])

    is counted as 17 bytes in Bash, and


    is counted as 7 bytes in Julia.

    All of these function declarations require a newlines before or after them to separate them from the rest of the code.



    as 2 bytes is consistent with that way of counting.

  • We shouldn't count separators in Vitsy or any other language.

    All four snippets define a function on their own, without any surrounding whitespace. A newline is only required if we want to add additional code to the program (like some code that actually calls the function), but not otherwise.

    Separating the function declaration from the caller is part of calling it, not of declarating it, so it shouldn't contribute to the byte count.

    It would be different if we had to submit two functions to a challenge. For example,


    should count as 5 bytes, since we need to separate functions somehow.

    This is consistent with how we count bytes for source code that consists of different files (added byte count, plus one extra byte for every file but the first).

  • The newline "names the function".

    In Python, we allow

    lambda x:2*x

    as well, since it evaluates to a function. To name it (which is required to make the function reusable), we surround it by f= and a newline, none of which contribute to the byte count.

    Prepending a newline to D+ is akin to that, since the function is now callable as <N>m, where N is the 0-based line number.

  • It defines a function, even without a newline.

    The program


    consists of a single, "main" function, which is callable as 0m.

    The main function is executed automatically (which may not be what we want at all), but it is still a callable function.

  • \$\begingroup\$ While I agree that this makes things consistent with other languages, my biggest concern is that this means that there's fundamentally no difference between a snippet and a function. In fact, I'm almost starting to wonder what a "function" is, since it seems like every language with goto could define a "function" the same way... \$\endgroup\$
    – Sp3000
    Commented Feb 27, 2016 at 3:39
  • \$\begingroup\$ A function has to be reusable (per community consensus), while a snippet does not. For example, 2* is not a function in CJam, since there's no way to execute it twice. My main concern with goto would be I/O, since reading from and writing to variables is not allowed. A goto block that reads from STDIN and writes to STDOUT probably isn't worth it anyway... \$\endgroup\$
    – Dennis
    Commented Feb 27, 2016 at 3:42
  • \$\begingroup\$ I don't know Vitsy, but I mean if you had 2* (or equivalent) on a separate line, it'd be a "function" you could keep jumping to, and that would make 2* a valid submission by your rules? \$\endgroup\$
    – Sp3000
    Commented Feb 27, 2016 at 3:47
  • \$\begingroup\$ Yes. If it's (e.g.) on the second line, it can be called with 1m as many times as necessary, making it reusable. (Methods in Vitsy seems to work exactly like links in Jelly, except for the location of the "main" one.) \$\endgroup\$
    – Dennis
    Commented Feb 27, 2016 at 3:51

Yes, count it

If you put it down on the 40th line, it would still be preceded by a linefeed that separates it from the previous function.

Imagine you hadn't use linefeeds, but ; as the separator say. It's impossible to introduce a function without writing at least one ; and every single function introduces exactly one ;. I think it's fair to say that the ; (or in your case the linefeed) is part of the function syntax.

  • \$\begingroup\$ That seems inconsistent with how we score function declarations in other languages. For example, nobody counts the trailing newline in def f(x):return x+1. \$\endgroup\$
    – Dennis
    Commented Feb 19, 2016 at 20:12
  • \$\begingroup\$ @Dennis Maybe we should though since we also count any trailing ; in languages that need them to terminate statements. \$\endgroup\$ Commented Feb 19, 2016 at 20:43
  • \$\begingroup\$ But the function definition doesn't really need it. A file that contains nothing but def f(x):return x+1 defines a function, then exits. You only need whitespace (before or after the declaration) if you actually want to use the function. \$\endgroup\$
    – Dennis
    Commented Feb 19, 2016 at 20:45
  • \$\begingroup\$ @Dennis That's the point of a function definition though, isn't it? \$\endgroup\$ Commented Feb 19, 2016 at 20:45
  • \$\begingroup\$ Sure is, but I'd consider that newline part of using the function, not part of defining it. \$\endgroup\$
    – Dennis
    Commented Feb 19, 2016 at 20:47


The newline is there only to serve as a barrier between the different methods. The newline is not part of the method itself and should not be counted.

  • \$\begingroup\$ The function(...){...} in JavaScript "isn't part of the method itself" either, but it's required syntax to define a function. \$\endgroup\$ Commented Feb 19, 2016 at 13:53
  • \$\begingroup\$ @MartinBüttner Hmm. That's a good point, I hadn't thought of that. I've already +1'd your answer myself. \$\endgroup\$ Commented Feb 19, 2016 at 13:54

You must log in to answer this question.

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