8
\$\begingroup\$

While there are only a few users of the Vitsy programming language right now, I wish to create a place for tips for golfing in Vitsy.

What general tips do you have for golfing in Vitsy? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Vitsy (e.g. "remove NOPs" is not an answer). Please post one tip per answer.

For reference, the online interpreter is here, the esolang page is here, and you can receive answer-per-answer help here.

\$\endgroup\$
0

3 Answers 3

2
\$\begingroup\$

Remember that \[] always runs at least once

Even if the top item of the stack is zero or less, \[] always runs. Think of it more as a do{}for(); loop. This has caught me off more than once, but it is important.

\$\endgroup\$
2
\$\begingroup\$

Do not doubt the power of m

Background: Fm calls the a specified line index in the current Vitsy class. (F is the line index you seek).

The m command (method) has saved me literally hundreds of bytes in the past. Any algorithm that uses repeated steps, or a common character sequence (such as D1M- (floor algorithm)).

This is extremely helpful in repetitive kolmogorov complexity challenges.

Instead of:

WD1M-(something else here)WD1M-(something different)WD1M-l\[NaO]

Use:

1m(something else here)1m(something different)1ml\[NaO]
WD1M-

(floor(prompt))

Also, you can return from method statements with ;, allowing for looping until condition(s) (over the general [ ] syntax, which isn't as powerful):

1mN
<;)

(loops through code until finding non-zero, popping it from the stack and returning to first line)

\$\endgroup\$
2
  • \$\begingroup\$ Since many people here don't know vitsy, perhaps briefly explain what m does? \$\endgroup\$
    – Cyoce
    Commented Feb 10, 2016 at 22:49
  • \$\begingroup\$ @Cyoce Yes, sorry. c: Corrected. \$\endgroup\$ Commented Feb 10, 2016 at 23:01
1
\$\begingroup\$

Filling Zeroes on an Empty Stack

Normally, to fill up the stack with a number, you would do something like this:

a\a

This fills up the stack with 10 10s, by pushing 10 10 times. However, if you wanted to push 10 0s, you'd do this:

a\0

After a recent update, however, the stack will attempt to fix for IndexOutOfBoundsExceptions by pushing 0s to a possibly empty stack, meaning that, if on an empty stack, you can do:

a%

Since % calls multistack, it tries to access every member between the top item (which is nothing after it pops 10) and the index you specify. Therefore, you get a stack with 10 0s when this is called. You can use this trick up to approximately 11380, although, annoyingly, it doesn't always go to a specific point...

UNKNOWN:Desktop addisonc17$ vitsy --code "2d^2b^+2a^+26^+25^+24^+5+%lNaO"
java.lang.StackOverflowError thrown in [command line] at command #0,25: %
UNKNOWN:Desktop addisonc17$ vitsy --code "2d^2b^+2a^+26^+25^+24^+5+%lNaO"
11381

Past that, you'll have to use the normal duplication method.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.