Fairy chess "leaper" movement patterns A leaper is a category of fairy chess piece which moves by "jumping."  A normal knight is a (1,2)-leaper, meaning each move involves moving a distance of 1 square in an orthogonal direction and 2 squares in the perpendicular direction.

.o.o.
o...o
..N..
o...o
.o.o.

There are many different leapers. The (1,3)-leaper is called the Long Knight, or Camel.  Its move pattern looks like this:

..o.o..
.......
o.....o
...L...
o.....o
.......
..o.o..

There's also the (2,2) Alfil...

o...o
.....
..A..
.....
o...o

...and even the (0,1) Wazir.

.o.
oWo
.o.

Challenge

Given a pair of numbers as input, output the corresponding movement diagram.  You may write a program or function, with input provided via STDIN/command-line or as an argument, and output provide by STDOUT or the return value. This is code-golf.

Input

Input will be a comma-separated list of two integers and an uppercase letter.  The two integers will be in the range 0-7 (inclusive) and in non-decreasing order. Trailing newline optional for input and output.

Here are the inputs for the above four examples:

1,2,N
1,3,L
2,2,A
0,1,W

Output

Output will be a square-shaped multiline string.  The capital letter will be placed in the center to represent the current location of the piece.  The movement locations will be represented by either 4 or 8 lowercase os.  All other spaces in the square will be filled with periods.

If the movement pattern is 0,0, output just the capital letter.

As a hint, if the second integer (the larger one) has value N, then the square will always have side length 2N+1.  The os will always be on the perimeter of the square.

Additional Testcases

1,1,F

o.o
.F.
o.o

5,7,Q

..o.........o..
...............
o.............o
...............
...............
...............
...............
.......Q.......
...............
...............
...............
...............
o.............o
...............
..o.........o..

0,0,J

J

Ruby,107
->a,b,n{(-b..b).map{|i|s='..'*b+?.
i%b==0&&(i==0?s[b]=n :s[b+a]=s[b-a]=?o)
i.abs==a&&s[0]=s[-1]=?o
puts s}}

Ungolfed in test program
f=->a,b,n{
  (-b..b).map{|i|                           #iterate from -i to i (lines of grit)
    s='..'*b+?.                             #make a string of 2n+1 .'s
    i%b==0&&(i==0?s[b]=n :s[b+a]=s[b-a]=?o) #if i%b=0 plot the centre character (if i=0) or the o's on the top and bottom rows
    i.abs==a&&s[0]=s[-1]=?o                 #if i.abs=a plot the o's in left and right columns
    puts s                                  #having substituted the .'s with o and centre as necessary, output the current line
  }
}

a=gets.to_i
b=gets.to_i
n=gets.chop
f[a,b,n]


Growing Quine Sequence You are to write a sequence of 10 programs p1 p2 ... p10 that satisfy the following properties:

pK prints pK+1 for K from 1 to 9
p10 prints p10
When the first K programs are concatenated, the resulting program p1...pK prints p1...pK.
Each program pK must be larger in byte size than the previous program pK-1.
All programs must be in the same language.
Built-in quining functions (e.g. Q in many languages) are allowed.

Your score is the sum of the byte counts of the 10 programs. Since there are only ten programs, you must make your codes as short as possible. Good luck.

Seriously, 245 bytes:

All ten programs concatenated:

Q9ucQc8<WX#dXεj0WX.Q9ucQc8<WX#dXεj0WX.
Q9ucQc8<WX#dXεj0WX.

Q9ucQc8<WX#dXεj0WX.

Q9ucQc8<WX#dXεj0WX.

Q9ucQc8<WX#dXεj0WX.

Q9ucQc8<WX#dXεj0WX.

Q9ucQc8<WX#dXεj0WX.

Q9ucQc8<WX#dXεj0WX.

Q9ucQc8<WX#dXεj0WX.

There are invisible characters that become visible when executed, a strange property of byte 7F. The trailing newlines on each program are significant. In fact, Seriously automatically appends newlines to its output whether you want it to or not. This just counts the number of newlines in the output, and as soon as that number exceeds 8, it deletes the last character of output. As such, p1..pK will print p1..pK for all K>4.

Q                                  Push source code.
 9uc                               Push \n
    Qc                             Push the number of times it appears in source code.
      8<                           Check if it appears more than 8 times.
        WX     0WX                 If so, run the included code.
          #dX                      Convert string to list, dequeue and discard a newline.
             εj                    Join list back into string.
                  .                Print and halt. (Invisible byte here.)


Code Crosswords - Solutions This is the companion question for Code Crosswords. Robber answers go here.

See Where should we put robbers? for meta-info.

professorfish, CJam, 41 darks

(This solution actually requires several spaces, so it's not the one professorfish was looking for.)

#K###I#'32
#HDJ*s\ ##
2##2#`#`#-
4Zm*`##L#3
m##6##]`'
f####e#`#'
`#0#'d1+eu
## #!####9
## '{;'"'m
C5(#}####q

That was great fun. Note that the # beneath the 6 is actually code and not a dark cell. Let's go through this:

Across

Hint 2: [[4 3]]. This was one of the trickier ones, because I really got stuck on trying 4Z]]` or similar. Turns out you can use the Cartesian product m* on stuff that isn't an array, and it will make an array for you. So here it is:

4Zm*`

Hint 4: 24717. By the time I got to this, the H, J, s and trailing space were already in place. The H gave away that I could probably just reuse the 17 and do \ at the end. The J pushes a 19 and 247 == 13 * 19, so:

HDJ*s\

Hint 7: 32. There are a bunch of ways to do this: Y5#, 3 2, ZY, YZ\, 4(2, 2)2, '32. I went with the last one, because starting with a character seemed promising for 7-down, and that turned out to be right.

Hint 8: E. I already had the 'd when I got there, so it was between choosing 'd1+eu, 'deu1+ or a variant where I used ) and a space instead of 1+ (for the non-CJam people, this taking the d character and increment and upper-casing it, in either order). However, the u in the final column looked useful for A-down. So I picked the first of those. In the end, 'd) eu would have worked, too.

Hint 9: "". Well, this had to be "empty string, get string representation, push a space". But also needed the ` for string representation in 7-down, and a space in A-down seemed useful, too, so I chose

]`'

Note that ] might also have been one of LMOQR.

Hint B: "m. I just really had to fit this one in with the rest, but there were few characters that mattered. I already had the { and the m. So instead of using a block, I turned { into a character, discarded it, and then pushed the two required characters:

 '{;'"'m

Hint D: 124. I solved this one together with C-down, which was easiest with a decrement at the end. So I push a 12, a 5, and decrement the latter:

C5(

Down

Hint 1: [2 2 2 3]. That looked too suspiciously like a prime factorisation for it not to be one. :)

24mf`

Hint 3: 3010936384. Factoring this showed that it's actually 386. The only question was how to get the 38 in compliance with 2-across. In the end I needed a * in the third place, so doubling 19 it was:

J2*6#

Hint 5: 2017. Two characters for such a large number? Just use built-in two-digit variables:

KH

Hint 6: "18". I think there's only a single way to do this in 3 characters. Use the built-in 18, convert it to a string, and then to its string representation.

Is`

Hint 7: ' "\"\"". Probably the hardest part of the puzzle. In particular, I needed to get the "\"\"" in only three characters. The trick was to get the string representation of the empty string twice. That led to:

' `L``+

THe + isn't necessary, but was needed by 8-across.

Hint 8: !{}. The block needed to go in the code, so that left only two characters for !, which meant using another literal:

'!{}

Hint A: -3u3.  With the u in place from 8-across, I started to put -3 and 3 in the corners where no other hint cared about them. But then I needed an m at the bottom. I think there are multiple ways to get a 3 with _m_, but the simplest was taking the square root of 9:

-3 'u9mq

Hint C: -1. I already had the decrement there, so I just put a 0 where no one else cared about:

0  (

Hint E: Stack: "". Well that was the simplest one. Just call the debugger:

ed


Reindent Java/C/C++/etc. code Write a program that adds or removes whitespace to format code nicely. Rules for what the code should look like when you're done:

No line should contain more than one of { and }.
A { should always be the last thing on a line.
A } should always be the only thing on a line (besides whitespace that comes before it).
The amount of whitespace in front of each line should be a fixed multiple of the current nesting count. (You can use any amount of indentation you want, as long as it doesn't change.)
No whitespace should be inserted or removed that doesn't contribute to satisfying one of these rules.

The nesting count for the first line is 0. The nesting count of any other line is the nesting count of the previous line, plus one if the previous line contains a {, minus one if the current line contains a }.
{ and } inside string literals and comments don't count in the above rules. A string literal is text enclosed in single or double quotes, where single or double quotes with an odd number of backslashes immediately before them aren't interpreted as the end of the string literal. A comment is text enclosed in /* and */, or text going from // to the end of the line. In a line multiple comment start markers, only the first one counts. Comments are not parsed inside string literals.
Examples
    main() {printf("Hello!"); // I don't care about the world...
        }

becomes:

main() {
    printf("Hello!"); // I don't care about the world...
}

int main(){
    puts("a");
        puts("b");
}

becomes:

int main(){
    puts("a");
    puts("b");
}

main()
{ printf("{"); /* }
} */
     printf("}//}"); ///*
    }

becomes:

main()
{
    printf("{"); /* }
} */
    printf("}//}"); ///*
}

int test[] = {1, 2, 3};

becomes:

int test[] = {
    1, 2, 3
}
;

JavaScript (ES6), 376 373 378 393 bytes

This was... quite the challenge...

let f =

s=>{F=(i,l=1)=>[a=a.map(([q,y])=>[q,ya.unshift(b=[q,y])&0))b=l=0
s=s[e=1,r](/[{}](?=.)|.(?=})/g,(c,i)=>F(i)&&c+`
`)[e=0,r](/.+/g,(x,i)=>x[r](/^\s*/,y=>" ".repeat(q=/{/.test(x)?l++:/}/.test(x)?--l:l,F(i,q-y.length))))
a.map(([q,y])=>s=s.slice(0,y)+q+s.slice(-~y))
return s}
<textarea rows=7 cols=50 oninput=O.innerText=f(value)>    main() {printf("Hello!"); // I don't care about the world...
    }</textarea>

Let me know if there's anything wrong with the output, though I couldn't find anything can't find anything more.

Ungolfed version

I golfed the code as I wrote it, so let's see how this goes...

function prettify(code) {
  let excerpts = [], extras, level;

  // Extract comments and strings for easy parsing
  // This has to be done recursively because of the nested comments
  for (let done = false; !done; ) {
    done = true;
    code = code.replace(/\/\*(?:(?!\/\*|\*\/)[^])*\*\/|\/\/.+|("|')(?:\\.|(?!\1).)*\1/, (excerpt, _, index) => {
      excerpts.unshift([excerpt, index]);
      done = false;
      return "0";
    });
  }

  // Update the indices of the excerpts when the code is changed
  let adjustIndices = (index, length) => {
    index += extras;
    excerpts = excerpts.map(([string, oldIndex]) => {
      var newIndex = oldIndex;
      if (oldIndex >= index) newIndex += length;
      return [string, newIndex];
    });
    extras += length;
  }

  // Add extra newlines where necessary:
  // - After a { or a } if there isn't one already
  // - Before a } if there isn't one already (note: already-indented '}'s will get an extra newline)
  extras = 0;
  code = code.replace(/[{}](?=.)|.(?=})/g, (char, index) => {
    adjustIndices(index + 1, 1);
    return char + "\n";
  });

  // Remove extra whitespace at the beginning of each line,
  // and the same time apply the necessary number of tabs
  extras = 0;
  level = 0;
  code = code.replace(/.+/g, (line, index) =>
    line.replace(/^\s*/, spaces => {
      let tabs;
      if (line.indexOf('{') > -1)
        tabs = level, level += 1;
      else if (line.indexOf('}') > -1)
        level -= 1, tabs = level;
      else
        tabs = level;

      adjustIndices(index, tabs - spaces.length);
      return "\t".repeat(tabs);
    })
  );

  // Add back in the excerpts
  for ([excerpt, index] of excerpts)
    code = code.slice(0, index) + excerpt + code.slice(index + 1);

  return code;
}
<textarea rows = 7 cols = 50 oninput = "O.innerText = prettify(this.value)">    main() {printf("Hello!"); // I don't care about the world...
    }</textarea>


Tips for golfing in 1+ What general tips do you have for golfing in 1+? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to 1+ (e.g. "remove unnecessary whitespace" is not an answer).

Please post one tip per answer.

Subroutines can have empty names

(|1+1<) is a valid definition for a subroutine, invoked as ().


Can I sweep the mines? Minesweeper is a popular puzzle game where you must discover which tiles are "mines" without clicking on those tiles. Instead, you click on nearby tiles to reveal the number of adjacent mines. One downside about the game is that it is possible to end up in a scenario where there are multiple valid answers and you may only guess. For example, take the following board:
1110
2*31
3*??
2*4?
112?

In this format, a number represents the number of adjacent mines, an * represents a known mine, and a "?" represents a potential mine. The unfortunate thing about this particular puzzle is that there are four distinct and valid potential solutions:
1110    1110    1110    1110
2*31    2*31    2*31    2*31
3*4*    3*5*    3**2    3**1
2*42    2*4*    2*4*    2*42
112*    1121    1121    112*

This means the board is unsolvable. Here is an example of a solvable board:
1121
1??*
12?*
0122

This board is solvable because there is only one possible valid solution:
1121
1*4*
12**
0122

Your task is to write either a program or function that takes a valid minesweeper board and determines if it is solvable or not. By "valid minesweeper board", I mean that the input will always be rectangular, have at least one solution, and not contain any invalid characters.
Your input may be an array of characters, an array of strings, a string containing newlines, etc. The output must be a truthy value if it is solvable and a falsy value if it is not. I am not extremely worried about performance, but your solution must theoretically work for any size input.
As usual, standard loopholes apply and the shortest solution in bytes wins!
Examples:
The following examples are all solvable:
1121
1??*
12?*
0122

1110
1???
1110
0000

1110
3???
??20
*310

****
****
****
****

0000
0000
0000
0000

1100
*100
2321
??*2
13*2
1221
1*10
1110

1121
2*??
2*31
2220
1*10

The following examples are all unsolvable:
1110
2*31
3*??
2*4?
112?

01??11*211
12??2323*1
1*33*2*210
12?2122321
13?3101**1
1***101221

1***
3*52
2*31
12??
02??
01??

00000111
000012*1
00001*21
22101110
**100111
?31123*1
?311**31
**113*20

GNU Prolog, 493 bytes

z(_,[_,_]).
z(F,[A,B,C|T]):-call(F,A,B,C),z(F,[B,C|T]).
i([],[],[],[]).
i([H|A],[I|B],[J|C],[H-I-J|T]):-i(A,B,C,T).
c(A/_-B/_-C/_,D/_-_/T-E/_,F/_-G/_-H/_):-T#=A+B+C+D+E+F+G+H.
r(A,B,C):-i(A,B,C,L),z(c,L).
q(63,V):-var(V).
q(42,1/_).
q(X,0/Y):-Y#=X-48.
l([],[0/_]).
l([H|T],[E|U]):-q(H,E),l(T,U).
p([],[[0/_,0/_]],0).
p([],[[0/_|T]],N):-M#=N-1,p([],[T],M).
p([H|T],[[0/_|E]|U],N):-p(T,U,N),l(H,E).
m([H|A],B):-length(H,N),p([],[R],N),p([H|A],M,N),z(r,[R|M]),p(B,M,N).
s(A):-setof(B,m(A,B),[_]).

An extra predicate that may be useful for testing (not part of the submission):

d([]).
d([H|T]):-format("~s~n",[H]),d(T).

Prolog's definitely the right language for solving this task from the practical point of view. This program pretty much just states the rules of Minesweeper and lets GNU Prolog's constraint solver solve the problem from there.

z and i are utility functions (z does a sort of fold-like operation but on sets of three adjacent elements rather than 2; i transposes 3 lists of n elements into a list of n 3-tuples). We internally store a cell as x/y, where x is 1 for a mine and 0 for a nonmine, and y is the number of adjacent mines; c expresses this constraint on the board. r applies c to every row of the board; and so z(r,M) checks to see if M is a valid board.

Unfortunately, the input format required to make this work directly is unreasonable, so I also had to include a parser (which probably accounts for more code than the actual rules engine, and most of the time spent debugging; the Minesweeper rules engine pretty much worked first time, but the parser was full of thinkos). q converts a single cell between a character code and our x/y format. l converts one line of the board (leaving one cell that's known to be not a mine, but with an unknown number of neighbouring mines, at each edge of the line as a border); p converts the entire board (including the bottom border, but excluding the top one). All of these functions can be run either forwards or backwards, thus can both parse and pretty-print the board. (There's some annoying wiggling around with the third argument to p, which specifies the width of the board; this is because Prolog doesn't have a matrix type, and if I don't constrain the board to be rectangular, the program will go into an infinite loop trying progressively wider borders around the board.)

m is the main Minesweeper solving function. It parses the input string, generating a board with a correct border (via using the recursive case of p to convert most of the board, then calling the base case directly to generate the top border, which has the same structure as the bottom border). Then it calls z(r,[R|M]) to run the Minesweeper rules engine, which (with this call pattern) becomes a generator generating only valid boards. At this point, the board is still expressed as a set of constraints, which is potentially awkward for us; we could perhaps have a single set of constraints which could represent more than one board. Additionally, we haven't yet specified anywhere that each square contains at most one mine. As such, we need to explicitly "collapse the waveform" of each square, requiring it to be specifically either a (single) mine or a nonmine, and the easiest way to do this is to run it through the parser backwards (the var(V) on the q(63,V) case is designed to prevent the ? case running backwards, and thus deparsing the board forces it to be fully known). Finally, we return the parsed board from m; m thus becomes a generator which takes a partially unknown board and generates all the known boards consistent with it.

That's really enough to solve Minesweeper, but the question explicitly asks to check whether there's exactly one solution, rather than to find all solutions. As such, I wrote an extra predicate s which simply converts the generator m into a set, and then asserts that the set has exactly one element. This means that s will return truthy (yes) if there is indeed exactly one solution, or falsey (no) if there is more than one or less than one.

d is not part of the solution, and not included in the bytecount; it's a function for printing a list of strings as though it were a matrix, which makes it possible to inspect the boards generated by m (by default, GNU Prolog prints strings as a list of ASCII codes, because it treats the two synonymously; this format is fairly hard to read). It's useful during testing, or if you want to use m as a practical Minesweeper solver (because it uses a constraint solver, it's highly efficient).


Blink the webcam light! This challenge is inspired by Blink the CAPS LOCK by zeppelin.

Most webcams feature a small integrated LED light, indicating if the webcam is in use, as controlled by a hardware mechanism to prevent spying.

Your task is to blink it:

Turn it on.
Wait for 0.5 (±0.1) seconds.
Turn it off again.
Wait for 0.5 (±0.1) seconds;
Repeat.

Please include a GIF or video of the webcam blinking, if possible. If an answer doesn't have the GIF, please add a GIF of the program running.

Rules

If your language is missing a subsecond sleep command, your program may use a 1 second delay instead, at a penalty of an additional byte. (replacing .5 with 1)

If your language, for some reason, doesn't support .5, your penalty is 2 bytes. (replacing 0.5 with 1)

Your program must loop unless halted by the user.
Your LED can start either on or off; whichever is more beneficial can be used.
If your LED has a turning-off delay, then it doesn't have to be taken into account, unless if you want to provide an additional version.

See this comment and its answer for more information.

Scoring

This is code-golf, which means the shortest answer in bytes wins.

MATLAB, 40 bytes
while 1;w=webcam;pause(.5);delete(w);end

Creates an infinite while loop and each time through the loop, a webcam object is initialized (turns on the webcam), the script is paused for 0.5 seconds using pause, and then the webcam object is deleted (turning the webcam off).


Implement Lazy Drop Sort This challenge already describes dropsort. However, I'm kinda lazy and I really only need my array to be a bit more sorted than before, it doesn't need to be sorted all the way.

In Drop Sort, we drop every element less than any element before it. In Lazy Drop Sort, we drop every element less than the one strictly preceding it.

Here's an example. Consider the following array:

8 6 9 9 7 2 3 8 1 3

Let's mark every element less than the one before it.

8 6 9 9 7 2 3 8 1 3
  ^     ^ ^     ^

Notice how neither 3 was marked, nor the last 8. They are all larger than the single element to the left of them.

Completing the algorithm, removing the marked elements, we get:

8 9 9 3 8 3

That basically looks more sorted. Kinda. I'm lazy.

Your task, as you may have already deduced, is to implement this algorithm.

Input is an array of at least 1 positive integer between 1 and 9, so you can take a string of digits as well.

This is code-golf, fewest bytes wins!

Additional test cases:

1
1

1 2 3
1 2 3

5 3 1
5

1 2 3 2 1
1 2 3

1 1 1 9 9 9 1 1 1 9 9 9 1 1 1
1 1 1 9 9 9 1 1 9 9 9 1 1

9 9
9 9

5 2 4 2 3
5 4 3

JavaScript (ES6), 28 25 bytes
Saved 3 bytes thanks to @Shaggy

a=>a.filter(n=>~-a<(a=n))

Try it online!


Roller coaster of numbers Write a program that generates a sequence of numbers starting with zero and then 100 random integers between -9 and 9.

That sequence will be displayed like a roller coaster.

Any increasing number in the sequence will go up and any decreasing number will go down

Sample sequence:

0 1 8 5 -1 -5 7 1 3 3 4 6 9 -2 ...

Sample output

                                                9
        8                                   6       -2...
    1       5                           4
0               -1      7       3   3
                    -5      1

This is code golf. Shortest code in bytes by November 5th wins.

Ruby, 167 bytes

l={}
y=p=n=0
101.times{|i|
d/=d.abs if(d=n-p)!=0
l[y-=d]||=Array.new 101," "*4
l[y][i]=n.to_s.ljust 4
p,n=n,rand(18)-9}
puts l.sort_by(&:first).map(&:last).map(&:join)

First time golfing Ruby, so I'm sure I'm missing something.


Fibonacci with n numbers instead of 2 How to

Given an integer n start with n ones (i.e. 4 -> 1 1 1 1). Then sum up the
last n numbers, and repeat.

For n = 4 this looks like this:

Start with 1 1 1 1, sum up the last 4 numbers resulting in 1 1 1 1 4, then
sum up the last 4 numbers resulting in 1 1 1 1 4 7, then sum up the last 4 numbers resulting in 1 1 1 1 4 7 13 and so on.

The task

Write a program or function that produces the first 30 numbers of this sequence given n as input (either as argument, stdin, command line argument, on the stack, ...)

The 30 terms for n = 4 are:

1 1 1 1 4 7 13 25 49 94 181 349 673 1297 2500 4819 9289 17905 34513 66526 128233 247177 476449 918385 1770244 3412255 6577333 12678217 24438049 47105854

The 30 terms for n = 5 are:

1 1 1 1 1 5 9 17 33 65 129 253 497 977 1921 3777 7425 14597 28697 56417 110913 218049 428673 842749 1656801 3257185 6403457 12588865 24749057 48655365

In case n is smaller than two or larger than 30 the behaviour can be undefined.


Fractal Smoke Sequence Introduction

A229037 has a quite intriguing plot (at least for the first few terms):

There is the conjecture, that it might indeed have some kind of fractal property.

How is this sequence constructed?

Define a(1) = 1, a(2) = 1 then for each n>2 find a minimal positive integer a(n) such that for every arithmetic 3 term sequence n,n+k,n+2k of indices, the corresponding values of the sequence a(n),a(n+k),a(n+2k) is not an arithmetic sequence.

Challenge

Given a positive integer n as an input, output the first n terms a(1), ... , a(n) of this sequence. (With any reasonable formatting. Possible leading/trainling characters/strings are irrelevant.)

There are snippets for generating this sequence available, but I think other approaches might be more golfable/more suitable for certain languages.

Please let us know how your progrm works. If you come a cross a particularly efficient algorithm you might want to mention that too, as it would allow to plot more terms of the sequence in shorter time.

First few test cases:

1, 1, 2, 1, 1, 2, 2, 4, 4, 1, 1, 2, 1, 1, 2, 2, 4, 4, 2, 4, 4, 5, 5, 8, 5, 5, 9, 1, 1, 2, 1, 1, 2, 2, 4, 4, 1, 1, 2, 1, 1, 2, 2, 4, 4, 2, 4, 4, 5, 5, 8, 5, 5, 9, 9, 4, 4, 5, 5, 10, 5, 5, 10, 2, 10, 13, 11, 10, 8, 11, 13, 10, 12, 10, 10, 12, 10, 11, 14, 20, 13

More testcases:

  a(100)  =   4
  a(500)  =   5
 a(1000)  =  55
 a(5000)  =  15
a(10000)  = 585

All terms up to n=100000 are available here: https://oeis.org/A229037/b229037.txt

Thanks @MartinBüttner for the help and encouragement.

Python 2, 95 bytes

l=[];n=input()
exec"a=min(set(range(n))-{2*b-c for b,c in zip(l,l[1::2])});print-~a;l=[a]+l;"*n

The main trick is in generating the numbers the new value must avoid. Keeping the reversed sequence so far in l, let's look at what elements might form a three-term arithmetic progression with the value we're about to add.
? 4 2 2 1 1 2 1 1   a b c
^ ^ ^               ? 4 2
^   ^   ^           ? 2 1
^     ^     ^       ? 2 2
^       ^       ^   ? 1 1

The other numbers are the paired members of l and every second element of l, so zip(l,l[1::2]). If this pair is (b,c) then the arithmetic progression (a,b,c) happens for a=2*b-c. After generating the set of a's to avoid, the code takes the minimum of the complement, prints it, and prepends it to the list. (Actually, the computation is done with numbers decreased by 1, and printed 1 higher, to let range(n) serve as a universe of candidates.)


Backwards Alphabet Triangle Without taking any input, output this exact text:

                         A
                        B A
                       C B A
                      D C B A
                     E D C B A
                    F E D C B A
                   G F E D C B A
                  H G F E D C B A
                 I H G F E D C B A
                J I H G F E D C B A
               K J I H G F E D C B A
              L K J I H G F E D C B A
             M L K J I H G F E D C B A
            N M L K J I H G F E D C B A
           O N M L K J I H G F E D C B A
          P O N M L K J I H G F E D C B A
         Q P O N M L K J I H G F E D C B A
        R Q P O N M L K J I H G F E D C B A
       S R Q P O N M L K J I H G F E D C B A
      T S R Q P O N M L K J I H G F E D C B A
     U T S R Q P O N M L K J I H G F E D C B A
    V U T S R Q P O N M L K J I H G F E D C B A
   W V U T S R Q P O N M L K J I H G F E D C B A
  X W V U T S R Q P O N M L K J I H G F E D C B A
 Y X W V U T S R Q P O N M L K J I H G F E D C B A
Z Y X W V U T S R Q P O N M L K J I H G F E D C B A

Rules

Output can be given by any convenient method.
You can print it to STDOUT or return it as a function result.
Either a full program or a function are acceptable.
A single trailing newline is acceptable, but no other formatting changes are allowed.
Capital letters are required.
Standard loopholes are forbidden.
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

Haskell, 53 bytes

[tail$do c<-reverse a;' ':[c|c<=d]|d<-a]
a=['A'..'Z']

Try it online!

This uses that each line has exactly 25 spaces. So, instead of separately handling the prefix spaces and the spaces between letters, we take 26 spaces, and decide whether to put a letter after each. This unfortunately gives one extra leading space, which we remove.

54 bytes

foldl(\m c->map(' ':)m++[c:' ':last m])["A"]['B'..'Z']

Try it online!

55 bytes

"A"%['B'..'[']
s%(h:t)=((' '<$t)++s):(h:' ':s)%t
s%_=[]

Try it online!


Display a Connect Four game Connect Four is a game where two players take turns to drop disks into columns of a vertically mounted grid, and attempt to connect four disks orthogonally or diagonally. When a column is chosen, the disk falls to the lowest empty position in that column, so any game may be completely specified by the size of the grid and the sequence of columns chosen. The task is to generate the configuration of the grid given this information.

Input

Width w and Height h of the grid, both positive integers.
Sequence of columns c1, c2, ..., cn chosen by the players, in any reasonable format (list, array etc.); either 0-based (0 to w-1) or 1-based (1 to w) indexing can be used.

It may be assumed that all of the column numbers lie within the grid (so the sequence won't contain -3 or w+50) and that any column number appears at most h times in the sequence (so a column can't be chosen once it is full).

Note that the sequence of columns may not constitute a complete game, nor a legal game. For instance, the players could opt to continue playing even after a player has connected four disks.

Output

Any reasonable representation of the resulting state of each position in the grid, either "occupied by Player 1", "occupied by Player 2", or "empty". Player 1 always moves first.

For example, a string, array, tuple etc. with each position containing one of three symbols (ASCII character, number etc.) representing the state of that position in the grid. The grid may be transposed.

For list/tuple/array outputs, the separator cannot be one of the three representative symbols. For string outputs, trailing spaces at the end of each line are permitted, provided a space is not one of the three representative symbols. Trailing newlines at the very end are permitted.

Test cases

Here, string output is used, with X, O, . denoting "occupied by Player 1", "occupied by Player 2", "empty".

IN: Width 1 Height 1 Sequence (empty sequence)
OUT:
.

IN: Width 7 Height 6 Sequence 4 4 5 5 6 7 3 [1-based]
                              3 3 4 4 5 6 2 [0-based]
OUT:
.......
.......
.......
.......
...OO..
..XXXXO

IN: Width 5 Height 5 Sequence 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4 5 5 5 5 5 [1-based]
                              0 0 0 0 0 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4 [0-based]
OUT:
XOXOX
OXOXO
XOXOX
OXOXO
xOXOX

IN: Width 4 Height 4 Sequence 3 3 2 4 3 2 4 2 2 3 4 4 1 1 1 1 [1-based]
                              2 2 1 3 2 1 3 1 1 2 3 3 0 0 0 0 [0-based]
OUT:
OXOO
XOXX
OOOX
XXXO

IN: Width 10 Height 10 Sequence 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 10  [1-based]
                                0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0  9 0  9  [0-based]
OUT:
X.........
X.........
X.........
X.........
X.........
X.........
X.........
X.........
X........O
XOOOOOOOOO

Shortest code in bytes wins.

Vim, 34 bytes

@wO-<Esc><C-V>(d@hpqq<C-O>+D@"G+bs<C-R>=!@.<CR><Esc>@qq@q

Input is width in the "w register, height in the "h register, and the 1-indexed moves in the buffer, one per line. Output is a transposed grid with - as blank, 1 as player 1, and 0 as player 2 (with a bunch of newlines at the end).

To clarify, if you want Height 6, Width 7: type qh6qqw7q before starting.

@wO-<Esc><C-V>(d@hp: Use the height and width in the registers to make a transposed grid of -s. Note that ( is run from the last line of the grid, one above the moves. This sets up the jump list.
<C-O>+D@"G: The <C-O> uses the jump list to move back to before the last G, always to the line above the next number. @"G moves to the line number indicated by the deleted text. + not only moves the cursor, but it's the failure point; when it runs on the last line, the macro dies.
+b: This maneuver goes to the first - in the line, even if it's the first character. (f- would go to the second character if the line was still all -s.)
s<C-R>=!@.: Replaces a - with the last insert @., but NOTted. First time through, the previous insert of - will NOT to 1 because that's the way Vim is. After that, it will alternate between 0 and 1.

Example

Start with the moves in the buffer:

4
4
5
5
6
7
3

Make sure you're on line 1 with gg, clear "q with qqq, set up the registers for width 7, height 6 with qw7qqh6q. Then run the solution above and get the following output (with newlines at the end):

------
------
1-----
10----
10----
1-----
0-----


Write a program to elasticize strings Nice verb there, in the title.

Write a program that given an input string, will "elasticize" this string and output the result. Elasticizing a string is done as follows:

The first character is shown once.
The second character is shown twice.
The third character is shown thrice,
and so on.

As you can see, the amount of duplications of a certain character is related to the character's index as opposed to its previous occurrences in the string.

You can expect to receive only printable ASCII characters. Based off the following link, these characters have decimal values 32-126.

Examples:

Why: Whhyyy

SKype: SKKyyyppppeeeee

LobbY: LoobbbbbbbYYYYY (Note how there are 7 b's since the first b is shown 3 times and the second b is shown 4 times, making a total of 7 b's).

A and B: A  aaannnnddddd      BBBBBBB

Shortest bytes wins :)

Jelly, 3 bytes
Code:
ĖP€

Explanation:
Ė     # Enumerate.
 P€   # Product of each.
      # Implicit joining of everything.

Uses the Jelly encoding. Try it online!.


Shortest Longest Common Subsequence Code Your task to to solve the SLCSC problem, which consists in finding the shortest possible code to solve the Longest Common Subsequence problem.

A valid solution to the LCS problem for two or more strings S1, … Sn is any string T of maximal length such that the characters of T appear in all Si, in the same order as in T.

Note that T does not have to be a substring of Si.

Example

The strings axbycz and  xaybzc have 8 common subsequences of length 3:

abc abz ayc ayz xbc xbz xyc xyz

Any of these would be a valid solution for the LCS problem.

Details

Write a program or a function that solves the LCS problem, as explained above, abiding the following rules:

The input will consist of two or more strings containing only lowercase letters.

You may read those strings as an array of strings or a single string with a delimiter of your choice.
Your code must output any single one of the possible solutions to the problem, optionally followed by a linefeed or surrounded by quotes.
You may assume that the strings are shorter than 1000 characters and that there are at most 20 strings.

Within these limits, your code should work as expected in theory (given unlimited time and memory).
Your code must complete the combined test cases of the next section in under an hour on my machine (Intel Core i7-3770, 16 GiB RAM).

Approaches that simply iterate over all possible subsequences will not comply with the time limit.
Using built-ins that trivialize this task, such as LongestCommonSequence, is not allowed.

Standard code-golf rules apply.

Test cases

a
ab

Output: a

aaaaxbbbb
bbbbxcccc
ccccxaaaa

Output: x

hxbecqibzpyqhosszypghkdddykjfjcajnwfmtfhqcpavqrtoipocijrmqpgzoufkjkyurczxuhkcpehbhpsuieqgjcepuhbpronmlrcgvipvibhuyqndbjbrrzpqbdegmqgjliclcgahxoouqxqpujsyfwbdthteidvigudsuoznykkzskspjufgkhaxorbrdvgodlb
qnnprxqpnafnhekcxljyysobbpyhynvolgtrntqtjpxpchqwgtkpxxvmwwcohxplsailheuzhkbtayvmxnttycdkbdvryjkfhshulptkuarqwuidrnjsydftsyhuueebnrjvkfvhqmyrclehcwethsqzcyfvyohzskvgttggndmdvdgollryqoswviqurrqhiqrqtyrl

Output: hxbbpyhogntqppcqgkxchpsieuhbncvpuqndbjqmclchqyfttdvgoysuhrrl or any other common subsequence of the same length

riikscwpvsbxrvkpymvbbpmwclizxlhihiubycxmxwviuajdzoonjpkgiuiulbjdpkztsqznhbjhymwzkutmkkkhirryabricvhb
jnrzutfnbqhbaueicsvltalvqoorafnadevojjcsnlftoskhntashydksoheydbeuwlswdzivxnvcrxbgxmquvdnfairsppodznm
kzimnldhqklxyezcuyjaiasaeslicegmnwfavllanoolkhvqkjdvxrsjapqqwnrplcwqginwinktxnkfcuuvoyntrqwwucarfvjg

Output: icsvllvjnlktywuar or any other common subsequence of the same length

rblartqkfggrjpiipuzzypkycnyckkcqceeujiyy
yfpnedyjtiwrhyuktripdwyvgkblzodeufkelhub
ywcyboxwqkibwvredkrbdsyudkulpvmhixeqxynh
bnxwahbzhwjxkotnvbxrojkkldtsodtjmvdrmbgr

Output: krkk or any other common subsequence of the same length

bwfscmotshoczmduwaev
coywaaizdaxjovipsmeh
dobzcpoiedenzlfdjpiu
bbhfeqscvvbwkuoxdoge
drqrzwbcpcsvneodelja

Output: code or any other common subsequence of the same length

nqrualgoedlf
jgqorzglfnpa
fgttvnogldfx
pgostsulyfug
sgnhoyjlnfvr
wdttgkolfkbt

Output: golf or any other common subsequence of the same length

epopyfuhgowedpiqpgfj
ddxyestqynpwmytxhozm
ptubgzyqqksieoovuezv
tovotqmnhgzttfpywjgr
aomvytkgaijlgqzkljls
vzvxpaixrnprxvenbbuo
syfuwxlpcyontqlmfvib
arxleuomstkjegpduwcx
xgqrxaopouvkvwgbzewn
yggunddigctgpnuztzai
izroomywwztdymqszsuo
kiawjnxjncdtufhkrjsp

Output: the empty string

Python - 665 644

Indentation levels:

1: space
2: tab
3: tab + space
4: 2 tabs
5: 2 tabs + space

The code defines a function o, which takes a list of strings as arguments and returns one of the LCS's for the strings.

def o(t):
 t=[[y for y in x if y in reduce(lambda x,y:x.intersection(y),t,set(t[0]))]for x in t];l=map(len,t);C=[0]*reduce(lambda x,y:x*-~y,l,1);y=lambda z:[x-1for x in z];m=len(t);e=enumerate
 def g(h):
    r,x=0,1
    for k,j in e(h):r+=-~j*x;x*=-~l[k]
    return r
 def f(h):
    i=len(h)
    if i==m:
     b=g(h);c=t[0][h[0]]
     for k,j in e(h):
         if t[k][j]!=c:break
     else:C[b]=1+C[g(y(h))];return
     r=0
     for k,_ in e(h):a=h[:];a[k]-=1;r=max(r,C[g(a)])
     C[b]=r;return
    for j,_ in e(t[i]):f(h+[j])
 def p(h):
    if min(h)==-1:return''
    v=C[g(h)]
    for k,_ in e(h):
        a=h[:];a[k]-=1
        if v==C[g(a)]:return p(a)
    return p(y(h))+t[0][h[0]]
 f([]);return p(y(l))

Test code:

tests = [
"""
a
ab
""",
"""
aaaaxbbbb
bbbbxcccc
ccccxaaaa
""",
"""
hxbecqibzpyqhosszypghkdddykjfjcajnwfmtfhqcpavqrtoipocijrmqpgzoufkjkyurczxuhkcpehbhpsuieqgjcepuhbpronmlrcgvipvibhuyqndbjbrrzpqbdegmqgjliclcgahxoouqxqpujsyfwbdthteidvigudsuoznykkzskspjufgkhaxorbrdvgodlb
qnnprxqpnafnhekcxljyysobbpyhynvolgtrntqtjpxpchqwgtkpxxvmwwcohxplsailheuzhkbtayvmxnttycdkbdvryjkfhshulptkuarqwuidrnjsydftsyhuueebnrjvkfvhqmyrclehcwethsqzcyfvyohzskvgttggndmdvdgollryqoswviqurrqhiqrqtyrl
""",
"""
riikscwpvsbxrvkpymvbbpmwclizxlhihiubycxmxwviuajdzoonjpkgiuiulbjdpkztsqznhbjhymwzkutmkkkhirryabricvhb
jnrzutfnbqhbaueicsvltalvqoorafnadevojjcsnlftoskhntashydksoheydbeuwlswdzivxnvcrxbgxmquvdnfairsppodznm
kzimnldhqklxyezcuyjaiasaeslicegmnwfavllanoolkhvqkjdvxrsjapqqwnrplcwqginwinktxnkfcuuvoyntrqwwucarfvjg
""",
"""
rblartqkfggrjpiipuzzypkycnyckkcqceeujiyy
yfpnedyjtiwrhyuktripdwyvgkblzodeufkelhub
ywcyboxwqkibwvredkrbdsyudkulpvmhixeqxynh
bnxwahbzhwjxkotnvbxrojkkldtsodtjmvdrmbgr
""",
"""
bwfscmotshoczmduwaev
coywaaizdaxjovipsmeh
dobzcpoiedenzlfdjpiu
bbhfeqscvvbwkuoxdoge
drqrzwbcpcsvneodelja
""",
"""
nqrualgoedlf
jgqorzglfnpa
fgttvnogldfx
pgostsulyfug
sgnhoyjlnfvr
wdttgkolfkbt
""",
"""
epopyfuhgowedpiqpgfj
ddxyestqynpwmytxhozm
ptubgzyqqksieoovuezv
tovotqmnhgzttfpywjgr
aomvytkgaijlgqzkljls
vzvxpaixrnprxvenbbuo
syfuwxlpcyontqlmfvib
arxleuomstkjegpduwcx
xgqrxaopouvkvwgbzewn
yggunddigctgpnuztzai
izroomywwztdymqszsuo
kiawjnxjncdtufhkrjsp
"""
]

for s in tests:
 print o(s.strip().split())

Time it takes to run the tests on my computer:

$ time python 52808-shortest-longest-common-subsequence-code-golfed.py
a
x
hecbpyhogntqtpcqgkxchpsieuhbncvhuqndbjqmclchqyfhtdvgoysuhrrl
icsvllvanlktywuar
krkk
code
golf

        9.03 real         8.99 user         0.03 sys


How often will this test fail? Preamble
There was a unit test in our codebase which was shuffling a string of length \$52\$ formed from the set of letters \$[A-Z]+[A-Z]\$ and then using the first \$20\$ characters of that shuffled string.
It failed quite a while after being written due to no repeated character being present in those twenty and we wondered how often such a test would be likely to fail. (A little more than one in five hundred and twenty-two times it turns out).
Challenge
Given an alphabet size (\$a\$), a number (\$n\$) of occurrences of each letter, and a prefix length (\$p\$), output the probability that a (uniformly chosen) random permutation of the \$a\times n\$ letters begins with \$p\$ distinct letters.
You may assume that:

There will be enough letters to make the prefix: \$p \le n\times a\$
Each of the three inputs will be non-negative integers: \$p,n,a\in\Bbb{Z}_{\ge 0}\$

Output in any reasonable format - e.g. a float, a fraction, a pair containing the numerator and denominator (no requirement to simplify); if you're unsure, just ask!
Potential method
This is the method we used to calculate the result we were interested in (from the preamble).
If one thinks of the \$n\times a\$ elements as a bag from which one repeatedly picks the next element of the prefix, then the probability of extending the prefix by one element such that it remains fully distinct is the number of elements remaining in the bag which do not yet appear in the prefix divided by the total number of elements remaining in the bag. As such the probability that the final length \$p\$ prefix will be fully distinct is the product of these probabilities starting with a full bag and an empty prefix:
$$
\prod_{i=0}^{p-1}\frac{n\times(a-i)}{n\times a-i}
$$
Test cases
Floating point inaccuracy is acceptable; fractions, if used, do not need to be in simplest form.
Ideally these test cases will all be runnable in a reasonable amount of time, but if golf means crazy inefficiency so be it!
 a   n   p    output                          (as a fraction)
 2   1   0    1                               (1/1)
 2   1   1    1                               (1/1)
 2   1   2    1                               (1/1)
50   1  50    1                               (1/1)
 3   2   0    1                               (1/1)
 3   2   1    1                               (1/1)
 3   2   2    0.8                             (4/5)
 3   2   3    0.4                             (2/5)
 3   2   4    0                               (0/1)
26   2   0    1                               (1/1)
26   2   1    1                               (1/1)
26   2   2    0.9803921568627451              (50/51)
26   2  13    0.13417306435734888             (77824/580027)
26   2  20    0.001916063061695329            (2097152/1094510949)
32   8  11    0.1777403166811693              (31138512896/175191051065)
32   8  22    0.00014139946994082153          (3477211257894250479616/24591402353555723779476075)
32   8  33    0                               (0/1)

Wolfram Language (Mathematica), 32 bytes
#3~b~#/b[#2#3,#]#2^#&
b=Binomial

Try it online!
Input [p, n, a].
The formula can be rewritten \$\dfrac{a\choose p}{an\choose p}n^p\$.

Incidentally, this is fairly trivial using Mathematica's statistics built-ins:
Wolfram Language (Mathematica), 69 bytes
CDF[MultivariateHypergeometricDistribution[#~Max~1,a=Table@##2],1^a]&

Try it online!
Unfortunately, 38-character name aside (the longest name in the default namespace), MultivariateHypergeometricDistribution doesn't handle a nonpositive prefix length, and overall this approach is quite slow for this particular problem.


Z̡̬a̧̯̔l̆̓g̛̘̟o̡ generator Write a program or function that transforms an input string into Zalgo text.
For example, for an input string Zalgo, a possible output might look like:

Z̗̄̀ȧ̛̛̭̣̖̇̀̚l̡̯̮̠̗̩̩̥̭̋̒̄̉̏̂̍̄̌ģ̨̭̭̪̯̫̒̇̌̂o̢̟̬̪̬̙̝̫̍̈̓̅̉̇

Zalgoification specs

Each letter (upper or lower case) must be zalgoified, and nothing else (spaces, punctuation).
The combining characters that can be placed on letters here are all those between U+0300  ̀  and U+032F  ̯
Each letter must have a total number of combining characters on it (above and under combined) which is randomly chosen according to a normal distribution of mean 10 and standard deviation 5 (If a negative number is chosen, 0 combining characters must be added).
Each combining character placed on a letter is chosen uniformly at random between the 48 possible combining characters (see 2nd item).

Inputs, Outputs

Input is a single line string that contains only characters between ASCII 32 (space) and ASCII 126 (tilde). No line breaks. You may assume there is at least one letter in the string. The input can be taken as command line argument, function parameter, or STDIN.
Output is the Zalgoified string. It can be written to a file, or printed to STDOUT, or returned from a function. A trailing line feed is fine. The output doesn't have to display properly in your interpreter/whatever, as long as when you copy it to a Stack Exchange answer it displays properly like here.

Test cases

The Zalgo example above.
Input: Programming Puzzles & Code Golf

Possible output:

P̢̭̟̟̮̍̅̏̍̀̊̕̚̚r̢̫̝̟̩̎̔̅̈̑o̡̠̣̪̠̍̈̐̏̌̆g̡̬̯̟̠̩̎̐́̅̚ȑ̢̨̩̠̙̭̤̩̟̔̕ą̟̟̯̠̪̜́̉̒̎̂̍̃́̚̚̚m̪̈̅̈m̨̛̛̪̤̟̔̍̓i̢̛̬̠̠̇̈̂̓̒̀̋̔̚̚n̛̝̩̜̓̐̑̅̅g̨̩̪̊ P̨̧̢̟̙̮̋̆ų̨̙̞̙̫̤̫̭̊̓̒̃̒̚z̜̤̮̪̫̄̌̃̈̉̑̋́̕z̡̥̯̠̬̜̥̑̌̓̌̋́̅ľ̫̙̟̪̖̉ė̢̨̘̦̘̖s̛̜̙̘̚ & C̨̠̟̯̟̙̠̉̄̄́̄̑̈̔̆̀ö̭̟̗̯̥̏̐̄̏̌d̞̬̀̆́̀é̟̙̩̗̙̣̋̎̌̌̋ Ğ̨̡̧̡̣̪̝̝̘̩̮̉̋̀̉̉̕̕ọ̠̠̘̟̑̇́̀̃̎̓̋̚ḽ̡̢̟̪̥̍̍̅̀́̎̆̕f̧̢̪̠̠̀̉̒̍̍̊́

Input: Golf is a club and ball sport in which players use various clubs to hit balls into a series of holes on a course in as few strokes as possible.

Possible output:

Ǧ̡̧̄̐̊ò̡̞̟̖̌́̄́̆̈̒l̡̬̣̜̫̞̘̪̇̈̏̊̆̃̑̉̓̒f̙̐̍̇́̐̍̉ į̦̘̝̣̊̒̎̚s à̡̛̠̜̙̣̙̞̣̗̯̝̘̩̅̊̓̄̒̃ ć̬̗̫̯̫̎́̚l̒̎̋ű̯̜̑̎b̯̣̮̭̤̃̊́ a̡̨̟̘̭̣̍̈̀̃̎́̐̋̆̂ń̨̖̭̝̬̘̦̣̓̇̚̕d̨̤̣̙̜̪̖̪̍̓̔̍̔̃̒̍̆̏̚̚̕̚ ḃ̬̪̇̕a̡̟̖̬̬̖̬̋́̎̎̔̄̏̒̑̚l̨̖̜̬̠̭̭̇l̡̡̛̛̬̤̆̔̑̍ s̠̙̣̠̖̜̜̅p̤̖̃́̅̕̕ǫ̢̥̬̠̞̭̭̘̟̞̋̊̌r̡̛̞̬̈̇̑̎̄̚t̟̩̏̀ ï̡̧̢̨̜̜̝̝̜̜̫̔̇̂̔̐n̞̖̫̪̟̤̦̫̂̓̍̑̆̒̚ w̨̧̟̠̯̜̙̘̏̎̈̆̂̅̔hi̧̝̖̗̖̒̆̆̈̚ć̪̜̫̖̠̣̞̋̈́̀̌̋h̢̢̨̥̮ p̜̣̋̔̆l̨̧̛̘̫̝̙̠̯̂̑̌̈̒̐ā̩̗̟̐ẏ̢̛̫̠̦̤̫̞̦̯̥̜̀̀̈̅̉̈̄ẹ̡̑̔̄̉̀̎̒̑r̛̫̭̤̋̄̓̀̅̓ș̜̯̆̋̒̍̔ ų̛̘̭̜̝̈̃̂̅̌̍̆̚s̡̡̡̨̫̥̪̋̈̀̀̆ê̢̡̡̥̖̮̞̫̪̥̘̥̯̎́ v̡̢̢̟̠̞̬̥̩̣̫̫̦̞̂̐̓̇ặ̢̧̙̝̥̪̗̆̎̓ŗ̦̙̩̑̒̕í̫̣̊̚ō̡̧̤̘̟̩̠̫̗̃̍̉̊̕ụ̡̪̠̈̈́̊̅s̢̢̘̤̝̪̀̎̅ c̡̢̛̖̫̗̑̒̆́̎̚l̥̥̖̘̉̎̓̔̀̔ų̘̘̣̟̃̆̓̉̏̅̓̂́̇b̡̝̗̙̗̮̖̩̗̦̏̌̏š̛̮̣̮̜̒̓̌ ṭ̣̫̗̮̙̈̔̅̂̎̃̌̈ò̮̘̍̅̃̃̅̚̕ ḩ̜̞̮̠̇i̮t̝̗̦̖̮̞̗̩̞̤̎̍̒̐ bȁ̢̮̩̝̣̉ļ̛̮̘̏ĺ̨̖̮̑s̢̬̪̗̬̖̟̅̀ i̢̗̖̊̃ń̨̧̛̫̮̞̎t̡̗̞̩̙̑̐̏̔̏ơ̧̯̮̦̖̇̆̔ ạ̧̉̍̚ s̤̬̫̠̉e̎̃r̟̪̥̗̜̥̍̆̍̇̕̕i̧̧̭̝̫̪̯̖̞̪̅̇̎̈̐̅̍ȇ̟̬́̄̃̐̊̕s̢̢̛̝̤̙̭̘̩̩̍̑̂̈̀̀̍̄̔̒̒ o̡̢̘̩̣̅̐̆̌̂̉̇̆̋̕f̡̯̜̝̘̮̠̖̐̂̒̃̚̕ h̪̘̫̪́ǫ̭̦̔̋̆̚̕l̢̡̧̨̙̯̤̔̅̓̆̑̍́ȅ̪̬̝̙̅̋̍s̪̖̭̫̪̟̖̐̀̕ ǫ̦̠̫̍̊̉̄̚n̐̎̂̀ ą̡̛̛̤̦̪̣̭̈̐̂̎ c̪̩̠̗̟̜̘̐̂̈̐̑̏̈ọ̡̡̙̫̞̜̐̇̄̓̏u̥̖̙̝̔̂̎̅̚̚r̙̜̬̭̠̮̙̙̪̫̝̙̬̥̥̯̐́̈́̊̈̍̍ș̀́e̞̜̒̌̚ ĩ̧̦̝̪̆n̛̞̞̆̆̀ a̟̅̐̈̍̉̚̚̕ş̫̭̍̐̚ f̘̝̠̪̦̜́̌̍̇̀̕e̩̫̣̊̎̇̚w̪ ŝ̨̨̠̠̝̦̣̜̦̗̮̞̞̥̥̅̄̄̕t̢̡̢̙̞̟̩̭̤̅̎̌̒̃̇̕r̞̤̙̄̊̃̇̅̈̏̈̌ǫ̝̬̀̋̏̐̌̈k̡̢̧̪̭̝̙̆̈̒̀ȩ̛̙̣̠̗̞̮̅̅s̙̣̒̉̎́̂̅ à̧̛̖̘̞̫̘̎̃̀̑̎̕̕s̢̟̟̭̩̈̏̇ p̣̟̭̗̪̜̫̦̝̣̎̋̎̀̐̏o̧̢̪̮̤̦̎́̐̒̀̚̕s̛̯̦̗̬̬̊̊̄̓̐̉̏́̚s̢̠̣̬̥̬̔̅̕̕i̡̠̣̣̫̞̣̮̥̟̅̎̇̄̋̌̌̇b̡̧̡̖̖̃̄̋̈̋l̢̢̙̪̣̉̉̐̑̆ẹ̢̒̎.

Scoring
This is code-golf, so the shortest answer in bytes ẁ̨̛̭̙̥̖̏̏̐̐̉̃̅̚i̜̟̭̤̞̘̗̐̐̔̈̍̋̏̚n̘̯̥̩̗̯̠̘̮̋̈̃̀̊̉̎̈̕s̛̬̦̙̮̩̜̄̑̐́̎̆̚.

CJam, 57 56 49 47 bytes

Thanks to Sp3000 for saving 7 bytes.

q{_eu_el={Pmrmc1.mrml-50*mq*A+mo{48mr'̀+}*}|}/

Test it here.

Explanation

This uses Box–Muller for the normal distribution: the basic algorithm generates two uniform variables in the range [0,1), U and V and then computes two normally distributed values from them. We only need one and the simpler one is X = √(-2 ln U) cos(2πV). This generates a distribution with mean 0 and standard deviation 1, so we need to multiply it by 5 to correct the standard deviation and add 10 to correct the mean. We can also simplify the cosine, because omitting the 2 gives the same distribution. So we compute X = √(-50 ln U) cos(πV) + 10 before rounding to get the number of combining marks.

Here is the code:

q{          e# For each character in the input...
  _eu_el=   e#   Make an upper case and a lower case copy and check if they are equal.
  {         e#   If they aren't... (i.e. if this is a letter)
    Pmr     e#     Generate a uniformly random value in [0,π).
    mc      e#     Take the cosine.
    1.mr    e#     Generate a uniformly random value in [0,1).
    ml      e#     Take the natural logarithm.
    -50*    e#     Multiply by -50.
    mq*     e#     Take the square root and multiply by the cosine.
    A+      e#     Add 10.
    mo      e#     Round to nearest integer.
    {       e#     That many times...
      48mr  e#       Generate a uniformly random integer in [0,47].
      '̀+    e#       Add it to the first combining mark.
    }*
  }|
}/

This means we just dump all the characters and combining marks on the stack in the correct order, where they are printed automatically at the end of the program.


Generate Probabilities around a Numpad Inspired by this question earlier today, I'd like to see interesting ways various programming languages can turn a numpad into probabilities. Commonly, tile-based games will allow you to use a numpad to move in any direction based on where your character currently is. When making an AI for these games, Math.random() * 8 is not sufficient, so I had to get a little creative to make the movement look and feel somewhat natural.

A numpad is defined as such:

7 | 8 | 9
- - - - -
4 | x | 6
- - - - -
1 | 2 | 3

Please note, 5 is an invalid number, as you cannot move onto yourself.

All examples will use these probabilities: [50, 40, 30, 20, 10]

If I wanted to generate probabilities around 8, it would look like this:

40 | 50 | 40
-- | -- | --
30 | xx | 30
-- | -- | --
20 | 10 | 20

The output would be [20, 10, 20, 30, 30, 40, 50, 40] (with 5 omitted) or [20, 10, 20, 30, null, 30, 40, 50, 40] (with 5 present)

If I wanted to generate them around 1, it would look like this:

30 | 20 | 10
-- | -- | --
40 | xx | 20
-- | -- | --
50 | 40 | 30

The output would be [50, 40, 30, 40, 20, 30, 20, 10] (with 5 omitted) or [50, 40, 30, 40, null, 20, 30, 20, 10] (with 5 present)

You may write a full program that takes the input in any usual way (command line, stdin) and prints the output, or you may write a function with a number argument, that prints or returns the output. Your program or function should accept one number - the position to generate around. You should use these probabilities: [50, 40, 30, 20, 10] (they do not have to be hardcoded).

Shortest code in bytes wins. Standard loopholes are disallowed. Answers posted in the linked thread are disallowed. Trailing or leading spaces are allowed. You may treat position 4 as absent or empty, depending on your preference. I'm not too picky on output format - print it out as comma-separated strings or as an array.

(This is my first question, go easy on me!)

CJam, 27 bytes

12369874s_$\_r#m<f{#4-z)0S}

Try it online in the CJam interpreter.

Idea

If we go through the digits around 5 in counterclockwise fashion, we obtain the string 12369874 or any of its rotations (depending on the starting point).

After rotating this string so that the input digit n is at the leftmost position, the digits in the rotated string have the following probabilities:

50 40 30 20 10 20 30 40

If we consider the indexes of these digits, which are

 0  1  2  3  4  5  6  7

subtract 4 from each to yield

-4 -3 -2 -1  0  1  2  3

and take absolute values to get

 4  3  2  1  0  1  2  3

we only have to add 1 and append a 0 to get the desired probabilities.

Code

12369874s                   e# Push "12369874".
         _$                 e# Push a sorted copy, i.e., "12346789".
           \                e# Swap it with the unsorted original.
            _r#             e# Find the index of the input in an unsorted copy.
               m<           e# Rotate the unsorted original that many units left.
                 f{       } e# For each character C in "12346789":
                            e#   Push the rotated string.
                   #        e#   Find the index of C.
                    4-      e#   Subtract 4.
                      z     e#   Compute the absolute value.
                       )    e#   Add 1.
                        0S  e#   Push a 0 and a space.


Decode Polybus Square/Tap Code/Prison Code The code has a lot of names, but is very simple:
  1 2 3 4 5
1 A B C D E
2 F G H I J
3 L M N O P
4 Q R S T U
5 V W X Y Z

A letter is coded by its coordinates, with the row first, then the column.  Ex:
M = 3, 2
     V
   1 2 3 4 5
 1 A B C D E
 2 F G H I J
>3 L M N O P
 4 Q R S T U
 5 V W X Y Z

Note the letter 'K' is missing, as a letter needs to be removed to make the alphabet fit in the grid. In some versions, the letter 'J' is removed but K is easier to remove because every line stays in order.
More info here on Wikipedia.
Challenge: Make a program that takes in a message encoded in this way, that outputs the decoded message. Input can be in any reasonable format.
23 15 31 31 34 52 34 42 31 14
23153131345234423114
etc

Are all reasonable input formats.
Standard loopholes apply.
Test Cases
23 15 31 31 34 52 34 42 31 14 => HELLOWORLD
24 25 31 32 => IJLM
11 22 33 44 55 => AGNTZ

Python 2,  40  39 bytes
-1 thanks to kops! (Multiply before integer division)

lambda a:[chr(r*16/3+c+59)for r,c in a]

An unnamed function accepting an iterable of pairs which returns a list of characters.
Try it online!


Build a numerical library without using any primitive data type The task is to build a numerical library for working with arbitrarily large integers that supports the following operations:

addition
subtraction
multiplication
division
modulo operation

However, the library must not use any primitive data types or arrays, neither directly nor indirectly (including booleans). For example, if you use Java, you can neither use AtomicInteger (because it uses bool internally) nor HashMap (because it uses arrays internally). You'll need to create your own data structures, without using any primitive data types, to represent numbers. (Inherited methods such as Java's hashCode don't count, as long as you don't use them in any way.) The only exception is local use of booleans in order to use conditionals (see the clarification points below).

There is only one exception: In order to make your library actually testable, provide two functions to convert from and to native integer representation. For example:

int toNative(MyNum n) { ... }
MyNum fromNative(int n) { ... }

This is the only part of your code that can use built-in data types, and it must not do anything except the conversion.

If in doubt, please ask.

Criteria: The code should be elegant, readable, concise (but no code-golf, readability is more important than code size),  well documented, and if possible, asymptotically efficient (provide and justify your functions asymptotic time and space complexity). The most up-voted answer in 10 days wins.

Update: Since the puzzle seemed impossible to many people, let me give a hint:

public abstract class Nat {
    public static Nat fromInt(int n) {
        Nat r = new Zero();
        for(int i = 0; i < n; i++)
            r = new Succ(r);
        return r;
    }

    public static int toInt(Nat n) {
        int i = 0;
        for(Nat m = n; m instanceof Succ; m = ((Succ)m).n)
            i++;
        return i;
    }
}

final class Zero extends Nat {
}

final class Succ extends Nat {
    public final Nat n;

    public Succ(Nat n) {
        this.n = n;
    }
}

This allows to represent any natural number without primitive types, even though not very efficiently.

To further clarify:

Pointers are allowed to work with data structures as long as you use them only as opaque references. In particular, you may not use any pointer arithmetic.
NULL/nulls are allowed.
If the language of your choice requires it, you can use booleans (or a similar data type) for conditionals, but only locally in functions/methods, not as fields in your data structures, and you can't use anything beyond boolean operations. Bonus if you manage it without booleans (many languages are capable of that, such as those that use pattern matching).
Higher-level languages are better suited for the puzzle.

Haskell

Haskell is pretty good at defining obvious things from scratch.
Almost all definitions are simple translations of math axioms.
Doesn't support negative numbers, behaves badly on errors (e.g. 1-2 or 1/0).

data MyNum = Zero | S MyNum

toNative :: MyNum -> Integer
toNative Zero = 0
toNative (S n) = (toNative n) + 1
fromNative :: Integer -> MyNum
fromNative 0 = Zero
fromNative n = S $ fromNative $ n-1

-- numIfGE a b c = c if a>=b else 0
numIfGE _ Zero n = n
numIfGE Zero _ n = Zero
numIfGE (S a) (S b) n = numIfGE a b n

instance Num MyNum where
    a + Zero = a
    a + (S b) = S (a + b)

    a - Zero = a
    (S a) - (S b) = a - b

    a * Zero = Zero
    a * (S b) = a + (a*b)

a `divi` b = numIfGE a b (S $ (a - b) `divi` b)
a `modu` b = a - ((a `divi` b) * b)


Output a unique sign sequence A sign sequence is an infinite sequence consisting entirely of \$1\$ and \$-1\$. These can be constructed a number of ways, for example:

Alternating signs: \$1, -1, 1, -1, ...\$
\$-1\$ for primes, \$1\$ for non-primes: \$1, -1, -1, 1, -1, 1, -1, ...\$
All \$1\$s: \$1, 1, 1, ...\$

Your task is to write a piece of code that outputs a deterministic sign sequence that no other answer already outputs. You must include a proof that your sequence is unique from  all sequences posted before yours and that your sequence only contains \$1\$ and \$-1\$. You do not have to worry about keeping up to date for newer answers, as they must ensure their sequences are unique, not you.
You may output in any reasonable manner, including (but not limited to):

Outputting an infinite list/generator/tuple of values
Outputting the next value in the sequence each time your code is run
Outputting the sequence infinitely

You may not take any input (unless necessary), so outputing the first \$n\$ terms or the \$n\$th term is not allowed.
I've included my implementation of a sequence as the first answer, to ensure that all answers have to provide a proof of uniqueness.

This is a popularity-contest, so the answer with the most votes wins. You should aim to do the following things in your answer:

Be creative. Avoid simply outputting constant runs of \$1\$s or \$-1\$s or outputting one value when a number is insert common numeric property here and the other when not (e.g. primes or Fibonacci numbers).
Avoid copying others. While all sequences must be unique, aim to be innovative, rather than simply slightly modify another user's sequence (for example, swapping the placements of \$1\$ and \$-1\$)
Make it clear what your program is doing. Not everyone can read a Jelly, R or Java answer, but they can read an explanation of the answer, as well as an explanation of how/why you chose this specific sequence and the proof of uniqueness included in your answer

Voters should consider the following when casting their votes:

How creative is the sequence? Has it been done to death before, or is it something you've never seen before?

Is the sequence using some properties of \$1\$ and \$-1\$ to be generated, or is it just applying the \$\text{sgn}\$ function to other sequences?

Is it unique, or is it simply a slight modification on a sequence that many other users have done? If it is a modification, is it uncreative, or has the author seen a property that others haven't?

How clever is the implementation of the sequence, and how well explained is it?  For this, consider both the actual code of the answer and the algorithm it implements. If the code uses a language specific trick you find particularly impressive, it may be worth an upvote. If the implementation of the algorithm is so general than any language could be used, yet is still creative and unique, it's probably worth an upvote. However, if the code is overly convoluted when a simpler method would work, or if the algorithm is incredibly inefficient when a better version exists, consider casting a downvote.
Furthermore, while you may not be able to understand the 10 bytes of 05AB1E posted, if explained well, you should be able to get a solid understanding of how those 10 bytes implement the chosen sequence, and how clever it is. And while you may be able to fluently read Python, if poorly coded with no explanation, you may not be able to fully understand how that program works. Consider this factor when voting.

Voters should not vote for an answer for any of the following reasons:

The program is written in your favourite/least favourite language

Voting for the use of tricks within a language are fine. Voting for an answer because of the language, is not an acceptable reason

The program is short/long/written with ASCII characters/written without ASCII characters
You recognize the user who wrote the answer and you love/hate them
Any other reason not specified above (e.g. "This answer uses the e character, I love it!")

05AB1E, 14 bytes
∞v®yÒgm=Ox<.±,

Try it online!
My first non-trivial 05AB1E answer! Happy for suggestions to improve it.
The code prints two interleaved sign sequences, both related to the Pólya conjecture. In 1919, George Pólya conjectured that the majority (no less than half) of positive integers up to any finite limit \$\ge2\$ have an odd number of prime factors, counted with multiplicity. Mathematically, the summatory Liouville function \$L(n)\$ (A002819) was posited to satisfy the inequality
$$
L(n)=\sum_{k=1}^n\lambda(k)\le0\
$$
for all \$n\ge2\$, wherein
$$
\lambda(k)=(-1)^{\Omega(k)}=\begin{cases}-1,\ \text{$k$ has an odd number of prime factors}\\\phantom{-}1,\ \text{$k$ has an even number of prime factors}\end{cases}
$$
is the Liouville function (A008836), related to the parity of the number of prime factors of \$k\$, and \$\Omega(k)\$ is the prime-factor-counting omega function that respects multiplicity.
The Pólya conjecture was shown to be false in 1958 when Brian Haselgrove proved the existence of an enormous counterexample near \$n=\exp(831.847)\approx1.845\times10^{361}\$. Subsequently, it has been shown that the smallest counterexample is \$n=906\,150\,257\$, and that the conjecture fails for most values of \$n\$ in the range \$906\,150\,257\le n \le 906\,488\,079\$. It is also now known that \$L(n)\$ changes sign infinitely often.
The code prints two values for each integer \$n\ge1\$:
$$
\DeclareMathOperator{\sgn}{sgn}
\begin{gather}
\lambda(n), \tag{1} \\
\sgn\bigl[2L(n)-1\bigr]. \tag{2}
\end{gather}
$$
The first value is the \$n\$th term of A008836. The second value, chosen to avoid zeros in \$L(n)\$, is (arguably) more interesting. Given the results quoted above, we see that sequence \$(2)\$ alternates between \$-1\$ and \$1\$ infinitely often. However, of its first \$906\,150\,257\$ values, only two (the first and the last) are \$1\$; the intervening \$906\,150\,255\$ values are all \$-1\$.
Commented code
∞v             # iterate over all positive integers y
  ®            # push -1
   yÒ          # push list of prime factors of y (with duplicates)
     g         # length of this list; yields Ω(y)
      m        # exponentiate top two stack items; yields -1**Ω(y) = λ(y)
       =       # print λ(y), keeping it on the stack
        O      # sum the stack; yields L(y)
         x<    # push 2*L(y)-1, keeping L(y) on the stack
           .±, # print the sign


Travel Back in Quine The challenge here is simple, and not at all about byte-count. Your job is to output the first 50 characters of the previous quine's source code, concatenated with the first 50 characters of yours starting with the 50 characters I've placed below:
abcdefghijklmnopqrstuvwxyzACDEFGHIJKLMNOPQRSTUVWXY

So, lets take an example here, if you were to answer in 05AB1E, a solution to simply output the first 50 bytes would be:
ži50£

Which would mean you'd need to output:
abcdefghijklmnopqrstuvwxyzACDEFGHIJKLMNOPQRSTUVWXYži50£

If your program is shorter, simply use the first x < 50 characters. If your program is longer only concatenate the first 50 characters, ending on the 50th character. The next person will then have to output the first 50 characters of your quine concatenated with their own code.
Your code can be any size, but you should only output the first 50 characters of your code concatenated to the end of the first 50-bytes of the previous answer's code.

Restrictions:
This uses the definition of a proper quine, and, in addition to this, the following things:

Comments are disallowed, entirely.
PAY ATTENTION TO THIS SECTION, IT MAY EVOLVE IF ABUSIVE LOOPHOLES ARISE

How to Post a Chained-Answer:

Post a placeholder:

Mention your answer number and the language you'll use.

Sort-by-date, if you notice someone else posted a placeholder 1 millisecond before you:

Delete yours, wait for the next opportunity, sorry.

If you've secured the next spot, PLEASE ANSWER WITHIN 6 HOURS:

If you can't answer, remove your reserved space.

IF the space has been hogged for more than 6 hours.

Vote to delete reserved space, I'll handle it.

Your Post Format:
#[Answer #]:[Character Count] Characters, [Language Used]

{TIO MARKDOWN}

{LINE_SEPARATOR="---"}

{ADDITIONAL EXPLANATION OR INFORMATION}

Some specific notes (Important for Ease-of-Competition):

If the person before you has included newlines or non-ASCII characters in their source, you may STRIP them. This means that x="a\nb" becomes ab, where x[0]=a;x[1]=b;.

You must state the mutation you've applied to the previous source.

All characters are counted as a single character, despite code-pages or language encoding. Please do not use byte-count, use character-count.

The accepted answer will be the 50th answer, just because; I mean, it's SE afterall.

1: 96 Characters, Haskell

abcdefghijklmnopqrstuvwxyzACDEFGHIJKLMNOPQRSTUVWXY:z=['`'..'z']++'A':['C'..'Y']
main=putStr$z++z

Try it online!

I was feeling silly, and saw nothing forbidding the first entry starting with the exact same 50 characters as the initial string.

['`'..'z']++'A':['C'..'Y'] is an expression evaluating to the string of those characters, with a ` prepended.
The result is pattern matched on,
making the variable abcdefghijklmnopqrstuvwxyzACDEFGHIJKLMNOPQRSTUVWXY equal to '`', and z equal to the 50 characters.
main=putStr$z+z then does the actual output.


Output the given English pronoun table Output the provided table of English pronouns exactly, in as few bytes as possible.
Code rules

The code will take no input
The table is tab-delimited
Each line begins with a single tab \t if there is no row heading
Each line ends in a single newline \n (not \r\n), including the last line
There are four tabs between "Plural" and the newline (Plural\t\t\t\t\n) because it refers to the next four columns as well, but no other line has trailing tabs or spaces

Spelling rules

There is no Possessive Pronoun for "it", so the data is "-"
The only pronoun to use an apostrophe is "one's". "It's" means "it is" or "is has" and is a contraction, not a pronoun
Some people use "themself" for the singular, gender non-specific, third person, but in this table it is "themselves"
This table is not complete; other non-standard, alternate and rare forms are not included

Output
Use this link to check your output.
Pretty-printed (do not output this!)
                Singular                                                  Plural
                                   Possessive   Possessive                                   Possessive   Possessive
                Subject   Object   Determiner   Pronoun      Reflexive    Subject   Object   Determiner   Pronoun      Reflexive
First Person    I         me       my           mine         myself       we        us       our          ours         ourselves
Second Person   you       you      your         yours        yourself     you       you      your         yours        yourselves
Third Person    he        him      his          his          himself      they      them     their        theirs       themselves
                she       her      her          hers         herself
                it        it       its          -            itself
                one       one      one's        one's        oneself
                they      them     their        theirs       themselves


Create an auto-cucumber program Oops, Auto-correct.

You have a word. But it's wrong. You wonder what word it would be. Thankfully, being a code golfer, You can make a code to take a rough guess.

I/O

You will be given a (wrong, all lowercase) word, and a '(All lowercase)Dictionary list'. You have to output the word with the least Levenshtein distance to the wrong word. If there are multiple words of the same levenshtein distance, use the last one in the list.

Examples

Input => Output
(["apple", "banana", "orange", "pineapple"], "baenanae") => "banana"
(["zeal", "zealot", "zealotry", "zealots", "zealous", "zealously", "zealousness"], "zealousl") => "zealously"
(["abductors", "abducts", "abe", "abeam", "abel"], "") => "abe"

05AB1E, 6 bytes

Σ.L(}¤

Try it online! (note: the trailing newline on the input is necessary for the empty string case.)

How?

Σ.L(}¤ - implicitly push the first input (the dictionary list)
Σ   }  - sort the list by:
       -   implicitly push second input (the misspelled word)
 .L    -   Levenshtein distance
   (   -   negated
     ¤ - tail the sorted list  and place the entry on the top of the stack
       - implicitly print top of stack


JavaScript: Tricks to shorten onkeydown, setInterval etc Are there any tricks to shorten defined function names like setInterval, onkeydown, onkeyup, createLinearGradient or even return?

When using it more than once it's nice to put it as a string into a variable and reuse it afterwards but most functions I only need once.

I know that ES6 has arrowed functions - maybe there is an apporach?

There is a rather clever trick for shortening method names for a particular object that I first learned about during the first JS1k competition.  See Martijn Haverbeke's page about it, under "Mechanized Abbreviation".

The idea is that you iterate over the keys of the object and apply a hash function h(k) to each of the keys in order to compute an alias for the key.  With some trickery you can make sure to only apply the aliasing to keys referring to function values (i.e. only if typeof o[k] == 'function'), but of course this costs some extra characters.  If only one of the keys being aliased hash to the same value, then you can use the abbreviated name unambiguously.  If there are collisions you have to fall back to the full name (since the order of iteration is undefined).

When using this trick, remember that it's a trade-off between length of hash function (expression) and number of collisions.  Of course, this approach is only helpful when you use a lot of long-name methods on one particular object (e.g. canvas code).  For a paricular snippet that you want to golf, it could be useful to find the number of occurrences of each identifier and put together something like this page, to simplify the search for a good hash function.

This trick could be used with global functions since the global object is this at the global scope (or even shorter, windows = window.top = top in a web environment).  Also, another thing to keep in mind with frequent use of methods on one object is the with statement.


Shortest Error Message Challenge

Write the shortest program that, when compiled or executed, produces a fatal error message smaller than the program itself. The error message may not be generated by the program itself, such as Python's raise. A valid answer must include both the code and the error message. Shortest valid answer wins.

No error message does not count as an error message.

Example (Lua)

Code (46 bytes):

[
--aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

Error (45 bytes):

[string "[..."]:1: unexpected symbol near '['

ed, 3 bytes

Note: Most of the answers here are ignoring the trailing newline printed as part of the error message in their count.  But I don’t see anything in the question to justify ignoring it, and the author commented that the newline should be included.  So unless the question is changed, I’m going to include it.

Code (with trailing newline):

??

Error (with trailing newline):

?


Print the Stack Exchange favicon Challenge

Print or return the Stack Exchange favicon, as provided below:

 ___________________
/                   \
---------------------
|                   |
---------------------
|                   |
---------------------
\__________    _____/
           |  /
           | /
           |/

This is code-golf, so the shortest answer in each language wins.

Operation Flashpoint scripting language, 263 195 bytes

f={r="                   ";t="---------------------\n";s=" ___________________\n/"+r+"\\n"+t+"|"+r+"|\n"+t+"|"+r+"|\n"+t+"\__________    _____/\n           |  /\n           | /\n           |/";s}

Not the right tool for the job.

Call with:

hint call f;

Output:

The formatting fails, because the font is not monospaced.


Creating words by structure Context

As a conlanger, I am interested in creating a uniform, naturalistic language. One of the tricks is to create vocabulary according to certain structures of words. An example from English: In English, we have the word “tap” structured consonant-vowel-consonant. Usually, this means that there are many other words of this structure: “cat”, “dog”, “rock”, “fog”, “good”, etc.

Task

As input, you have:

an array C containing strings: consonants (C is the first letter in the word consonants). Identical consonants cannot be repeated on this list. For example, this list cannot contain ['b', 'b'].
an array V containing strings: vowels (V is the first letter of the word vowels).  Identical vowels cannot be repeated on this list.
string S, which contains something like this "CVCCV" (any combination of "C" and "V")

Your task is to replace “C” in the string with a randomly taken string from array C and replace “V” in the string with a randomly taken string from array V and return (or display) this string.

"randomly" is defined as all possibilities having an equal chance of being selected. This is a kind of simplification: in real languages as well as in conlangs, there are very frequent (for example 'r' in English) and not very frequent sounds but this is just a code-golf.

Rules

This is code-golf so the lowest byte count wins.

Examples

Input:
C = ['p', 'b', 't', 'd', 'k', 'g', 'm', 'n', 'w']
V = ['a', 'o', 'u', 'i', 'e', 'ä']
S = 'CVCCV'

Output:
pakto

Input:
C = ['p', 'b', 't', 'd', 'k', 'g', 'v', 's', 'r']
V = ['a', 'o', 'u', 'i', 'e', 'ä', 'ᵫ']
S = 'CVVCCVCCV'

Output:
koebrᵫvtä

05AB1E, 4 bytes

Takes input as S, [V,C]

Çè€Ω

Try it online!


A poly-moly-holy quine. (Well, it's not, but the title's cool.) This is an answer chaining puzzle, where each answer must add on to the last.

The \$n\$th submission must output its own source code in the \$n\$th language and the \$n−1\$ languages before it.

A language can be either a dialect or a major version of a language, so Python version 2.121 is only counted as version 2 and Common Lisp and Clojure are considered different languages. This excludes compiler flags.

You can post 2 answers in a row, but have to use different languages.

The winner of this puzzle is the person to submit the second-to-last quine if there have been no new quines for a week. The aim of this puzzle is to go on as long as it can, so if you want the green tick, you'll have to respect that.

Have fun.


OOP: Overlapping Oriented Programming One of the lesser known programming paradigms which seems rather fitting for code golfing is Overlapping Oriented Programming (OOP) *. When writing partly identical code, many bytes can be saved by simply overlapping the identical parts and remembering in some way where the two original code lines start. Your task is to write two overlapping programs or functions compress and decompress with the following specification:

*Do not use in production code, probably.

compress

compress takes two strings in any convenient format and overlaps them as much as possible. That is a string s with minimal length is returned such that both input strings are substrings of s. Additionally, some output which identifies the start and end indices of both string is returned.

Examples: (The exact IO-format is up to you)

compress("abcd", "deab") -> "deabcd" ((2,5),(0,3))
compress("abcd", "bc")   -> "abcd" ((0,3),(1,2))
compress("abc", "def")   -> "abcdef" ((0,2),(3,5)) or "defabc" ((3,5),(0,2))

decompress

decompress computes the inverse function of compress, that is given a string and two start and end indices (in the format in which they are returned by your compress), return the two original strings. You need only handle valid inputs.
The following equality should hold for all strings s1, s2:

(s1, s2) == decompress (compress (s1, s2))

Examples: (inverses of compress examples)

decompress "deabcd" ((2,5),(0,3)) -> "abcd" "deab"
decompress "abcd" ((0,3),(1,2))   -> "abcd" "bc"

decompress "abcdef" ((0,2),(3,5)) -> "abc" "def"
 or (whichever version your "compress" generates)
decompress "defabc" ((3,5),(0,2)) -> "abc" "def"

Scoring

Your score is the size of the string returned by calling compress("<code of compress>", "<code of decompress>"). As this is code-golf a lower score is better.

Example:

Assume the code for your function compress is c=abcd and the code for decompress is d=efghi. Then compress("c=abcd", "d=efghi") yields "c=abcd=efghi" (and the indices, but those don't affect scoring) so the score is length "c=abcd=efghi" = 12.

Additional Rules

In the spirit of this challenge, your compress and decompress must overlap in at least one character. You may achieve this trivially by adding a comment, but note that doing so will increase your score and there might be shorter solutions using inherently overlapping code.
compress and decompress should be able to handle strings containing any printable ASCII characters as well as all characters you used to define compress and decompress.
The indices can be zero- or one-indexed.
Your programs or functions don't have to actually be named compress and decompress.

GNU Prolog, 105 points

s(U,L/M,C):-prefix(A,C),length(A,M),suffix(U,A),length(U,L).
o(A-B,C-X-Y):-length(C,_),s(A,X,C),s(B,Y,C).

(This requires GNU Prolog because prefix and suffix are not portable.)

Prolog has one interesting, major advantage for this challenge; you can write a function to handle multiple call patterns (i.e. not only can you give the function an input to get a corresponding output, you can give the function an output to get the corresponding input). As such, we can define a function that can handle both compression and decompression, leading to a 105-byte submission that defines a function o that works both ways round. (Incidentally, I mostly wrote it as a decompressor – as it's simpler – and got the compressor "for free". ) In general, we could expect a very short program in Prolog for this task, if not for the fact that it's so bad at string handling (both in terms of missing primitives, and in terms of the primitives in question having terribly long names).

The first argument to o is a tuple of strings, e.g. "abcd"-"deab". The second argument has a form like "deabcd"-4/6-4/4; this is a fairly standard nested tuple, and means that the string is "deabcd", the first string has length 4 and ends at the sixth character, the second string has length 4 and ends at the fourth character. (Note that a string in GNU Prolog is just a list of character codes, which makes debugging annoying because the implementation prefers the latter interpretation by default.) If you give o one argument, it'll output the other for you (thus working as a compressor if you give the first argument, and a decompressor if you give the second). If you give it both arguments, it'll verify that the compressed representation matches the strings given. If you give it zero arguments, it'll generate output like this:

| ?- o(X,Y).
X = []-[]
Y = []-0/0-0/0 ? ;

X = []-[]
Y = [_]-0/0-0/0 ? ;

X = []-[A]
Y = [A]-0/0-1/1 ? ;

…many lines later…

X = [A]-[B,A,C]
Y = [B,A,C]-1/2-3/3 ? ;

The above description of the I/O format is pretty much entirely just a description of the program, too; there's not very much in the program at all. The only subtlety is to do with evaluation order hints; we need to ensure that the program doesn't just use a search strategy that's guaranteed to terminate, but also produces the shortest possible output string.

When compressing, we start with length(C,_) ("C has a length"), which is a trick that I've used in many Prolog and Brachylog answers; if this is the first thing Prolog sees, it'll cause it to prioritise reducing the length of C over anything else. This ensures that we have a minimum-length C. The ordering of the constraints in s is carefully chosen so that the search will take a finite time for each possible candidate length of C; A is constrained by C (we don't know C, but we do know the target value we have for its length), M by A, U by A, and L by U, so none of the searches can take unlimited time.

When decompressing, we're given C directly by the user. This again ensures the program will run in finite time, due to the same sequence of constraints. (People who are aware of Prolog's evaluation order will note that the definition of s is very inefficient when decompressing; placing length(A,M) and length(U,L) first would be faster, but moving length(A,M) to the start could cause an infinite loop when compressing because neither A nor M is bound by anything at the time.)


Sort and Table a Sentence by Word Lengths In as few bytes as possible, sort the input, a delimited string OR list/vector/array of words, words contain printable ASCII except space (ASCII values 33-126) into a numbered list, table, or something resembling a table, by length.

Table rules are as follows:

Order is mandatory, direction is optional, either labelled rows from shortest to longest or vice versa,
Formatting is not the challenge. So as long as the output is some form of numerically labelled rows of words, a numbered list, or a list of lists, or similar output, then it is a satisfactory answer.
including/excluding gaps (NA values, see below examples for both methods of output)
Word case is untouched. How the word appears in input should be shown in output.

Input 1:

Code Golf and Coding Challenges Meta

or

("Code","Golf","and","Coding","Challenges","Meta")

or similar

Output 1:

 1. NA
 2. NA
 3. and
 4. Code Golf Meta
 5. NA
 6. Coding
 7. NA
 8. NA
 9. NA
 10. Challenges

or

3. and
4. Code Golf Meta
6. Coding
10. Challenges

or

[[3, ['and']], [4, ['Code', 'Golf', 'Meta']], [6, ['Coding']], [10, ['Challenges']]]

Input 2:

My v3ry 3xc3113nt m0th3r ju5t 53rv3d u5 nin3 pizz@5 #JusticeForPluto

Output 2:

1. NA
2. My u5
3. NA
4. v3ry ju5t nin3
5. NA
6. m0th3r 53rv3d pizz@5
7. NA
8. NA
9. 3xc3113nt
10. NA
11. NA
12. NA
13. NA
14. NA
15. NA
16. #JusticeForPluto

or

2. My u5
4. v3ry ju5t nin3
6. m0th3r 53rv3d pizz@5
9. 3xc3113nt
16. #JusticeForPluto

or

[[2, ['My', 'u5']], [4, ['v3ry', 'ju5t', 'nin3']], [6, ['m0th3r', '53rv3d', 'pizz@5']], [9, ['3xc3113nt']], [16, ['#JusticeForPluto']]]

More examples can be provided if necessary but I think this should suffice for now.
Please ask questions if you have them, this is my second attempt at a challenge. (the first failed dramatically)

R, 28 bytes

split(w<-scan(,""),nchar(w))

Try it online!

split does the trick; results in a list() where the element names are the lengths and  the elements are vectors containing the words.


Make me a window manager! I hate code bloat!

So I have decided to replace my Windows 7 system by a golfed version. However, I know that it is not easy, so let's build a prototype first. It will take a list of windows from the user and show them using a pseudo-graphic display on the standard output.

For example: user input:

0,0,15,10
15,10,20,15
10,13,15,15
9,1,16,3
17,5,20,7
11,2,17,4
15,4,19,6
13,3,18,5

The Code Golf® Window Manager™ outputs:

┌──────────────┐
│::::::::┌─────┴┐
│::::::::│:┌────┴┐
│::::::::└─┤:┌───┴┐
│::::::::::└─┤::::├┐
│::::::::::::└─┬──┘├┐
│::::::::::::::├─┬─┘│
│::::::::::::::│ └──┘
│::::::::::::::│
│::::::::::::::│
└──────────────┼────┐
               │::::│
               │::::│
          ┌────┤::::│
          │::::│::::│
          └────┴────┘

Input:

Taken from standard input (or, if your system has no stdin, any method that can provide several lines of input)
Each line contains 4 numbers, delimited by commas - coordinates of a window
First two numbers: upper-left corner; last two numbers: lower-right corner
Using x,y notation

Output:

Write it to standard output (or, if your system has no stdout, anything that displays monospaced text)
Use single box-drawing characters from Code Page 437 for drawing window boundaries
Windows specified later in input obscure those specified earlier
Fill the windows with the colon character: :
Leading and trailing spaces are OK, as long as they don't break alignment of the windows

Notes:

Maximum resolution I want to support: 76 (horizontal) by 57 (vertical)
No need to support bad input
Maximum number of windows: 255 (if you need a limit)
My Windows 7 cmd shell displays codepage 437 characters by default; if anyone has a way to do that on linux (using xterm or whatever), please describe it here

For reference, the character codes are:

┌da   ─c4   ┬c2   ┐bf

│b3   :3a   │b3   │b3

├c3   ─c4   ┼c5   ┤b4

└c0   ─c4   ┴c1   ┘d9

Total: 12 different characters.


Decode My String (Brackets) Taken from StackOverflow Question

Challenge

Given an encoded string in format n[s] where n is the amount of times s will be repeated, your task is to output the corresponding decoded string.

n will always be a positive number
s can not contain empty spaces
strings only contains letters from the alphabet
s length can be >= 1
encoded format is number [ string ]
string can have nested encoded string number [ number [ string ] ]
return the same string if not encoded

Examples

2[a]                 => aa
3[2[a]]              => aaaaaa
2[b3[a]]             => baaabaaa
3[a]5[r3[c]2[b]]a    => aaarcccbbrcccbbrcccbbrcccbbrcccbba
a                    => a  // Not Encoded
3                    => 3  // Not Encoded
3a3[b]               => 3abbb
10[b20[a]]           => baaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaa
3[hello]             => hellohellohello

Other test cases

a[a] => a[a]
a1[a] => aa
3[] =>    // Nothing because are 3 empty string
2[2][a] => 2[2][a]

This is my own submission.

f=i=>(r=/(\d+)\[([a-z]*)\]/g).test(l=i.replace(r,(m,n,s)=>s.repeat(n)))?f(l):l

console.log(f("2[a]"))
console.log(f("3[2[a]]"))
console.log(f("2[b3[a]]"))
console.log(f("3[a]5[r3[c]2[b]]a"))
console.log(f("a"))
console.log(f("3"))
console.log(f("3a3[b]"))
console.log(f("10[b20[a]]"))
console.log(f("3[hello]"))

If more test cases needed please tell me.

QuadR, 17 + ≡ flag = 28 bytes

\d+\[\pL*]
∊(⍎⍵M∩⎕D)⍴⊂⍵M∩⎕A

Try it online!

Find:

 \d+\[\pL*] find digit(s) followed by bracketed Letters

Replace with:

⎕A uppercase Alphabet

 ⍵M∩ intersection of Match and that

 ⊂ enclose (to treat as a whole)

 (…)⍴ reshape to length:

  ⎕D Digits

  ⍵M∩ intersection of Match and that

  ⍎ execute (converts text to number)

 ∊ ϵnlist (flatten)

This is equivalent to the Dyalog APL function:

'\d+\[\pL*]'⎕R{∊(⍎⍵.Match∩⎕D)⍴⊂⍵.Match∩⎕A}⍣≡


Take It or Leave It III: A Game Show for Computers This is the third in a series of puzzles that I will be posting every Monday at Midnight PST, and the final variant of "Take It or Leave It".
The first puzzle is located Here
The second puzzle is located Here
Context:

A reclusive billionaire has created a game show to attract the world's best and brightest programmers. On Mondays at the stroke of midnight, he chooses one person from a pool of applicants to be the contestant of the week, and provides them with a game. You are this week's lucky contestant!

This week's game:

The host provides you with API access to a stack of 15,000 digital envelopes. These envelopes are randomly sorted, and contain within them a dollar value, between $1 and $15,000 (no two envelopes contain the same dollar value).
You have 5 commands at your disposal:

Read(): Read the dollar figure in the envelope at the top of the stack.

Take(): Add the dollar figure in the envelope to your game show wallet, and pop the envelope off the stack.

Pass(): Pop off the envelope on the top of the stack.

Oracle(M): Returns the mean value of the next M envelopes in the stack, not including the one you can currently Read().

End(): Stop the game, and walk away the money currently in your wallet (your final score).

The Rules:

If you use Pass() on an envelope, the money within is lost forever.

If you use Take() on an envelope containing $X, from that point forward, you may never use Take() on an envelope containing < $X. Take() on one of these envelopes will add $0 to your wallet.

If you use Oracle(M) on turn T, envelopes T+1 through T+M's mean will be returned. Oracle() is disabled until turn T+M.

If you use Take() or Pass() on turn T, $T is removed from your wallet.

Write an algorithm that finishes the game with the maximal amount of money.
Note 1: "Maximal" in this case means the median value in your wallet after N >= 1000 runs. I expect, though I would love to be proven wrong, that the median value for a given algorithm will converge as N increases to infinity. Feel free to try to maximize the mean instead, but I have a feeling that the mean is more likely to be thrown off by a small N than the median is.
Note 2: This puzzle has a significant difference from the first two iterations (namely, needing to pay for each envelope you take). Feel free to use any strategies from the first puzzles as a base, but be warned: They will probably (read: definitely) get a negative score without some kind of modification.
Edit: The prize condition has been removed, in light of this post on meta.

Java, $3889.5 Median
        int highest=0;
        int topp=0,tott=0;
        for(int i=0;i<1000;i++){
            if(Read()>topp&&tott+Read()-i>tott){
                topp=Read();
                tott += Read();
                tott -= i;
                Take();
            }else{
                if(tott-i>i/2){
                    tott -= i;
                    Pass();
                }else{
                    End();
                    break;
                }
            }
            if(highest/1.1>tott){
                End();
                break;
            }
            if(tott>highest)
            highest=tott;
        }

Try it Online


Compile Commentscript Commentscript is a variant on Javascript that I made up for the purpose of this question. Only commented-out code is evaluated.
Javascript has two types of comments:
// this is a single line comment, which starts with `//` and ends on a newline.

/*
This is a multiline comment.
It starts with /* and ends with */

Example:
//console.log('goodbye world')
console.log('hello world')

will output goodbye world to the console.
Your challenge is to compile Commentscript code into regular Javascript.
Scoring
This is code-golf, so shortest bytes wins!
Clarifications
Nested comments like // comment // nested comment should just have the top-level comment removed, for example comment // nested comment.
To avoid complications, comments in strings should be read as comments, e.g. 'abc //' def //ghi => ' def //ghi
Newlines from single line comments should be kept, but ones by multiline comments shouldn't.
Ignore shebangs, e.g. #! /usr/bin/env node
//a
//b
=>
a
b

/*a*/

/*b*/
=>
ab

Test cases
//console.log('hello world') => console.log('hello world')

//console.log('hello world')//do stuff => console.log('hello world')//do stuff

/*var a = 5;*/function f(){}/*console.log(a)*/ => var a = 5; console.log(a)

/////////// => /////////

//console.log('hello world')/*More nested comments*/ => console.log('hello world')/*More nested comments*/

"abc //" def //ghi => " def //ghi

//a
//b
=>
a
b

/*a*//*b*/ => ab

//a

//b

//c
=>
a
b
c

/*
for(var x of array){
    console.log(x)
}
*/
=>
for(var x of array){
    console.log(x)
}

/*
//this is a comment
*/

=>

//this is a comment

#!/usr/bin/env node =>  [NOTHING]

Retina 0.8.2, 63 bytes
(//.*|/\*(.|¶)*?\*/|¶)|.
$1
//(.*)|/\*((.|¶)*?)\*/|(¶)¶*
$1$2$4

Try it online! Link includes test cases, but the newline-collapsing rule means that they're not double-separated on output. Explanation:
(//.*|/\*(.|¶)*?\*/|¶)|.
$1

Delete anything not a newline or comment.
//(.*)|/\*((.|¶)*?)\*/|(¶)¶*
$1$2$4

Keep the content of comments and one newline of consecutive newlines.


Create a program that output's itself as a series of punch cards Create a program that output's itself as a series of punch cards:

Rules:

You can use any programming language.
The output (i.e. punch cards) can be ASCII art.
Each line of code must be able to be punched into a single 80 column x 9 row punch card - i.e. you can only use 80 characters.
To fit in the 9 rows you need to encode your characters using 4-bit BCD.
Extra kudos if you use an old programming language like FORTRAN.

Background

You can find out more about computer punch cards here.
Doug Jones paper on punch card codes.

Ruby - 925

I'll get the ball rolling. Run as "ruby hammer.rb hammer.rb".

Golfed

def z x
l=x.unpack u='C*'
d=[]
(0..9).each do|i|d<<[].fill(48+i,0,80);end
d<<a=[].fill(32,0,80)
d<<a.dup
h=Hash.new
i=0;' abcdefghi'.unpack(u).each do|c|h[c-32]=[i,11];h[c]=[i,11,0];i+=1;end
i=0;' jklmnopqr'.unpack(u).each do|c|h[c-32]=[i,10];h[c]=[i,10,11];i+=1;end
i=0;'  stuvwxyz'.unpack(u).each do|c|h[c-32]=[i,0];h[c]=[i,0,10];i+=1;end
h[47]=[1,0]
i=0;'0123456789-&'.unpack(u).each do|c|h[c]=[i];i+=1;end
i=0;'  :#@\'="'.unpack(u).each do|c|h[c]=[i,8];i+=1;end
i=0;'  [.<(+|'.unpack(u).each do|c|h[c]=[i,8,11];i+=1;end
i=0;'  ]$*);^'.unpack(u).each do|c|h[c]=[i,8,10];i+=1;end
i=0;'  \,%_>?'.unpack(u).each do|c|h[c]=[i,8,0];i+=1;end
h[32]=[]
i=0;l.slice(0,80).each do|c|h[c].each do|r|d[r][i]=215;end;i+=1;end
puts'    %s'%('_'*81)
puts'   /%-80s |'%l.pack(u)
puts'  / %s |'%d[11].pack(u)
puts' /  %s |'%d[10].pack(u)
(0..9).each do|i|puts'|   %s |'%d[i].pack(u);end
puts'|%s|'%('_'*84)
end
ARGF.each do|l|z l.chop;end

Ungolfed

def punch029(line) # line is array of ASCII characters in ordinal (integer) form
  chad=[]
  (0..9).each do |i| chad<<[].fill(48+i,0,80) end
  chad<<[].fill(32,0,80)
  chad<<[].fill(32,0,80)

  r10 = 10-10
  r11 = 11-1
  r12 = 12-1
  # Reward "bad" input characters with all-row multi-punch.
  # hash = Hash.new( [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] )
  #
  #   OR
  #
  # Reward "bad" input characters by letting Ruby puke. (Jam the machine.)
  hash = Hash.new
  '0123456789-&'.unpack('C*').each_with_index do|c,i| hash[c]=[i] end
  ' ABCDEFGHI'.unpack('C*').each_with_index do|c,i| hash[c]=[i,r12] end
  ' JKLMNOPQR'.unpack('C*').each_with_index do|c,i| hash[c]=[i,r11] end
  ' /STUVWXYZ'.unpack('C*').each_with_index do|c,i| hash[c]=[i,r10] end
  '  :#@\'="'.unpack('C*').each_with_index do|c,i| hash[c]=[i,8] end
  '  [.<(+|'.unpack('C*').each_with_index do|c,i| hash[c]=[i,8,r12] end
  '  ]$*);^'.unpack('C*').each_with_index do|c,i| hash[c]=[i,8,r11] end
  '  \,%_>?'.unpack('C*').each_with_index do|c,i| hash[c]=[i,8,r10] end
  ' abcdefghi'.unpack('C*').each_with_index do|c,i| hash[c]=[i,r12,r10] end
  ' jklmnopqr'.unpack('C*').each_with_index do|c,i| hash[c]=[i,r11,r12] end
  '  stuvwxyz'.unpack('C*').each_with_index do|c,i| hash[c]=[i,r10,r11] end
  hash[32] = []              # fix space

  hole = 215
  line.slice(0,80).each_with_index do |c, index|
    hash[c].each do |row| chad[row][index] = hole end
  end

  puts '    %s' % ('_'*81)
  puts '   /%-80s |' % line.pack('C*')
  puts '  / %s |' % chad[11].pack('C*')
  puts ' /  %s |' % chad[10].pack('C*')
  (0..9).each do |i|
    puts '|   %s |' % chad[i].pack('C*')
  end
  puts "|%s|" % ('_'*84)
end
#        1         2         3         4         5         6         7         8
#2345678901234567890123456789012345678901234567890123456789012345678901234567890

ARGF.each do |line|
  punch029(line.chomp.unpack('C*'))
end


Code golfing my guess the number game with feedback in NS-HUBASIC - Can it be code golfed any further? The player has to keep guessing a number from 1 to 10 until they guess the correct number to win the game. If they make an incorrect guess, they're told if their guess was too low or too high.

Each line has to render below the previous line for me to accept the solution as the new code for the game (However, you can still share any solutions that break that rule.). For example, no lines can be rendered over other lines, such as "CORRECT." over "TOO LOW." or "TOO HIGH.".

Here's the code:

0N=RND(10)+1:DIMT$(2):T$(0)="CORRECT.":T$(1)="TOO LOW.":T$(2)="TOO HIGH.":F.T=0TO0:I."WHAT'S MY NUMBER? (1-10) ",G:T=G<>N:?T$(-(G>N)-T):N.

As for how I'm running NS-HUBASIC code, I'm doing it in Family BASIC V3.0, which I'm running under Nestopia v1.40.

If you need any documentation, you can find it here: https://gamefaqs.gamespot.com/nes/938747-family-basic-v3/faqs/59317

 134  133 characters

Note: I don't know for sure whether a line-break counts as 1 character.

0N=RND(10)+1:DIMT$(2):T$(0)="TOO LOW.":T$(1)="CORRECT.":T$(2)="TOO HIGH."
1I."WHAT'S MY NUMBER? (1-10) ",G:?T$(SGN(G-N)+1):IF G-N T.1

Example output