text:
Code Golf: Your own pet ASCII snake
So, I wrote myself a one-liner which printed out a snake on the console. It's a bit of fun, and I wondered how I might condense my code...
Here's a (short) example output:
                +
                 +
                  +
                   +
                   +
                   +
                  +
                   +
                    +
                    +
                    +
                     +
                     +
                      +
                      +
                       +
                      +
                     +
                     +
                    +

Here's the specs:

In each line, a single non-whitespace character (whichever you like) is printed to the console, initially with 29 to 31 spaces padding to the left of it.
Each iteration, a random decision is made between these three actions

The amount of padding decreases by 1
The amount of padding remains the same
The amount of padding increases by 1

Do this 30 times, to print 30-segment long a snake to the console.
The shortest answer in bytes wins.

Can we return an array of lines? Are leading/trailing spaces or newlines allowed?

@Shaggy I want to see the snake. I don't care if it's an array, as long as it's printed to a console and you can see it.

"is printed to the console" implies a full-program only, but the default on PPCG is to allow functions too (which I recommend)

I assume trailing spaces on each line are allowed, right?

What should happen on a screen with less than 30 columns for text?  Can we start with cols/2 padding and iterate cols/2 times, or should the snake just wrap around?

What does "random" mean? Uniformly random? Random from any distribution with positive support on each of the three outcomes? Random from any distribution whatsoever? Do the results have to be different on each run of the program?

Note that, by default, random does not mean uniformly so. For example, the second part of my brainfuck answer is (as of now)  perfectly valid, despite it generating a straight line most of the time.

Seriously has nobody made a golfing language yet that takes as input a Stack Exchange question ID number?

Right now, there are two points that are unclear: 1) Does random mean uniformly random? (affects this answer) and 2) Must the output be different every time? (i.e., can the random number generator be unseeded? Affects this answer)

05AB1E, 15 14 bytes
30DF2Ý<+ΩD0sú,

Try it online!
Uses 0.
Explanation
30DF2Ý<+ΩD0sú,
30D            # Push 30 to the stack (One for the amount of iterations we are going to perform and one for the initial padding)
   F           # Pop one of the 30s and perform the following that many times...
    2Ý          # Push [0,1,2] ...
      <         # and create [-1,0,1] from that
       +        # Add the last padding to every entry (e.g. 30 in the beginning resulting in [29,30,31]
        Ω       # Pick one of the results at random ...
         D      # and push it to the stack twice
          0     # Push 0 (Any character will work fine here) ...
           sú   # and pad it with the randomly chosen amount of spaces in the front
             ,  # Finally print the result with a trailing newline

05AB1E: 0-bytes, Try it online!... wait, no, almost though.

Random Brainfuck, 123 122 121 bytes
+[--[<]>>+<-]>+[->+>+>+<<<]++++++++++>>++<[>>[->+<<.>]>[-<+>]>?>+++<[>->+<[>]>[<+>-]<<[<]>-]>-->,<[-<<<+>>>]<<<<+.-<<.>-]

Try it online!
Random Brainfuck is an extension of brainfuck, with the helpful addition of the ? command, which sets the current cell to a random byte. This prints a snake made of !s, which looks more like footsteps than a snake funnily enough.
How It Works:
+[--[<]>>+<-]>+ Create the value 30
[->+>+>+<<<]    Copy it three times
++++++++++      Create a newline cell
>>++<            Adds 2 to the second copy to make it a space and move to the counter
[ While counter
  >>[->+<<.>]>[-<+>] Print out the padding cell number of spaces
  ?>+++<[>->+<[>]>[<+>-]<<[<]>-] Get 3-(random byte%3)
  >-->,<[-<<<+>>>]   Add (result-2) to the padding cell
  <<<<+.-<           Print an exclamation mark
  <<.                Print a newline
  >-                 Decrement counter
] end loop

Another solution that sticks to the letter of the question, rather than the spirit.
87 bytes
+[--[<]>>+<-]>+[->+>+>+<<<]++++++++++>++>[>[->+<<<.>>]>[-<+>]?[,<+>]?[,<->]<<<+.-<.>>-]

Try it online!
This one is heavily biased towards leaving the padding alone, but increasing or decreasing the padding are both equally possible. Each one has a slightly less than 1 in 256 chance to happen.

Very nice! I was unaware of the ? command. +1

@GrantMiller ? is only available in Random Brainfuck, not classic brainfuck

C (gcc), 61 58 56 bytes
Answer edited to reflect rules changes...
i;f(s){for(s=i=31;--i;printf("%*d\n",s+=1-rand()%3,8));}

Try it online!

save a byte by moving s+=1-rand()%3 to the printf function. i;f(s){for(s=i=31;--i;)printf("%*c\n",s+=1-rand()%3,43);}

@Vaelus That makes the first line have a varying amount of spaces instead of the 30 specified in the question.

@Steadybox Which is allowed in the comments apparently..

JavaScript (ES8), 63 62 60 bytes
Includes a trailing newline. *2-1 could be replaced with -.5 for a 1 byte saving but the chances of each line being the same length as the previous line would be greatly increased. Of course, as "random" isn't defined in the challenge, the RNG could be replaced with new Date%3-1 for a total byte count of 55.
f=(x=y=30)=>x?``.padEnd(y+=Math.random()*2-1)+`+
`+f(--x):``

Saved a byte thanks to someone who deleted their comment before I could catch the name. I'd actually tried it this way with repeat and padStart but didn't think to try padEnd - don't know why!

o.innerText=(
f=(x=y=30)=>x?``.padEnd(y+=Math.random()*2-1)+`+
`+f(--x):``
)()

Bonus
For the same number of bytes, here's a version that takes the number of starting spaces & iterations as input.
f=(x,y=x)=>x?``.padEnd(y)+`+
`+f(--x,y+Math.random()*2-1):``

o.innerText=(
f=(x,y=x)=>x?``.padEnd(y)+`+
`+f(--x,y+Math.random()*2-1):``
)(i.value=30);oninput=_=>o.innerText=f(+i.value)
<input id=i type=number>

f=(x=y=30)=>x?\+\n`.padStart(y+=Math.random()*2-1)+f(--x):```
is one byte shorter.
(Note: Since SO doesn't allow line breaks in comments, I had to type \n instead of actually using a line break.)

Thanks, @Stefnotch. Unfortunately, even with an initial value of y=31, there would be a possibility of the first line being too short. https://tio.run/##BcFLDsIgEADQvSeZkUCs7kzQE7hyqSYzKfRjKBCYGHp6fO/LP65jWbPomJzvY4o1BW9CmgH6ZKHZ3V4GtDet253UgUxm9xQuAruyD5bFFI4ubYDHsx5QTdDwStQR0NQcVqF3pNfpY4KPsyzY/w

Correct me if I'm wrong, but doesn't your current solution also suffer from that issue?

Not quite, @Stefnotch. The first line should contain 29-31 spaces. In my version, we start with y=30, add -1, 0 or 1 to that and then pad an empty string out to that length, giving us the required number of spaces. In your version, though, the string we're padding is already 2 characters long so the padStart would only add 27-29 spaces to it. Even if the initial value of y was raised to 31, which wouldn't cost any bytes, we'd still only end up with 28-30 spaces.

Oh, I see. Then, couldn't you just use an initial value of 32? (29-31 spaces)

@Stefnotch, I could but it would cost me more than the 1 byte saving as x and y would have to be initiated individually.

The first line should have exactly 30 spaces, according to the challenge.

@Nit, the OP has confirmed that the first line may contain 29-31 spaces but has yet to edit that fact into the challenge, despite repeated requests to do so.

C# (.NET Core), 112 110 106 100 99 98 bytes
v=>{var r="";for(int t=30,i=t;i-->0;r+="+\n".PadLeft(t+=new System.Random().Next(3)-1));return r;}

-1 byte thanks to @raznagul.
-1 byte thanks to @auhmaan.
Explanation:
Try it online.
v=>{                      // Method with empty unused parameter and no return-type
  var r="";               //  Result-string, starting empty
  for(int t=30,           //  Temp-integer, starting at 30
      i=t;i-->0;          //  Loop 30 times
    r+=                   //   Append the result-String with:
       "+\n"              //    The character and a new-line,
            .PadLeft(     //    left-padded with `t` spaces,
                     t+=new System.Random().Next(3)-1));
                          //    after `t` first has been changed with -1, 0, or 1 randomly
  return r;}              //  Return the result-string

One strange thing: If I call new Random().Next() multiple times locally (.net Framework Version 4.6.1) I always get the same result. I need to add a Thread.Sleep(10) between the call to reliably get different results. With a sleep time of less than 10ms I sometimes still get the same result. So .net-Framework and TIO (.net-Core) have different PRNGs or at least use different seeds. If I switch your program in TIO to C#-mono I get the same behavior as I get locally in .net-Framework.

@raznagul Hmm, that output with C# (Mono C# compiler) is indeed weird..

@raznagul new Random() uses the time as the seed so in a tight loop the time is the same and so the result is the same.

@TheLethalCoder: Yes, that is what I (more or less) expected. The strange things are that 1) .net-Core (at least on TIO) behaves differently. 2) That I need Thread.Sleep(10) to reliably get different results and Thread.Sleep(1) or even 9ms is not enough.

@raznagul Well sleeping for 1, 9 or 10ms should all sleep for the same time depending on other processes running... odd indeed.

Retina, 24 bytes

30* +
-29{¶<`^

S,2@1`

Try it online!
Explanation

30* +

Initialise the working string to the first line, i.e. 30 spaces and a +.
-29{¶<`^

There's a space on the second line. -29{ wraps the remainder of the program in a loop, which is run 29 times. ¶< prints the working string at the beginning of each loop iteration with a trailing linefeed. The atomic stage itself inserts a space at the beginning of the string (the basic idea is to insert one space, and then randomly remove 0–2 spaces, because that's a byte shorter than randomly choosing between deletion, inserting and no-op).
S,2@1`

This matches the empty regex against the input, which gives us every position between characters (and the start and end of the string). Then ,2 keeps only the first three matches, i.e. the matches after zero, one and two spaces. @ selects a random one of those three matches. Then the split stage (S) splits the input around that match. And the 1 tells it to keep only the second part of the split. In other words, we discard everything up to our random match.
The 30th line, which is the result of the final loop iteration, is printed implicitly at the end of the program.

You know what's even shorter than removing 0--2 spaces? Shuffling spaces around!. By the way, the new Retina is great :D

VBA, 60 59 49 Bytes
For l=1To 30:?Spc(30+i)"+":i=i+Sgn(Rnd()-.5):Next

Paste it in the Immediate window and hit enter.  (Make sure explicit declaration is turned off!)
Far more likely to move than to stay in a line (i.e. actions are not equally weighted) but that was not a specified requirement (Fortunately!)
{EDIT} Saved 1 byte by removing the space between =1 and To
{EDIT2} Saved 10 bytes thanks to remoel's comment
Old Versions:
'V1
i=30:For l=1 To 30:?String(i," ")&"+":i=i+Sgn(Rnd()-.5):Next
'V2
i=30:For l=1To 30:?String(i," ")&"+":i=i+Sgn(Rnd()-.5):Next

Welcome to PPCG!

You can save a few bytes by replacing String(i," ") to Spc(30+i) then remove i=30: . Or -1 byte by removing & . :)

C, 56 bytes
n;f(p){n>29?n=0:f(printf("%*d\n",n++?p-rand()%3:31,0));}

Try it online!
Explanation:
n; // As a global variable, n is initialized to zero.
f(p)
{
    // Call the function recursively until n > 29.
    n > 29

        // At the end, set n back to zero.
        ? n=0

        // On the first iteration, n == 0 and p has an indeterminate value.
        // 'n++ ? p-rand()%3 : 31' returns 31 (without reading p), and thus
        // 30 spaces get printed. printf() returns the number of characters
        // printed, 32 (30 spaces + '0' + '\n').
        //    On subsequent iterations, p has the value the previous printf
        // call returned, which is the padding on last iteration + 2. Also,
        // n > 0, so the same expression now returns p-rand()%3, and thus
        // the padding changes either by -1, 0, or 1 spaces. The function
        // is again called with the value of the current line's padding + 2.
        : f(printf("%*d\n", n++ ? p-rand()%3 : 31, 0));
}

C (gcc), 55 bytes
n;f(p){n=n<30&&f(printf("%*d\n",n++?p-rand()%3:31,0));}

Depends on f "returning" the value assigned to n in the function, which is undefined behaviour, but works consistently with gcc when no optimizations are enabled.
Try it online!

APL (Dyalog), 20 bytes
1 byte saved thanks to ngn
↑'+'↑⍨¨-+\30,2-?29⍴3

Try it online!

¯2+ ---> 2-

Charcoal, 14 11 bytes
× ³⁰Ｆⅈ✳～‽³+

Try it online! Link is to verbose version of code. Explanation:
× ³⁰        Print 30 spaces (forces the desired indentation)
    Ｆⅈ      Repeat the same number of times
      ✳～‽³  Move a random downward direction after printing
          + Print a `+`

Would be only 10 8 bytes if there was no initial indentation requirement.

@KevinCruijssen Hmm, that's awkward, because Charcoal likes to trim by default.

Python 2 , 83 65 64 bytes
Straightforward approach:
import os
k=30
exec"print' '*k+'+';k+=ord(os.urandom(1))%3-1;"*k

Try it online!
Thanks to @Rod for saving some bytes!
Thanks to @ovs for -1 byte!
Edit: changed variable name and output string to the letter 's'
More snake-like output for 88 bytes:
from random import*
s=[30,0]
exec"print' '*sum(s)+'(S)'[s[-1]+1];s+=[randint(-1,1)];"*30

I like this. Really neat solution.

Java 8, 89 87 bytes
First golf, I'm sure it could be much better..
Edit: Fixed first line thanks to Steadybox.
l->{for(int a=31,b=a;--a>0;){System.out.printf("%"+b+"c\n",'+');b+=2-Math.random()*3;}}

Try it online!
 l->{                                           //Begin lambda
    for(int a=31,b=a;--a>0;)                  //Initialise vars, loop through 30 lines
    {
        System.out.printf("%"+b+"c\n",'+');     //Print result
        b+=2-Math.random()*3;                   //Change padding by -1, 0, or 1
    }

Welcome to PPCG! :)

83 bytes

Java 8, 131 129 127 126 119 108 101 bytes
v->{String r="";for(int i=30,j,t=i;i-->0;r+="+\n")for(j=t+=Math.random()*3-1;j-->0;r+=" ");return r;}

Explanation:
Try it online.
v->{                     // Method with empty unused parameter and String return-type
  String r="";           //  Result-String, starting empty
  for(int i=30,j,t=i;    //  Two index integers, and a temp integer (starting at 30)
      i-->0;             //  Loop 30 times:
      r+="+\n")          //    After every iteration: Append the character and a new-line
    for(j=t+=Math.random()*3-1;
                         //   Change `t` with -1, 0, or 1 randomly
        j-->0;r+=" ");   //    And append that many spaces to the result-String
  return r;}             //  Return the result-String

Old 119 byte answer:
v->{String s="",r=s;int i=90,t=30;for(;i-->t;s+=" ");for(;i-->0;t+=Math.random()*3-1)r+=s.substring(t)+"+\n";return r;}

Explanation:
Try it online.
v->{                      // Method with empty unused parameter and String return-type
  String s="",            //  Temp-String, starting empty
         r=s;             //  Result-String, starting empty
  int i=90,t=30;          //  Temp integer, starting at 30
  for(;i-->t;s+=" ");     //  Fill the temp String with 60 spaces
  for(;i-->0;             //  Loop 30 times:
      t+=Math.random()*3-1//    After every iteration: Change `t` with -1, 0, or 1 randomly
    r+=s.substring(t)     //   Append the result with `60-t` amount of spaces
       +"+\n";            //   + the character and a new-line
  return r;}              //  Return the result-String

PHP, 61 bytes
for($p=32;$i<30;$i++)echo str_pad("+
",$p+=rand(-1,1),' ',0);

Try it online!

$i<30;$i++ can be $i++<30; to save 2 bytes.

55 bytes: for($p=30;$i++<30;$p+=rand(-1,1))printf("%{$p}s\n",'+'); (the \n is counted as 1 char, and should be replaced by a real newline)

Alternative 55-byte long, without warnings: for($i=$p=30;$i--;$p+=rand(-1,1))printf("%{$p}s\n",'+');

Perl, 36 bytes
perl -E '$#a=29;map{$#a+=rand(3)-say"@a -"}@a'

So good. I always forget you can set an array length like that... and using say for subtraction. Am I right in thinking it doesn't change the number of runs when $#a is incremented because it's not a reference?

@DomHastings: It's because I use map which seems to first lay out the elements on the stack. for does not and would have had an unpredictable loop length

That's really useful to know. Thanks!

Nice golfing. I tried to shave off another byte with perl -E 'map{$#a+=rand(3)-say"@a -"}@a=1..30', but that sometimes (not every time) resulted in segmentation fault. Could it be a bug in perl v5.22.1 and v5.16.3?

@Kjetil Yes, that is a well known problem that probably will never be fixed. When looping an array the entries don't get an extra refcount, so if you delete them they are freed by the time the loop reaches them and you hit freed memory. Fortunately you never do this in real programs.

Japt, 13 12 bytes
Outputs an array of lines.
The first line can be removed, saving 3 bytes, to allow the number of starting spaces & iterations to be taken as input.
30
°ÆQùU±Ó3ö

Test it or try it with input
30\n°ÆQùU±Ó3ö
30\n              :Assign 30 to variable U
    °             :Postfix increment U
     Æ            :Map the range [0,30)
      Q           :  Quotation mark
       ù          :  Left pad with space to length
        U±        :    Increment U by
          Ó       :      Bitwise NOT of the negation of (i.e., decrement)
           3ö     :      Random integer in the range [0,3)

Wow, can't believe we're winning at the moment! I think you can save a byte with this (on mobile so I can't really verify)

@ETHproductions: Ha! That's identical to what I started out with. The problem is, though, if -1 is returned by the RNG on the first iteration, we'll end up with a total line length of 29 when it should be 30, 31 or 32.

Hmm, I'm confused about how your version gets around that then... Also, I believe OP has clarified in the comments that they don't care if an extra space is removed or added in the initial iteration.

Actually I'm confused by "when it should be 30, 31, or 32"—where is that required?

@ETHproductions: We start with 30 and then add -1, 0 or 1 giving us 29, 30  or  31 - add the " and that gives us a total length of 30, 31 or 32 for the first line.

Oh ok, I didn't realize you meant the length of the entire line. Sorry if this is another dumb question, but how could my suggestion end up with an initial line length of 29 (28 spaces)?

@ETHproductions: if the RNG gives us -1 on the first iteration, U becomes 29 and ù would pad the start of the line with spaces until the total line length is 29 - 28 spaces plus the " character.

Hah, I thought the quote was just appended at the end of the string—sorry for my ignorance :P

Doors Japt really not have a decrement command???

@cairdcoinheringaahing, ± is the Japt shortcut for +=. It could be replaced with µ, which is the shortcut for -=, but the results would be the same.

Vyxal, 12 bytes
30:(kɽ℅+:×꘍,

Try it Online!
30:          # Push 30 twice
   (         # Iterate over one copy (30 times)
       +     # Increment the number on the stack (initially 30) by...
      ℅      # A random choice from
    kɽ       # [-1, 0, 1]
        :    # Duplicate
         ×꘍  # Prepend that many spaces to an asterisk
           , # And output, leaving the number on the stack

An alternative

R, 72 69 67 bytes
cat(sprintf(paste0("% ",cumsum(c(30,sample(3,29,T)-2)),"s"),"+\n"))

Thanks to Zahiro Mor for 2 extra bytes!
Try it online!

Switching from sample(3,29,T)-2 to runif(29,-1,1) will reduce byte count by 2 but moves are not equally likely anymore. And could you also switch to paste("%" instead of paste0("% " or am I missing something here?

@Rift if i was using paste the resulting strings would be of the form % 30 s instead of % 30s. As you said runif would mess up the probabiities.

Locally sprintf("%30s"), sprintf("% 30s") and sprintf("% 30 s") return the same results for me. But on TIO only the first two have identical results, so paste0("%" should save a byte. And there is no requirement that every move has the same probability.

Ruby, 45 39 bytes
x=30
x.times{puts' '*(x+=rand(3)-1)+?S}

Try it online!
Modifying x during the loop does not affect the loop counter. I chose S as a particularly snakelike output character.
-6 bytes: Use rand(3)-1 instead of [-1,0,1].sample. Thanks, Eric Duminil!

You can save two bytes with x.map instead of x.times (equivalent since you don't use the return value)

I don't think I can... map is defined on Enumerable, which Integer isn't.

Oops, you're right, ignore me!

OK I've got a better one: rand -1..1 is five bytes shorter than [-1,0,1].sample

@RJHunter: Or rand(3)-1 for 6 bytes less.

You can get a one-liner : (x=30).times{puts' '*(x+=rand(3)-1)+?S} without changing the byte-count.

(x=30).times{puts' '*x+?+;x+=rand(3)-1} (same size) will print exactly 30 spaces for the head of the snake as requested by the challenge

Jelly, 18 bytes
1ŒRX+
30Ç’Ð¡⁶ẋ;€0Y

Try it online!
The chosen character is 0. If returning a list of list of characters is allowed, then the Y can be dropped and the submission can be turned into a niladic chain for 17 bytes. Alternative.
How it works

30Ç’Ð¡⁶ẋ;€0Y | Niladic main link.
30           | Starting from 30...
  Ç’Ð¡       | ... Repeat the helper link 29 times and collect the results in a list.
             | (This list includes the first 30, so there are actually 30 numbers).
      ⁶ẋ     | Repeat a space that many times, for each item in the list.
        ;€0  | Append a 0 to each.
           Y | And join by newlines.
-------------+
1ŒRX+        | Monadic helper link. Alternatively, you can use µ1ŒRX+µ instead of the Ç.
1            | The literal one.
 ŒR          | Symmetric range from –1 to 1.
   X+        | Choose a random number therein and add it to the argument.

Jelly, 16 bytes
Combining mine, Erik’s and Jonathan’s solutions, we can golf this down to 16 bytes. The chosen character is 1.
’r‘X
30Ç’Ð¡Ṭ€o⁶Y

Try it online!
Thanks to Jonathan Allan for the heads-up (on Ṭ€o⁶).

You could use Ṭ€o⁶ in place of ⁶ẋ;€0 like my 18 byter does and get to down to 17.

@JonathanAllan Thank you! Combining the three Jelly answers, I actually ended up having 16 bytes. But I posted that as a secondary solution because it is not entirely mine. :-)

Swift, 101 bytes
import UIKit
var g=29;for _ in 0...g{print((0..<g).map{_ in" "}.joined(),0);g+=Int(arc4random()%3)-1}

Explanation
A full program. This uses a rather odd trick: arc4random() is a member of the Darwin module, but UIKit also comes with this function installed, so it saves a byte :) Also uses one of my Swift golfing tips for repeating strings an arbitrary number of times.
import UIKit        // Imports the UIKit module, necessary for the RNG.
var g=29;           // Declares an integer variable g by assigning it to 30.
for _ in 0 ... g {  // Execute the code block 30 times (for each integer in [0; g]):
 print(             // Output the following:
  (0..<g).map       // For each integer in [0; g)...
   {_ in" "}        // ... return a literal space character.
    .joined()       // ... And join the result to a single string.
             ,0     // Also print a "0" preceded by a single space (g starts from 29).
 );
g+=                 // Increment the variable g by...
   arc4random()%3   // ... A random integer, modulo 3...
   Int(...)-1       // ... Casted to an integer (yes, this is needed!) and decremented.
}

Doesn't for _ in 0 ... g execute the code block 29 times now instead of 30 (loop from 0 to 29 (exclusive))?

@KevinCruijssen No, 0...g generates all the integers in [0; g]. My bad, fixed the explanation. 0..<g would generate the integers in [0; g) :P

Ah, the [0; g) you've edited to [0; g] indeed confused me. :) Hmm, but isn't it possible to start at g=30 and loop [1; g] in that case?

@KevinCruijssen Looping over either [0; g) or [1; g] would definitely be possible if I choose g=30 instead, but then print(...,0) needs to be changed to print(...+"0"), because an additional (extraneous) space would be prepended before the 0 otherwise. Either way, the byte count remains the same.

R, 54 53 bytes
cat(sprintf('
%*s',cumsum(c(30,sample(3,29,T)-2)),0))

Similar idea as above, but with shortened sprintf code and a shorter character string literal. Instead of \n (two bytes) I’m using a literal line break (one byte).
Try it online!

A field width or precision (but not both) may be indicated by an asterisk *: in this case an argument specifies the desired number.  I've been using sprintf for years and somehow always missed that part... Thanks for the reminder!

The second line is sometimes indented two spaces instead of one.

@ScottMilner Found some time to fix it.

SenseTalk, 237 198 Bytes
This is a language that I came to know and love about a decade ago. It's the scripting language that drives the automated testing tool Eggplant Functional. I was an avid user of the tool for many years before joining the company for a while. It's not the most golf-capable language, but I find it very enjoyable to write in. Golfing in it is actually quite challenging as the language is meant to be verbose and English-like... took me quite a while to get it down to 237 bytes.
set s to "                              +"&lf
set p to s
repeat 30
set a to random(0,2)
if a equals 0
delete first char of p
else if a equals 1
put " " before p
end if
put p after s
end repeat
put s

Ungolfed/Explanation
set the_snake to "                              +"&lf #assign the first line of the snake
set previous_line to the_snake                        #set up for the loop

repeat 30 times                                       #loop 30x
    set action to random(0,2)                         #random add/subtract/stay the same

    if action equals 0
        delete the first character of previous_line   #SenseTalk really shines at string manipulation
    else if action equals 1
        put " " before previous_line                  #insert a character at the beginning
    end if

    put previous_line after the_snake                 #plop the new segment into the string
end repeat                                            #close the loop

put the_snake                                         #print to standard out

Edit: Saved 36 bytes thanks to @mustachemoses

Is the whitespace necessary?

I've a lot of respect for this. Particularly against the background of 'golfing languages' which seem to exist to be utterly unreadable, but short. It's nice to have an example that's just showing what you can do with your language.

Good call @MustacheMoses! Updated.

I count 198 bytes (well, the userscript counts that many)

@AllenFisher Do you have a standalone interpreter or compiler for this language that I can use without getting a Eggplant demo?

@MustacheMoses I wish I did. They used to have one, but when TestPlant acquired the EP tool, they shelved it.

@HyperNeutrino yeah I realized I was using the wrong operator in my counting script... updated

J, 23 bytes
echo(8":~+/)\31,1-?29$3

Try it online!

PowerShell, 42 bytes
1..($l=30)|%{" "*$l+"x";$l+=-1,0,1|Random}

Try it online!
Loops from 1 to $l=30. Each iteration we put $l spaces plus an x onto the pipeline as a string, then += either of -1, 0, 1 based on Get-Random into $l for the next loop. Those strings are gathered from the pipeline and an implicit Write-Output gives us a newline-separated list for free.

Bash, 53

3 bytes saved thanks to @Dennis

for((i=p=30;i--;p+=RANDOM%3-1));{ printf %${p}s+\\n;}

Try it online.

p+=RANDOM%3-1 works too.

@Dennis Yes of course! Thanks!

Octave, 53 51 50 49 bytes
printf('%*d\n',[a=31+cumsum(randi(3,1,30)-2);~a])

Try it online!
Saved 1 byte by no longer doing any looping. Saved another as Octave has printf as well as fprintf.
This new code creates an array of 30 random integers in the range -1:1. It then cumulatively sums the array and adds 30, which gives the desired sequence.
The result is printed using fprintf with a format that says "A decimal number, padded to a specified width, followed by a new line. The width will be the first value input, and the decimal number will be the second value input. If the number of values input is more than this, Octave will keep repeating the print automatically to get the desired output.
To achieve the looping then, we need only interleave zeros between the sequence array so the fprintf function uses each value in the sequence as a width, and each zero as the digit to be printed.
Prints an output like:
                              0
                             0
                              0
                             0
                              0
                               0
                              0
                               0
                              0
                              0
                             0
                            0
                           0
                           0
                           0
                          0
                           0
                            0
                             0
                              0
                              0
                             0
                             0
                              0
                               0
                              0
                              0
                               0
                               0
                                0

The above code doesn't always print exactly 30 spaces on the first line. It will be either 29, 30, or 31. To correct that, you would use this 53 byte version:
x=31;for i=2:x;fprintf('%*d\n',x,0);x+=randi(3)-2;end

You can save two bytes: x=31;for i=2:x;fprintf('%*d\n',x+=randi(3)-2,0);end

@KevinCruijssen I thought about that, but it doesn't work the same. It would result in the first line starting with either 29, 30, or 31 spaces.

@KevinCruijssen in fact, never mind. I've just noticed the OPs comments saying that is allowed.

Yep. It's a bit annoying a rule is in the comment (especially since it contradicts with the current challenge description..). I've asked OP to edit the challenge to reflect you can start with 29, 30 or 31, since he seems to allow it in the comments.

Python 3.6, 84 73 69 bytes
from random import*
x=30
exec("print(' '*x+'+');x+=randint(-1,1);"*x)

Thanks to @WheatWizard for -11 bytes.
Thanks to @JoKing for -4 bytes.

Since you don't end up using i you can use for i in[1]*30 instead to save bytes.

You can also from random import* so that you don't need the random. later on.  And you can remove the newline space after your :.

And if you change 30 to 29 the "+".rjust(x) can be replaced with " "*x+"+".

Actually regarding my last comment it should be 30 spaces not 29.  Your current answer only puts 29 spaces and thus fails to meet the spec.  This can be fixed by changing 30 to 31.

@WheatWizard Thanks! I've added your changes and credited you as well. I changed [1]*30 to [1]*x because it's one byte shorter.

69 bytes

@JoKing Thanks I'll edit in your changes.

ES5, 97 95 81 bytes

for(p=i=30;i--;)console.log(Array(p).join(" ",r=Math.random()*3|0,p+=r>1?-1:r)+0)

ES5, 112 98 bytes if function format is needed:

function a(){for(p=i=30;i--;)console.log(Array(p).join(" ",r=Math.random()*3|0,p+=r>1?-1:r)+0)}a()

Welcome to PPCG! I think your variables have to be declared inside of a function - _=>{p=30;for(i=0;i<p;i++){console.log(Array(p).join(" ")+"+\n");r=~~(Math.random()*3);p+=r==2?-1:r}}

That'll kill the bytes, I'll tell you that. ES5 doesn't include the arrow functions by default.
I'll update

@Oliver, function format added :)

Nice! I'm not sure when it was introduced, but I think you can replace join(" ") with join\ ``

@Oliver I'm not sure you could do that in ES5, could you? I thought that was a template literal added in ES6?

Maybe, I'm not sure when that was introduced. Why not use ES6?

@Oliver It's more of a challenge, and there was already an ES8 answer which takes the full syntactical sugar of Javascript and turns it into some awesome.

Welcome to PPCG! Here are some quick improvements to get you down to 81 bytes.

@Shaggy .repeat is an ES6 function, so won't work for this version.

Huh, it looks like repeat has already become so invaluable I'd completely forgotten it wasn't introduced until ES6. Here's an alternative 81 byte version, so.

@Shaggy, looks good, and has shaved 14 bytes off of the answer I gave, nice job

Lua, 81 75 bytes
n=30;for i=1,n do print(("%-"..n.."s+"):format(" "))n=n-2+math.random(3)end

In for i=1,n ... the to_exp n is evaluated only once before entering the loop, saving one byte.
-6 thanks to @user202729
Try it online!

Welcome to PPCG! You may want to add a TIO link to your post so people can test your program more easily.

You can golf your answer down to 76 bytes. Besides the page Tips for golfing in Lua may be useful.

75 bytes.

Red, 54 bytes
loop n: 30[loop n[prin" "]print"+"n: n - 2 + random 3]

Try it online!

Pyth, 21 19 16 15 bytes
Thanks to Rod for saving 2 bytes and Mr. Xcoder for saving another 3 :)
Uses 0
VK30p*KdZ=+KtO3

Try it online!

Python 2, 73 bytes
from random import*
l=c=30
while c>0:l+=randint(-1,1);print' '*l+"+";c-=1

Try it online!

I really like the idea of creating a snake in Python

I must have been half asleep yesterday - I didn't even think about that ;-)

Mathematica, 74 bytes
""<>(" "&~Array~#<>"+
"&)/@Accumulate@Prepend[{-1,1}~RandomInteger~29,30]&

Pure function. Takes no input and returns a string as output.

Julia 0.6, 52 49 bytes
Full program, prints a snake with 0. I usually prefer comprehensions to for...end blocks because comprehensions return things. But since I'm printing anyway this is shorter, and you can use newlines at no cost (meaning equal to ;) for a nice readable golf. Saved a byte by using 1:n instead of 1:30 and two bytes with println(" "^n,0) instead of println(" "^n*"+").
n=30
for i=1:n
println(" "^n,0)
n+=rand(-1:1)
end

Try it online!

K4, 26 bytes
Solution:
-1(-31+\0,-1+29?3)$\:,"$";

Example:
q)k)-1(-31+\0,-1+29?3)$\:,"$";
                              $
                             $
                             $
                            $
                           $
                            $
                             $
                              $
                              $
                              $
                              $
                              $
                               $
                                $
                               $
                              $
                               $
                              $
                              $
                               $
                                $
                                 $
                                 $
                                $
                                 $
                                $
                               $
                                $
                                $
                                 $

Explanation:
Build a list of negative numbers to left-pad "$", perform padding and print to stdout.
-1(-31+\0,-1+29?3)$\:,"*"; / the solution
-1                       ; / print to stdout and swallow return
                     ,"$"  / enlist "$" (e.g. ["$"])
  (              )$\:      / pad right with each-left
             29?3          / 29 choose 3, takes from 0 1 2
          -1+              / subtract 1, so range is -1 0 1
        0,                 / join 0
      +\                   / sums
   -31                     / add to -31

Bonus:
27 byte version in K (oK):
`0:(-31+\0,-1+29?3)$\:,"*";

Try it online!

oK 22 bytes: \0:(-31+\1-30?3)$:$0;`

@zgrep, probably worth posting as a separate oK solution :) stringing 0 in K4 gives an atom rather than an enlisted char (so you can't pad it) and the above solution always pads the first line with 30 chars - a requirement which was removed as a comment.

Icon, 51 bytes
-2 bytes thanks to Kevin Cruijssen
n:=30;every 1to 30do{write(repl(" ",n),8);n+:=?3-2}

Try it online!

PHP, 58 56 bytes
for($a=$b=30;$a--;)echo str_pad('',$b+=rand(-1,1))."+
";

Try it online!
-2 bytes thanks to @Shaggy

Welcome to PPCG! :) Seeing as the first line can contain 29-31 spaces, I think you could do this to save 2 bytes.

Thx @Shaggy. Yeah, I only just read the comments on the question saying I could do that xD. Thanks for helping me shave 2 bytes!

Clojure, 88 77 bytes
Always happy to provide a Clojure answer. Always sad, it's quite long.
(loop[x 30 p x](when(> x 0)(printf(str "%"p"d\n")1)(recur(dec x)(+(-(rand-int 3)1)p))))

Ungolfed:
(loop [x 30 p x]
  (when (> x 0)
    (printf (str "%" p "d\n") 1)
    (recur (dec x) (+ (- (rand-int 3) 1) p))))

Update 1
Managed to shave off 11 bytes by making the code more idiomatic. Who would have thought that making things "more right" would end up being more effective in a Code Golf challenge.
(doseq[p(take 30(iterate #(+ %(-(rand-int 3)1))30))](printf(str "%"p"d\n")1))

Ungolfed:
(doseq [p (take 30
            (iterate
              #(+ % (- (rand-int 3) 1))
              30))]
  (printf (str "%" p "d\n") 1))

Try it online!

Hi, I added a TIO link of your solution to your post. According to TIO, it's 77 bytes long, so I updated this also.

SmileBASIC, 40 bytes
This answer turned out to be pretty boring.
X=30FOR I=1TO 30?" "*X;0X=X+RND(3)-1NEXT

Pip, 21 bytes
Ln:30{PsXn.0--n+:RR3}

Try it online!
Explanation
                       s is space (implicit)
 n:30                  Set n to 30
L    {              }  Loop that many times:
      P                 Print, with trailing newline:
       sXn               space, repeated n times
          .0             with "0" concatenated
            --n         Decrement n
               +:       and add to it (in-place)
                 RR3    randrange(3), i.e. a random integer between 0 and 2

Jelly, 18 bytes
30µ3ẋX€_2+\+⁸Ṭ€o⁶Y

Uses 1 as the character.
Try it online!

Your first line does not always start with 30 spaces.

See my comment under the OP

Jelly, 17 bytes
30µ’r‘Xµ’Ð¡⁶ẋp”.Y

Try it online!
Full program.

Haskell, 108 bytes
import System.Random
0%_=pure()
n%p=putStrLn(([1..p]>>" ")++"+")>>randomRIO(-1,1::Int)>>=((n-1)%).(p+)
30%30

Try it online! I was surprised to find that this code works in GHCi without the explicit type annotation but not on TIO, until BMO told me about the ExtendedDefaultRules flag which is set by GHCi.

SOGL V0.12, 14 bytes
'∑:{:@*O2ψH+╗p

Try it Here!

AWK, 54 bytes
{for(f=30;a++<30;f+=int(4*rand()-2))printf"%"f"s\n",1}

Try it online!
Very straightforward. This requires a 1 line input to run.  Could make it a "program" by using a BEGIN label.

CJam, 31 bytes
{S*TN}:F;30:V{3,{V1-+}%mRz:VF}*

Try it online!
Sort of a port of @Datboi's answer
Explanation
{S*TN}:F                         -The padded string function
{                                -Start block
 S*                              -Multiply space string by argument and push to stack
   T                             -Push integer 0 to stack
    N                            -Push newline string to stack
     }                           -End block
      :F                         -Store top of stack(the block) in variable F
        ;                        -Pop from stack
         30:V                    -Push integer 30 to stack and store in variable V
             {3,{V1-+}%mRz:VF}   -The main loop
              3                  -Push integer 3 to stack
               ,                 -Array range from 0 to n-1
                {V1-+}%          -Map to array
                 V               -Push variable V to stack
                  1              -Push integer 1
                   -+            -subtract values from each other and add to array index
                       mR        -Random choice
                         z       -Absolute value
                          :V     -Store in variable V
                            F    - Execute function in F
                              *  -pop stack and repeat block

21 bytes: Try it online!

Clearly, I still have a lot of practicing to do.

Go, 123 107 94 bytes
import(."fmt"
."math/rand")
func s(){s:=30
for i:=0;i<30;i++{Printf(`%*d
`,s,4)
s+=Intn(3)-1}}

call function s
Try it online!

Perl 6, 39 bytes
$_=30;say(" "x($_+=^3 .roll-1)~"x")xx$_

Explanation:
$_=30: Sets the number of spaces to prefix to 30.
say(" "x($_+=^3 .roll-1)~"x"): Outputs that number of spaces and updates it (^3 .roll-1: pick a random integer from 0 to 2 and subtract it by 1), followed by x and a newline.
xx$_: Does this 30 times. Using $_ instead of 30 saves one space before 30.

Commodore BASIC (Tested on a Commodore 64, but recommended 128 80 columns mode) 72 tokenised BASIC bytes
0X=29:FORI=.TOX:PRINTSPC(X)"O":X%=3*RND(.):ONX%GOSUB1,2:NEXT:END
1X=X-1:RETURN
2X=X+1:RETURN

How it works
X is declared as the spacing and is reused in the FOR/NEXT loop - the . is a slightly faster way of using 0 in Commodore BASIC, so the loop counts from 0 to the initialised value in X (30 iterations). PRINT SPC(X) will print X number of spaces, so on the first iteration, this is 29, and the "O" will print the O character. X% = 3 * RND(.) declares (loosely) an integer variable (the % means integer, though internally it's a floating point number) - a number from 0 to 2 inclusive is decided (as a floating point number, but will be used as an integer). the ON X% GOSUB 1, 2 will branch to lines 1 or 2 depending on the value. a 0 will not branch and fall through to the next instruction (which instigates the next iteration with the NEXT command). Finally the END will gracefully end the program (otherwise it will continue to line 1 and there will be an error because of a RETRURN statement without a GOSUB call).
Note that although X is manipulated in the loop, the number of iterations is set by the value that it's initialised to. Also, the Commodore C64 screen (as well as the PET, C128 and C16/+4) only has 25 rows of text in BASIC, so that's why you don't see the full 30 character PETSCII Snake.

><>, 53 bytes
 "+ ␞␞"r4[r}:}>1-$:\
<~x<1 }-1}o:}+^?:$o/oa;!?:{
^ \-

(Replace ␞ with the corresponding byte 0x1E; it is replaced with a printable unicode character here for clarity.)
Try it online! The first + always starts at position 30.
Explanation
Initialization and Iteration Cleanup
 "+ ␞␞"r4[r}:}

Let's examine this section bit-by-bit, as it's a bit more complicated than a simple stack initialization.
 "+ ␞␞"

This initializes the stack with [43, 32, 30, 30], which are the [OutputChar, PadChar, InitialPosition, IterationCount] respectively.
       r4[r

This is a no-op on the first iteration, but on each next iteration, it only retrieves the bottom-most four entries on the stack. Our method of repeating the iteration here is to simply return to the first line, which will re-push the initial string. We want to ignore this on every subsequent iteration, hence these four characters. (While I could remove them and simply jump to the corresponding position on line 1, this should require more bytes, given the rather delecate structure of the code.)
           }:}

The last thing that needs to be done before our output loop is to move the iteration count to the bottom of the stack (}), and save a copy of the current horizontal position to the bottom of the stack (:}).
Horizontal Position Output
              >1-$:\
              ^?:$o/

This is a relatively simple loop. We first subtract 1 from the horizontal position (1-), output a copy of our padding character ($:o$, which is split across the mirrors to save bytes), and, if the counter has reached zero, we skip repeating this loop; otherwise, we repeat this process (:?).
Post-loop procedures
  +                \
<~x<1 }-1}o:}+     /oa;!?:{
^ \-

I've kept in only the bits necessary to illustrate the function of the more delicate part of the code. Starting at the + in the middle, going left, we do a few things. We discard the 0 counter we do not need anymore (+), output a copy of the snake character (}:o), subtract 1 from the copy of the iteration counter we saved earlier (}1-), and then we prepare to do the random procedure }1. This pushes a 1 to the stack, which we will randomly add, subtract, or ignore relative to the horizontal position we saved earlier.
  +
<~x<1
^ \-

Remember the + is part of the initialization string from earlier. The x instruction is ><> source of randomness; it chooses a random direction and sets the IP to go that way. This means we have four options: left, right, up, and down. If it goes right, it simply encounters the < instruction and we are redirected back to the x, once again obtaining a random direction. Effectively, we limit the random directions to be only left, up, or down.
If we go left, we'll simply pop the 1; the horizontal position does not change. We then continue left and wrap around to the rest of the post-loop procedures.
If we go up, we encounter the + from earlier, adding 1 to the horizontal position. We will then continue up and wrap around to the mirror, reflecting left, then following the arrows to the rest of the post-loop procedures.
If we go down, we find that same mirror, but reflect right instead, encountering the -, and subtracting 1 from the horizontal position. We continue and wrap around to the right, following the arrows as before and continuing on.
                   \
                   /oa;!?:{

After modifying the horizontal position, we now want to examine the loop counter ({). If it is 0, we terminate (:?!;). Otherwise, we continue on, outputting a newline (ao), hitting the mirror from before, going down, wrapping around, hitting the other mirror, and going to the left. This brings us back to the very start of the code, and the process begins again.


text:
Integer Linear Programming
Introduction
Write a solver for integer linear programming.
Challenge
Your task is write a solver for integer linear programming (ILP). In ILP, linear inequalities of a set of unknowns (all of which are integers) are given, and the goal is to find the minimum or maximum of a linear function.
For example, for the inequalities (example taken from Mixed Integer Linear Programming)
 4x+2y-15≤0
  x+2y- 8≤0
  x+ y- 5≤0
- x      ≤0
   - y   ≤0

and the objective function 3x+2y, the maximum of the objective function should be 12 (x=2,y=3), while the minimum should be 0 (x=y=0).
The input is given as an 2d array (or any equivalent following the standard specifications), each row corresponds to one inequality, with the exception of the final row. The numbers in the array are the coefficients, and the ≤0 part is always omitted. If there are n elements in each row, it means there are n-1 unknowns.
The last row of the array correspond to the linear function. The coefficients are listed.
For example, the input array for the problem above is
[[4,2,-15],[1,2,-8],[1,1,-5],[-1,0,0],[0,-1,0],[3,2,0]].

The output should be the minimum and the maximum, given in any reasonable form.
For the following problem (two of the restrictions are taken away from the problem above):
[[4,2,-15],[1,2,-8],[1,1,-5],[3,2,0]].

The maximum is still 12, but the minimum does not exist and the objective function can have arbitrarily large (in the sense of absolute value) negative values. In this case, the program should output 12, following a falsy value that is decided by the answerer. Another case is that there are no solution at all, for example,
[[4,2,-15],[-1,-2,7],[-1,0,3],[0,1,0],[3,2,0]].

In this case, falsy values should be output as well. It would be nice to discern the case where the "optimal value" for the objective function is infinity and the case where there are no solutions at all, but this is not necessary.
The input only contains integer coefficients both for the inequalities and for the objective function. All the unknowns are also integers. The coefficient matrix of the inequalities is guaranteed to have full rank.
Test Cases
Credit to @KirillL. for finding a bug in the original test suite and deepening my understanding of ILP problems.
Input
Output

[[4,2,-15],[1,2,-8],[1,1,-5],[-1,0,0],[0,-1,0],[3,2,1]]
[1,13]

[[4,2,-15],[1,2,-8],[1,1,-5],[3,2,0]]
[-inf, 12]

[[4,2,-15],[-1,-2,7],[-1,0,3],[0,1,0],[3,2,0]]
[NaN, NaN]

[[-1,-1,-1,-1,-1,8],[1,1,1,1,0,0],[5,5,5,5,6,7]]
[55, inf]

[[-1,-1,-1,-1,-1,8],[1,1,1,1,0,0],[0,0,0,0,0,4]]
[4, 4]

[[4,2,-15],[-1,-2,7],[-1,0,3],[0,1,0],[0,0,4]]
[NaN, NaN]

Specs

No need to worry about exception handling.

This is code-golf, the lowest number of bytes wins.

Maximal number of unknowns: 9. Maximal number of inequalities: 12.

You can take input and provide output through any standard form, and you are free to choose the format.

As usual, default loopholes apply here.

Generalises https://codegolf.stackexchange.com/q/155460/194

You haven't explicitly mentioned it in the task description, but I suspect you are seeking original implementations of the algorithm, and not some boring code that makes use of existing libraries? Nevertheless, I played with your test cases in R and couldn't exactly reproduce the results.E.g., [55, inf] case only works when the variables are bounded to be non-negative. But then [-inf, 12] case also produces normal results [0, 12]. On the other hand, when the lower bound is -inf, the [55, inf] case fails to solve in both min and max scenarios.

Yes I am looking for original implementations.

@KirillL. Can you provide a vector where the function in test case [55, inf] gives a value smaller than 55? I just checked it against an online solver and the case seems to be fine. I have the following reasoning when making this test case: The first restriction requires the sum of all the free variables to be geq 8, but the second requires the sum of all except the last to be leq 0. If we ever try to decrease the goal by reducing any of the first 4 free var, it would require the final var to be increased by the same amount hence a larger value for the goal.

Here is my snippet, although it won't work on TIO due to missing library. This gives 55, but exits with "model is unbounded" when I uncomment the set.bounds line. Quite possibly, the error is on my side, though. Could you also give a link to online solver?

Here it is. I don't like the ads but at least it works.

OK, that site specifically formulates the problem with x>=0. So, 55 test case is correct. But then I get 0 instead of -inf/error in [-inf, 12] case. I enter the constraints as 4 2 -1 15;1 2 -1 8;1 1 -1 5. Is that correct?

Oh sorry I didn't notice the restriction. I don't mean the unknowns have to be nonnegative. So the issue is still with the 55. Can you give me a vector that gets a goal below 55 or point out what is wrong in my reasoning above? Thank you very much for your time and interest. Edit: I see what is faulty. Changed accordingly.

@Sanchises In the challenge I stated that you can use any falsy value of your choice that is discernible from other cases as the output for cases without solutions. You can even use the same output for NaN and Inf and -Inf.

@WeijunZhou Sorry, I misread that bit. Thanks.

The unknowns may be negative. Correct?

Yes, the unknowns may be negative.

@Scrooble You can use any set of value of your choice as the falsy value, as long as they are discernible from the cases where there are solutions, as stated in the question.

@Scrooble Yes, you may output a space (or a letter, if you like).

For test cases which function to optimize? still 3x+2y?

3x+2y is specified by the last subarray [3,2,0]

Can I output same value for both "all range" and "no range"?

You can take input and provide output through any standard form, and you are free to choose the format. so can we split out the objective function?

Yes, of course.

Farewell, bounty. So tragic.

Python 3, 534 bytes
import itertools as t
import operator as o
I=float("inf")
e=lambda p,A:sum([i[0]*i[1]for i in zip(p,A[:-1])])+A[-1]
def w(x,j):
	d=len(x[0])-1;C=[0]*d;v,w=I,I
	while 1:
		L={(*n,):(sum([0 if e(n,A)<=0 else e(n,A)for A in x[:-1]]),j*e(n,x[-1]))for n in [[sum(a) for a in zip(C,c)]for c in t.product(*[[-1,0,1]]*d)]};C,P=min(L.items(),key=o.itemgetter(1))[0],C;v,w,p,q=L[C][0],L[C][1],v,w
		if(all([e(C,A)<=e(P,A)for A in x[:-1]]))*(j*(e(C,x[-1])-e(P,x[-1]))<0)+(p==v>0):return I
		if(p==v)*(q<=w):return j*q
f=lambda x:(w(x,1),w(x,-1))

Try it online!
Overview
It is an iterative algorithm, starting from the origo. It collects the neighbour positions and assigns a potential function: x:(a,b) where x is the position, a is the sum of the position's distances from the half-spaces of each linear inequality, b is the value of the objective at that position.
x:(a,b) < y:(c,d) iff a<c or a=c and b<d
The iteration stops, when:

the first coordinate of the potential hasn't decreased and positive: the system is infeasible
the distance from every half-space has decreased just like the objective: the system is unbounded.
none of previous and the potential hasn't decreased: it is the optimal value.

Matlab, 226 bytes
DISCLAIMER: Not an "original" implementation, only for fun.
Simple solution taking advantage of the intlinprog function:
function r=f(a);b=-1*a(1:end-1,end);p=a(end,1:end-1);c=a(1:end-1,1:end-1);[~,f,h]=intlinprog(p,1:size(a,2)-1,c,b);[~,g,i]=intlinprog(-p,1:size(a,2)-1,c,b);s=[inf,nan,f];t=[inf,nan,g];r=a(end,end)+[s(4-abs(h)) -t(4-abs(i))];end

It returns the optimal values, or inf (-inf) if the problem is unbounded or nan if it is infeasible.
a = [4 2 -15; 1 2 -8; 1 1 -5; -1 0 0; 0 -1 0; 3 2 1]
b = [4 2 -15; 1 2 -8; 1 1 -5; 3 2 0]
c = [4 2 -15; -1 -2 7; -1 0 3; 0 1 0; 3 2 0]
d = [-1 -1 -1 -1 -1 8;  1 1 1 1 0 0; 0 0 0 0 0 4]
e = [4 2 -15; -1 -2 7; -1 0 3; 0 1 0; 0 0 4]

>> f(a)
ans =

     1    13

>> f(b)
ans =

   Inf    12

>> f(c)
ans =

   NaN   NaN

>> f(d)
ans =

     4     4

>> f(e)
ans =

   NaN   NaN

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Want to see a Magic Card Trick?
The first magic card trick I ever learned as a child was the following:

Have 1 deck of cards where the pattern on the back is not vertically symmetric.
Organize all cards to be facing one direction.
Ask an individual to, "pick a card, any card, memorize it and give it back to you".
Proceed to put it into the deck (in the wrong direction).
Shuffle vigorously, giving the illusion that you won't know where their card is.
Produce their card to their amazement.

This trick is obviously a little bit lack-luster in nature now-a-days, however it makes for a good challenge. Write a program, that when given no input, outputs a randomly shuffled deck of cards with one of the cards, chosen at random, reversed. However, when the input is a deck of cards with one card reversed, you must output the reversed card (in the correct order).

The Deck of Cards
A deck of cards is defined to be:
[2S,3S,4S,5S,6S,7S,8S,9S,TS,JS,QS,KS,AS,
 2D,3D,4D,5D,6D,7D,8D,9D,TD,JD,QD,KD,AD,
 2H,3H,4H,5H,6H,7H,8H,9H,TH,JH,QH,KH,AH,
 2C,3C,4C,5C,6C,7C,8C,9C,TC,JC,QC,KC,AC]

A card is defined as it's number, then the first letter of its suit. The reverse of a card is the exact opposite, the first letter of its suit followed by a number.
The Drawn Card
Example, if the card we randomly chose to reverse was the 4 of Clubs (4C), we'd end up with (without shuffling, obviously):
[2S,3S,4S,5S,6S,7S,8S,9S,TS,JS,QS,KS,AS,
 2D,3D,4D,5D,6D,7D,8D,9D,TD,JD,QD,KD,AD,
 2H,3H,4H,5H,6H,7H,8H,9H,TH,JH,QH,KH,AH,
 2C,3C,C4,5C,6C,7C,8C,9C,TC,JC,QC,KC,AC]

The Shuffling
Then, after shuffling:
[2H,2C,6S,4D,QH,6C,TD,8C,7H,5H,C4,3D,7S,7C,KC,QD,QC,JS,7D,6D,2S,5C,KD,3C,3S,2D,8H,KH,6H,AH,8S,JH,TS,AD,5D,9H,4H,JD,QS,4S,JC,3H,8D,TC,AS,TH,KS,AC,9C,9S,5S,9D]

This is a valid output given empty input.
The Deck Input
However, conversely, when our program receives the above output as input, it should output 4C. That is to say, for an input of:
[2H,2C,6S,4D,QH,6C,TD,8C,7H,5H,C4,3D,7S,7C,KC,QD,QC,JS,7D,6D,2S,5C,KD,3C,3S,2D,8H,KH,6H,AH,8S,JH,TS,AD,5D,9H,4H,JD,QS,4S,JC,3H,8D,TC,AS,TH,KS,AC,9C,9S,5S,9D]

You iterate through until you find the reversed card, and return it, reversed back to the normal state. So here we'd find C4, know that C isn't a number, and return it as 4C, which is correct.

Rules

You may not load the deck from any external sources.
An empty input should result in a randomly shuffled deck with 1 random card reversed.
A deck of cards with 1 card reversed as input should result in the reversed card.
Any other inputs can result in explosive llamas riding segways through a futuristic tube.

Or anything else, for that matter.

Both the chosen card and the shuffling order must be uniformly random.

I.E. all cards have equal chance of being selected to be reversed.
I.E. all combinations of cards have an equal chance of appearing.

You may use SHCD or shcd for the suits, but be consistent:

If you choose uppercase suits (SHCD) you must also use TJQKA.
If you choose lowercase suits (shcd) you must also use tjqka.

This is code-golf, winner is lowest bytes.

thanks for letting me finally understand how the trick works .-.

@labela--gotoa there's FAR too many variations of this haha. I remember my dad blowing my mind using vertically symmetric cards and doing a different trick, but making me think it was this one.

"Explosive llamas riding segways through a futuristic tube" - I'm looking forward to your next ascii-art challenge...

@LevelRiverSt ahhh crap!!! That's the FIRST time I've let a sarcastic sandbox comment get through to main off sandbox :(

Are mixed type lists OK for input and output (i.e. 2C = [2,'C'] while JS = ['J','S'])?

Rotating the entire deck by a random offset from 0 to 51 inclusive satisfies the condition that "all cards have an equal chance of appearing anywhere in the shuffled deck", but should probably not be considered a random shuffling. Do you mean that all (52!) orders are approximately equally likely?

Just to extend on what @aschepler said: with the period length of the default PRNG in many languages, most of the 52! possible shuffles have a probability of appearing exactly equal to zero (although it might be better or worse depending on the shuffling algorithm).

Is a dalai lama riding a lama on a dolly also acceptable? I'm out of segways  and explosives, but I have got candy worms... https://i.imgur.com/gEkVR5P.gif

@JonathanAllan yessir.

@Tschallacka I really want to know why that Image exists.

@MagicOctopusUrn went through google and it seems that this site is the origin of that somewhere between 2013 and 2014 gif http://www.weirdlyawesome.com/ Note i'm not responsible for heartburn at sight of that site(at least that site is not as horrible as https://www.lingscars.com/ [note i'm not responsible for permanent eye damage])

Retina, 61 60 59 bytes
G`[HCDS].
^$
23456789TJQK
/^2/&L$`.
$&H¶$&D¶$&C¶$&S
@V`
O?`

Try it online! Edit: Saved 1 2 bytes thanks to @MartinEnder. Explanation:
G`[HCDS].

Delete all unreversed cards. This should leave one reversed card or no cards.
^$
23456789TJQK
/^2/&L$`.
$&H¶$&D¶$&C¶$&S

If the input is (now) empty, create a pack of cards.
@V`

Randomly select one card and reverse it (unreverses the single reversed card).
O?`

Shuffle the card(s).

05AB1E, 29 bytes
Y9ŸJ.•§®т•«.•öB•âsKDgiëDΩÂ:.r

Try it online!

.•Āk{?Öw•9LJì#`â would save a few bytes to compress those two together.

@MagicOctopusUrn: After removing 1 and 2, that ends up at the same bytecount doesn't it?

Try it online! - 28, right?

@MagicOctopusUrn: Unfortunately not. You've got both 1 and a in there.

Leave it to me to misinterpret Y9ŸJ as 9LJ

PowerShell v2 or later, 175 bytes
%{$s=[char[]]'SDHC';if($_){$_|?{$s-contains$_[0]}|%{$_[1]+$_[0]}}else{$d=$s|%{$e=$_;[char[]]'23456789TJQKA'|%{$_+$e}}|random -c 52;$r=random 52;$d[$r]=$d[$r][1]+$d[$r][0];$d}}

Long version:
ForEach-Object {
    $s = [char[]]'SDHC'                         # Create a character array with the suits
    if ($_) {                                   # If there's pipeline input ...
        $_ |                                    # ... write it to the output pipeline ...
            Where-Object {$s -contains $_[0]} | # ... but let only those input elements pass where the first letter appears in the suits ...
            ForEach-Object {$_[1] + $_[0]}      # ... and swap the two elements
    } else {
        $d = $s | ForEach-Object {              # Assign $d to the output of the suits, processing each element first.
                $e = $_                         # Store the current suit element for use in the inner loop
                [char[]]'23456789TJQKA' | ForEach-Object {$_ + $e}  # Process each of the numbers, joining it with the current suit, ...
            } | Get-Random -Count 52            # ... and the resulting 2-char-strings goes back into the output to be shuffled
        $r = Get-Random -Maximum 52
        $d[$r] = $d[$r][1] + $d[$r][0]          # Swap the two chars of a random array element in $d
        $d                                      # Write $d to the output pipeline
    }
}

Usage:
Create a shuffled deck and store it in a variable:
$Deck = %{$s=[char[]]'SDHC';if($_){$_|?{$s-contains$_[0]}|%{$_[1]+$_[0]}}else{$d=$s|%{$e=$_;[char[]]'23456789TJQKA'|%{$_+$e}}|random -c 52;$r=random 52;$d[$r]=$d[$r][1]+$d[$r][0];$d}}

Inspect the variable at will, for example
$Deck -join ','

Pipe the deck back into the script:
$Deck | %{$s=[char[]]'SDHC';if($_){$_|?{$s-contains$_[0]}|%{$_[1]+$_[0]}}else{$d=$s|%{$e=$_;[char[]]'23456789TJQKA'|%{$_+$e}}|random -c 52;$r=random 52;$d[$r]=$d[$r][1]+$d[$r][0];$d}}

Python 2, 175 bytes
from random import*
s='SHCD';c='23456789TJQKA'
d=input()
if d:print[b+a for a,b in d if a in s];q
k=sample
r=k(c,1)+k(s,1)
print k([(a+b,b+a)[r==a+b]for a in c for b in s],52)

Try it online! empty input is denoted as []

Jelly, 26 bytes
9ḊṾ€;“AJKQT”p“CDHS”ḟ⁸ẊU-¦Ẋ

A monadic link accepting a list of lists of characters (a stub of 0 cards or a full-deck of 52 cards with one card reversed) and returning a list of lists of characters (a stub of the 1 reversed card but forward or a full-deck with one random card reversed).
Try it online! (footer to make input and output representations match - as a full program Jelly code Python-evals the argument and smashes the characters together for the output)
How?
9ḊṾ€;“AJKQT”p“CDHS”ḟ⁸ẊU-¦Ẋ - Link: list of lists of characters, Z
9Ḋ                         - nine dequeued = [2,3,4,5,6,7,8,9]
  Ṿ€                       - unevaluate €ach = ['2','3','4','5','6','7','8','9']
     “AJKQT”               - literal list of characters = ['A','J','K','Q','T']
    ;                      - concatenate = ['2','3','4','5','6','7','8','9','A','J','K','Q','T']
             “CDHS”        - literal list of characters = ['C','D','H','S']
            p              - Cartesian product = [['2','C'],['2','D'],...,['T','S']]
                           -   a full deck of forward cards
                    ⁸      - chain's left argument, Z
                   ḟ       - filter discard
                           -   leaving either that deck or the 1 reversed card in the input
                     Ẋ     - shuffle
                        ¦  - sparse application...
                       -   - ...to index: -1 (which doesn't exist when the length is only 1)
                      U    - ...do: upend (reverses the penultimate card of the deck)
                         Ẋ - shuffle

This seems to always reverse the ten of hearts. Shouldn't it be a random card?

Ah, thanks, yes there is a bug - it can be fixed with an extra Ẋ before the U (maybe I can fix for zero bytes instead) but will have to do it later...

Since this is a function, I'm not sure if you can return [[number, suit]] instead of [number, suit] to represent a single card when the input is non-empty.

Also, no, I don't think there's any 0-byte fix for that.

@EriktheOutgolfer I don't see why not, a lonesome card is a stub (short deck) of just one card after all.

@JonathanAllan Uh, now we're getting into deep technicalities. :P I don't want to oppose between each other so I'll ask OP instead. :)

><>, 215 193 bytes
i:0)?\~"CHSD":"2"$:"3"$:"4"$:"5"$:"6"$:"7"$:"8"$:"9"$:"T"$:"J"$:"Q"$:"K"$:"A"$&105&"S"=?.~~~{c0.
=+i$?\i$:::"B")$"I"(*$"S"
_oo$~/;
x0
x0
x0
x0
x0
x0
x0
x0
x0
x0
\l&>?!<
>&"3"%:?\~$>o<
\  }}&-1/

Try it online!
Takes input as not separated cards, and output as the same (e.g. KCAC5C6S...)
To make it easier to test, here's a version that takes input as comma separated and outputs as newline separated.
All the x0s are just an attempt to make a semi-uniform random number generator. More of them increases the range of possible values, and the opposite for less. 10 of them is where I judged it to be random enough.
Note that it follows the rules in that:

All cards have an equal chance of being selected to be reversed.
All cards have an equal chance of appearing anywhere in the shuffled deck.

But not all shuffled combinations are possible outputs (and in fact, the vast majority aren't).

R, 177 171 bytes
function(l=1,F="(.)(.)",R="\\2\\1",S=sample)if(l>1)sub(F,R,grep("^[SDHC]",l,v=T))else{m=S(outer(c(2:9,"T","J","Q","K"),c("S","D","H","C"),paste0))
m[1]=sub(F,R,m[1])
S(m)}

Try it online!
Given empty input, (call f with no input), we default to l=1 and thus create a random permutation m of the deck. Assuming sample is truly random, there is an equal probability of any card being the first in this list. So we modify the first one, and then shuffle again, returning the list.
Reversing it, we look for a card starting with one of SDHC and reverse it.

Ruby, 95 (or 100) bytes
->n{s=(0..51).map{|i|"A23456789TJQK"[i/4]+"HCDS"[i%4]}
n[0]?s-n:s[rand 52].reverse!&&s.shuffle}

Given an empty array as input, returns the deck as an array of strings. Given a nonempty array as input, returns the flipped card as an array containing a single string. If the flipped card is required as a string rather than a single-element array containing a string, the following adds 5 bytes: change s-n to (s-n)[0]
Try it online!
The first line generates a standard deck. The second line breaks down as follows
 n[0]?                  #If the input array is not empty (contains a truthy first element)
  s-n:                  #Find the contents of s with the contents of n removed. The only card remaining from the standard deck corresponds to the flipped card in the input.
                        #ELSE
  s[rand 52].reverse!&& #Flip one card in place in the array s. As the result is truthy, whatever is next will be returned.
 s.shuffle              #shuffle the deck and return the shuffled deck with one element flipped
}

Java 8, 275 274 259 bytes
import java.util.*;s->{if(s==null){List l=new Stack();char i=52,r=i,x,y;for(r*=Math.random();i-->0;y="23456789TJQKA".charAt(i%13),l.add(i==r?x+""+y:y+""+x))x="HSDC".charAt(i&3);Collections.shuffle(l);return l;}return s.replaceAll(".*,(.)([^HSDC]).*","$2$1");}

Input is a String, output is either a String or a java.util.List depending on the input.
Explanation:
Try it online.
import java.util.*;          // Required import for List, Stack and Collections
s->{                         // Method with String parameter and Object return-type
  if(s==null){               //  If the input is `null`:
    char i=52,               //   Index-integer
         r=i,                //   Random-integer
         x,y;                //   Temp characters
    List l=new Stack();      //   Create a List
    for(r*=Math.random();    //   Determine the random integer in the range (0;52]
        i-->0                //   Loop `i` 52 times:
        ;                    //     After every iteration:
         y="23456789TJQKA".charAt(i%13)
                             //      Set `y` to one of 23456789TJQKA based on `i` modulo-13
         ,l.add(i==r?        //      If the random integer equals the current `i`
                 x+""+y      //       Add the current card reversed
                :            //      Else:
                 y+""+x))    //       Add the current card as is
      x="HSDC".charAt(i&3);  //    Set `x` to one of HSDC based on `i` bitwise-AND 3
    Collections.shuffle(l);  //   Shuffle the generated Deck
    return l;}               //   And return this Deck as result
                             //  If the input was a Deck instead:
  return s.replaceAll(".*,(.)([^HSDC]).*",
                             //   Get the reversed card from the Deck,
            "$2$1");}        //   and output it non-reversed

Pyth, 45 bytes
J"CDHS"KO52=NsM.S*+c"AKQJT"1S9J|f}hTJQXNK_@NK

Takes the empty list for empty input.
Try it online
Explanation
J"CDHS"KO52=NsM.S*+c"AKQJT"1S9J|f}hTJQXNK_@NK
J"CDHS"                                        Save the suits as J.
       KO52                                    Save a random index as K.
           =NsM.S*+c"AKQJT"1S9J                Save a shuffled deck as N.
                                f}hTJQ         Find all cards with suit first.
                               |      XNK_@NK  If there aren't any, flip a card.

Python 2, 135 bytes
from random import*
s=shuffle
d=zip('A23456789TJQK'*4,'SCDH'*13)
s(d)
D=input()
if D:d=list(set(D)-set(d))
d[0]=d[0][::-1]
s(d)
print d

Try it online!
Cards are tuples of (value,suit)
Empty input is []

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Regex for multiples of 9
It is easy to describe a finite state machine that recognizes multiples of 9: keep track of the digit sum (mod 9) and add whatever digit is accepted next. Such a FSM has only 9 states, very simple! By the equivalence between FSM-recognizability and regular languages, there is a regular expression for multiples of 9. However, any such regular expression is likely... very... long. As in, likely on the order of a gigabyte.
There is a worked example at https://www.quaxio.com/triple/ for multiples of 3. At the bottom of the page, the author provides a somewhat "hand-optimized" solution that's a bit shorter than the naive conversion from FSM to regex.
The challenge:
You must make a regex to detect multiples of 9. Since such a regex is expected to be very long, I ask that you provide a program that can print out your regex. (If you really want to give a whole regex, perhaps host it elsewhere and link it here!)
You must be able to tell us the exact character count of your program's output -- so having a program that simply tries all regexes up to a certain length, until it finds one that works, is not acceptable unless it runs quickly enough that you can run it to completion and give us the resulting regex length!
Points are for having the shortest output regex, not based on program length, of course. Since the regex is the "program" I am asking for, and it's just too long to conveniently transmit here, I'm still tagging this code-golf.
Rules:

The input will only include characters matching [0-9]*.
Your regex should match multiples of 9, but not anything else. Cases that aren't made entirely of the digits 0-9 and are invalid inputs can either match or fail as you wish.
Given the motivation that it's easily recognized by a DFA, the resulting regex must actually be regular expression in the more theoretic terminology, that is, only operators under which regular languages are closed. To be precise, the only things that are allowed:

Literals, character ranges ([ab], [a-f], [^k]), Kleene star (*), anchors (^ and $), grouping via parentheses, alternation (|), optional terms (?), one-or-more terms (+), lookaheads ((?=)), negative lookaheads ((?!)), lookbehinds ((?<=)), negative lookbehinds ((?<!)), conditionals (as in https://www.regular-expressions.info/conditional.html -- (?(?=test)then|else) ), and backreferences of bounded length (see below).

Examples of things that are not allowed:

Backreferences of arbitrary length, forward references, Recursion, subroutines, looping constructs, executable code, any variation of 'eval', or built-in constructs for casting the string to an arithmetic value.

Backreferences that can be shown to have a bounded-length binding string are acceptable, as they can be stored in finite state and do not alter the regularity of the language. For instance, the regex (..2.[3-5])4\1.\1 is acceptable, as there is bound length on the capturing group \1. This is a regular construction. A construct such as (2*)0\1 is not acceptable, as the captured group cannot be stored in finite state.
Your regex is free to accept or reject integers with extraneous leading zeroes as you wish. However, the string "0" must be accepted.

Related, not sure if this would be considered a duplicate

Ah, hmm! I had search for "regex multiple" but not "regex divisible". I suppose that's awfully similar, yes.

It hasn't been said yet, so Welcome to PPCG and interesting first challenge! As mentioned by another user, it is often recommended, but not required, to post challenge proposals in the Sandbox so they can get feedback, before posting on main. However, this is a well thought out and clear challenge, so there is no reason to move this to the Sandbox. Hope you enjoy our community!

Solutions of less than 200 kibibytes are possible, so it won't be THAT huge

Just so you know, this was already solved generally here.

Solution using .NET's extensions: ^(0|9|(?<c>1|(?<c>2|(?<c>3|(?<c>4|(?<c>5|(?<c>6|(?<c>7|(?<c>8))))))))((?<-c>){9})?)*$(?(c).)

@Neil, can you explain a bit about how that works? I'm not familiar enough with .NET syntax. What is the ?<c> and ?<-c> construct? It looks like a back-reference, and I'm not convinced it satisfies the "bounded size" aspect.

I'm not suggesting it satisfies the question criteria, which is why I submitted it as a comment rather than an answer. The ?<c> is a named capture group; .NET allows you multiple capture groups with the same name as well as repeating a capture with */+ and it tracks the list of captures of each group; ?<-c> removes the latest capture from the group (failing if there isn't one). So each digit adds its value in captures, and then we try to remove 9 captures (but that's ? optional). Finally the $(?(c).) only matches if there are no captures left at the end of the string.

Ah, I see. Very clever, the way you nested them like that! I like it. :) Does this evaluate efficiently in practice? It seems like it should, as there is essentially only ever "one way" to capture the next character, and the engine would ideally recognize that.

Haskell, 207,535 202,073 bytes
5,462 bytes saved by using 0|9 instead of [09] where possible.
digits n
  | x == 0    = "0|9"
  | otherwise = show x
  where x = mod n 9

regex 0 = "[09]*"
regex n = (regex' n (-1) (-1)) ++ "*"

regex' 0 start end = digits (end - start)
regex' n start end = '(':(regex' 0 start end) ++ (concat ['|':(regex' (n-x) (start-x) (-1)) ++ (regex (n-x))
                                                  ++ (regex' (n-x) (-1) (end-x)) | x <- [1..n]]) ++ ")"

main = do
  putStr ("^" ++ (regex 8) ++ "$")

Try it online!
Just a quick adaptation of the regex given in the footnotes of the linked article to get things started.
Pastebin of output regex, courtesy of Herman Lauenstein.
While I have not been able to test the full regex, modifying the program to check divisibility by 3 instead gives something exactly equivalent to the regex I based this on.  Furthermore, modifying the program to check the digit sum's divisibility by 4 or 5 also seems to work on the numbers I tested it on.

You can also test what your method gives for divisibility by 2 (should be something like /even$/) and divisibility by 5 (should be something like /[05]$/). PS: Mention the language of your code

Here is a pastebin with the output (with all occurences of ([09]| replaced with (0|9| to save thousands of bytes)


text:
Print the numbers -1, 0, 1
This is a very simple challenge, and it is to print the numbers -1, 0, and 1.
The following paragraph is credited to Print numbers from 1 to 10
Your output format can be whatever your language supports. This includes arbitrary separators (commas, semicolons, newlines, combinations of those, etc., but no digits), and prefixes and postfixes (like [...]). However, you may not output any other numbers than -1 through 1. Your program may not take any input. Standard loopholes are disallowed.
This is code-golf, so the shortest answer in bytes wins. Happy golfing!

I don't think we need one of these for all number ranges.

@Dennis but all the others start at 0 or 1. plus, I'd also like to see if any get it in 2 bytes or less

Starting at -1 might be annoying for languages that have only unsigned integers, but it will make no difference whatsoever for all others. If you want to satisfy your 2-byte curiosity, you can join us in The Nineteenth Byte.

Does this count?

@ETHproductions yes!

Possibilities: 1_k_, 3k2-

This may be trivial in more practical languages, but for some I think the inclusion of negative numbers could be interesting. While I think this challenge potentially warrants a downvote, I don't think it should be closed.

I've reopened this challenge, as, while trivial, I agree with @RedwolfPrograms that negative numbers and zero make this different enough from Print numbers 1 to 10

Jelly, 3 bytes
-r1

Try it online!
1r-

Try it online!
-ŒR

Try it online!
1ŒR

Try it online!
Ø-Ż

Try it online!
Ø+Ż

Try it online!
-rN

Try it online!
1rN

Try it online!
2Ż’

Try it online!
3Ḷ’

Try it online!
and a bonus one:
M, 2 bytes
-R

Try it online!

This is what we call "flexing". Have my upvote.

Pyt, 4 bytes
3ř⁻⁻

Try it online!
Explanation:
3      Push 3
ř      Push [1,2,3]
⁻⁻     Decrement twice
       Implicit print

R, 9 bytes
cat(-1:1)

Try it online!

7, 11 characters, 4 bytes
17370074023
Try it online!
Hexdump to prove byte count:
00000000: 3df0 3c09                                =.<.

This challenge is very easy in most languages, so I decided to solve it in a language where it's actually an interesting problem.
Explanation
It took me ages to golf this down to 4 bytes – there are a really huge number of ways to do this with 12 characters, but reaching 11 is very difficult.
The only part of the code here that actually runs (after the first cycle, which just sets up the stack to mirror the structure of the program) is 4623 (which is the code generated by the code 4023 in the original program; the 4023 is a literal which pushes 4623 to the stack; as usual, I'm using non-bold for commands that just push code to the stack and bold for the commands they push). After the first cycle, each new cycle runs the top stack element, without actually popping it from the stack.
The 4 swaps the top two stack elements, and inserts a blank element between them (thus, a b goes to b blank a). Then the 6 analyzes the top element to determine what source code is most likely to have produced it, and appends the resulting source code to the element below it (which will be blank at this point because we just ran a 4). Thus, the net effect of 46 is to swap the top two stack elements, and replace the top stack element with (a guess at, but the guesses are always correct for this program) the source code that produced it.
2 duplicates the top stack element, and 3 outputs the top stack element, popping both it and the element below. Thus, the net effect of 23 is to output and pop the top stack element, without disturbing elements below it.
As such, the effect of our program 4623 is to pop and output the source code that produced the second stack element, whilst leaving the top stack element unchanged. The top stack element in question is the actively running program (which doesn't get popped when we start to run it), so once the program finishes running, it'll just run again, etc. – this is in effect an infinite loop which, for each element on the stack, outputs the source code that produced it (and eventually the program crashes due to stack exhaustion). As such, the data being given to the output routines is 00, 3, 1 (i.e. the sections of the source code  in between 7s – the source code has already run to produce runnable code by this point, but the source is reconstructed from the runnable code rather than the runnable code actually being run).
The first 0 sent to the output routine selects numerical output mode. Then, 0, 3, 1 get output. The numerical value of a string in 7 is the total number of 1 and 7 characters it contains, minus the total number of 0 and 6 characters it contains. Thus, the values of these strings are -1, 0, and 1, as required by the question.
One complication is that if we try to output an empty string, we just get no output, rather than its numerical value of 0 being output: this is a special case needed because the output command 3 is the primary way to pop and discard stack elements (basically, you push an empty element above the one you want to pop, output that empty element and pop the element below as a side effect). A "clean" way to output 0 thus requires outputting a string like 01 which is nonempty and has a numerical value of zero. This program uses 3, which is shorter, but the numerical output formatter will append a comma when outputting strings ending 3 (in addition to outputting their numerical value). As a consequence, the output of the program is actually -1 0, 1, but this is permitted by the question. (All eight of the one-character strings either have a side effect when output via the numerical formatter, or else have a value different from zero, so outputting -1 0 1 exactly would make the program longer.)

JavaScript, 19 15 bytes
[-1,0,1].map(alert)
alert([-1,0,1])

Python - 15 bytes
print("-1 0 1")

I would say "Good luck improving this.", but past experience has taught me never to assume: though, this won't be easily beat (for i in range(3), %ding the spaces and %sing the 1s are all overweight, so you can eliminate those.)

-2 bytes

-4 bytes if you switch to Python 2

I see. Numeric output requires no quotes.

You need commas between the numbers, otherwise this is invalid syntax, and you can remove the space before the -

As pointed out above, your answer was invalid due to the broken syntax. I've rolled it back to your previous valid answer. Feel free to implement @Zionmyceliaadamancy's suggestions properly this time


text:
The weight of a Zero
Given an ordered list of numbers (possibly with leading zeros), arrange the numbers vertically, then let all zeros drop all the way to the bottom and all overhangs drop to the bottom-most open slot. Output the resulting integers, removing leading zeros.
Worked Example
Say we were given the following as input:
['0000312941295', '239124000124581598', '32852353800451258', '10235923505185190', '1491359102149']

First we arrange it vertically:
0000312941295
239124000124581598
32852353800451258
10235923505185190
1491359102149

Then, column by column, drop the zeros "through" the other numbers so they rest on the bottom and "push" the other numbers up. This would result in the first couple steps being as follows:
2000312941295
339124000124581598
12852353800451258
10235923505185190
0491359102149
^

2300312941295
329124000124581598
14852353800451258
10235923505185190
0091359102149
 ^

2390312941295
328124000124581598
14252353800451258
10935923505185190
0001359102149
  ^

...

2391312941295
328524538124581598
14232323525451258
10915991001185190
0000350000049
                ^

Next, drop all overhangs as if gravity is pulling them down like sand.
2391312941295
3285245381245 1598
14232323525458258
10915991001181190
00003500000495
             ^

2391312941295
3285245381245  598
14232323525458158
10915991001181290
000035000004951
              ^

...

2391312941295
3285245381245
14232323525458159
10915991001181258
000035000004951908
                 ^

Finally, output these numbers, removing leading zeros. For our worked example, output:
[2391312941295, 3285245381245, 14232323525458159, 10915991001181258, 35000004951908]

For another example, suppose input of [1234000,12345678,1234,12340608,12341234].
1234000
12345678
1234
12340608
12341234

Drop the zeros:
1234
12345678
1234163
12340208
12340004

Drop the remaining overhanging digits:
1234
1234567
12341638
12340208
12340004

Output is [1234, 1234567, 12341638, 12340208, 12340004].
Rules

The input may contain leading zeros. The output must not contain leading zeros.
If applicable, you can assume that the input/output will fit in your language's native Integer type.
The input and output can be given by any convenient method.
Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
Standard loopholes are forbidden.
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

May we assume that the output numbers will not exceed our language's precision? (JS rounds 14232323525458159 to 14232323525458160)

@ETHproductions I think that's a PPCG default.

and all overhangs drop to the bottom-most open slot was a good fix to my broken challenge :).

Yeah, @ETHproductions, that's a standard of my challenges. I must have missed it when copy-pasting the Rules section.

The output must not contain leading zeros. This applies only if you're printing the output as text, right?  If you produce a list / array of int in a language like C or x86 asm, I assume they can be stored the normal way, in fixed-width binary integers (which have leading 0 bits unless they're negative, or unsigned and very large).

@PeterCordes Yes, that's fine. Limitations/quirks of the language like fixed-width integers aren't applicable for that output restriction. For example, the number being talked about is still 1234, regardless of what the actual binary representation looks like. You wouldn't say the number is 00..001234. I hope that makes sense.

Yeah, mostly I was just nit-picking the wording.  I doubt anyone really thought you meant anything else.  BTW, does the input have to be in a format that can express (a variable number of) leading zeros?  e.g. that can differentiate between 01234 and 0001234?

@PeterCordes Yes, the input may contain leading zeros, so it should be able to handle that. I imagine for most languages, that means take input as a string.

And it has to be in base 10?  i.e. I couldn't apply this algorithm on the bits of binary integers?  Hmm, maybe fixed-width BCD integers would be good for x86 asm...  I could justify that because 32-bit x86 does still have instructions for manipulating BCD integer data (like AAA, so it's a native integer type.  Except that the instructions only work on a single byte at a time, designed for extended precision not fixed-width 16 or 32-bit BCD (I think).  Probably dealing with leading zeros in fixed-width ASCII strings is easier, though.

Is it allowed to replace leading zeros with leading spaces?  e.g. a C or asm function which modifies its input in place, where the input is an array of fixed-width char arrays like char s[n][16]?  Or would you require the output strings to be left-justified, so the most-significant digit of the actual number is the first character of each string?  It might be fun to implement this with x86 SIMD packed-compare and blend, and replacing leading zeros with spaces might be easier than shifting the rest of the buffer over.

@PeterCordes Input and output doesn't necessarily need to be in base-10 (that's in the allowed default I/O methods), so long as using a different base doesn't trivialize the task (that's a standard loophole). Secondly, I guess I didn't specify that the leading zeros must be removed completely, though that was the intent. I'm going to rule that replacing the zeros with spaces is not allowed, as outputting .    1234 is very different than outputting 1234.

Jelly, 8 bytes
Z¬Þ€UZṚḌ

Try it online!
How it works
Z¬Þ€UZṚḌ  Main link. Argument: M (2D array / matrix)

Z         Zip; transpose M by reading columns as rows.
 ¬Þ€      Sort each row of the transpose by logical NOT, pushing 0's to the end.
    U     Upend; reverse all sorted rows of the transpose.
     Z    Zip again, restoring rows from columns. Overhangs rise to the top.
      Ṛ   Reverse the order of the rows.
       Ḍ  Decimal; convert the rows from base 10 to integer.

WHAT?
As I was reading the question I was thinking: "Finally, there's no way someone can pull off less than 20 bytes for this".
Madness

Sort each row of the transpose by logical NOT, pushing 0's to the end. Is this guaranteed to be a stable sort?

Yes, Jelly uses Python's sorted, which is guaranteed to be stable.

I kind of like this commutative looking version: ṚZẸÞ€ZṚḌ :)

05AB1E, 11 bytes
ζεð†R0†R}øï

Try it online!

Never seen † used before, nice one.

Python 2, 118 bytes
lambda l:[int(''.join(z))for z in zip(*map(lambda*a:['']*a.count(None)+[e for e in a if'0'<e]+['0']*a.count('0'),*l))]

Try it online!
Ungolfed version
def f(list_):
 max_len = max(len(x) for x in list_)
 transposed_list = zip(*[list(row)+(max_len-len(row))*[None] for row in list_])
 weighted_list = [['']*column.count(None)+[cell for cell in column if cell != '0' and cell != None]+['0']*column.count('0') for column in transposed_list]
 return [int(''.join(row)) for row in zip(*weighted_list)]

The first two lines are equivalent to map(lambda*a...), the default behaviour if for map to fill with Nones if one list is shorter than the other.
e>'0' is equivalent to cell != '0' and cell != None, because if it is any digit (1~9) it will have a higher codepoint, and (any) string is higher than None.

Care to post an ungolfed version of this?

@PeterCordes added the ungolfed version and a short explanation for some obscure points

Husk, 12 bytes
md↔TmoÖ±miT↔

Try it online!
Explanation
md↔Tm(Ö±mi)T↔  -- input as list of strings, example: ["103","32","258"]
            ↔  -- reverse: ["258","32","103"]
           T   -- transpose: ["231","520","83"]
    m(    )    -- with each line do (example with "520")
        mi     -- | convert each char to digit: [5,2,0]
      Ö±       -- | sort by signum (stable): [0,5,2]
               -- : [[2,3,1],[0,5,2],[8,3]]
   T           -- transpose: [[2,0,8],[3,5,3],[1,2]]
  ↔            -- reverse: [[1,2],[3,5,3],[2,0,8]]%
md             -- convert each to integer: [12,353,208]

Ruby, 104 bytes
->a{a.map{|x|x.ljust(99).chars}.transpose.map{|x|x.sort_by{|x|x<?1?x:?!}}.transpose.map{|x|x.join.to_i}}

Try it online!
Explanation
->a{
  a.map{|x|x.ljust(99).chars}  # Fill spaces to make this rectangular
    .transpose.map{|x|
       x.sort_by{|x|x<?1?x:?!} # Treat all chars but " 1" as ! (see ascii table)
    }.transpose.map{|x|x.join.to_i} # Convert back to numbers
                       # note: if no leading 0s, eval x*'' , doesn't work here
}

Pyth, 11 bytes
iRT_C_M!DMC

Try it online!

Retina 0.8.2, 95 92 bytes
m(+`^((.)*)(.+)(¶(?<-2>.)*)(?(2)_)$
$1$4$3
+`^((.)*)0(.*¶(?>(?<-2>.)*))([^0])
$1$4${3}0
^0+

Try it online! Explanation: The first stage drops the overhanging digits as this makes it easier (edit: even easier for a 3-byte saving) for the second stage to drop the zeros. The third stage then removes leading zeros.

Perl 5, -p0 77 bytes
Old style counting: 79 bytes (+2 for p0)
Give input as lines on STDIN without final newline (otherwise everything is seen as overhang and the final newline rises to the top as the input string crashes down). E.g.:
0000312941295
239124000124581598
32852353800451258
10235923505185190
1491359102149

It was a bit tricky to get the overhang dropping and the 0 dropping into one regex
#!/usr/bin/perl -p0
s/^.{@{+}}\K((0)|.+$)(.*
.{@{+}})((?(2)[1-9]|$))/$4$3$1/m while/|/g;s/^0+//mg

Try it online!

APL (Dyalog Unicode), 26 bytesSBCS
Anonymous tacit prefix function taking a character matrix as argument and returning a list of numbers.
⍎⍤1∘⍉' 0'(∩∘⊃,~,∩∘⊃∘⌽)⍤1⍨⍉

Try it online!
⍉ transpose the input (as we need to work on the columns)
' 0'(…)⍤1⍨ apply the following tacit function to each row (sub-array of tensor rank 1) with ' 0' as right argument (⍨ swaps the arguments) :
 ∩ intersection of the row and
 ∘ and
 ⊃ the first of ' 0'
 (i.e. row∩' '; all the spaces from each row)
 , followed by…
 ~ the set difference
 (i.e. row~' 0'; the row but without spaces and zeros)
 , followed by…
 ∩ intersection of the row and
 ∘ and
 ⊃ the first
 ∘ of
 ⌽ the reversed ' 0'
 (i.e. row∩'0'; all the zeros from each row)
⍎⍤1 evaluate each row (sub-array of tensor rank 1)
∘ of
⍉ the transpose of that (i.e. each column; the now modified input rows)

The parenthesised bit is clever. It took me a while to understand the intention there, though I know what individual squiggles do. Once I understood it, it's easy to beat: ⍎⍤1∘⍉{⍵[⍋3|2×' 0'⍳⍵]}⍤1∘⍉ (⎕io←0) It may be golfable further, e.g. I didn't explore dyadic ⍋

actually, the above is shorter as a complete program (not a train): ⍎⍤1⍉{⍵[⍋3|2×' 0'⍳⍵]}⍤1⍉⎕

@ngn Such a different method merits own post. The pre- and post-processing is obvious.

APL (Dyalog Classic), 24 23 22 bytes
⍎⍤1⍉{⍵[⍒⌈9÷⍨⎕d⍳⍵]}⍤1⍉⎕

Try it online!
based on Adam's solution

Ruby, 203 bytes
->a{t=->b{b[0].zip(*b[1..-1])}
m=a.map{|s|s.size}.max
a.map!{|s|(s+" "*m)[0...m].chars}
a=t[a].map{|c|c.size.times{|i|" 0"[c[i]]&&(c.slice!(i)==?0?c.push(?0):c.unshift(" "))}
c}
t[a].map{|r|r.join.to_i}}

Try it online!
A lambda accepting an array of strings and returning an array of ints. I feel like I'm missing something; this feels enormous :/
->a{
  t = -> b { b[0].zip(*b[1..-1]) }     # t is a lambda that transposes 2D arrays
  m = a.map{ |s| s.size }.max          # m is the maximum input string length
  a.map!{ |s| (s+" "*m)[0...m].chars } # Right-pad every string to the same length
  a = t[a].map{ |c|                    # Transpose a, and for every row (column)
    c.size.times{ |i|                  # For every character in the column
      " 0"[c[i]] && (                  # If the character is 0 or space
        c.slice!(i) == ?0 ?            # Remove it from the column, and if it was 0,
          c.push(?0) :                 # Push a 0 to the end (bottom) of the column, else
          c.unshift(" ")               # Add a space to the top of the column
      )
    }
    c
  }
  t[a].map{ |r| r.join.to_i }          # Transpose a back, and parse each row to int
}

I outgolfed this (for now)

@Unihedron Wow, you beat me by 50%. You've got my +1 for sure.