Implement a Simple Stopwatch Challenge

Your task is to write a program which, once a second (including immediately when your program is started), prints the elapsed time from the time your program was started.

Rules

Time must be printed in hh:mm:ss format. (leading zeros for single-digit values)
The time stamps must be separated by CR, LF, or CRLF. (no leading whitespace)
A new time must appear every second. (stdout cannot be buffered for a second)
The behavior of the program if it is run past 23:59:59 is undefined.
You may use sleep(1) even if a specific second may be skipped whenever the overhead to print, calculate, loop, etc. accumulates to a second.

Example output:

00:00:00
00:00:01
00:00:02
00:00:04
00:00:05
⋮

Note that 00:00:03 is missing here due to processing overhead. The actual skipped values (if any) are of course dependent on implementation and/or system.

Reference implementation in C: (POSIX-compatible systems only)

#include <unistd.h> // sleep()
#include <tgmath.h>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>

#ifndef __STDC_IEC_559__
#error "unsupported double"
#endif
static_assert(sizeof(double) == 8, "double must have double precision");
#define MAX_PRECISE_DOUBLE ((double)(1ULL << 52))

int main(void) {
    time_t start = time(NULL);
    if (start == (time_t)-1) return EXIT_FAILURE;
    while (1) {
        time_t now = time(NULL);
        if (now == (time_t)-1) return EXIT_FAILURE;

        double diff = difftime(now, start);
        if (isnan(diff) || diff < 0) return EXIT_FAILURE;
        if (diff > MAX_PRECISE_DOUBLE) return EXIT_FAILURE;

        unsigned long long seconds = diff;
        unsigned long long h = seconds / 3600;
        seconds %= 3600;
        unsigned long long m = seconds / 60;
        seconds %= 60;
        unsigned long long s = seconds;

        (void)printf("\r%02llu:%02llu:%02llu", h, m, s);
        (void)fflush(stdout);

        (void)sleep(1);
    }
}

Winning criteria

This is code-golf, shortest code in bytes win!

Operation Flashpoint scripting language,  174  171 bytes

s=""
#l
t=_time
t=t-t%1
a=t%60
c=(t-a)/60
b=c%60
c=(c-b)/60
d=""
e=d
f=d
?a<10:d=0
?b<10:e=0
?c<10:f=0
s=s+format["%1%2:%3%4:%5%6\n",f,c,e,b,d,a]
hint s
@t+1<_time
goto"l"

In action:

158 bytes, if the previous time is overwritten by the next time:

#l
t=_time
t=t-t%1
a=t%60
c=(t-a)/60
b=c%60
c=(c-b)/60
d=""
e=d
f=d
?a<10:d=0
?b<10:e=0
?c<10:f=0
hint format["%1%2:%3%4:%5%6",f,c,e,b,d,a]
@t+1<_time
goto"l"

Technically, no carriage return is used, so I'm not sure if this version confines to the rules.


The Great API Easter Egg Hunt! API Easter egg hunt!

There's an API at http://easter_egg_hunt.andrewfaraday.com which will provide a special Easter egg hunt, just for you...

You can see the API docs at the above address, or try it from here.

The API:

All calls to this API are GET requests, which will return a JSON string.

These examples are in a 5x5 garden, for illustration only.
The API will actually operate on a 100x100 garden (from indexes 1 to 100)

/new_game

Internally, the API produces a garden, and hides an egg in it.

In this example the egg is at 4, 4

+----------+
|          |
|          |
|          |
|          |
|   E      |
|          |
|          |
|          |
|          |
|          |
+----------+

Call

/new_game

Returns

{game_id: 'abcde'}

/guess/:game_id/:x/:y

The API looks in the garden and tells you how close you are.

If you guess 2 across and 8 down, the garden looks like this

+----------+
|          |
|          |
|          |
|          |
|   E      |
|          |
|          |
| g        |
|          |
|          |
+----------+

Call

/guess/abcde/2/8

Returns

{x: 'higher', y: 'lower'}

This means:
* Your x is too low (the egg position is higher)
* Your y is too high (The egg position is lower)

Correct call:

/guess/abcde/4/4

Returns

{x: 'right', y: 'right', turns: 10}

The Rules

Write a program to find the Easter egg with an API.

Use any language.
Try to write concise, but readable code.
Your program MUST call '/new_game' every time, and use the game_id returned in all 'guess' calls. No peeking at the garden!
Try to consistently finish the game with the smallest number of calls possible.
This is not code golf.

Competetive answer?

To be in with a chance of winning here's what we need to know:

What code are you using (In your answer, or a github link if it's bigger than you like to put in an answer).
Run your code 10 times, and record the game_id and score each time.

-game_id-: -score-

e.g.

abbbbbbb: 10

abbbbbdd: 5

(Note: The game_ids are required to verify a result)

The score will be calculated thus:

The highest and lowest two results will be ignored.
The remaining 6 scores will be added together.
This is your score.
Lowest score wins.

Addendum

Tl,dr: The app is a little shoddy.

The API was written in the space of about 90 minutes, and is deployed on a Raspberry Pi 2. Please be gentle with my API server. If you DDOS this poor thing you could spoil it for everyone.

Also, it's implemented with NOIP to simulate a static IP address, but sometimes this will drop out for a little while. That's what I get for using for zero-budget web hosting.

Just for giggles, here's a simple statistical analysis of games played... http://easter_egg_hunt.andrewfaraday.com/stats

APL+WIN
Works by starting in the centre and converges on the location by setting the upper or lower limit to the last value and adding or subtracting half the difference to the appropriate limit to the last guess on each iteration.
API
id←¯20↑¯2↓GetUrl 'http://easter_egg_hunt.andrewfaraday.com/new_game'
xh←yh←100 ⋄ xl←yl←0 ⋄ x←50 ⋄ y←50 ⋄ c←0
:repeat
    xy←GetUrl 'http://easter_egg_hunt.andrewfaraday.com/guess/',id,'/',(⍕x),'/',⍕y
    xy←(('higher'⍷xy)+(¯1×'lower'⍷xy)+2×'right'⍷xy)~0
    :if xy[1]=1 ⋄ xl←x ⋄ x←x+⌈(xh-x)÷2 ⋄ :endif
    :if xy[1]=¯1 ⋄ xh←x ⋄ x←x-⌈(x-xl)÷2 ⋄ :endif
    :if xy[2]=1 ⋄ yl←y ⋄ y←y+⌈(yh-y)÷2 ⋄ :endif
    :if xy[2]=¯1 ⋄ yh←y ⋄ y←y-⌈(y-yl)÷2 ⋄ :endif
    c←c+1
:until 4=+/2↑xy
'id:',id,' x:',(⍕x),' y:',(⍕y),' count:',⍕c

This function uses the following function to do the API calls:
r←GetUrl url
⎕wself←'HTTP' ⎕wi 'Create' 'MSXML2.ServerXMLHTTP'
⎕wi 'XOpen' 'GET' url 0
⎕wi 'XSend'
r←⎕wi 'xresponseText'

The results for 10 trys were:
id:rbgprkxrqzzhwdfsbszn x:36 y:52 count:7
id:nmpcxdqsdzhgrbtlcpbp x:35 y:49 count:6
id:qqnsbpwnlbptxxblywnz x:99 y:22 count:6
id:nsytnvcgnsyrgzvjcysc x:45 y:28 count:6
id:yfkpfhphjpqxtqnwpmhv x:95 y:40 count:7
id:kxhszzrhxqlnvwvwjgnm x:49 y:6 count:6
id:rwnwfgdpzcjpzzfmgcfn x:93 y:34 count:7
id:tcvhtpqlfrwngybsyzqh x:95 y:94 count:6
id:pmlmqnprwcjggjfhttmy x:20 y:41 count:6
id:kpsmmhfhxxrrlvbbgzkv x:9 y:28 count:5


Braille-ify a string And no, This is not a dupe of Translate ASCII text to braille.

There are 28=256 Braille patterns in Unicode. (By 'Braille' I mean 8-cell ones)
W, wait. How many ASCII characters were there?
27 = 128?
Well then, Let's turn ASCII into Braille, 'cause there is absolutely no reason not to!

The way from ASCII, to Braille
We can see each cells represent a bit, which each cell is 'punched' or not.
Now we can allocate each cells to represent the bits of the ASCII character as binary.
(1  )(16 )
(2  )(32 )
(4  )(64 )
(8  )( - )

* ( - ) is blank
Now we can convert ASCII to Braille. For example, A(65=01000001) equals to ⠡.
Examples
Input -> Output
Braille! -> ⠢⠺⠱⡱⡴⡴⠵⠑
(Upscaled)
.. .o o. o. .. .. o. o.
o. oo .o .o .o .o .o .o
.o .o .o .o oo oo oo ..
.. .. .. o. o. o. .. ..

CJam, 27 26 bytes

80qf{i2b7Te[4/~\)\@+++2bc}

Try it online!

Explanation

The Braille code points are neatly ordered so that the individual dots do count up in binary. However, the ordering of the bits in the code points is different. We want the following order:

04
15
26
37

Whereas the characters are laid out in Unicode in this order:

03
14
25
67

(Which kinda makes sense, because historically, Braille only used the first six dots.) Note that we don't need the 7 dot, since the input is guaranteed to be in the ASCII range. So given a list of bits [6 5 4 3 2 1 0] of an input character, we want to reorder them into [3 6 5 4 2 1 0], to pull the bit representing the bottom-left dot to the most significant position.

80     e# Push 80... we'll need this later.
q      e# Read all input.
f{     e# Map this block onto each character, putting a copy of the 80
       e# below each character.
  i    e#   Convert the character to its code point.
  2b   e#   Get its binary representation.
  7Te[ e#   Pad it to 7 bits with zeros. We've now got some bit list
       e#   [6 5 4 3 2 1 0].
  4/   e#   Split into chunks of 4: [[6 5 4 3] [2 1 0]]
  ~    e#   Dump them onto the stack: [6 5 4 3] [2 1 0]
  \    e#   Swap them: [2 1 0] [6 5 4 3]
  )    e#   Pull off the last element: [2 1 0] [6 5 4] 3
  \    e#   Swap: [2 1 0] 3 [6 5 4]
  @    e#   Rotate: 3 [6 5 4] [2 1 0]
  ++   e#   Concatenate twice: [3 6 5 4 2 1 0]
       e#   That's the reordering done.
  +    e#   Prepend the 80. That puts it in the 2^7 position of the
       e#   binary digit list, which gives it a value of 10240, which
       e#   is where the Braille characters start.
  2b   e#   Convert the bits back to an integer.
  c    e#   Convert the code point to the corresponding integer.
}%


Do the NP: find the largest clique Background
At the time of writing this, the P vs NP problem is still unsolved, but you might have heard of Norbert Blum's new paper claiming proof that P != NP, which is already suspected to be erroneous (but we will see).
The problem discussed in this paper is the clique problem. At least that's what I read in a newspaper article, so correct me if I'm wrong, but in any case, I'd like you to write a program that solves the following variant:
The task
Assume we have a large school with lots of students. Each of these students has some friends at this school. A clique of students is a group consisting only of students who are friends with each other member.
Your program will receive pairs of students who are friends as its input. From this information, the program must find the size of the largest clique. Students are identified by integer IDs.
If you prefer mathematical terms, this means you're fed the edges of an undirected graph, identified by two nodes each.
Input
Your input will be a non-empty list of positive integer pairs, e.g. [[1,2],[2,5],[1,5]]. You can take this input in any sensible form, e.g. as an array of arrays, as lines of text containing two numbers each, etc ...
Output
The expected output is a single number n >= 2: the size of the largest clique. With the example input above, the result would be 3, as all students (1, 2 and 5) are friends with each other.
Test cases
[[1,2]]
=> 2

[[1,2],[3,1],[3,4]]
=> 2

[[1,2],[2,5],[1,5]]
=> 3

[[2,5],[2,3],[4,17],[1,3],[7,13],[5,3],[4,3],[4,1],[1,5],[5,4]]
=> 4 (the largest clique is [1,3,4,5])

[[15,1073],[23,764],[23,1073],[12,47],[47,15],[1073,764]]
=> 3 (the largest clique is [23,764,1073])

[[1296,316],[1650,316],[1296,1650],[1296,52],[1650,711],[711,316],[1650,52],
 [52,711],[1296,711],[52,316],[52,1565],[1565,1296],[1565,316],[1650,1565],
 [1296,138],[1565,138],[1565,711],[138,1650],[711,138],[138,144],[144,1860],
 [1296,1860],[1860,52],[711,1639]]
=> 6 (the largest clique is [52,316,711,1296,1565,1650])

You can use this (stupid) reference implementation (prints extra output with -d flag) for verifying the results of other test cases.
The rules

Your program doesn't need a defined result on invalid input. So you can assume that:

you will always get at least one pair of IDs
each pair consists of two different IDs
no pair appears twice (swapping the places of the IDs would still be the same pair)

Your algorithm isn't allowed to set an upper bound on input size. Purely technical limitations and limitations set by your language/environment (like stack size, computation time, etc) are of course inevitable.
Standard loopholes are forbidden.
This is code-golf, so the shortest code, measured in bytes, wins.
If your algorithm has polynomial time complexity, you score -1 immediately regardless of your code size, but in that case, you might want to submit your solution somewhere else. ;)


Build a solver for the monks and buns problem An old Chinese poem goes:

  一百饅頭一百僧，
  大僧三個更無爭，
  小僧三人分一個，
  大小和尚得幾丁？

When translated into English, this math problem reads:

  100 buns and 100 monks,
  Big monks eat 3 buns with no shortage,
  Little monks share one bun among three,
  Big and little monks, how many are there?

Once again, like in the cow and chicken problem, there is no simple calculation you can perform. You need the power of systems of equations.

Your task is to build a program that takes the following inputs, all positive integers:

b, the number of buns.
m, the number of monks.
bl, the number of buns a big monk can eat.
ms, the number of small monks who share one bun.

and output l and s, the number of big monks and small monks respectively. ("L" stands for "large").

Again, this problem has various states of solvability, but this time around, only output something if there is a unique solution in the nonnegative integers.

The shortest code to do all of the above in any language wins.

The problem input of the poem is 100 100 3 3, and the solution is 25 75.

R: 81 characters

i=scan();p=combn(0:i[2],2);cat(p[,p[1,]+p[2,]==i[2]&i[3]*p[1,]+p[2,]/i[4]==i[1]])

A brute force solver which takes all possible combinations of non-negative integers and subset the one corresponding to criteria.


Add and multiply perplexing numbers The split-complex numbers, also known as "perplex numbers" are similar to the complex numbers.  Instead of i^2 = -1, however, we have j^2 = 1; j != +/-1.  Each number takes the form of z = x + j*y.

In one attempt to limit the complexity of this challenge, I will use the symbol - to represent negation, as there will not be any subtraction.

Here are some examples for your viewing pleasure:

6 * 9 = 54            // real numbers still act normally
5 + -7 = -2
j*1 + j*1 = j*2           // two `j`s added together make a j*2
7 * j*1 = j*7           // multiplication is commutative & associative
j*1 + 2 = 2+j*1           // like oil and water, "combine" to form a split-complex number
j*1 + j*-3 = j*-2          // seems okay so far
j*j*1 = j*-1*j*-1 = 1     // kinda sketchy, but such is its inherent nature
j*j*-1 = j*-1*j*1 = -1
(2+j*3)+(4+j*7) = 6+j*10  // combine like terms
7 * (2+j*3) = 14+j*21 // distributive property
j * (2+j*3) = (j*2) + (j*j*3) = 3+j*2   // since j^2 = 1, multiplying my j "swaps" the coefficients
(2+j*3)*(4+j*7) = (2*4)+(2*j*7)+(j*3*4)+(j*3*j*7) = 8+j*14+j*12+21 = 29+j*26 // a complete multiplication

Challenge

The goal of this challenge is to evaluate an expression with split-complex numbers.

This is code-golf, the fewest bytes wins.

Input

Input will be a single line containing only the symbols +*()-, the digits 0123456789, and the letter j, with an optional newline.  This string represents an expression, using infix notation and operator precedence (multiplication before addition, with parenthesis grouping).

The symbol - will always represent negation, never subtraction.  If you so desire, you can replace - with either _ or ~ for ease of I/O.
Parenthesis can be nested up to three times to denote grouping: (1+(1+(1)))
The letter j will never be directly prefixed with negation, and will always be followed by *.
Parentheses will not be preceded by negation -(7), but instead like -1*(j*5+2)
There will never be implicit operations. All multiplication will be expressed as (7)*7 instead of (7)7, and as j*5 instead of j5.
No leading zeros.

Output

Output will be in the form of X+j*Y, where X and Y can be any integer.  If an integer is negative, it should be prefixed with the negation sign.

Additional Restrictions

Although I am not aware of any language with native support, built-ins that deal with split-complex numbers are forbidden.  Regular complex numbers are fair game.

Test Cases

Similar to the above examples, but tidied up.  Input on one line and output the line beneath.

(2+j*3)+(4+j*7)
6+j*10

(2+j*3)*(4+j*7)
29+j*26

(-5+j*1+j*2+2)*(4+j*7)
9+j*-9

(1+j*-1)*(1+j*1)
0+j*0 // this is why division does not exist.

j*((j*-1)+2)
-1+j*2

(2+(5+-1*(j*1))+2)
9+j*-1

Python 2, 62 bytes

def f(s):b,a=[eval(s)/2.for j in-1,1];print'%d+j*%d'%(a+b,a-b)

We simply evaluate the expression s with  j=1 and j=-1, and output half their sum and half their difference as the coefficients of 1 and j.
This works because both j=1 and j=-1 satisfy the defining equation defining equation j*j==1. So, the original and simplified expressions must be equal for both these values. The simplified expression is linear, so this gives two linear equations in two unknowns:
x + 1*y  = s(1)  = 2*a
x - 1*y  = s(-1) = 2*b

which is solved by x=a+b, y=a-b.


Unminify a Pythlike String Pyth is perhaps the most successful general-purpose golfing language. Though it is somewhat in decline as a result of newer languages, from 2014 to 2016 Pyth's concise syntax, constant updates, overloading, and (for its era) many builtins made it a favorite for the majority of questions.
Pyth code is often difficult to read. Even the output of the debug mode (transpiled Python) often consists of a long line, sometimes with parentheses nested ten deep. However, correctly formatted Pyth is very readable.
Here's a piece of Pyth code, written by @isaacg in Play the Word Chain.
.MlZfqhMtTeMPT+Lzs.pMyQ

It's much more readable like this.
.M                     Filter by gives-maximal-value of
   l Z                   lambda Z:length(Z) over
   f                     filter by (lambda T:
     q                     equal
       hM t T                head-map tail T
       eM P T                end-map Pop T)
     +L                    Append z to each element in
        z
        s .pM y Q            flattened permutations of each subset of Q

For this challenge, we eliminate the kolmogorov-complexity aspect of categorizing Pyth characters and focus on formatting. Instead of being Pyth code, the input will consist of characters in 0123456789M. The digit n represents a function of arity n, and M represents an operator. For example, the above code is represented as 210221M101M102M011M10. Here are the steps to unminify:
Separate the string into tokens.
A token matches [0-9]M*. 0M will not occur in input.
Add trailing 0s.
When there are not enough arguments, Pyth appends as many implicit variables (lambda variables or Qs) to the code as are necessary to fill the arguments of the program; these should be represented by 0s.
Group tokens into lines.
The arity of a token is the value of its digit.

An arity-0 token (i.e. a 0) ends a line.

For an arity-1 token the next token should go on the same line, separated by a space.

For an arity >=2 token, its arguments go on separate lines, in the order they appear in the code, each followed by their own subarguments and so on. Arguments to a token are indented to the end of that token plus one space.

Input
A nonempty string (or char array, array of length-1 strings, etc. as allowed by Standard I/O Methods) consisting of 0123456789M, which will not contain the substring 0M.
Output
The string formatted according to the above rules.
Test cases
210221M101M102M011M10

2
  1 0
  2
    2
      1M 1 0
      1M 1 0
    2M
       0
       1 1M 1 0

123M4M

1 2
    3M
       4M
          0
          0
          0
          0
       0
       0
    0

2MM

2MM
    0
    0

11011100

1 1 0
1 1 1 0
0

9000000

9
  0
  0
  0
  0
  0
  0
  0
  0
  0

Haskell, 192 190 187 bytes

unlines.snd.f
f(n:r)|(m,t)<-span(>'9')r,(s,l)<-n#t=(s,n?((n:m):map((' '<$(n:n:m))++)l))
f e=(e,["0"])
'1'?(a:b:r)=(a++drop(length a)b):r
_?s=s
'0'#s=(s,[])
n#s|(r,l)<-f s=(l++)<$>pred n#r

Try it online!

There has to be a better way to handle the arity-1 case, it currently takes up 45 bytes.

Edits:

-2 bytes by switching to a different method of handling 1, though the previous method has probably more optimization potential.
-3 bytes by not converting the character digits to numbers and using pred instead of n-1.

unlines.snd.f
f(n:r)|(m,t)<-span(>'9')r,(s,l)<-read[n]#t,w<-map((' '<$(n:n:m))++)=(s,last$((n:m):w l):[(n:m++' ':h):w t|n<'2',h:t<-[l]])
f e=(e,["0"])
0#s=(s,[])
n#s|(r,l)<-f s=(l++)<$>(n-1)#r

Try it online!


Smallest image containing one of every RGB color I'm not sure if this kind of golf is allowed, but here it is.
Your objective is to create an image containing one pixel of every possible RGB color. The image with the smallest file size wins.
Rules:

The image must be a PNG.
The image must contain exactly one of every possible RGB color.
Acceptable image dimensions are:

1x16777216
2x8388608
4x4194304
8x2097152
16x1048576
32x524288
64x262144
128x131072
256x65536
512x32768
1024x16384
2048x8192
4096x4096
8192x2048
16384x1024
32768x512
65536x256
131072x128
262144x64
524288x32
1048576x16
2097152x8
4194304x4
8388608x2
16777216x1

Example Image

49683 bytes

Generated by this Python code:

import struct
import zlib

width = 2 ** 16
height = 2 ** 8
bit_depth = 8
color_type = 2
compression_method = 0
filter_method = 0
interlace_method = 0
scanlines = bytes(
    ([1] + (2 ** 8) * ([2, 1, 1] + (2 ** 8 - 1) * [1, 1, 1]))
    + (2 ** 8 - 1) * ([2] + 2 ** 16 * [2, 1, 2])
)

header = struct.pack(
    "!IIBBBBB",
    width,
    height,
    bit_depth,
    color_type,
    compression_method,
    filter_method,
    interlace_method,
)
compress = zlib.compressobj(level=9, wbits=15, memLevel=9)
compressed = compress.compress(scanlines) + compress.flush()
png = b"\x89PNG\r\n\x1a\n"
for type, data in [(b"IHDR", header), (b"IDAT", compressed), (b"IEND", b"")]:
    crc = 0xFFFFFFFF
    for b in type + data:
        crc ^= b
        for k in range(8):
            crc = 0xEDB88320 * (crc & 1) ^ crc >> 1
    crc ^= 0xFFFFFFFF
    png += struct.pack("!I4s", len(data), type) + data + struct.pack("!I", crc)

print(len(png))
with open("rgb.png", "wb") as f:
    f.write(png)

Try it online!
(Note: many PNG readers accept an image missing the IEND chunk, but it is required by the PNG specification so I have included it.)


Yeah But No But Yeah My colleague recently sent me the following piece of JavaScript as a joke:

let butScript = (nrOfButs) => {
    for(var i = 0; i < nrOfButs; i++){
        if(i % 3 == 0){
            console.log("Yeah")
        }
        if(i % 2 == 0){
            console.log("But")
        }
        if(i % 3 == 1){
            console.log("No")
        }
    }
}

Since the code was written during work hours, it was obviously a huge waste of company resources. To prevent similar occurrences in the future, we must minimize the waste of worked hours. And since it is common knowledge that a shorter program is faster to write, we must golf this code to be as short as possible!

Input

A single non-negative integer. You must not handle faulty input.

Output

Your program must produce output identical to that of the script above. You should output one word per line, and the number of words should be consistent with the original script.

It is permissible to include non-newline whitespace characters at the end of each line (but not at the beginning) since they are invisible. One additional newline character is permissible at the very end of the output.

Examples

Input: 0
Output:

Input: 1
Output:
Yeah
But

Input: 2
Output:
Yeah
But
No

Input: 10
Output:
Yeah
But
No
But
Yeah
But
No
Yeah
But
No
But
Yeah

Excel, 78 bytes

Assumes input in cell A1, and that Wordwrap formatting is turned on for cell.  Use Alt+Enter to add line feeds within the string and note the whitespace.  Only handles input up to 3570 due to limit of REPT function (Good luck getting a cell to be that tall, though).

=LEFT(REPT("Yeah
But
No
But
Yeah
But
No
",595),A1*9)

Reprinting, with periods for whitespace

=LEFT(REPT("Yeah
But
No......
But.....
Yeah....
But
No...........
",595),A1*9)

How it works:
The pattern repeats every 6 numbers:

0 = Yeah and But      Yeah + linefeed + But + linefeed
1 = No                No + 6 whitespace + line feed
2 = But               But + 5 whitespace + linefeed
3 = Yeah              Yeah + 4 whitespace + linefeed
4 = But and No        But + linefeed + No + 3 whitespace
5 = Blank             8 whitespace + linefeed

Each of these can be expressed with 9 characters, so a string is made of 54 characters (9 * 6), then repeated as large as Excel will allow.  Then it takes the left 9 * (number of input) characters as the output.

Linefeed for the "but and no" one is placed after the blank so that the Yeah for #6, #12, (etc) is formatted to the left rather than the right, and so that there is no blank linefeed added every 6th line for that item.


Fibonacci distribution validator Related: Hello world!!! Fibonacci distribution

Create a program that returns True if a given input meets the following specifications, and False otherwise:

The count of numeric characters (0-9) in the input matches a Fibonacci number.
The count of non-numeric characters !(0-9) in the input matches the Fibonacci number immediately preceding the count of numeric characters.

Additional Rules:

Your program must use the proper Fibonacci sequence, per OEIS - that is, the Fibonacci sequence must start with 0, 1, 1, 2, ...
If the numerics or non-numerics count is 1, the following must occur:

Numerics 1: Non-numeric count of 0 or 1 should be handled as True - all others False.
Non-Numerics 1: Numerics count of 1 or 2 should be handled as True - all others False.

Input may be taken however you like, but the program must be capable of handling any arbitrary text.
True/False are not case-sensitive, and can be substituted with 1/0 or T/F.
You may only hard-code up to two Fibonacci numbers.
Output may only be True/False or 1/0 or T/F. Any additional text or visible errors generated is unacceptable.

Javascript, 92 88 86 characters
t=prompt()
for(b=c=1;c<t[l='length'];c=a+b)a=b,b=c
alert(c==t[l]&b==t.match(/\d/g)[l])

I hope you don't mind I've hard-coded the the first three Fibonacci numbers.


A program that deletes itself If a compiled language is used, the program must delete the compiled executable (but need not delete the source file). If an interpreted language is used, the program must delete the source file.

My opening bid:

Python (29 characters)

import os;os.remove(__file__)

Edit: to prevent solutions like rm -rf /, the program must not delete anything except the executable or source file.

html,body{margin:0;padding:0;height:100%;overflow:hidden}
 <iframe src="https://xmikee1.github.io/ppcg-leaderboard/?id=19355" width="100%" height="100%" style="border:none;">Oops, your browser is too old to view this content! Please upgrade to a newer version of your browser that supports HTML5.</iframe>

Bash script (7 characters, 7 bytes)

rm "$0"


Are my triangles similar? Given (in any structure; flat list, two lists of lists, a tuple of matrices, a 3D array, complex numbers,…) the coordinates for two non-degenerate triangles ABC=[[Ax,Ay],[Bx,By],[Cx,Cy]] and PQR=[[Px,Py],[Qx,Qy],[Rx,Ry]], determine if they are similar, that is,

  they both have the same shape, or one has the same shape as the mirror image of the other. More precisely, one can be obtained from the other by uniformly scaling (enlarging or reducing), possibly with additional translation, rotation and reflection.[Wikipedia]

You may assume that all coordinates are integers.

You must either return a truthy/falsey value indicating similar/dissimilar respectively, or two consistent values; please state your choice.

Failing on some cases due to limitations in floating point precision  is acceptable so long as the algorithm is correct in principle.

Bonus task: Add a comment to this post stating whether you would like the same challenge generalised to polygons in N-space.

Walked-through example case

ABC=[[0,0],[1,0],[0,1]] and PQR=[[1,0],[-1,0],[1,-2]]

Reflect ABC in the x-axis: [[0,0],[-1,0],[0,1]]
Reflect in the y-axis: [[0,0],[-1,0],[0,-1]]
Enlarge by a factor of 2: [[0,0],[-2,0],[0,-2]]
Translate right by 1 unit: [[1,0],[-1,0],[1,-2]]

This gives us PQR.

Test cases

Similar

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

[[-2,1],[4,-2],[6,2]] and [[-1,-1],[2,-1],[-1,1]]

[[-1,0],[1,0],[0,2]] and [[-2,5],[2,5],[0,1]]

Dissimilar

[[0,0],[-1,0],[0,1]] and [[1,0],[-1,0],[2,-3]]

[[2,1],[4,2],[6,2]] and [[-1,-1],[2,-1],[-1,1]]

[[-1,0],[1,0],[0,3]] and [[-2,5],[2,5],[0,1]]

MATL, 15 12 bytes
,i4:)d|S]/da

The program inputs two  3×1 vectors of complex numbers representing the coordinates; and outputs 0 for similar, 1 for not similar.
Try it online! Or verify all test cases.
Explanation
The code checks if the side lengths, sorted for each triangle, are proportional between the two triangles.
,      % Do twice
  i    %   Take input: 3×1 vector of complex numbers
  4:)  %   Modular index to repeat 1st number after the 3rd. Gives a 4×1 vector
  d    %   Consecutive differences
  |    %   Absolute value, element-wise
  S    %   Sort
]      % End
/      % Divide, element-wise
d      % Consecutive differences
a      % Any: gives 0 if and only if all values are 0
       % Implicit display


Basic sort, with annoying bug Your input is a list/sequence/vector/array of 5-255 positive integers, not necessarily unique.  You may assume whatever input format is most suitable, and that each integer (as well as the quantity of integers) is chosen uniformly at random from the range 5-255.

The goal is to output the same list, in the same (or equivalent) format, but sorted into increasing (nondecreasing) order. A common early exercise in learning a language.  Submissions to include:

An answer which works correctly and achieves the goal; and
A second answer which contains an annoying bug.  Between 1% and 10% of the time, the output needs to be a list in the correct format and containing the correct elements, but in the wrong order (any order except correctly sorted).  The rest of the time, the program must work correctly and achieve the goal.

The two answers must have Levenshtein distance one; that is, we can get one from the other by deleting one byte, or adding one byte, or changing one byte.

Scoring as usual in code-golf (based on the shorter of your two answers), with usual loopholes forbidden.

10% bonus (decrease to score) if the annoying bug is input-independent, i.e. using the same input again doesn't reproduce the bug (except between 1% and 10% of the time).

Python 3, 36 bytes

Bug-free version, 37 bytes

lambda l:sorted(l,reverse=l[-9:]==[])

Try it online!

Annoying version, 36 bytes

lambda l:sorted(l,reverse=l[9:]==[])

Try it online!

This depends on the input and therefore does not qualify for the bonus.
It has a probability of around 2% to fail. It fails when the input length is lower then 10.

Combined with LyricLy's answer this gets 34 bytes:

lambda l:sorted(l)[::l[9:]>[]or 1]
lambda l:sorted(l)[::l[9:]>[]or-1]


Remove the mininum sum seam from an array The seam carving algorithm, or a more complex version of it, is used for content-aware image resizing in various graphics programs and libraries. Let's golf it!

Your input will be a rectangular two dimensional array of integers.

Your output will be the same array, one column narrower, with one entry removed from each row, those entries representing a path from top to bottom with the lowest sum of all such paths.

https://en.wikipedia.org/wiki/Seam_carving

In the above illustration, each cell's value is shown in red. The black numbers are the sum of a cell's value and the lowest black number in one of the three cells above it (pointed to by the green arrows). The white highlighted paths are the two lowest sum paths, both with a sum of 5 (1+2+2 and 2+2+1).

In a case where there are two paths tied for the lowest sum, it does not matter which you remove.

Input should be taken from stdin or as a function parameter. It can be formatted in a manner convenient to your language of choice, including brackets and/or delimiters. Please specify in your answer how the input is expected.

Output should be to stdout in an unambiguously delimited format, or as a function return value in your language's equivalent to a 2d array (which might include nested lists, etc).

Examples:

Input:
1 4 3 5 2
3 2 5 2 3
5 2 4 2 1
Output:
4 3 5 2      1 4 3 5
3 5 2 3  or  3 2 5 3
5 4 2 1      5 2 4 2

Input:
1 2 3 4 5
Output:
2 3 4 5

Input:
1
2
3
Output:
(empty, null, a sentinel non-array value, a 0x3 array, or similar)

EDIT: The numbers will all be non-negative, and every possible seam will have a sum that fits in a signed 32 bit integer.

Haskell, 187 bytes

l=length
f a@(b:c)=snd$maximum$(zip=<<map(sum.concat))$map(zipWith((uncurry((.drop 1).(++)).).flip splitAt)a)$iterate((\e@(f:_)->[f-1:e,f:e,min(f+1)(l b-1):e])=<<)[[y]|y<-[0..l b-1]]!!l c

Usage example:

*Main> f [[1,4,3,5,2],[3,2,5,2,3],[5,2,4,2,1]]
[[4,3,5,2],[3,5,2,3],[5,4,2,1]]

*Main> f [[1],[2],[3]]
[[],[],[]]

*Main> f [[1,2,3,4,5]]
[[2,3,4,5]]

How it works, short version: build a list of all paths (1), per path: remove corresponding elements (2) and sum all remaining elements (3). Take the rectangle with the largest sum (4).

Longer version:

Input parameters, assigned via pattern matching:
a = whole input, e.g. [[1,2,4],[2,5,6],[3,1,6]]
b = first line, e.g. [1,2,4]
c = all lines, except first, e.g. [[2,5,6],[3,1,6]]

Step (1), build all paths:

iterate((\e@(f:_)->[f-1:e,f:e,min(f+1)(l b-1):e])=<<)[[y]|y<-[0..l b-1]]!!l c

     [[y]|y<-[0..l b-1]]           # build a list of single element lists
                                   # for all numbers from 0 to length b - 1
                                   # e.g. [[0],[1],[2]] for a 3 column input.
                                   # These are all possible start points

     \e@(f:_)->[f-1:e,f:e,min(f+1)(l b-1):e]
                                   # expand a list of paths by replacing each
                                   # path with 3 new paths (up-left, up, up-right)

     (...)=<<                      # flatten the list of 3-new-path lists into
                                   # a single list

     iterate (...) [...] !! l c    # repeatedly apply the expand function to
                                   # the start list, all in all (length c) times.

Step (2), remove elements

map(zipWith((uncurry((.drop 1).(++)).).flip splitAt)a)

     (uncurry((.drop 1).(++)).).flip splitAt
                                   # point-free version of a function that removes
                                   # an element at index i from a list by
                                   # splitting it at index i, and joining the
                                   # first part with the tail of the second part

      map (zipWith (...) a) $ ...  # per path: zip the input list and the path with
                                   # the remove-at-index function. Now we have a list
                                   # of rectangles, each with a path removed

Step (3), sum remaining elements

zip=<<map(sum.concat)             # per rectangle: build a pair (s, rectangle)
                                  # where s is the sum of all elements

Step (4), take maximum

snd$maximum                      # find maximum and remove the sum part from the
                                 # pair, again.


A rainbow of identity functions Closely related: How high can you count?

Challenge

In your programming language of choice, write as many different identity programs/functions as possible, under the following constraints:

Each program should be a function or full program that is one of the following:

A function that takes a single positive integer and returns it unchanged
A function that takes a single string of printable ASCII (codepoints 32 to 126 inclusive) and returns it unchanged
A full program that takes a single positive integer from stdin and prints to stdout unchanged, with an optional trailing newline (and possibly other outputs that cannot be suppressed in your language)
A full program that takes a single line of printable ASCII from stdin and prints to stdout unchanged, with an optional trailing newline (and possibly other outputs that cannot be suppressed in your language)

Different programs using different I/O methods is acceptable.
Any single byte cannot appear in two or more programs, though it may appear more than once in a single program. You may freely use multi-byte characters, as long as every byte value consisting of each multi-byte character follows this exact rule.
The programs must be independent of each other.
If an empty program satisfies the condition above, you can include it only once in your answer.
Symbol independent languages such as Lenguage (including partially independent ones such as Headsecks) are disallowed.
If your language accepts flags, all programs in an answer must use a single combination of flags (e.g. one answer for "Keg" programs without flags, a separate answer for "Keg -hr" programs). According to this meta, a language with different flag combination is a different language.

Examples

In Python 3, all of lambda a:a, print(input()), int, and str are valid identity programs independently, but only two of them can be used in an answer since the last three programs share the character t.

Scoring

The submission with the largest number of programs wins.

05AB1E, 130 133 144 148 150 151 155 156 157 159 programs
Uses the custom  05AB1E encoding for all programs.
All programs are a TIO-link to verify them.
Either type of input is fine:
1) (empty program): Implicit input is output implicitly
2,3)   (a space), \n (a newline): The whitespaces are ignored; implicit input is output implicitly  (with trailing newline)
4) w: Unbound no-op; implicit input is output implicitly (with trailing newline)
5) I: Explicit input is output implicitly (with trailing newline)
6) ¹: Explicit first input is output implicitly (with trailing newline)
7) $: Push 1 and the input, after which the top input is output implicitly (with trailing newline)
8) Î: Push 0 and the input, after which the top input is output implicitly (with trailing newline)
9) ,: Implicit input is output explicitly with trailing newline
10) =: Implicit input is output explicitly with trailing newline (without popping)
11) ?: Implicit input is output explicitly without trailing newline
12) q: Exit program; implicit input is output implicitly (with trailing newline)
13,14) D, Ð: Duplicate / triplicate the implicit input and output the top implicitly (with trailing newline)
15) r: Reverse the values on the stack (which is empty); implicit input is output implicitly (with trailing newline)
16,17) s, Š: Swap / triple swap two / three implicit inputs; the top is output implicitly (with trailing newline)
18) Δ: Loop until the result no longer changes; the implicit input is used, it loops twice, and the unmodified input is output implicitly (with trailing newline)
19) :: Replace the implicit input-string with the implicit input-string, after which the unmodified input is output implicitly (with trailing newline)
20,21,22,23) J, », O, P: Join the empty stack without delimiter / join the empty stack with newline delimiter / sum the empty stack / take the product of the empty stack, after which the implicit input is output implicitly (with trailing newline)
24,25) U, V: Pop the implicit input, and store it in variable X or Y respectively, after which the implicit input is output implicitly (with trailing newline)
26) ©: Store the implicit input in variable ® (without popping), after which it is output implicitly (with trailing newline)
27) ˆ: Pop the implicit input, and add it to the global array, after which the implicit input is output implicitly (with trailing newline)
28) i: If-statement, if the (implicit) input is 1 it enters it. But whether the input is 1 and it enters the if-statement or not, the implicit input is output implicitly (with trailing newline) either way
29) v: For-each over each character/digit of the implicit input (but don't push any, since we don't use y). After the loop, the implicit input is output implicitly (with trailing newline)
30,31) }, ]: Close the inner-most or all if-statement(s)/loop(s), for which there are none right now. The implicit input is output implicitly (with trailing newline)
32) †: Filter the implicit input to the front of the implicit input; it will remain unmodified and is output implicitly (with trailing newline)
33) ‡: Transliterate the characters of the implicit input to the characters of the implicit input; it will remain unmodified and is output implicitly (with trailing newline)
34) ´: Clear the global array (which is already empty). After which the implicit input is output implicitly (with trailing newline)
35) §: Cast the implicit input to a string, after which it is output implicitly (with trailing newline)
36) Ã: Keep all values of the implicit input in the implicit input, after which the unmodified result is output implicitly (with trailing newline)
37) é: Sort the implicit input by length. Since it's a single string/integer, the characters/digits will remain at the same position, after which the unmodified input is output implicitly (with trailing newline)
38,39) ., Å, ž: All three are used to open up more 2-byte operations, but on their own they're unbound no-ops. So the implicit input is output implicitly (with trailing newline).
40) \: Discard the top item on the stack (which is already empty), after which the implicit input is output implicitly (with trailing newline)
41) ¼: Increase the counter_variable by 1. After which the implicit input is output implicitly (with trailing newline)
42) ½: If the implicit input is 1, increase the counter_variable by 1. After which the implicit input is output implicitly (with trailing newline)
43) ë: Else-statement, which is a no-op without if-statement. So the implicit input is output implicitly (with trailing newline)
44) ÿ: Used for string interpolation; outside of a string it's a no-op. So the implicit input is output implicitly (with trailing newline)
45) šн: Convert the implicit input implicitly to a character-list, and prepend the implicit input at the front. Then pop and push the first item of this list, which is output implicitly (with trailing newline).
46) ªθ: Convert the implicit input implicitly to a character-list, and append the implicit input at the end. Then pop and push the last item of this list, which is output implicitly (with trailing newline).
47) η¤: Get all prefixed of the implicit input. Push its last item (without popping), after which the top of the stack is output implicitly (with trailing newline).
48) ðý: Join the empty stack with space delimiter, after which the implicit input is output implicitly (with trailing newline).
49) õK: Remove all empty strings from the implicit input, after which the unmodified result is output implicitly (with trailing newline).
50) ¸` : Wrap the implicit input into a list, and then pop and dump the contents of that list to the stack, after which it is output implicitly (with trailing newline)
51) ʒX: Start a filter, and push variable X, which is 1 (truthy) by default. So all characters/digits in the implicit input will remain, and the unmodified input is output implicitly (with trailing newline)
52) RR: Reverse the implicit input, and reverse it back. After which the unmodified input is output implicitly (with trailing newline).
53) ÂÂ: Bifurcate (short for Duplicate & Reverse copy) twice, after which the unmodified input at the top of the stack is output implicitly (with trailing newline)
54) ÁÀ: Rotate the implicit input once towards the right, and then back towards the left. After which the unmodified input is output implicitly (with trailing newline).
55) Ć¨: Enclose the implicit input, appending its own first character/digit, and then remove the last character/digit again. After which the unmodified input is output implicitly (with trailing newline).
56) Σ9: Sort the characters/digits in the implicit input by 9 (so they'll all stay at the same positions), after which the unmodified input is output implicitly (with trailing newline).
57) 8ì¦: Prepend an 8 in front of the implicit input, and then remove the first character again. After which the unmodified input is output implicitly (with trailing newline)
58) āĀÏ: Push a list in the range [1, implicit input-length] (without popping). Python-style truthify each value in this list (so they'll all becomes 1s). Only keep the characters/digits of the implicit input at the truthy (1) indices, after which the unmodified result is output implicitly (with trailing newline).
59) ""«: Append an empty string to the implicit input, after which the unmodified input is output implicitly (with trailing newline).
60,61) ‘‘Û, ’’Ü: Trim all leading / trailing empty strings of the implicit input, after which the unmodified input is output implicitly (with trailing newline).
62) ““¡: Split the implicit input on an empty string, after which the unmodified input is output implicitly (with trailing newline).
63) ₆¢: Count the amount of 36 in the implicit input. Not sure why, but when using a multi-character value with the count, there seems to be a bug and it results in the unmodified string, instead of the actual amount of 36 substrings in the string I was expecting.. So this will output the unmodified input implicitly (with trailing newline).
Only string input:
64 through 125) ǝαβив!%&(*+-/÷;<>BLbcefhjmnoptxz~‰£°±·¿ÃÆÈÉÌÍÑÒÓÕÖ×ØÝãäçèîôöùú: All these are integer operations (see the Wiki-page linked in the title to see what each does). They are no-ops for the (implicit) input-string(s); after which the unmodified input at the top of the stack is output implicitly.
126) ∍: Extend/shorten the implicit input-string to a size equal to the implicit input-string, after which it is output implicitly (with trailing newline).
127) δ: Apply double-vectorized. For integer inputs, it will implicitly convert to a \$[1, a]\$ range before applying double-vectorized. For strings, the implicit input is output implicitly.
128) Λ: Apply the Canvas with three options. For the digits 0 through 7, it will output the digit in a certain direction and length, depending on the input. For any other input, it will be a no-op outputting the implicit input implicitly (with trailing newline).
129) –: If the top of the stack is 1, it will print index N. So this will output 0 for input 1, but will output the implicit input itself implicitly (with trailing newline) for any other input.
130) —: If the top of the stack is 1, it will print item y. So this will output an empty string for input 1, but will output the implicit input itself implicitly (with trailing newline) for any other input.
131) œW: Get all permutations of the implicit input-string. Then push the minimum (without popping), which for string inputs will simply use the very first string. Then output this unmodified input at the top of the stack implicitly (with trailing newline).
Only string input, and the output is a character-list:
132) S: Convert the implicit input to a list of characters and output it implicitly (with trailing newline).
133,134) ε, €: Map over each character in the implicit input, and output the resulting character-list implicitly (with trailing newline).
135) gι: Push the length of the implicit input. Uninterleave the implicit input using this length as block-size. After which the resulting character-list is output implicitly (with trailing newline).
136) øøø¬: Zip/transpose three times; swapping rows/columns. If it's a matrix, it will do as expected. If it's a string or list, it will use the implicit input as a pair-and-zip/tranpose. Since we're doing it three times, the following will happen: "abc" → ["aa","bb","cc"] → [["a","aa"],["b","bb"],["c","cc"]] → [["a","b","c"], ["aa","bb","cc"]]. Then we'll push the first inner list (without popping), after which this list at the top of the stack is output implicitly (with trailing newline).
137) ü1: ü is the overlapping builtin. It can be used with any other builtin to execute that builtin on every overlapping pair. But it can also be used with a single digit to create overlapping pair (2), triplets (3), quartets (4), etc. Apparently it also works with 1 to just convert the (implicit) input-string into a character-list, which is output implicitly (with trailing newline).
Only character-list input:
138) í: Reverse each character in the implicit input-list, after which the unmodified input-list is output implicitly (with trailing newline).
139) ˜: Flatten the implicit input-list, after which the unmodified input-list is output implicitly (with trailing newline).
140) ζζΩ: Zip/transpose the (implicit) input-list twice: ["a","b","c"] → [["a","a"],["b","b"],["c","c"]] → [["a","b","c"],["a","b","c"]]. And then pop and push a random item of this list of lists, which are both the unmodified input-list. After which it will be output implicitly (with trailing newline).
Only integer input:
141,142,143,144) E, F, G, ƒ: Start a ranged loop with the implicit input (E = \$[1, a]\$; F = \$[0, a)\$; G = \$[1, a)\$; ƒ = \$[0, a]\$), and output the implicit input implicitly (with trailing newline) afterwards.
145) ï: Convert the implicit input to an integer, after which the unmodified input is output implicitly (with trailing newline).
146) ò: Round to the nearest integer (which it already is), after which the unmodified input is output implicitly (with trailing newline).
147) þ: Only keep the digits of the implicit input-integer, after which the unmodified input is output implicitly (with trailing newline).
148) #: Split the implicit input-integer by spaces (it has none), after which the unmodified input is output implicitly (with trailing newline).
149,150,151) u, l, ™: Convert the implicit input-integer to uppercase / lowercase / titlecase, after which the unmodified input is output implicitly (with trailing newline).
152) ¶м: Remove all newline characters of the implicit input-integer, after which the unmodified input is output implicitly (with trailing newline).
153) ‚ß: Pair the implicit input-integer with the implicit input-integer, and then pop and push its minimum. After which it is output implicitly (with trailing newline).
154) AÚ: Trim leading and trailing lowercase alphabets of the implicit input-integer, after which the unmodified input is output implicitly (with trailing newline).
155) |M: Push all inputs as list. Push the largest value on the stack (including in all inner lists/matrices). After which the top of the stack is output implicitly (with trailing newline).
156) ∞@0k: Push an infinite positive list [1,2,3,...]. Check for each value if the (implicit) input is larger than or equal to this value (1 if truthy; 0 if falsey). And then get the 0-based index of the first 0 in this infinite list. After which it is output implicitly (with trailing newline).
157) µ¾Ê: Continue looping until the counter_variable (default 0) is equal to the implicit input-integer. Push the counter_variable each iteration, and check that it's NOT equal to the implicit input-integer. If this is truthy, the counter_variable will implicitly be increased by 1 after every iteration. When it becomes falsey, it means it's equal to the input-integer, and thus the loops stops, after which the counter_variable is output implicitly (with trailing newline) as result.
158) Œà: Push all substrings of the implicit input-integer, and then pop and push its maximum. After which this top of the stack is output implicitly (with trailing newline).
159) Z)Z: Get the largest digit of the implicit input-integer (without popping). Then wrap all values on the stack into a list, which is the input itself and its max digit. And then get the maximum again of this integer-pair (without popping), which will be the input itself. Then output the input at the top of the stack implicitly (with trailing newline).
Unused characters / builtins:
I'm pretty sure nothing useful is left anymore now..
Integer constants: 234567Tт₁₂₃₄₅Y®N•
Empty list constant: ¯
Empty string constant (if used twice): ”
(Partially) uniquify / sort builtins: Ù{êÔγ
Convert from binary/hexadecimal to integer (which works on any input unfortunately): CH
Checks resulting in truthy/falsey (0/1): Θ≠Qad›‹Ëå
Recursive environment (which I can't close without `}` nor `]`): λ
Infinite loop (which I can't stop without `#` nor `q`): [
(Compressed) string/integer builtins, which result in errors on their own: '„…ƵŽ
Ord (convert to codepoint integers): Ç
Convert to a list and cycle infinitely: Þ
Only leave the letters (which won't work if the input contains anything else): á
Get the second or third input (we are only allowed to take a single input): ²³
Palindrome / mirror: ûº
Cartesian product: â


Balanced and Centre-Free Sets of Points Taking in Input

Define a function f as follows:

IF x < 0:
    f(x) = -√|x|
ELSE:
    f(x) = √x

In your programs/functions, each point (x, y) given as input will correspond to the point (f(x), f(y)). For example, if the points (4, -2) and (-1, 5) are given as input, your program will be dealing with the points (2, -√2) and (-1, √5). From now on, we will be referring to points in this format, rather than points in the format given in the input.

You will take in a set/list of points as input which will then be converted to Cartesian points with the function f.

Balanced Sets of Points

Denote by PQ the Euclidean distance from point P to point Q.

A set of points S is balanced if, and only if, for all pairs of distinct points A and B in S, there exists a point C in S such that AC = BC. For example, the set of points {(0, 2), (-√3, -1), (√3, -1)} is balanced because the points in this set are the vertices of an equilateral triangle. Note that this set of points would be taken as input by the program/function as {(0, 4), (-3, -1), (3, -1)}.

Centre-Free Sets of Points

Again, denote by PQ the Euclidean distance from point P to point Q.

A set of points S is centre-free if, and only if, for all triples of distinct points A, B and C in S, there does not exist a point P in S such that AP = BP = CP. For example, the set of points {(0, 2), (-√3, -1), (√3, -1)} is centre-free, but if you add the point (0, 0) to this set, it is no longer centre-free.

Formatting the Output

The output will be in the form of a two-digit binary number. Suppose we are given the set of points S. After having applied the function f to each point (see section "Taking in Input"), the first digit of this binary number will indicate whether this set of points is balanced and the second digit of this binary number will indicate whether this set of points is centre-free. For example, 10 will indicate that the given set of points is balanced, but not centre-free.

Also note that the digits 1 and 0 may be replaced with any truthy and falsy values. As opposed to strings, arrays and ordered pairs are also acceptable.

Test Cases

> {(0, 4), (-3, -1), (3, -1)}
11

> {(0, 4), (3, 1), (3, -1), (0, -4), (-3, -1), (-3, 1)}
01

> {(0, 4), (-3, -1), (3, -1), (0, 0)}
00

> {(0, 4), (-3, -1), (3, -1), (0, -4), (0, 0)}
00

> {(0, 16), (-3, 1),(-12, -4), (0, -4), (12, -4), (3, 1)}
10

Winning Criterion

Make your code as short as possible.

Credits

This was inspired by Problem 1 from IMO 2015. (Great problem, by the way!)

Jelly, 36 bytes

ạþE€Ṁ
®Œcç€®Ạ
A½×Ṡ×1,ıSµ€©œc3ñ€®Ṁ¬¢,

A full program printing the representation of a list of two ones/zeros.

This relies on theoretical infinite-precision floating point arithmetic, which is, of course, not the case. So here is a (43 byte) version which uses a 1e-10 leeway for the pair-wise distance comparisons it makes:

ạþI€×ȷ10ỊẠ€Ṁ
®Œcç€®Ạ
A½×Ṡ×1,ıSµ€©œc3ñ€®Ṁ¬¢,

Try It Online!

How?

(I'll include the replacement code used in place of E - equals to allow the leeway here)

ạþI€×ȷ10ỊẠ€Ṁ - Link 1: any all-equal distance complex numbers?: list of lists; list
ạþ           - outer-product with absolute difference
  I€         - incremental differences for €ach
    ×ȷ10     - multiply by 10^10
        Ị    - insignificant (abs(z)<=1) (vectorises)
         Ạ€  - all? for €ach
           Ṁ - maximum

®Œcç€®Ạ - Link 2: isBalanced? no-arguments (requires register to be populated - see Main)
®       - recall from register (the points as a list of complex numbers)
 Œc     - pairs
     ®  - recall from register (the points as a list of complex numbers)
   ç€   - call the last link (1) as a dyad for €ach pair
      Ạ - all truthy?

A½×Ṡ×1,ıSµ€©œc3ñ€®Ṁ¬¢, - Main link: list of (x, y) inputs
         µ€            - for €ach (x,y) pair, p:
A                      -   absolute value of p (vectorises)
 ½                     -   square root (vectorises)
   Ṡ                   -   sign of p (vectorises)
  ×                    -   multiply (vectorises)
     1,ı               -   literal [1, 0+1i]
    ×                  -   multiply (vectorises)
        S              -   sum
           ©           - (copy the result to the register)
            œc3        - combinations of length 3
                 ®     - recall from register
               ñ€      - call the next link (1) as a dyad for €ach triple
                  Ṁ    - maximum (1 if any triple has a centre)
                   ¬   - not (0 if any triple has a centre - hence isCentreFree?)
                    ¢  - call the last link as a nilad
                     , - pair with the calculated isCentreFree?
                       - implicit print


Generating the alphabet in JavaScript I'm pretty sure there's not a better way to do this but figured it couldn't hurt to ask.

I'm tired of typing out a='abcdefghijklmnopqrstuvwxyz'.

Cool languages have Range('a'..'z') or similar

What can we come up with with JS that's as short as possible??

for(i=97,a='';i<123;){a+=String.fromCharCode(i++)}

is longer than just the alphabet - but guarantees I don't screw up somewhere.

I'm hoping there's a nasty bit-shifty way to produce a-z in less than 50 characters.

I messed around with i=97;Array(26).map(x=>String.fromChar....i++

but it was always way longer by the time I joined then split the array(26) to be useable

Edit: I've gotten it down to

[...Array(26)].reduce(a=>a+String.fromCharCode(i++),'',i=97)

60 bytes

Alternative to String.fromCharCode
... if you are happy with a lowercase only alphabet.

for(i=9,a='';++i<36;)a+=i.toString(36) // 38, cannot be used in an expression
[...Array(26)].map(_=>(++i).toString(36),i=9).join`` // 52 directly returnig the string desired
[...Array(26)].map(_=>a+=(++i).toString(36),a='',i=9) // 53 assign to a variable
(i=9,[for(_ of Array(26))(++i).toString(36)].join``) // 52 ES7 direct return
i=9,a='',[for(_ of Array(26))a+=(++i).toString(36)] // 51 ES7 assign to a variable


Print out execution time of program Challenge

Write a complete program that prints out the time it took to execute a certain part of itself. That part must include a process whose total number of operations (and therefore execution time) is dependent on a user-substituted numeric value - this can be denoted in any way in your code (uppercase N for example) and doesn't count as a byte.

Unlike many code golf challenges, this one is a valid use case - in environments that allow executing code from command line, you may want to have a short code snippet to roughly compare performance across different systems.

Rules

Execution time is denoted as a nonnegative integer or decimal value, followed by the corresponding time unit (let's accept ns, µs/us, ms, s, m and h). A space between the number and unit is optional, more spaces are also allowed (but not newline characters).
Output must include the execution time exactly once. There can be additional text around it, as long as no part of it could be matched with the execution time itself. This allows using standard functions for timing code execution that may use various formats for printing out the execution time.
Output goes to STDOUT. Anything in STDERR is disregarded.
You can import any standard libraries before the actual code, without any cost to the total number of bytes, but you are not allowed to change the library name in the import declaration.
Do not just use sleep to control the execution time, as that does not increase the number of operations (and also doesn't work as a performance benchmark). The execution time must also depend on the user-substituted value linearly, exponentially or polynomially (before you ask, a constant polynomial doesn't count).

Scoring

This is code golf, so the shortest answer in bytes wins.

Example

This is an unnecessarily long program written in Python:

import time

start_time = time.time()

for i in range(N):
    pass

end_time = time.time()

print("%fs" % (end_time - start_time))

Program description:

imports the standard time library (this adds no bytes to the code size)
stores the current time in seconds
loops N times, does nothing each iteration
stores the time after the loop
prints the time difference in the correct format

Zsh, 14(?) bytes

If N is substituted in place of $1 (as described in the prompt), then 14 bytes. If N is given as an argument, then 16 bytes.

time (: {0..$1})

Try it online!

Uses the builtin time (you can verify that this is a Zsh builtin: run type time). The time to expand the brace expansion increases with the input.

You might think to use time sleep $1, but sleep is an external program, not pure Zsh.


Stable marriage problem Background

Suppose that there are 2*n people to be married, and suppose further that each person is attracted to exactly n other people under the constraints that:

Attraction is symmetric; i.e. if person A is attracted to person B, then person B is attracted to person A.
Attraction is antitransitive; i.e. if person A and person B are each attracted to person C, then person A and person B are not attracted to each other.

Thus the network of attractions forms the (undirected) complete bipartite graph Kn,n. We also assume that each person has ranked the people they are attracted to.  These may be represented as edge weights in the graph.

A marriage is a pairing (A,B) where A and B are attracted to each other. The marriage is unstable if there is another marriage where one person from each marriage could divorce their partner and marry each other and both end up with someone they ranked higher than their former partner.

Goal

Your task is to write a complete program or function which takes each person's preferences as input and outputs a marriage for each person such that each marriage is stable.

Input

Input may be in any convenient format; e.g., weighted graph, ordered list of preferences, dictionary/assocation, etc. You may optionally take the total number of people as input, but no other input is allowed.

Output

Output can also be in any convenient format; e.g. list of tuples, minimal edge cover, a function which associates to each person their partner, etc. Note that the only constraint is that each marriage is stable, there are no other optimality requirements.

Notes

You can find more information and an O(n^2) algorithm to solve this problem on Wikipedia or this Numberphile video. You are free to use any algorithm, however.
Standard loopholes are forbidden.
This is code-golf. Shortest answer (in bytes) wins.

Mathematica, 28 bytes

On would think, this is cheating. I for myself like this:

Combinatorica`StableMarriage

Needs to be called with the weight matrices of the preferences for
men and women.
Returns the direct indizes for the coupling.

(Yes Combinatorica is deprecated but it costs fewer bytes than FindIndependentEdgeSet)

Example (GoT-like):
(To be fair - i guessed the weights...but i'm okay with the results)

m = {{2, 4, 3, 1}, {1, 2, 4, 3}, {3, 2, 1, 4}, {4, 2, 1, 3}};
w = {{2, 3, 4, 1}, {3, 2, 1, 4}, {3, 2, 4, 1}, {4, 1, 2, 3}};
result = Combinatorica`StableMarriage[w, m];
MapThread[
  UndirectedEdge[Show[#1, ImageSize -> 130],
    Show[#2, ImageSize -> 130]] &, {names1,
   names2[[result]]}] // TableForm


Which side has more? The challenge is to golf a program when given a string composed of any number of asterisks, then a comma, than any number of asterisks, say which side has more.

The asterisk-strings can be empty.

Output

0 for ties.

1 for the left.

2 for the right.

Examples

Input: ***,**** Output: 2

Input: ***, Output: 1

Input: ***,*** Output: 0

Input: , Output: 0

Scoring

This is code-golf. Shortest answer wins.

Python 2, 25 bytes

lambda s:cmp(s[::-1],s)%3

Try it online!


Local periods of strings Local periods

Take a non-empty string s.
The local period of s at index i is the smallest positive integer n such that for each 0 ≤ k < n, we have s[i+k] = s[i-n+k] whenever both sides are defined.
Alternatively, it is the minimal length of a nonempty string w such that if the concatenation w w is placed next to s so that the second copy of w begins at index i of s, then the two strings agree wherever they overlap.

As an example, let's compute the local period of s = "abaabbab" at (0-based) index 2.

Try n = 1: then s[2+0] ≠ s[2-1+0], so this choice is not correct.
Try n = 2: then s[2+0] = s[2-2+0] but s[2+1] ≠ s[2-2+1], so this is also not correct.
Try n = 3: then s[2+0-3] is not defined, s[2+1] = s[2-3+1] and s[2+2] = s[2-3+2]. Thus the local period is 3.

Here is a visualization of the local periods using the second definition, with semicolons added between the two copies of w for clarity:

index      a b a a b b a b      period
 0       a;a                     1
 1       b a;b a                 2
 2       a a b;a a b             3
 3             a;a               1
 4     b b a b a a;b b a b a a   6
 5                 b;b           1
 6               a b b;a b b     3
 7                   b a;b a     2

Note that w is not necessarily a substring of s.
This happens here in the index-4 case.

The task

Your input is a nonempty string s of lowercase ASCII characters.
It can be taken as a list of characters if desired.
Your output shall be the list containing the local period of s at each of its indices.
In the above example, the correct output would be [1,2,3,1,6,1,3,2].

The lowest byte count in each language wins.
Standard code-golf rules apply.

Test cases

a -> [1]
hi -> [1, 2]
www -> [1, 1, 1]
xcxccxc -> [1, 2, 2, 5, 1, 3, 2]
abcbacb -> [1, 4, 7, 7, 7, 3, 3]
nininini -> [1, 2, 2, 2, 2, 2, 2, 2]
abaabbab -> [1, 2, 3, 1, 6, 1, 3, 2]
woppwoppw -> [1, 4, 4, 1, 4, 4, 4, 1, 4]
qwertyuiop -> [1, 10, 10, 10, 10, 10, 10, 10, 10, 10]
deededeededede -> [1, 3, 1, 5, 2, 2, 5, 1, 12, 2, 2, 2, 2, 2]
abababcabababcababcabababcaba -> [1, 2, 2, 2, 2, 7, 7, 7, 7, 2, 2, 2, 19, 19, 5, 5, 2, 5, 5, 12, 12, 2, 2, 2, 7, 7, 5, 5, 2]

Java 8, 167 154 152 bytes

s->{int l=s.length,r[]=new int[l],i=0,n,k;for(;i<l;r[i++]=n)n:for(n=0;;){for(k=++n;k-->0;)if(i+k<l&i+k>=n&&s[i+k]!=s[i-n+k])continue n;break;}return r;}

-2 bytes thanks to @ceilingcat.
Try it online.
Explanation:
s->{                          // Method with char-array parameter and int-array return-type
  int l=s.length,             //  Length of the input-array
      r[]=new int[l],         //  Result-array of the same size
      i=0,n,k;                //  Integers `i`, `n`, and `k` as defined in the challenge
  for(;i<l;                   //  Loop `i` in the range [0, `l`):
      r[i++]=n)               //    After every iteration: Add `n` to the array
    n:for(n=0;;){             //   Inner loop `n` from 0 upwards indefinitely
      for(k=++n;k-->0;)       //    Inner loop `k` in the range [`n`, 0]:
                              //    (by first increasing `n` by 1 with `++n`)
        if(i+k<l&i+k>=n)      //     If `i+k` and `i-n+k` are both within bounds,
           &&s[i+k]!=s[i-n+k])//     and if `s[i+k]` is not equal to `s[i-n+k]`:
          continue n;         //      Continue loop `n`
                              //    If we haven't encountered the `continue n` in loop `k`:
      break;}                 //     Break loop `n`
  return r;}                  //  Return the result


Chain reaction of bombs Introduction:

Before the task, here is what every element does on the map:

Plain land (X): This does nothing.

Destroyed land (-): This is the same as plain land, but destroyed by a bomb.

The active bomb (!): On a map, this will destroy everything in a 3x3 square:

XXXXX                         XXXXX
XXXXX                         X---X
XX!XX     > will become >     X---X
XXXXX                         X---X
XXXXX                         XXXXX

The passive bomb (@): It does nothing, until it is detonated by another bomb. This also has a 3x3 square explosion radius:

XXXXX                         XXXXX
XXXXX                         XXXXX
XX@XX     > will become >     XX@XX (nothing happened)
XXXXX                         XXXXX
XXXXX                         XXXXX

But:

XXXXX                         XXXXX
XXXXX                         X---X
XX@XX     > will become >     ----X (both bombs have exploded)
X!XXX                         ----X
XXXXX                         ---XX

The nuke (~): It does nothing, until it is detonated by another bomb. The difference is that this bomb has a 5x5 square explosion radius:

XXXXX                         XXXXX
XXXXX                         XXXXX
XX~XX     > will become >     XX~XX (nothing happened)
XXXXX                         XXXXX
XXXXX                         XXXXX

But:

XXXXX                         -----
XXXXX                         -----
XX~XX     > will become >     ----- (both bombs have exploded)
X!XXX                         -----
XXXXX                         -----

The task

Given a 9x9 map, output the map after the chain reaction.
You may provide a function or a program.
This is code-golf, so the submission with the least amount of bytes wins!

Test cases

Test case 1 (3 steps):

XXXXXXXXX           XXXXXXXXX
----XXXXX           ----XXXXX
XXXX@XXXX           XXXX@XXXX
XXXXXXXX-           XXX---XX-
XXXX@XXXX     >     ------XXX
XXXXXXXX-           ------XX-
XX~XXXXXX           -----XXXX
X!XXXXXX-           -----XXX-
XXXXXXXXX           -----XXXX

Test case 2 (2 steps):

XXXXXXXXX           XXXXXXXXX
XXXXXXXXX           XXXXXXXXX
XX~XXXXXX           XX~XXXXXX
---------           ---------
XXXX!XXXX     >     XXX---XXX
XXXXXXXXX           XXX------
XXX@@X@!X           XXX@@----
XXXXXXXXX           XXXXX----
XXXXXXXXX           XXXXXXXXX

Test case 3 (2 steps):

XXXXXXXXX           XXXXXXXXX
XXXXXXXXX           XXXXXXXXX
XX~XXXXXX           XX~XXXXXX
XXXXXXXXX           XXX---XXX
XXXX!XXXX     >     XXX---XXX
XXXXXXXXX           XXX------
XXX@@X@!X           XXX@@----
XXXXXXXXX           XXXXX----
XXXXXXXXX           XXXXXXXXX

Test case 4 (1 step):

XXXXXXXXX           XXXXXXXXX
XXXX-XXXX           XXXX-XXXX
XXXXXXXXX           XXX---XXX
XX-X!X-XX           XX-----XX
XXXXXXXXX     >     XXX---XXX
XX-----XX           XX-----XX
XXXX-XXXX           XXXX-XXXX
XXXXXXXXX           XXXXXXXXX
XXXXXXXXX           XXXXXXXXX

Test case 5 (9 steps):

!XXXXXXXX           ---XXXXXX
X@XXXXXXX           ----XXXXX
XX@XXXXXX           -----XXXX
XXX@XXXXX           X-----XXX
XXXX@XXXX     >     XX-----XX
XXXXX@XXX           XXX-----X
XXXXXX@XX           XXXX-----
XXXXXXX@X           XXXXX----
XXXXXXXX@           XXXXXX---

Test case 6 (9 steps):

XX@@@XXXX           ------XXX
XXXXXXXXX           ------XXX
~XXXXXXXX           ---XXXXXX
XXXXXXXXX           ---XXXXXX
~XXXXXXXX     >     ---XXXXXX
XXXXXXXXX           ---XXXXXX
~XXXXXXXX           ---XXXXXX
@XXXXXXXX           ---XXXXXX
!XXXXXXXX           ---XXXXXX

Test case 7 (3 steps):

!XXXXXXXX           ---XXXXXX
X@XXXXXXX           ----XXXXX
XX@XXXXXX           ----XXXXX
XXXXXXXXX           X---X----
XXXXXX@@!     >     XXXXX----
XXXXXXXXX           X---X----
XX@XXXXXX           ----XXXXX
X@XXXXXXX           ----XXXXX
!XXXXXXXX           ---XXXXXX

Matlab, 120 111 bytes
function f=c(f);c=@(x,i)conv2(x+0,ones(i),'s');a=c(f<34,3);for k=f;a=c(a&f<65,3)|a;a=c(a&f>99,5)|a;end;f(a)='-'

Convolution is the key to success.

The idea is following: Find the active bomb. Enlarge this area to a 3x3 square. Find new affected bombs, enlarge the correspoding areas to the corresponding size and add those to the previously destroyed area. Repeat this enough times (in my case as many times as we have input characters, just because that is the shortest variant) to be sure that we reached a stationary point (=no more exploding bombs). Then set all the destroyed area to - and display the result.
The input is assumed to be a matrix of characters, e.g.
['!XXXXXXXX';
'X@XXXXXXX';
'XX@XXXXXX';
'XXX@XXXXX';
'XXXX@XXXX';
'XXXXX@XXX';
'XXXXXX@XX';
'XXXXXXX@X';
'XXXXXXXX@'];


Python 3, 80 bytes
Saved 1 byte thanks to Halvard Hummel and 1 byte thanks to Jonathan Allan.
import math
def f(*l):
 for k in 0,1:print(l[~k]//math.gcd(*l)*(~-l[k]*"-"+"|"))

Test it online!
lambda*l:"\n".join(l[0]*l[1]//math.gcd(*l)//k*(~-k*"-"+"|")for k in l)
import math

Test it online! (82 bytes - initial answer)
This is the best I could do in Python 2 (81 bytes). It seems like I cannot comment on that answer, I'll just post this here instead:
from fractions import*
l=a,b=input()
for k in l:print a*b/gcd(*l)/k*(~-k*"-"+"|")

Test it online!
First attempt here, probably sub-optimal!


Partitions of a list The answer to this question is much too long

Your challenge is to write a partitioning function in the smallest number of characters.

Input example

['a', 'b', 'c']

Output example

[(('a'),('b'),('c')),
 (('a', 'b'), ('c')),
 (('a', 'c'), ('b')),
 (('b', 'c'), ('a')),
 (('a', 'b', 'c'))]

The input can be a list/array/set/string etc. whatever is easiest for your function to process

You can also choose the output format to suit yourself as long as the structure is clear.

Your function should work for at least 6 items in the input

GolfScript, 51 characters
{[[]]\{[.;]`{1$[1$]+@@`1$`{[2$]-@@[+]+}++/}+%}/}:P;

The script defines a variable P which takes an array from top of the stack and pushes back a list of all partitions, e.g.
[1 2] P            # => [[[1] [2]] [[1 2]]]
["a" "b" "c"] P    # => [[["a"] ["b"] ["c"]] [["b"] ["a" "c"]] [["a"] ["b" "c"]] [["a" "b"] ["c"]] [["a" "b" "c"]]]

It does also work on larger lists:
6, P ,p            # prints 203, i.e. Bell number B6
8, P ,p            # 4140

You may perform own tests online.


Find the last three words of each paragraph if they are shorter than 20 characters in total Based on my SO question, but more specifically:

Find a RegEx such that, given a text where paragraphs end with an empty line (or $ at the very end), match the up to twenty last characters of a paragraph excluding the \r or $ but no more than three complete "words" including the "separators" in between and the punctuation following it. The following constraints apply:

"words" also include abbreviations and the like (and thus punctuation), i.e. "i.e." and "non-trivial" count as one word each
whitespaces are "separators"
isolated dashes do not count as "words" but as "separators"
"separators" before the first word must not be included
trailing punctuation counts to that limit, but not the leading one nor the linebreaks and $ that must not be in the matching group
whether trailing punctuation is included in the match or not is up to you

Some examples:

  The early bird catches the worm. Two words.

  But only if they got up - in time.

  Here we have a supercalifragilisticexpialidocious etc. sentence.

  Short words.

  Try accessing the .html now, please.

  Vielen Dank und viele Grüße.

  Did any-one try this?

Score is given in bytesteps: bytes multiplied by amount of steps according to https://regex101.com, but there are three penalties:

if the upper limit of words cannot trivially+ be modified: +10%
if the upper limit of character count cannot trivially+ be modified: +10%
failure to handle unicode used in actual words: add the percentage of world population speaking the language according to Wikipedia the failing word stems from. Example: Failing to match the German word "Grüße" as a word => +1.39%. Whether you consider a language's letters as single characters or count the bytes to utf8-encode them is up to you. The penalty does not have to be applied before someone actually provides a counter-example, so feel free to demote your competitors ;)

Since this is my first challenge, please suggest any clarifications. I assume regular-expression means there are no "loopholes" to exclude.

+ With trivially modified I mean expressions such as {0,2} and {21} are valid but repeating something three times (which would have to be re-repeated to increase the amount words) is not.

37 bytes * 1403 steps = 51911 bytesteps
34 bytes * 1036 steps = 35224 bytesteps
37 bytes * 666 steps = 24642 bytesteps
(?<!\S)(?!.{21})\S+(( | - )\S+){0,2}$

Verify it here!


A regex to match three consecutive integers iff the third integer is the sum of the first two Write a regular expression which matches a given string consisting of three non-negative, space-separated integers if and only if the last integer is the sum of the previous two. Answers may be for integers of any numeral system with radix between 2 and 10.

Test cases

These should fail:

0 1 2
10 20 1000

These should match:

10 20 30
28657 46368 75025
0 0 0

Rules

Your answer should consist of a single regex, without any additional code (except, optionally, a list of regex modifiers required to make your solution work). You must not use features of your language's regex flavour that allow you to invoke code in the hosting language (e.g. Perl's e modifier).

Please specify your regex flavour in your answer.

This is regex golf, so the shortest regex in bytes wins. If your language requires delimiters (usually /.../) to denote regular expressions, don't count the delimiters themselves. If your solution requires modifiers, add one byte per modifier.

Credits to Martin Ender and jaytea for the regex-golfing rules.

I have reason to believe it's possible based on the solution of Martin Ender for finding and incrementing integers with regex.


Swapping heightmaps to depthmaps Description

Your task is to output a 'depthmap' - that is, a heightmap of an object but not seen from its top but from its front.

For example, consider the following object as shown on the image. The height map is shown on the left. The corresponding depth map would be (as seen from standing at the arrow):

010
211   <- Depthmap
322

If you stand at the arrow, there are 3 cubes behind each other at the bottom left-hand point, 2 behind each other on the middle left-hand point, 0 at the top left-hand point etc.

Input

Input is a two dimensional array of any sizes (not necessarily square).

Output

Output is another two dimensional array which represents the depthmap. As you can deduce, its sizes are (height x width). In the image, it would be (3 x 3). Note that if the highest tower of cubes was 5, the depthmap would be an array of (5 x 3).

Winning condition

The shortest code wins.

Disallowed

All languages allowed, no explicit restrictions. (I don't know what you can come up with, but play fair please.)

Examples

Input:     Ouput:

5321       0001
1456       1012
2105       1112
           1212
           2222
           3323

Input:     Output:

22         01
13         12
00         22

Input:     Output:    (of the sample image)

232        010
210        211
101        322


Find the submatrix with the smallest mean, 2.0 You're given a n-by-m matrix of integers, where n,m > 3. Your task is to find the 3-by-3 sub-matrix that has the lowest mean, and output this value.

Rules and clarifications:

The integers will be non-negative
Optional input and output format
The output must be accurate up to at least 2 decimal poins (if it's non-integer)
The submatrices can be made up of arbitrary columns and rows

Test cases:

1   0   4   0   1   0
1   0   4   0   1   0
4   3   4   3   4   3
1   0   4   0   1   0

Minimum mean: 0   (We have chosen columns 2,4,6 and rows 1,2,4 (1-indexed)
-----------------------------
4    8    9    7
5   10    1    5
8    5    2    4
8    3    5   10
6    6    3    4

Minimum mean: 4.2222
-----------------------------
1   0   0   0   0
0   2   0   0   0
0   0   3   0   0
0   0   0   4   0
0   0   0   0   5

Minimum mean: 0.11111
-----------------------------
371   565   361   625   879   504   113   104
943   544   157   799   726   832   228   405
743   114   171   506   943   181   823   454
503   410   333   735   554   227   423   662
629   439   191   707    52   751   506   924

Minimum mean: 309.56

Mathematica, 77 50 bytes

±x_:=x~Subsets~{3}
Min[Mean/@Mean/@±#&/@±#]&

 is Mathematica's transposition operator (and is rendered as a superscript T in Mathematica).

This answer first defines a helper operator ± which returns all 3-element subsets of a list, and then evaluates to an unnamed function which uses this operator to solve the problem.

This is done by first computing all 3-element subsets of the matrix's rows. Then for each such subset, we transpose it and compute its 3-element subset of rows. This gives us all possible 3x3 submatrices (although they are transposed). We then compute the mean on all of them and find the overall minimum.


Electron Configuration Diagrams Challenge

Given an element name, output its electron configuration.

Input

Your input will be the full name of each element (the range being from Hydrogen, 1, to Calcium, 20) with some exceptions - you should be able to account for the following inputs:

Natrium - This is sodium
Kalium - This is potassium

Note that inputs "sodium" and "potassium" must still be valid.

The first letter will always be capitalised.

Output

You can refer to this webpage for guidance on how to generate an electron configuration diagram.

The following list shows the maximum number of electrons in each shell:

1st shell - 2 electrons
2nd shell - 8 electrons
3rd shell - 8 electrons
4th shell - 14 electrons (although the maximum number of electrons in this shell required is 2)

An example output of the electron configuration is the following:

In the centre of the diagram must be the element's one to two letter symbol.

Either dots or crosses may be used and where they are placed does not matter.

The output does not have to be exactly like this but it does have to be an ASCII graphic. The one thing it cannot be is in the form 2.8.8.1 or any other form like this.

The circles are not necessary

Built in functions which access the periodic table of elements or produce diagrams or electron configurations are hereby disallowed.

Winning

The shortest program in bytes wins.

Python 3, 529 bytes
thanks Thomas and Beta for pointing out some things that should've been obvious to me, saving me some bytes
massive improvement: using string slicing instead of dict lookup
s="""    {18}
    {10}{14}
    {2}{6}
    {0}{1}
 {17}{9} %s {3}{11}
 {13}{5}    {7}{15}

    {8}{4}
    {16}{12}
    {19}"""
e="H HeLiBe B C N O F NeNaMgAlSiP S ClArK Ca"
r="hydrogen   helium     lithium    beryllium  boron      carbon     nitrogen   oxygen     fluorine   neon       natrium    sodium     magnesium  aluminium  silicon    phosphoroussulfur     chlorine   argon      kalium     potassium  calcium    "
n=r.find(input().lower())//11
n-=(n>10)+(n>18)
print(s.format(*[' *'[i<=n]for i in range(20)])%e[n*2+1:n*2+3])

Not the prettiest of programs or outputs, but hey, we needed something to kick this challenge off. Try it online.


Length of a Sumac sequence A Sumac sequence starts with two integers: t1 and t2.

The next term, t3, = t1 - t2

More generally, tn = tn-2 - tn-1

The sequence ends when tn < 0.

Your challenge: Write a program or function that prints the length of a Sumac sequence, starting with t1 and t2.

t1 and t2 are integers within your language's range.
Standard loopholes apply.

Test cases

t1  t2       sumac_len(t1,t2)

120  71      5
101  42      3
500  499     4
387  1       3

Bonus street cred:

3    -128    1
-314 73      2

This is code-golf, so shortest answer in bytes wins.

Husk, 8 bytes

→V<¡oG-↔

Takes input as a 2-element list.
Try it online!

Explanation

→V<¡oG-↔  Implicit input, say p=[101,42]
   ¡      Iterate on p:
       ↔    Reverse: [42,101]
    oG-     Cumulative reduce by subtraction: [42,59]
          Result is infinite list [[101,42],[42,59],[59,-17],[-17,76],[76,-93]...
 V<       Find the first index where adjacent pairs are lexicographically increasing.
          In our example [42,59] < [59,-17], so this gives 2.
→         Increment: 3


String truncation/summarization Not entirely sure if this one or a similar challenge has already been posted, but here it goes anyway.

Write a program that takes a string as input and writes its trucated/summarized output form such that a specific sep (separator) is placed in the middle, removing the necessary characters of the original string so that the length of output equals a given width.

Rules

Input is a string, a width and a sep (separator);
if len(string) <= width: output = string, meaning that the output is the string itself unchanged;
if width <= len(sep): output = sep, meaning that the output is the separator only;
len(output) must be equal to width, with the exception of the previous case;
The excess character in case of uneven number of remaining characters for each half of the string can be placed on the left or right halve;
Standard code-golf challenge with the smallest program to win.

Examples

Format: "string" [length(string)] --> "output" [length(ouput) / width] with sep equal to _(...)_ (_ are whitespaces).

"xtlgxbdwytxcjacu" [16] --> "x (...) " [8 / 8]
"upjptz" [6] --> " (...) " [7 / 3]
"h" [1] --> "h" [1 / 1]
"qsshkvmawcmf" [12] --> " (...) " [7 / 7]
"tvdknroxszhufgck" [16] --> "tv (...) k" [10 / 10]
"ag" [2] --> "ag" [2 / 5]
"vbgdegtgshnzjrudca" [18] --> "vbgd (...) udca" [15 / 15]
"bscwimjjhmgvcwp" [15] --> "bscwimjjhmgvcwp" [15 / 18]
"xwhgbaenornbzwirlp" [18] --> "xwhgbaenornbzwirlp" [18 / 18]
"tbqyrekkzyizc" [13] --> "t (...) " [8 / 8]
"oowdwbeezeh" [11] --> "o (...) h" [9 / 9]
"avlzfzpjazhjc" [13] --> "avlzfzpjazhjc" [13 / 15]
"dngxmebwenfrbidonses" [20] --> "dngxme (...) donses" [19 / 19]
"bqfxyffdemjghipk" [16] --> "bqfxyffdemjghipk" [16 / 16]
"sfwnlkreghzff" [13] --> " (...) " [7 / 5]
"dznlsyaojtferxh" [15] --> "dznlsyaojtferxh" [15 / 17]
"zwkhjdafkzjdgc" [14] --> "zwk (...) dgc" [13 / 13]
"kpzochngmwoulne" [15] --> "kpz (...) lne" [13 / 13]
"vluqvhpcxg" [10] --> "vluqvhpcxg" [10 / 10]
"wuc" [3] --> "wuc" [3 / 8]

Python 2, 93 76 72 bytes

s,w,p=input()
l=len(s)
if w<l:w=max(w-len(p),0);s[-~w/2:l-w/2]=p
print s

Try it online!

Input and output are a list of characters


A bank for less Trustworthy Friends Introduction

You have gotten a job as the minister of finance in your made-up country in your back yard. You have decided to make your own bank in your country for you and your less trustworthy friends. Since you don't trust your friends, you have decided to write a program to validate all transactions to stop your friends from overspending your made-up currency and ruining your economy.

Task

Given the starting balance and all transactions, filter out all transactions where someone tries to overspend and block anyone who tries to overspend (this includes trying to overspend to a closed account) from ever using your bank again by filtering out future transactions to or from his/her bank account.

Input/Output

Two lists A and B as input and a list C as output. A is the starting balance of each account with the format [["Alice", 5], ["Bob", 8], ["Charlie", 2], ...]. B is a list of transactions with the format [["Bob", "Alice", 3], ["Charlie", "Bob", 5], ...] where ["Bob", "Alice", 3] means that Bob wants to pay Alice 3 currency units. C should have the same format as B. A, B and C may be in any reasonable format.

Test Cases

A: [["Alice", 5], ["Bob", 2]]
B: [["Alice", "Bob", 5], ["Bob", "Alice" 7]]
C: [["Alice", "Bob", 5], ["Bob", "Alice" 7]]

A: [["A", 2], ["B", 3], ["C", 5]]
B: [["C", "A", 2], ["B", "C", 4], ["A", "B", 2]]
C: [["C", "A", 2]]

A: [["A", 2], ["B", 3]]
B: [["A", "B", 2], ["A", "B", 2]]
C: [["A", "B", 2]]

A: [["A", 4], ["B", 0]]
B: [["A", "B", 1], ["A", "B", 5], ["A", "B", 2]]
C: [["A", "B", 1]]

A: [["A", 2], ["B", 3], ["C", 4]]
B: [["A", "B", 3], ["C", "B", 4]]
C: [["C", "B", 4]]

A: [["A", 2], ["B", 3], ["C", 4]]
B: [["A", "B", 3], ["B", "A", 4], ["C", "B" 2]]
C: []

Scoring

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

JavaScript (ES6), 91 88 79 bytes

Saved 8 bytes thanks to @NahuelFouilleul

Takes input in currying syntax (a)(b).

a=>b=>b.filter(([x,y,z])=>(a[x]+=z)<0&a[y]<0?a[y]-=z:0,a.map(([x,y])=>a[x]=~y))

Test cases

let f =

a=>b=>b.filter(([x,y,z])=>(a[x]+=z)<0&a[y]<0?a[y]-=z:0,a.map(([x,y])=>a[x]=~y))

console.log(JSON.stringify(f(
  [["Alice", 5], ["Bob", 2]]
)(
  [["Alice", "Bob", 5], ["Bob", "Alice", 7]]
)))

console.log(JSON.stringify(f(
  [["A", 2], ["B", 3], ["C", 5]]
)(
  [["C", "A", 2], ["B", "C", 4], ["A", "B", 2]]
)))

console.log(JSON.stringify(f(
  [["A", 2], ["B", 3]]
)(
  [["A", "B", 2], ["A", "B", 2]]
)))

console.log(JSON.stringify(f(
  [["A", 4], ["B", 0]]
)(
  [["A", "B", 1], ["A", "B", 5], ["A", "B", 2]]
)))

console.log(JSON.stringify(f(
  [["A", 2], ["B", 3], ["C", 4]]
)(
  [["A", "B", 3], ["C", "B", 4]]
)))

Beautified and commented

a => b =>                 // given the two lists a and b
  b.filter(([x, y, z]) => // for each (x = payer, y = payee, z = amount) in b:
    (a[x] += z) < 0 &     //   update the payer's account; if it's still valid
    a[y] < 0 ?            //   and the payee's account is also valid:
      a[y] -= z           //     update the payee's account
    :                     //   else:
      0,                  //     do nothing
    a.map(([x, y]) =>     //   initialization: for each (x = owner, y = amount) in a:
      a[x] = ~y           //     set up this account (>= 0: closed, -1: $0, -2: $1, etc.)
    )                     //   end of map()
  )                       // end of filter()


Counting Goats to Sleep Some people count sheep to get to sleep. Others count goats.
Write a program or function that takes in a positive integer N and outputs N-1 awake goats followed by one sleeping goat, as if someone was counting N goats and at the very last one they fell asleep.
Awake goats look like this:
      \
  ___/o>
-(___)"
 '' ''

Sleeping goats look like this:
      \
  ___/->
,(___)"
 `` ``

They are chained together with a single space between beard and tail of adjacent goats:
      \       \       \
  ___/o>  ___/o>  ___/->
-(___)" -(___)" ,(___)"
 '' ''   '' ''   `` ``

The output is allowed to have trailing spaces and a single trailing newline.
The shortest code in bytes wins.
Examples
N = 1:
      \
  ___/->
,(___)"
 `` ``

N = 2:
      \       \
  ___/o>  ___/->
-(___)" ,(___)"
 '' ''   `` ``

N = 3:
      \       \       \
  ___/o>  ___/o>  ___/->
-(___)" -(___)" ,(___)"
 '' ''   '' ''   `` ``

N = 4:
      \       \       \       \
  ___/o>  ___/o>  ___/o>  ___/->
-(___)" -(___)" -(___)" ,(___)"
 '' ''   '' ''   '' ''   `` ``

Larger N should work just as well.

MATL, 56 53 bytes
:"'!!((!((!!#*```).?p0```!!!]'8eP!P]'p(.' '.a-'XE&hqc

Try it online!
Explanation
Awake goat
The awake goat can be packed into the string
  '' ''  ")___(->o/___   \

and unpacked as will be explained shortly. However, the single-quote symbols would need to be duplicated in order to escape them, so the string literal would have to be defined as (note the enclosing single-quote symbols and the duplication of the original ones):
'  '''' ''''  ")___(->o/___   \'

To save bytes, we define the string using characters one code point above that, thus avoiding duplication. The string literal becomes
'!!((!((!!#*```).?p0```!!!]'

At the end of the code we will subtract 1 and convert to char. (We could do it now, right after the string literal; but leaving it for the end will save another single-quote duplication, as we will see).
To explain how the string is unpacked, we will work with the original characters (that are produced at the end of the code by subtacting 1), so the explanation is easier to follow. We first reshape the string
  '' ''  ")___(->o/___   \

into an 8-row 2D char array, in column-major order (down, then across). This automatically pads the last column with char 0 (at the end of the code, subtracting 1 will transform it into number −1, which converted to char gives again char 0). Char 0 is displayed as a space. So effectively we are padding with spaces. The result of reshaping is
  >
 "o\
')/
'__
 __
'__
'(
 -

We now flip vertically:
 -
'(
'__
 __
'__
')/
 "o\
  >

and then transpose and flip vertically again to produce the awake goat:
      \
  ___/o>
-(___)"
 '' ''

The two flip operations are needed because the original packed string is "in reverse". This is to exploit the fact that the actual 2D char array representing the goat has 6 initial spaces in its first row, which get automatically filled by padding when the string is reshaped into an 8-row 2D array. But the padding is done at the end (not beginning) of the last column (not row), hence the flips and transpose.
Sleeping goat
A sleeping goat is generated from an awake goat by transliterating chars o, ', - into -, `, , respectively. Actually, because of the one-code-point-above transformation, we transliterate chars p, (, ' into ., a, -, which again saves us from having to duplicate the single-quote symbol. This is why the subtract-one operation was left for the end of the program.
Code structure

Generate an awake goat N times, working with code points increased by 1.
Transform the last goat into a sleeping goat.
Concatenate all goats horizontally. Subtract 1 to code points and cast to char.

Commented code
:                              % (Step 1) Implicitly input N. Push range [1 2 ... N]
"                              % For each (i.e. repeat N times)
  '!!((!((!!#*```).?p0```!!!]' %   Push this string. Quotes are escaped by duplicating
  8e                           %   Reshape into an 8-row 2D array of char, in
                               %   column-major order, padding last column with
                               %   char 0
  P                            %   Flip vertically
  !P                           %   Transpose and flip vertically
]                              % End
'p(.'                          % (Step 2) Push this string: source for transliteration
'.a-'                          % Push this string: target for transliteration
XE                             % Transliterate. Transforms last goat into sleeping
&h                             % (Step 3) Horizontally concat all 2D char arrays
qc                             % Subtract 1 and convert to char. 0 becomes −1, which
                               % is converted to char 0, which is displayed as a space
                               % Implicitly display


What key did I press? The task is to write code to identify which key is pressed on the keyboard. You can assume that only one key is pressed at a time and that there is a standard US keyboard layout. That is the layout with the @ over the 2.

Your code should output a unique identifier for any key pressed. This includes PrtScn, Scroll Lock, Pause, left Shift, right Shift, left Ctrl, right Ctrl, Caps Lock, Tab, Enter, Enter on the number pad, Num Lock, Insert, Ins on the number pad, Backspace, Del, F1...F12, Esc, left Windows key, right Windows key, Alt, AltGr, application key (context menu) and so on.

Your code should carry on  waiting for key presses and outputting their identity until it is killed.  It should output the identifier as soon as a key is released however. It shouldn't carry out any other action from the key presses it receives and it shouldn't output anything apart from the unique identifier.

In your answer, please show what you code outputs for the following key presses: Tab, Pause, Enter, Enter on the number pad, left Windows key, right Windows key, Insert and Ins on the number pad.

If you have a very different keyboard, the challenge is still to output a different identifier for every single key on your keyboard.

x86 machine code, DOS executable, 29* 28 bytes

FAE464D0E873FAE460D0E073F4D41005212192B402CD2188F2CD21EBE3

This is a COM executable for MS-DOS, it requires a IBM PC compatible hardware.
Particularly an 8042 PS/2 controller or more likely an emulation of it through SMM.
Long story short, it should work out of the box in any mainstream PC.

The source code is

BITS 16

 ;Disable the interrupts so we don't compete with the IRQ 1 (the 8042 main
 ;device IRQ) handler (the ISR n. 9 by default) for the reading of the codes.
 cli

_wait:

 ;Is 'Output buffer full (OBF)' bit set?

 in al, 64h                ;Read the 8042 status register
 shr al, 1                 ;Move bit 0 (OBF) into the carry flag

jnc _wait                  ;Keep spinning if CF = OBF not set

 ;Read the scan code S
 in al, 60h

 ;Is S a break code?

 shl al, 1                 ;Bit 7 is set if it is
jnc _wait

 ;PART 2

 ;AL = S mod 10h := y, AH = S / 10h := x
 aam 16
 add ax, 2121h             ;Make both quantities in the printable ASCII range (skip space though)

 ;Print y
 xchg dx, ax
 mov ah, 02h
 int 21h                   ;int 21/ah=02 prints the char in DL

 ;DH is still valid here, it holds x. We print it now
 mov dl, dh
 int 21h

 ;Never terminate
jmp _wait

I've divided the program into two parts.

The first part deals with the reading of the scancodes. Scancodes are numeric values associated with every key.
Note that these are hardware code, they don't depend on the OS or the charset. They are like an encoded pair (column, row) of the key.
Every key has a scancode, even those non-standard weird function keys found on some keyboard (e.g. the "open calc" key).
Some key has multi-byte scancode, they have prefixes designed to make the stream decodificable by just looking at the sequence of bytes.
So each key gets its unique identifier, even CTRL, SHIFT, WinKeys and so on.

Only the "break codes", sent when a key is released, are processed, the "make codes" are ignored.
The formers have the higher bit (bit 7 for a byte) set, so it's easy to recognise them.

The second part deals with the printing of a byte.
Printing is always lengthy in assembly, we have no builtins.
To keep it short, and since it was required to write an identifier of the key, I abandoned decimal or hex numerals in favour of a personal encoding.

A byte xy, where x is the higher nibble and y the lower is printed as two successive chars c0 and c1 defined as:

c0 = 0x21 + y
c1 = 0x21 + x

Note that the lower nibble is printed first (this spared me a swap).
The rationale is to map the each one of the 16 possible values of a nibble into consecutive ASCII characters from '!'.
Simply put this is a hex numeral but with

The nibbles swapped
!"#$%&'()*+,-./01 as digit(als) instead of 0123456789abcdef

Running it in DOSBox and pressing some random key (some of which is a special key but note that as a Windows process DOSBox can't capture all the keys) yields

Note that this program never terminates (further, it takes complete control of the PC by disabling the interrupts) as I believe was intended by the question (simply there is no killing of processes in DOS).

* Reduced thank to CodyGray.