答:
Turing Machine Code, 1544 bytes

Try it online!

```<code>0 + _ r s
0 - _ r s
0 0 _ r u
0 1 _ r u
0 2 _ r u
0 3 _ r u
0 4 _ r u
0 5 _ r u
0 6 _ r u
0 7 _ r u
0 8 _ r u
0 9 _ r u
0 a _ r l
0 b _ r l
0 c _ r l
0 d _ r l
0 e _ r l
0 f _ r l
0 g _ r l
0 h _ r l
0 i _ r l
0 j _ r l
0 k _ r l
0 l _ r l
0 m _ r l
0 n _ r l
0 o _ r l
0 p _ r l
0 q _ r l
0 r _ r l
0 s _ r l
0 t _ r l
0 u _ r l
0 v _ r l
0 w _ r l
0 x _ r l
0 y _ r l
0 z _ r l
0 A _ r l
0 B _ r l
0 C _ r l
0 D _ r l
0 E _ r l
0 F _ r l
0 G _ r l
0 H _ r l
0 I _ r l
0 J _ r l
0 K _ r l
0 L _ r l
0 M _ r l
0 N _ r l
0 O _ r l
0 P _ r l
0 Q _ r l
0 R _ r l
0 S _ r l
0 T _ r l
0 U _ r l
0 V _ r l
0 W _ r l
0 X _ r l
0 Y _ r l
0 Z _ r l
0 * _ r y
s 0 _ r s
s 1 _ r s
s 2 _ r s
s 3 _ r s
s 4 _ r s
s 5 _ r s
s 6 _ r s
s 7 _ r s
s 8 _ r s
s 9 _ r s
s . _ r d
s _ _ r i
s * _ r T
u 0 _ r u
u 1 _ r u
u 2 _ r u
u 3 _ r u
u 4 _ r u
u 5 _ r u
u 6 _ r u
u 7 _ r u
u 8 _ r u
u 9 _ r u
u . _ r D
u _ _ r I
u * _ r T
l _ _ r L
l * _ r T
y _ _ r S
y * _ r T
d 0 _ r d
d 1 _ r d
d 2 _ r d
d 3 _ r d
d 4 _ r d
d 5 _ r d
d 6 _ r d
d 7 _ r d
d 8 _ r d
d 9 _ r d
d _ _ r e
d * _ r T
i 0 _ r i
i 1 _ r i
i 2 _ r i
i 3 _ r i
i 4 _ r i
i 5 _ r i
i 6 _ r i
i 7 _ r i
i 8 _ r i
i 9 _ r i
i _ _ r j
i * _ r T
D 0 _ r D
D 1 _ r D
D 2 _ r D
D 3 _ r D
D 4 _ r D
D 5 _ r D
D 6 _ r D
D 7 _ r D
D 8 _ r D
D 9 _ r D
D _ _ r E
D * _ r T
I 0 _ r I
I 1 _ r I
I 2 _ r I
I 3 _ r I
I 4 _ r I
I 5 _ r I
I 6 _ r I
I 7 _ r I
I 8 _ r I
I 9 _ r I
I _ _ r J
I * _ r T
L * L r M
M * E r halt
S * S r Y
Y * Y r halt
e * S r f
f * D r halt
j * S r k
k * I r halt
E * U r f
J * U r k
T _ S r U
T * _ r T
U * T r halt
</code>```

Title: Determine the type of an input

Body:
Turing Machine Code, 1544 bytes

Try it online!

0 + _ r s
0 - _ r s
0 0 _ r u
0 1 _ r u
0 2 _ r u
0 3 _ r u
0 4 _ r u
0 5 _ r u
0 6 _ r u
0 7 _ r u
0 8 _ r u
0 9 _ r u
0 a _ r l
0 b _ r l
0 c _ r l
0 d _ r l
0 e _ r l
0 f _ r l
0 g _ r l
0 h _ r l
0 i _ r l
0 j _ r l
0 k _ r l
0 l _ r l
0 m _ r l
0 n _ r l
0 o _ r l
0 p _ r l
0 q _ r l
0 r _ r l
0 s _ r l
0 t _ r l
0 u _ r l
0 v _ r l
0 w _ r l
0 x _ r l
0 y _ r l
0 z _ r l
0 A _ r l
0 B _ r l
0 C _ r l
0 D _ r l
0 E _ r l
0 F _ r l
0 G _ r l
0 H _ r l
0 I _ r l
0 J _ r l
0 K _ r l
0 L _ r l
0 M _ r l
0 N _ r l
0 O _ r l
0 P _ r l
0 Q _ r l
0 R _ r l
0 S _ r l
0 T _ r l
0 U _ r l
0 V _ r l
0 W _ r l
0 X _ r l
0 Y _ r l
0 Z _ r l
0 * _ r y
s 0 _ r s
s 1 _ r s
s 2 _ r s
s 3 _ r s
s 4 _ r s
s 5 _ r s
s 6 _ r s
s 7 _ r s
s 8 _ r s
s 9 _ r s
s . _ r d
s _ _ r i
s * _ r T
u 0 _ r u
u 1 _ r u
u 2 _ r u
u 3 _ r u
u 4 _ r u
u 5 _ r u
u 6 _ r u
u 7 _ r u
u 8 _ r u
u 9 _ r u
u . _ r D
u _ _ r I
u * _ r T
l _ _ r L
l * _ r T
y _ _ r S
y * _ r T
d 0 _ r d
d 1 _ r d
d 2 _ r d
d 3 _ r d
d 4 _ r d
d 5 _ r d
d 6 _ r d
d 7 _ r d
d 8 _ r d
d 9 _ r d
d _ _ r e
d * _ r T
i 0 _ r i
i 1 _ r i
i 2 _ r i
i 3 _ r i
i 4 _ r i
i 5 _ r i
i 6 _ r i
i 7 _ r i
i 8 _ r i
i 9 _ r i
i _ _ r j
i * _ r T
D 0 _ r D
D 1 _ r D
D 2 _ r D
D 3 _ r D
D 4 _ r D
D 5 _ r D
D 6 _ r D
D 7 _ r D
D 8 _ r D
D 9 _ r D
D _ _ r E
D * _ r T
I 0 _ r I
I 1 _ r I
I 2 _ r I
I 3 _ r I
I 4 _ r I
I 5 _ r I
I 6 _ r I
I 7 _ r I
I 8 _ r I
I 9 _ r I
I _ _ r J
I * _ r T
L * L r M
M * E r halt
S * S r Y
Y * Y r halt
e * S r f
f * D r halt
j * S r k
k * I r halt
E * U r f
J * U r k
T _ S r U
T * _ r T
U * T r halt


问:
Showcase of Languages

Notes

This thread is open and unlocked only because the community decided to make an exception. Please do not use this question as evidence that you can ask similar questions here. Please do not create additional showcase questions.

This is no longer a popularity-contest, nor are snippet lengths limited by the vote tally. If you know this thread from before, please make sure you familiarize yourself with the changes.

This thread is dedicated to showing off interesting, useful, obscure, and/or unique features your favorite programming languages have to offer. This is neither a challenge nor a competition, but a collaboration effort to showcase as many programming languages as possible as well as possible.

How this works

All answers should include the name of the programming language at the top of the post, prefixed by a #.

Answers may contain one (and only one) factoid, i.e., a couple of sentences without code that describe the language.

Aside from the factoid, answers should consist of snippets of code, which can (but don't have to be) programs or functions.

The snippets do not need to be related. In fact, snippets that are too related may be redundant.

Since this is not a contest, all programming languages are welcome, whenever they were created.

Answers that contain more than a handful of code snippets should use a Stack Snippet to collapse everything except the factoid and one of the snippets.

Whenever possible, there should be only one answer per programming language. This is a community wiki, so feel free to add snippets to any answer, even if you haven't created it yourself. There is a Stack Snippet for compressing posts, which should mitigate the effect of the 30,000 character limit.

Answers that predate these guidelines should be edited. Please help updating them as needed.

Current answers, sorted alphabetically by language name

$.ajax({type:"GET",url:"https://api.stackexchange.com/2.2/questions/44680/answers?site=codegolf&filter=withbody",success:function(data){for(var i=0;i<data.items.length;i++){var temp=document.createElement('p');temp.innerHTML = data.items[i].body.split("\n")[0];$('#list').append('
' + temp.innerText || temp.textContent + '');}}})```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><base href="http://codegolf.stackexchange.com"><ul id="list"></ul></code>```

答:
IPOS

Factoid

IPOS is a stack-based golfing-language for string processing. An IPOS program places it's input on the stack at the start and prints the concatenated stack contents at the end. This has the nice side-effect that a zero byte IPOS program is equivalent to a basic cat-program.

Length 1

```<code>L
</code>```

IPOS has a set of predefined variables. This program pushes the value of the variable L to the stack which is the alphabet in lowercase letters. Remember that any input string gets placed on the stack initially. So this program appends the lowercase alphabet to the input and prints it.

Length 2

```<code>SA
</code>```

This program takes a string with space-separated words and sorts them in ascening order. For example the input Programming Puzzles & Code Golf yields the result & Code Golf Programming.

How this works

The input string is already placed at the stack. We push a space (variable S) to the stack and apply the command A which splits the input on spaces, sorts the resulting substrings in ascending order and joins the result back on spaces.

Length 3

```<code>'A=
</code>```

As mentioned in the first program, IPOS has a set of predefined variables. If you want to define a custom variable, you can do that with the = command. It creates a new variable with the name given in the top stack item and assigns the value given by the stack item below that.

Variable names can only be one character long. Also they overwrite the original meaning of this character which means that we can no longer use A for sorting as we did in the program with length 2.

So this program simply takes the input and saves it in a variable named A. Since you usually need this value right away, = also leaves the assigned value on the stack, so the output of this program is identical to the input.

Length 4

```<code>P!r%
</code>```

This program takes an input string and reverses each substring between dots. So the input abc.def.ghij yields jihg.fed.cba.

Straight to the code breakdown this time:

```
P!r%

P      # Push a dot '.', one of the predefined variables.
 !r    # Push a command that reverses a string
   %   # Split the input on dots, apply the reverse command to every substring
       # and join the resulting substring back on dots.
```

This shows one of the commands for functional programming. Those make use of command objects that are basically strings which get treated as IPOS code. They can be created like normal strings, but instead of quotes, we use backticks for them. To create a command object with only one command we can just put a ! before it.

Length 5

```<code>S'+Re
</code>```

This program takes a string of space seperated numbers and outputs their sum. Pretty simple task, but the way it does that is quite interesting.

IPOS does not have any builtins for math operations besides simple incrementing and decrementing. It is still a language for string processing, so I didn't see a reason to include those. However, we can make use of the eval command e to do some basic math. This command takes a string and performs the numeric calculations in it using Python syntax.

You might already suspect where this is going. The above program simply replaces spaces with pluses by pushing a space and a plus character and applying the replace command R to them and the input. The resulting string then gets evaluated by e which yields the expected result.

Length 6

```<code>S`2<`%
</code>```

This program takes a string of space separated words and removes all but the first two characters from them.

We are using % again here which splits the input on a given character (here space), applies a set of commands to each part and joins the parts back. As mentioned above, command objects can be created just like a string, but are enclosed in backticks. The command we are applying to each part here is 2< which takes the first two characters of a string and discards the rest.

Length 7

```<code>SC/eCPj
</code>```

This program takes a string followed by a space and a number, splits the string into that many pieces and joins the result back on dots.

```
SC       # Split input on spaces
  /      # Swap the two top stack items so the number is on top
   e     # Convert the number into an integer
    C    # Split the string into pieces and pushe the substrings to the stack
     Pj  # Join the whole stack on dots
```

ContentLicense: CC BY-SA 3.0

Title: Showcase of Languages

Body:
IPOS

Factoid

IPOS is a stack-based golfing-language for string processing. An IPOS program places it's input on the stack at the start and prints the concatenated stack contents at the end. This has the nice side-effect that a zero byte IPOS program is equivalent to a basic cat-program.

Length 1

L

IPOS has a set of predefined variables. This program pushes the value of the variable L to the stack which is the alphabet in lowercase letters. Remember that any input string gets placed on the stack initially. So this program appends the lowercase alphabet to the input and prints it.

Length 2

SA

This program takes a string with space-separated words and sorts them in ascening order. For example the input Programming Puzzles & Code Golf yields the result & Code Golf Programming.

How this works

The input string is already placed at the stack. We push a space (variable S) to the stack and apply the command A which splits the input on spaces, sorts the resulting substrings in ascending order and joins the result back on spaces.

Length 3

'A=

As mentioned in the first program, IPOS has a set of predefined variables. If you want to define a custom variable, you can do that with the = command. It creates a new variable with the name given in the top stack item and assigns the value given by the stack item below that.

Variable names can only be one character long. Also they overwrite the original meaning of this character which means that we can no longer use A for sorting as we did in the program with length 2.

So this program simply takes the input and saves it in a variable named A. Since you usually need this value right away, = also leaves the assigned value on the stack, so the output of this program is identical to the input.

Length 4

P!r%

This program takes an input string and reverses each substring between dots. So the input abc.def.ghij yields jihg.fed.cba.

Straight to the code breakdown this time:

P!r%

P      # Push a dot '.', one of the predefined variables.
 !r    # Push a command that reverses a string
   %   # Split the input on dots, apply the reverse command to every substring
       # and join the resulting substring back on dots.

This shows one of the commands for functional programming. Those make use of command objects that are basically strings which get treated as IPOS code. They can be created like normal strings, but instead of quotes, we use backticks for them. To create a command object with only one command we can just put a ! before it.

Length 5

S'+Re

This program takes a string of space seperated numbers and outputs their sum. Pretty simple task, but the way it does that is quite interesting.

IPOS does not have any builtins for math operations besides simple incrementing and decrementing. It is still a language for string processing, so I didn't see a reason to include those. However, we can make use of the eval command e to do some basic math. This command takes a string and performs the numeric calculations in it using Python syntax.

You might already suspect where this is going. The above program simply replaces spaces with pluses by pushing a space and a plus character and applying the replace command R to them and the input. The resulting string then gets evaluated by e which yields the expected result.

Length 6

S`2<`%

This program takes a string of space separated words and removes all but the first two characters from them.

We are using % again here which splits the input on a given character (here space), applies a set of commands to each part and joins the parts back. As mentioned above, command objects can be created just like a string, but are enclosed in backticks. The command we are applying to each part here is 2< which takes the first two characters of a string and discards the rest.

Length 7

SC/eCPj

This program takes a string followed by a space and a number, splits the string into that many pieces and joins the result back on dots.

SC       # Split input on spaces
  /      # Swap the two top stack items so the number is on top
   e     # Convert the number into an integer
    C    # Split the string into pieces and pushe the substrings to the stack
     Pj  # Join the whole stack on dots


问:
Passwordify the string
Your challenge is to passwordify the string! What is passwordifying, you ask?

Take a string as input. This string will only contain uppercase letters, lowercase letters, digits, and spaces.

You must replace all spaces with underscores and move all numbers to the end of the string in the order that they appear from left to right. Then, for every letter in the string, randomly change it to uppercase or lowercase.

Examples (case of characters should vary every time):

```<code>Input
Hello world
Output
HElLo_wORld

Input
pa55 w0rd
Output
pA_Wrd550

Input
14 35
Output
_1435

Input
0971
Output
0971

Input
[space]
Output
_
</code>```

Shortest code in bytes wins!

Whoever asks on Information Security SE if this is a good hashing algorithm wins!--Don't worry SE overlords, I'm just kidding.

答:
Python 3, 151 bytes

```<code>import random as r
x=input();s="";n=""
for c in x:
 if c.isdigit():n+=c
 else:s+=c.upper() if r.randint(0,1) else c.lower()
print(s.replace(" ","_")+n)
</code>```

Title: Passwordify the string

Body:
Python 3, 151 bytes

import random as r
x=input();s="";n=""
for c in x:
 if c.isdigit():n+=c
 else:s+=c.upper() if r.randint(0,1) else c.lower()
print(s.replace(" ","_")+n)


问:
Determine the type of an input
The challenge is simple: Determine the type of an input, and output an identifier telling what type it is.

"UI", Unsigned integer: 0, 1,34, 111111111111111111111111111111111111111111

"SI", Signed integer: +0, +1, +42, -1, -3, -111111111111111111111111111111111111111111

"UD", Unsigned decimal: 0.0, 1.23, 1234.1234

"SD", Signed decimal: -0.0, +0.0, -1.235

"LE", Letter: a-z and A-Z

"SY", Symbol: ASCII code points: [32-47, 58-64, 91-96, 123-126] (i.e. all characters except numbers and letters)

"ST", String: Two or more character that can't be parsed as any of the above number formats

Rules:

The input will be 1-99 characters long

The input will only contain printable ASCII characters, code points: 32-126.

The output should be the two identifier letters as defined above (UI, SI ...)

Standard I/O rules apply

Examples:

```<code>UI:
0
01
34
12938219383278319086135768712319838871631827319218923

SI:
-0
+01
+1
-123
+123

UD:
0.0
3.1415
2.718281828459045235360287471352662497757

SD:
+0.0
-3.1415
+2.718281828459045235360287471352662497757

LE:
a
k
L
Z

SY:
@
"
+
-

ST:
Hello, World!
f2!"
+23df
1234A
'"!
.012
1.
UI
+-1
5+3
</code>```

Title: Determine the type of an input

Body:
JavaScript (ES6), <s>125</s> 120 bytes

s=>"UISIUDSDLESYST".substr(s.match(/^((\d+)|([+-]\d+)|(\d+\.\d+)|([+-]\d+\.\d+)|([A-Z])|(.)|(.*))$/i).indexOf(s,2)*2-4,2)

Alternative version, also 120 bytes:

s=>"STUISIUDSDLESY".substr(s.match(/^(?:(\d+)|([+-]\d+)|(\d+\.\d+)|([+-]\d+\.\d+)|([A-Z])|(.)|.*)$/i).lastIndexOf(s)*2,2)


问:
Parse a Quaternion
If you don't know already, a quaternion is basically a 4-part number. For the purposes of this challenge, it has a real component and three imaginary components. The imaginary components are represented by the suffix i, j, k. For example, 1-2i+3j-4k is a quaternion with 1 being the real component and -2, 3, and -4 being the imaginary components.

In this challenge you have to parse the string form of a quaternion (ex. "1+2i-3j-4k") into a list/array of coefficients (ex. [1 2 -3 -4]). However, the quaternion string can be formatted in many different ways...

It may be normal: 1+2i-3j-4k

It may have missing terms: 1-3k, 2i-4k (If you have missing terms, output 0 for those terms)

It may have missing coefficients: i+j-k (In this case, this is equivalent to 1i+1j-1k. In other words, a i, j, or k without a number in front is assumed to have a 1 in front by default)

It may not be in the right order: 2i-1+3k-4j

The coefficients may be simply integers or decimals: 7-2.4i+3.75j-4.0k

There are some things to note while parsing:

There will always be a + or - between terms

You will always be passed valid input with at least 1 term, and without repeated letters (no j-js)

All numbers can be assumed to be valid

You can change numbers into another form after parsing if you want (ex. 3.0 => 3, 0.4 => .4, 7 => 7.0)

Parsing/quaternion builtins and standard loopholes are disallowed. This includes eval keywords and functions. Input will be a single string and output will be a list, an array, values separated by whitespace, etc.

As this is code-golf, shortest code in bytes wins.

Tons o' test cases

```<code>1+2i+3j+4k             => [1 2 3 4]
-1+3i-3j+7k            => [-1 3 -3 7]
-1-4i-9j-2k            => [-1 -4 -9 -2]
17-16i-15j-14k         => [17 -16 -15 -14]

7+2i                   => [7 2 0 0]
2i-6k                  => [0 2 0 -6]
1-5j+2k                => [1 0 -5 2]
3+4i-9k                => [3 4 0 -9]

42i+j-k                => [0 42 1 -1]
6-2i+j-3k              => [6 -2 1 -3]
1+i+j+k                => [1 1 1 1]
-1-i-j-k               => [-1 -1 -1 -1]

16k-20j+2i-7           => [-7 2 -20 16]
i+4k-3j+2              => [2 1 -3 4]
5k-2i+9+3j             => [9 -2 3 5]
5k-2j+3                => [3 0 -2 5]

1.75-1.75i-1.75j-1.75k => [1.75 -1.75 -1.75 -1.75]
2.0j-3k+0.47i-13       => [-13 0.47 2.0 -3] or [-13 .47 2 -3]
5.6-3i                 => [5.6 -3 0 0]
k-7.6i                 => [0 -7.6 0 1]

0                      => [0 0 0 0]
0j+0k                  => [0 0 0 0]
-0j                    => [0 0 0 0] or [0 0 -0 0]
1-0k                   => [1 0 0 0] or [1 0 0 -0]
</code>```

Title: Parse a Quaternion

Body:
PHP, 179 bytes

$a=[''=>0,'i'=> 0,'j'=>0,'k'=>0];preg_match_all("/([-+]?)(\d*(\.\d+)?)([ijk]?)/",$argv[1],$m,2);foreach($m as$n)if($n[0])$a[$n[4]]=$n[1].($n[2]===''?1:$n[2]);echo implode(',',$a);

Try the test suite.


问:
A multiplication table for the Cheela
The Cheela (from the book Dragon's Egg by Robert L. Forward) are creatures that live on the surface of a neutron star. Their body is flat and circular with twelve eyes on the perimeter, so they naturally use a base-12 numbering system.

Among the Cheela, care of the hatchlings and education of the young are tasks carried out by the Old Ones. Since young Cheela need to be taught how to multiply, the Old Ones could use a multiplication table.

Your task is to produce a 12x12 multiplication table in base 12, like the following. Uppercase letters A and B are used for digits corresponding to decimal 10  and 11 respectively.

```<code>  1   2   3   4   5   6   7   8   9   A   B  10
  2   4   6   8   A  10  12  14  16  18  1A  20
  3   6   9  10  13  16  19  20  23  26  29  30
  4   8  10  14  18  20  24  28  30  34  38  40
  5   A  13  18  21  26  2B  34  39  42  47  50
  6  10  16  20  26  30  36  40  46  50  56  60
  7  12  19  24  2B  36  41  48  53  5A  65  70
  8  14  20  28  34  40  48  54  60  68  74  80
  9  16  23  30  39  46  53  60  69  76  83  90
  A  18  26  34  42  50  5A  68  76  84  92  A0
  B  1A  29  38  47  56  65  74  83  92  A1  B0
 10  20  30  40  50  60  70  80  90  A0  B0 100
</code>```

The output shoud be printed on screen. The format should be as follows:

Numbers should be aligned to the right within each column.

Leading spaces before the first column, trailing spaces after the last column, or a trailing new line after the last row are allowed.

Separation between columns can be one space (as shown above) or more than one space, but the number of spaces should be consistent between columns. To measure column separation, consider that displayed numbers include any leading spaces that may have been necessary fo fulfill requirement 1 (so each number occupies three characters, the first of which may be spaces). For example, the table with two-space separation would be as follows:

```<code>  1    2    3    4    5    6    7    8    9    A    B   10
  2    4    6    8    A   10   12   14   16   18   1A   20
  3    6    9   10   13   16   19   20   23   26   29   30
  4    8   10   14   18   20   24   28   30   34   38   40
  5    A   13   18   21   26   2B   34   39   42   47   50
  6   10   16   20   26   30   36   40   46   50   56   60
  7   12   19   24   2B   36   41   48   53   5A   65   70
  8   14   20   28   34   40   48   54   60   68   74   80
  9   16   23   30   39   46   53   60   69   76   83   90
  A   18   26   34   42   50   5A   68   76   84   92   A0
  B   1A   29   38   47   56   65   74   83   92   A1   B0
 10   20   30   40   50   60   70   80   90   A0   B0  100
</code>```

Computer storage on a neutron star is really expensive, so your code should use as few bytes as possible.

Extended challenge and bonus

Ideally your code should be reused in other parts of the universe, where other numbering systems may be in use. To that end, the challenge is optionally extended as follows: Your code accepts a number N as input and generates an NxN multiplication table in base N, with the above format.

Input may be from keyboard or as a function argument. The program or function should work for 2 ≤ N ≤ 36, using as digits the first N characters of the sequence 0, 1, ..., 9, A, B, ..., Z (uppercase letters)

This extended challenge is optional. If you follow this route, take 20% off your byte count (no need to round to an integer number).

答:
Pyke, 14 bytes * 0.8 = 11.2 bytes, noncompetitive

```<code>QhD]UA*MbQMl2P
</code>```

Try it here!

Explanation:

```<code>            - autoassign Q = eval_or_not_input()
QhD]        - [Q+1, Q+1]
    U       - nd_range(^)
     A*     - apply(*, ^)
       MbQ  - map(base(Q), ^)
          Ml2 - map(lower, ^)
          P - print_grid(^)
</code>```

Or 12 bytes without the bonus

```<code>13D]UA*Mb12P
</code>```

Title: A multiplication table for the Cheela

Body:
Pyke, 14 bytes * 0.8 = 11.2 bytes, noncompetitive

QhD]UA*MbQMl2P

Try it here!

Explanation:

            - autoassign Q = eval_or_not_input()
QhD]        - [Q+1, Q+1]
    U       - nd_range(^)
     A*     - apply(*, ^)
       MbQ  - map(base(Q), ^)
          Ml2 - map(lower, ^)
          P - print_grid(^)

Or 12 bytes without the bonus

13D]UA*Mb12P


答:
Python 3.5 - 496 bytes [using Regular Expressions]:

```<code>from re import*
def wq(r):
 a=sub('[+](?![0-9])','+1',sub('[-](?![0-9])','-1',r));q=lambda x:(not x.isdigit(),''.join(filter(str.isalpha,x)))
 for z in findall('(?<![0-9])[a-z]',a):a=a.replace(z,('+1{}'.format(z)))
 if not str(sorted(((sub('[.]','',sub('[+-]',' ',a))).split(' ')),key=q)[0]).isdigit():a+='+0, '
 for i in list(set(findall('[a-z]',a))^{'i','j','k'}):a+='+0{}, '.format(i)
 print(findall('[-]?\d+(?:\.\d+)?',''.join(sorted(sub('(?<=[A-Za-z0-9])(?=[+-])',', ',a).split(' '),key=q))))
</code>```

It may be long, but in my defense, it works perfectly in doing what the OP wants, since all the test cases given were successful using my code.

Ungolfed version with explanation included:

```<code>from re import*
def w(r):
    # Substitute all minus (-) and plus (+) signs NOT followed by a number  (if there are any) with a "-1"/"+1", respectively.
    a=sub('[+](?![0-9])','+1',sub('[-](?![0-9])','-1',r))
    # Lambda function created for later use to sort the Quaternion. This function, when given as a key to the "sorted" function, arranges the input Quaternion in the order where the whole number comes first, and then the rest are placed in order of increasing letter value (i,j,k in this case)
    q=lambda x:(not x.isdigit(),''.join(filter(str.isalpha,x)))
    # The following "for" loop replaces the letters NOT preceded by a number with a one followed by that letter
    for z in findall('(?<![0-9])[a-z]',a):
        a=a.replace(z,('+1{}'.format(z)))
    # The following first substitutes all pluses and minuses (+ and -) with a space, and then that new string is split at those spaces, and returned as a list. After that, the list is sorted according the the "lambda" function shown above. Then, the first item in that list, which is supposed to be a lone number, is checked to make sure that it indeed is a lone number. If it isn't, then "+0, " is appended to the Quaternion.
    if not str(sorted(((sub('[.]','',sub('[+-]',' ',a))).split(' ')),key=q)[0]).isdigit():
        a+='+0, '
    # The following "for" loop finds ALL the letters NOT in the list, by finding the symmetric difference between a set of all the letters found, and a set containing all the letters needed. For the letters not in the list, a '+0' is added the quaternion, followed by that letter, and then a comma and a space.
    for i in list(set(findall('[a-z]',a))^{'i','j','k'}):
        a+='+0{}, '.format(i)
    # Finally, in this last step, a ", " is added IN BETWEEN unicode characters and pluses/minuses (+/-). Then, it splits at those spaces, and the commas separate different parts of the Quaternion from each other (otherwise, you would get something like `12i+3j+4k` from `2i+3j+4k+1`) in a returned list. Then, that list is sorted according to the lambda expression "q" (above), and then, finally, the NUMBERS (of any type, courtesy to Regex) are extracted from that joined list, and printed out in the correct order.
    print(findall('[-]?\d+(?:\.\d+)?',''.join(sorted(sub('(?<=[A-Za-z0-9])(?=[+-])',', ',a).split(' '),key=q))))
</code>```

If the above is a little too hard to read, basically what is happening is that:

If there are any, all + or - signs NOT followed by a number are replaced with a "+1"/"-1", respectively.

A lambda function is defined, which, when used in a sorted function as a key, sorts the list according to putting the whole number first, and then ordering the rest in increasing letter value ("i",then "j", then "k" in this instance).

The Quaternion, now having all +/- signs replaced with a 1 if needed, is searched, using Regular Expressions, for ALL letters NOT preceded by at least one number, and those letters that match are replaced with a "+1" followed by that letter.

The "if" statement then replaces ALL +/- signs with a space, and then the modified Quaternion is now "split" at those spaces, and returned in a list. Then, the list is sorted according to the lambda function explained earlier. Finally, the first item in that list is checked to make sure it's a number, since it's supposed to be, and if it's not, then a "+0, " is added to the Quaternion.

The second "for" loop finds ALL the letters NOT in the Quaternion by finding a symmetric difference between a set of those letters found in the expression, and then a set including all letters required. If any are found, then a "+0" followed by the missing letter and a space is added to the Quaternion.

Finally, in this last step, a ", " is added in between each character followed by a +/- symbol, and then the Quaternion is split at those spaces, then the list returned is sorted, for the last time, according to the lambda function defined as "q" earlier on. The commas in the expression separate each part of the quaternion (otherwise, you would be getting something like 14i+5j+6k from 4i+5j+6k+1). Lastly, that now sorted list is joined together into a string, and only the numbers of any type (courtesy of Regular Expressions) are extracted, and finally returned in a list, in the correct order, every single time.

Title: Parse a Quaternion

Body:
If you don't know already, a quaternion is basically a 4-part number. For the purposes of this challenge, it has a real component and three imaginary components. The imaginary components are represented by the suffix i, j, k. For example, 1-2i+3j-4k is a quaternion with 1 being the real component and -2, 3, and -4 being the imaginary components.

In this challenge you have to parse the string form of a quaternion (ex. "1+2i-3j-4k") into a list/array of coefficients (ex. [1 2 -3 -4]). However, the quaternion string can be formatted in many different ways...

It may be normal: 1+2i-3j-4k

It may have missing terms: 1-3k, 2i-4k (If you have missing terms, output 0 for those terms)

It may have missing coefficients: i+j-k (In this case, this is equivalent to 1i+1j-1k. In other words, a i, j, or k without a number in front is assumed to have a 1 in front by default)

It may not be in the right order: 2i-1+3k-4j

The coefficients may be simply integers or decimals: 7-2.4i+3.75j-4.0k

There are some things to note while parsing:

There will always be a + or - between terms

You will always be passed valid input with at least 1 term, and without repeated letters (no j-js)

All numbers can be assumed to be valid

You can change numbers into another form after parsing if you want (ex. 3.0 => 3, 0.4 => .4, 7 => 7.0)

Parsing/quaternion builtins and standard loopholes are disallowed. This includes eval keywords and functions. Input will be a single string and output will be a list, an array, values separated by whitespace, etc.

As this is code-golf, shortest code in bytes wins.

Tons o' test cases

```<code>1+2i+3j+4k             => [1 2 3 4]
-1+3i-3j+7k            => [-1 3 -3 7]
-1-4i-9j-2k            => [-1 -4 -9 -2]
17-16i-15j-14k         => [17 -16 -15 -14]

7+2i                   => [7 2 0 0]
2i-6k                  => [0 2 0 -6]
1-5j+2k                => [1 0 -5 2]
3+4i-9k                => [3 4 0 -9]

42i+j-k                => [0 42 1 -1]
6-2i+j-3k              => [6 -2 1 -3]
1+i+j+k                => [1 1 1 1]
-1-i-j-k               => [-1 -1 -1 -1]

16k-20j+2i-7           => [-7 2 -20 16]
i+4k-3j+2              => [2 1 -3 4]
5k-2i+9+3j             => [9 -2 3 5]
5k-2j+3                => [3 0 -2 5]

1.75-1.75i-1.75j-1.75k => [1.75 -1.75 -1.75 -1.75]
2.0j-3k+0.47i-13       => [-13 0.47 2.0 -3] or [-13 .47 2 -3]
5.6-3i                 => [5.6 -3 0 0]
k-7.6i                 => [0 -7.6 0 1]

0                      => [0 0 0 0]
0j+0k                  => [0 0 0 0]
-0j                    => [0 0 0 0] or [0 0 -0 0]
1-0k                   => [1 0 0 0] or [1 0 0 -0]
</code>```

Body:
Python 3.5 - 496 bytes [using Regular Expressions]:

from re import*
def wq(r):
 a=sub('[+](?![0-9])','+1',sub('[-](?![0-9])','-1',r));q=lambda x:(not x.isdigit(),''.join(filter(str.isalpha,x)))
 for z in findall('(?<![0-9])[a-z]',a):a=a.replace(z,('+1{}'.format(z)))
 if not str(sorted(((sub('[.]','',sub('[+-]',' ',a))).split(' ')),key=q)[0]).isdigit():a+='+0, '
 for i in list(set(findall('[a-z]',a))^{'i','j','k'}):a+='+0{}, '.format(i)
 print(findall('[-]?\d+(?:\.\d+)?',''.join(sorted(sub('(?<=[A-Za-z0-9])(?=[+-])',', ',a).split(' '),key=q))))

It may be long, but in my defense, it works perfectly in doing what the OP wants, since all the test cases given were successful using my code.

Ungolfed version with explanation included:

from re import*
def w(r):
    # Substitute all minus (-) and plus (+) signs NOT followed by a number  (if there are any) with a "-1"/"+1", respectively.
    a=sub('[+](?![0-9])','+1',sub('[-](?![0-9])','-1',r))
    # Lambda function created for later use to sort the Quaternion. This function, when given as a key to the "sorted" function, arranges the input Quaternion in the order where the whole number comes first, and then the rest are placed in order of increasing letter value (i,j,k in this case)
    q=lambda x:(not x.isdigit(),''.join(filter(str.isalpha,x)))
    # The following "for" loop replaces the letters NOT preceded by a number with a one followed by that letter
    for z in findall('(?<![0-9])[a-z]',a):
        a=a.replace(z,('+1{}'.format(z)))
    # The following first substitutes all pluses and minuses (+ and -) with a space, and then that new string is split at those spaces, and returned as a list. After that, the list is sorted according the the "lambda" function shown above. Then, the first item in that list, which is supposed to be a lone number, is checked to make sure that it indeed is a lone number. If it isn't, then "+0, " is appended to the Quaternion.
    if not str(sorted(((sub('[.]','',sub('[+-]',' ',a))).split(' ')),key=q)[0]).isdigit():
        a+='+0, '
    # The following "for" loop finds ALL the letters NOT in the list, by finding the symmetric difference between a set of all the letters found, and a set containing all the letters needed. For the letters not in the list, a '+0' is added the quaternion, followed by that letter, and then a comma and a space.
    for i in list(set(findall('[a-z]',a))^{'i','j','k'}):
        a+='+0{}, '.format(i)
    # Finally, in this last step, a ", " is added IN BETWEEN unicode characters and pluses/minuses (+/-). Then, it splits at those spaces, and the commas separate different parts of the Quaternion from each other (otherwise, you would get something like `12i+3j+4k` from `2i+3j+4k+1`) in a returned list. Then, that list is sorted according to the lambda expression "q" (above), and then, finally, the NUMBERS (of any type, courtesy to Regex) are extracted from that joined list, and printed out in the correct order.
    print(findall('[-]?\d+(?:\.\d+)?',''.join(sorted(sub('(?<=[A-Za-z0-9])(?=[+-])',', ',a).split(' '),key=q))))

If the above is a little too hard to read, basically what is happening is that:

If there are any, all + or - signs NOT followed by a number are replaced with a "+1"/"-1", respectively.

A lambda function is defined, which, when used in a sorted function as a key, sorts the list according to putting the whole number first, and then ordering the rest in increasing letter value ("i",then "j", then "k" in this instance).

The Quaternion, now having all +/- signs replaced with a 1 if needed, is searched, using Regular Expressions, for ALL letters NOT preceded by at least one number, and those letters that match are replaced with a "+1" followed by that letter.

The "if" statement then replaces ALL +/- signs with a space, and then the modified Quaternion is now "split" at those spaces, and returned in a list. Then, the list is sorted according to the lambda function explained earlier. Finally, the first item in that list is checked to make sure it's a number, since it's supposed to be, and if it's not, then a "+0, " is added to the Quaternion.

The second "for" loop finds ALL the letters NOT in the Quaternion by finding a symmetric difference between a set of those letters found in the expression, and then a set including all letters required. If any are found, then a "+0" followed by the missing letter and a space is added to the Quaternion.

Finally, in this last step, a ", " is added in between each character followed by a +/- symbol, and then the Quaternion is split at those spaces, then the list returned is sorted, for the last time, according to the lambda function defined as "q" earlier on. The commas in the expression separate each part of the quaternion (otherwise, you would be getting something like 14i+5j+6k from 4i+5j+6k+1). Lastly, that now sorted list is joined together into a string, and only the numbers of any type (courtesy of Regular Expressions) are extracted, and finally returned in a list, in the correct order, every single time.


问:
Evaluate a minimax tree
Alice and Bob are playing a little game. First, they draw a tree from a root node (indicated by a thick dot), with no internal nodes, with numbers at the leaves. Any node may have any number of children.

We start at the root, and first to play is Alice (A). She must select one of the current node's children. Then it's Bob's turn, and he similarly selects a child node. This continues until a leaf node is reached.

When a leaf node is reached, the game is over. It is Alice's goal to end at a node with as large of a value as possible, and Bob's goal to end at a node with as small of a value as possible.

Given a tree in nested array form, return the value of the leaf that will be reached if both Alice and Bob play perfectly.

Examples:

```<code>18: [[67, [[100, [[67, 47], [86], 21, 16], [[46, [14], 35, 85], [71, [18, 63, 69], 99, 22], 3]]], [[18, 32, 42, 80]], [[36, 70], [86, 53, 46, 59], [[41], 86, 35]]], 3]
60: [[[84, 35], [44, 60]], [[24, 98], [16, 21]]]
58: [[53, 77], [58, [82, 41]], 52]
59: [[93, [100, 53], 58, 79], [63, 94, 59], [9, [55, 48]], [40, 10, 32]]
56: [[20, 10, [[[89, 22, 77, 10], 55], [24, 28, 30, 63]]], [[49, 31]], 17, 56]
0: [0]
</code>```

You may assume that the root node never is a leaf node and points to at least one leaf node. You may assume that leafs are nonnegative numbers.

Shortest code in bytes wins.

答:
Pyth, 21 bytes

```<code>M?sIG*GH_hSmgd_HGLgb1
</code>```

My first Pyth answer! Thanks to Dennis for the help :).

```<code>M                      # define a binary function (G, H)
 ?sIG                  # if G (first argument) is the same with s applied
                       # (check if it's an integer, so, a leaf node)
     *GH               # in such a case, calculate G*H
        _              # negation
         hS            # take the first element of the sorted list (that's the min)
           mgd_HG      # map over G, applying ourself (g) recursively,
                       # with the current lambda's value (d)
                       # and the negation of H
                 Lgb1  # Define a unary function to call our previous
                       # one with the correct base argument (1)
</code>```

ContentLicense: CC BY-SA 4.0

Title: Evaluate a minimax tree

Body:
Pyth, 21 bytes

M?sIG*GH_hSmgd_HGLgb1

My first Pyth answer! Thanks to Dennis for the help :).

M                      # define a binary function (G, H)
 ?sIG                  # if G (first argument) is the same with s applied
                       # (check if it's an integer, so, a leaf node)
     *GH               # in such a case, calculate G*H
        _              # negation
         hS            # take the first element of the sorted list (that's the min)
           mgd_HG      # map over G, applying ourself (g) recursively,
                       # with the current lambda's value (d)
                       # and the negation of H
                 Lgb1  # Define a unary function to call our previous
                       # one with the correct base argument (1)


问:
Print the sum of the squares of some numbers
This is a little codegolf challenge from codingame.com. I was wondering how much Python3 code is necessary (but of course answers are not limited to Python3).

Input

The first line contains one positive integer n. The second line contains n positive integers. Each consecutive integers on the second line are separated by one space. There is no newline at the end of the second line.

Output

One line containing the sum of the squares of the numbers on the second input line, and no white space except an optional newline at the end.

Each entry must be a complete program with input and output, not only a function. Shortest code wins.

For example, input:

```<code>5
1 2 5 7 8
</code>```

and output:

```<code>143
</code>```

答:
Pylongolf2, 8 bytes

```<code>c| n²+~
</code>```

```<code>c  - read the input
|  - split by space (note the 1 space after |)
n  - convert all of that in the list to numbers
²  - Square everything in the list
+  - Sum everything in the list
~  - Print it
</code>```

Body:
Pylongolf2, 8 bytes

c| n²+~

c  - read the input
|  - split by space (note the 1 space after |)
n  - convert all of that in the list to numbers
²  - Square everything in the list
+  - Sum everything in the list
~  - Print it


Title: Determine the type of an input

Body:
The challenge is simple: Determine the type of an input, and output an identifier telling what type it is.

"UI", Unsigned integer: 0, 1,34, 111111111111111111111111111111111111111111

"SI", Signed integer: +0, +1, +42, -1, -3, -111111111111111111111111111111111111111111

"UD", Unsigned decimal: 0.0, 1.23, 1234.1234

"SD", Signed decimal: -0.0, +0.0, -1.235

"LE", Letter: a-z and A-Z

"SY", Symbol: ASCII code points: [32-47, 58-64, 91-96, 123-126] (i.e. all characters except numbers and letters)

"ST", String: Two or more character that can't be parsed as any of the above number formats

Rules:

The input will be 1-99 characters long

The input will only contain printable ASCII characters, code points: 32-126.

The output should be the two identifier letters as defined above (UI, SI ...)

Standard I/O rules apply

Examples:

```<code>UI:
0
01
34
12938219383278319086135768712319838871631827319218923

SI:
-0
+01
+1
-123
+123

UD:
0.0
3.1415
2.718281828459045235360287471352662497757

SD:
+0.0
-3.1415
+2.718281828459045235360287471352662497757

LE:
a
k
L
Z

SY:
@
"
+
-

ST:
Hello, World!
f2!"
+23df
1234A
'"!
.012
1.
UI
+-1
5+3
</code>```

Body:
Java, 192 bytes

String t(String v){for(String[]x:new String[][]{{"\\d+","UI"},{"[-+]\\d+","SI"},{"\\d+\\.\\d+","UD"},{"[-+]\\d+\\.\\d+","SD"}})if(v.matches(x[0]))return x[1];return (v.length()==1?"SY":"ST");}


问:
Identify arborally satisfied point sets
An arborally satisfied point set is a 2D set of points such that, for any axis-aligned rectangle that can be formed using two points in the set as opposite corners, that rectangle contains or touches at least one other point.  Here is an equivalent definition from Wikipedia:

A point set is said to be arborally satisfied if the following property holds: for any pair of points that do not both lie on the same horizontal or vertical line, there exists a third point which lies in the rectangle spanned by the first two points (either inside or on the boundary).

The following image illustrates how the rectangles are formed.  This point set is NOT arborally satisfied because this rectangle needs to contain at least one more point.

In ASCII art, this point set can be represented as:

```<code>......
....O.
......
.O....
......
</code>```

A slight modification can make this arborally satisfied:

```<code>......
....O.
......
.O..O.
......
</code>```

Above, you can see that all rectangles (of which there is only one) contain at least three points.

Here is another example of a more complex point set that is arborally satisfied:

For any rectangle that can be drawn spanning two points, that rectangle contains at least one other point.

The Challenge

Given a rectangular grid of points (which I represent with O) and empty space (which I represent with .), output a truthy value if it is arborally satisfied, or a falsey value if it is not.  This is code-golf.

Additional rules:

You can choose to have the characters O and . swapped out with any other pair of printable ASCII characters.  Simply specify which character mapping your program uses.

The grid will always be rectangular.  A trailing newline is allowable.

More Examples

Arborally satisfied:

```<code>.OOO.
OO...
.O.OO
.O..O
....O

..O..
OOOO.
...O.
.O.O.
...OO

O.O.
..O.
OOOO
.O.O
OO..

...
...
...

...
..O
...

O.....
O.O..O
.....O

OOO.OO
</code>```

Not Arborally Satisfied:

```<code>..O..
O....
...O.
.O...
....O

..O..
O.OO.
...O.
.O.O.
...OO

O.....
..O...
.....O
</code>```

答:
MATL, 38 bytes

```<code>Ti2\2#fh!XJ"J@-XKtAZ)"@K-@/Eq|1>~As2>*
</code>```

This uses a 2D char array as input, with rows separated by ;. So the first example is

```<code>['......';'....O.';'......';'.O..O.';'......']
</code>```

The rest of the test cases in this format are as follows.

Arborally satisfied:

```<code>['.OOO.';'OO...';'.O.OO';'.O..O';'....O']
['..O..';'OOOO.';'...O.';'.O.O.';'...OO']
['O.O.';'..O.';'OOOO';'.O.O';'OO..']
['...';'...';'...']
['...';'..O';'...']
['O.....';'O.O..O';'.....O']
['OOO.OO']
</code>```

Not arborally satisfied:

```<code>['..O..';'O....','...O.';'.O...';'....O']
['..O..';'O.OO.';'...O.';'.O.O.';'...OO']
['O.....';'..O...';'.....O']
</code>```

Try it online! You can also verify all test cases at once.

Explanation

The code first gets the coordinates of characters O in the input. It then uses two nested loops. The outer loop picks each point P (2-tuple of its coordinates), compares with all points, and keeps points that differ from P in the two coordinates. Those are the points than can form a rectangle with P. Call them set R.

The inner loop picks each point T from R, and checks if the rectangle defined by P and T includes at least 3 points. To do that, it subtracts P from all points; that is, moves the origin of coordinates to P. A point is in the rectangle if each of its coordinates divided by the corresponding coordinate of T is in the closed interval [0, 1].

```<code>T          % push "true"
i          % take input 2D array
2\         % modulo 2: gives 1 for 'O', 0 for '.'
2#f        % row and column coordinates of ones. Gives two column arrays
h!         % concatenate horizontally. Transpose. Each point is a column
XJ         % copy to clipboard J
"          % for each column
  J        %   push all points
  @-       %   subtract current point (move to origin)
  XK       %   copy to clipboard K
  tA       %   logical index of points whose two coordinates are non-zero
  Z)       %   keep only those points. Each is a column
  "        %   for each column (point)
    @K-    %     push that point. Subtract all others
    @/     %     divide by current point
    Eq|1>~ %     true if in the interval [0,1]
    A      %     true if that happens for the two coordinates
    s      %     sum: find out how many points fulfill that
    2>     %     true if that number is at least 3
    *      %     multiply (logical and). (There's an initial true value at the bottom)
           %   end
           % end
           % implicit display
</code>```

Title: Identify arborally satisfied point sets

Body:
MATL, 38 bytes

Ti2\2#fh!XJ"J@-XKtAZ)"@K-@/Eq|1>~As2>*

This uses a 2D char array as input, with rows separated by ;. So the first example is

['......';'....O.';'......';'.O..O.';'......']

The rest of the test cases in this format are as follows.

Arborally satisfied:

['.OOO.';'OO...';'.O.OO';'.O..O';'....O']
['..O..';'OOOO.';'...O.';'.O.O.';'...OO']
['O.O.';'..O.';'OOOO';'.O.O';'OO..']
['...';'...';'...']
['...';'..O';'...']
['O.....';'O.O..O';'.....O']
['OOO.OO']

Not arborally satisfied:

['..O..';'O....','...O.';'.O...';'....O']
['..O..';'O.OO.';'...O.';'.O.O.';'...OO']
['O.....';'..O...';'.....O']

Try it online! You can also <a href="http://matl.tryitonline.net/#code=YApUaTJcMiNmaCFYSiJKQC1YS3RBWikiQEstQC9FcXwxPn5BczI-KgpdXURU&input=WycuT09PLic7J09PLi4uJzsnLk8uT08nOycuTy4uTyc7Jy4uLi5PJ10KWycuLk8uLic7J09PT08uJzsnLi4uTy4nOycuTy5PLic7Jy4uLk9PJ10KWydPLk8uJzsnLi5PLic7J09PT08nOycuTy5PJzsnT08uLiddClsnLi4uJzsnLi4uJzsnLi4uJ10KWycuLi4nOycuLk8nOycuLi4nXQpbJ08uLi4uLic7J08uTy4uTyc7Jy4uLi4uTyddClsnT09PLk9PJ10KWycuLk8uLic7J08uLi4uJywnLi4uTy4nOycuTy4uLic7Jy4uLi5PJ10KWycuLk8uLic7J08uT08uJzsnLi4uTy4nOycuTy5PLic7Jy4uLk9PJ10KWydPLi4uLi4nOycuLk8uLi4nOycuLi4uLk8nXQ" rel="nofollow">verify all test cases at once.

Explanation

The code first gets the coordinates of characters O in the input. It then uses two nested loops. The outer loop picks each point P (2-tuple of its coordinates), compares with all points, and keeps points that differ from P in the two coordinates. Those are the points than can form a rectangle with P. Call them set R.

The inner loop picks each point T from R, and checks if the rectangle defined by P and T includes at least 3 points. To do that, it subtracts P from all points; that is, moves the origin of coordinates to P. A point is in the rectangle if each of its coordinates divided by the corresponding coordinate of T is in the closed interval [0, 1].

T          % push "true"
i          % take input 2D array
2\         % modulo 2: gives 1 for 'O', 0 for '.'
2#f        % row and column coordinates of ones. Gives two column arrays
h!         % concatenate horizontally. Transpose. Each point is a column
XJ         % copy to clipboard J
"          % for each column
  J        %   push all points
  @-       %   subtract current point (move to origin)
  XK       %   copy to clipboard K
  tA       %   logical index of points whose two coordinates are non-zero
  Z)       %   keep only those points. Each is a column
  "        %   for each column (point)
    @K-    %     push that point. Subtract all others
    @/     %     divide by current point
    Eq|1>~ %     true if in the interval [0,1]
    A      %     true if that happens for the two coordinates
    s      %     sum: find out how many points fulfill that
    2>     %     true if that number is at least 3
    *      %     multiply (logical and). (There's an initial true value at the bottom)
           %   end
           % end
           % implicit display


答:
Jelly, 7 bytes

```<code>Nß€¬¡ṂN
</code>```

Try it online! or verify all test cases.

This uses the algorithm from @xnor's answer. For comparison purposes, a more straightforward approach that alternately computes minima and maxima weighs 8 bytes:

```<code>ß€¬¡€Ṃ€Ṁ
</code>```

How it works

```<code>Nß€¬¡ṂN  Main link. Argument: x (array or integer)

N        Negate. For an array, this negates all integers in it.
   ¬     Logical NOT. For an array, this applies to all integers in it.
    ¡    Apply the second link to the left once if ¬ returned an array or 1, or not
         at all if it returned 0.
 ß€      Recursively call the main link on all elements at depth 1 of -x.
         If -x == 0, € will cast 0 to range before mapping ß over it.
         Since the range of 0 is [], mapping ß over it simply yields [].
     Ṃ   Minimum.
         For an integer, Ṃ simply returns the integer. For [], Ṃ returns 0.
      N  Negate the minimum.
</code>```

Title: Evaluate a minimax tree

Body:
Alice and Bob are playing a little game. First, they draw a tree from a root node (indicated by a thick dot), with no internal nodes, with numbers at the leaves. Any node may have any number of children.

We start at the root, and first to play is Alice (A). She must select one of the current node's children. Then it's Bob's turn, and he similarly selects a child node. This continues until a leaf node is reached.

When a leaf node is reached, the game is over. It is Alice's goal to end at a node with as large of a value as possible, and Bob's goal to end at a node with as small of a value as possible.

Given a tree in nested array form, return the value of the leaf that will be reached if both Alice and Bob play perfectly.

Examples:

```<code>18: [[67, [[100, [[67, 47], [86], 21, 16], [[46, [14], 35, 85], [71, [18, 63, 69], 99, 22], 3]]], [[18, 32, 42, 80]], [[36, 70], [86, 53, 46, 59], [[41], 86, 35]]], 3]
60: [[[84, 35], [44, 60]], [[24, 98], [16, 21]]]
58: [[53, 77], [58, [82, 41]], 52]
59: [[93, [100, 53], 58, 79], [63, 94, 59], [9, [55, 48]], [40, 10, 32]]
56: [[20, 10, [[[89, 22, 77, 10], 55], [24, 28, 30, 63]]], [[49, 31]], 17, 56]
0: [0]
</code>```

You may assume that the root node never is a leaf node and points to at least one leaf node. You may assume that leafs are nonnegative numbers.

Shortest code in bytes wins.

Body:
Jelly, 7 bytes

Nß€¬¡ṂN

Try it online! or <a href="http://jelly.tryitonline.net/#code=TsOf4oKswqzCoeG5gk4Kw4figqw&input=&args=W1s2NywgW1sxMDAsIFtbNjcsIDQ3XSwgWzg2XSwgMjEsIDE2XSwgW1s0NiwgWzE0XSwgMzUsIDg1XSwgWzcxLCBbMTgsIDYzLCA2OV0sIDk5LCAyMl0sIDNdXV0sIFtbMTgsIDMyLCA0MiwgODBdXSwgW1szNiwgNzBdLCBbODYsIDUzLCA0NiwgNTldLCBbWzQxXSwgODYsIDM1XV1dLCAzXSwgW1tbODQsIDM1XSwgWzQ0LCA2MF1dLCBbWzI0LCA5OF0sIFsxNiwgMjFdXV0sIFtbNTMsIDc3XSwgWzU4LCBbODIsIDQxXV0sIDUyXSwgW1s5MywgWzEwMCwgNTNdLCA1OCwgNzldLCBbNjMsIDk0LCA1OV0sIFs5LCBbNTUsIDQ4XV0sIFs0MCwgMTAsIDMyXV0sIFtbMjAsIDEwLCBbW1s4OSwgMjIsIDc3LCAxMF0sIDU1XSwgWzI0LCAyOCwgMzAsIDYzXV1dLCBbWzQ5LCAzMV1dLCAxNywgNTZdLCBbMF0" rel="nofollow noreferrer">verify all test cases.

This uses the algorithm from @xnor's answer. For comparison purposes, a more straightforward approach that alternately computes minima and maxima weighs 8 bytes:

ß€¬¡€Ṃ€Ṁ

How it works

Nß€¬¡ṂN  Main link. Argument: x (array or integer)

N        Negate. For an array, this negates all integers in it.
   ¬     Logical NOT. For an array, this applies to all integers in it.
    ¡    Apply the second link to the left once if ¬ returned an array or 1, or not
         at all if it returned 0.
 ß€      Recursively call the main link on all elements at depth 1 of -x.
         If -x == 0, € will cast 0 to range before mapping ß over it.
         Since the range of 0 is [], mapping ß over it simply yields [].
     Ṃ   Minimum.
         For an integer, Ṃ simply returns the integer. For [], Ṃ returns 0.
      N  Negate the minimum.


问:
Javascript left-pad golf

Introduction

In the wake of the left-pad npm package fallout, let's have a code golf for implementing left-pad.

The left-pad function consists of 2 default arguments and 1 additional argument, in the form string, length, (padchar). If the padchar is not given, this is standardized to a space character. Let's take an example with two arguments:

```<code>left_pad("abc", 6)
</code>```

First, we observe the length of the string, which is 3. After this, we need to pad this string in the left until the length of the full string has reached the length given in the function. In this case 6. Since the padchar is not given, we need to pad this with spaces:

```<code>   abc
</code>```

This is a string with 3 spaces and the initial string, resulting into a string with length 6. Here is an example with the padchar given:

```<code>left_pad("abc", 6, "-")
</code>```

We just do the same as the example above, but replace the spaces with the padchar. In this case, the hyphen:

```<code>---abc
</code>```

The Task

Given the string, length, and maybe the additional argument padchar, output the left-padded string. You can assume that the length number is equal or greater than the length of the string. The padchar will always consist of 1 character.

Test cases

```<code>left_pad("string", length, ("padchar")) === "left-padded string"

left_pad("foo", 5) === "  foo"
left_pad("foobar", 6) === "foobar"
left_pad("1", 2, "0") === "01"
left_pad("1", 2, "-") === "-1"
</code>```

This is code-golf, so the submission with the smallest number of bytes wins!

答:
Bash, 57 Bytes

Parameters: string width padchar

```<code>printf -vX %$2s;Y="${X// /${3- }}$1";echo -n "${Y:${#1}}"
</code>```

Make a string of width spaces.

Convert each space character into padchar.

Write padding then string.

Title: Javascript left-pad golf

Body:
Bash, 57 Bytes

Parameters: string width padchar

printf -vX %$2s;Y="${X// /${3- }}$1";echo -n "${Y:${#1}}"

Make a string of width spaces.

Convert each space character into padchar.

Write padding then string.


答:
Javascript (ES6), 138 bytes

I tried to use a replace to be more "fancy".

This creates an anonymous function that returns the string of the type.

```<code>s=>s.replace(/^((([+-])?(\d+)(\.\d+)?)|([a-z])|([ -~])|([^\0]*))$/i,(_,a,b,c,d,e,f,g)=>b?(c?'S':'U')+(e?'D':'I'):(f?'LE':'S'+(g?'Y':'T')))
</code>```

Any tips to improving this will be entirely welcome.

Title: Determine the type of an input

Body:
Javascript (ES6), 138 bytes

I tried to use a replace to be more "fancy".

This creates an anonymous function that returns the string of the type.

s=>s.replace(/^((([+-])?(\d+)(\.\d+)?)|([a-z])|([ -~])|([^\0]*))$/i,(_,a,b,c,d,e,f,g)=>b?(c?'S':'U')+(e?'D':'I'):(f?'LE':'S'+(g?'Y':'T')))

Any tips to improving this will be entirely welcome.


Title: Determine the type of an input

Body:
JavaScript (ES6), 99

x=>(z=x.match(/^([+-])?\d+(\.\d+)?$/))?'SU'[+!z[1]]+'DI'[+!z[2]]:x[1]?'ST':parseInt(x,36)?'LE':'SY'

Test

f=x=>(z=x.match(/^([+-])?\d+(\.\d+)?$/))?'SU'[+!z[1]]+'DI'[+!z[2]]:x[1]?'ST':parseInt(x,36)?'LE':'SY'

console.log=x=>O.textContent+=x+'\n'

;console.log(['0','01','34','12938219383278319086135768712319838871631827319218923'].map(x=>f(x)+' '+x).join`\n`)
;console.log(['-0','+01','+1','-123','+123'].map(x=>f(x)+' '+x).join`\n`)
;console.log(['0.0','3.1415','2.718281828459045235360287471352662497757'].map(x=>f(x)+' '+x).join`\n`)
;console.log(['+0.0','-3.1415','+2.718281828459045235360287471352662497757'].map(x=>f(x)+' '+x).join`\n`)
;console.log([...'akLZ'].map(x=>f(x)+' '+x).join`\n`)
;console.log([...'@"+-'].map(x=>f(x)+' '+x).join`\n`)
;console.log(['Hello, World!','f2!"','+23df','1234A',`'"!`,'.012','1.','UI','+-1','5+3'].map(x=>f(x)+' '+x).join`\n`)

<pre id=O></pre>


答:
Ruby, 46 bytes

Used @xnor's trick with min for alternating between max and min.

```<code>f=->n,a=1{n==[*n]?-n.map{|c|f[c,-a]}.min: a*n}
</code>```

Title: Evaluate a minimax tree

Body:
Ruby, 46 bytes

Used @xnor's trick with min for alternating between max and min.

f=->n,a=1{n==[*n]?-n.map{|c|f[c,-a]}.min: a*n}


问:
Tips for golfing in Haskell
What general tips do you have for golfing in Haskell? I am looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Haskell. Please post only one tip per answer.

If you are new to golfing in Haskell, please have a look at the Guide to Golfing Rules in Haskell. There is also a dedicated Haskell chat room: Of Monads and Men.

答:
Bind using guards

When defining a named function, you can bind an expression to a variable in a guard. For example,

f s|w<-words s=...
```
<p>does the same as</p>
<pre class="lang-haskell prettyprint-override"><code>f s=let w=words s in ...
f s=(\w->...)$words s
</code>```

Use this to save on repeated expressions. When the expression is used twice, it breaks even at length 6, though spacing and precedence issues can change that.

(In the example, if the original variable s is not used, it's shorter to do

g w=...
f=g.words
```

but that's not true for binding more complex expressions.)

Title: Tips for golfing in Haskell

Body:
Bind using guards

When defining a named function, you can bind an expression to a variable in a guard. For example,

f s|w<-words s=...

does the same as

f s=let w=words s in ...
f s=(\w->...)$words s

Use this to save on repeated expressions. When the expression is used twice, it breaks even at length 6, though spacing and precedence issues can change that.

(In the example, if the original variable s is not used, it's shorter to do

g w=...
f=g.words

but that's not true for binding more complex expressions.)


答:
Python 3.5 - 241 240 bytes:

(Saved 1 byte thanks to @CatsAreFluffy)

```<code>import re
def r(g):
 y={'^\d+$':'UI','^[+-]\d+$':'SI','^[0-9]\d*(\.\d+)?$':'UD','[+-](?=[0-9]\d*(\.\d+))':'SD','[a-zA-Z]+':'LE','^[^A-Za-z0-9]+$':'SY'};d=[y[i]for i in list(y.keys())if re.match(i,g)]
 if len(d)>0:return d[0]
 else:return'ST'
</code>```

It may be a bit long, but does the job pretty much perfectly. This was a really good way to improve my regular expression skills. Thanks for the challenge. :) I will try and shorten it more if I can.

Title: Determine the type of an input

Body:
Python 3.5 - 241 240 bytes:

(Saved 1 byte thanks to @CatsAreFluffy)

import re
def r(g):
 y={'^\d+$':'UI','^[+-]\d+$':'SI','^[0-9]\d*(\.\d+)?$':'UD','[+-](?=[0-9]\d*(\.\d+))':'SD','[a-zA-Z]+':'LE','^[^A-Za-z0-9]+$':'SY'};d=[y[i]for i in list(y.keys())if re.match(i,g)]
 if len(d)>0:return d[0]
 else:return'ST'

It may be a bit long, but does the job pretty much perfectly. This was a really good way to improve my regular expression skills. Thanks for the challenge. :) I will try and shorten it more if I can.


答:
Julia, <s>27</s> 25 bytes

```<code>!a=0==0a?a:-minimum(!,-a)
</code>```

This uses the algorithm from @xnor's answer. Try it online!

Title: Evaluate a minimax tree

Body:
Julia, <s>27</s> 25 bytes

!a=0==0a?a:-minimum(!,-a)

This uses the algorithm from @xnor's answer. <a href="http://julia.tryitonline.net/#code=IWE9MD09MGE_YTotbWluaW11bSghLC1hKQoKcHJpbnRsbighKHt7NjcsIHt7MTAwLCB7ezY3LCA0N30sIHs4Nn0sIDIxLCAxNn0sIHt7NDYsIHsxNH0sIDM1LCA4NX0sIHs3MSwgezE4LCA2MywgNjl9LCA5OSwgMjJ9LCAzfX19LCB7ezE4LCAzMiwgNDIsIDgwfX0sIHt7MzYsIDcwfSwgezg2LCA1MywgNDYsIDU5fSwge3s0MX0sIDg2LCAzNX19fSwgM30pKQpwcmludGxuKCEoe3t7ODQsIDM1fSwgezQ0LCA2MH19LCB7ezI0LCA5OH0sIHsxNiwgMjF9fX0pKQpwcmludGxuKCEoe3s1MywgNzd9LCB7NTgsIHs4MiwgNDF9fSwgNTJ9KSkKcHJpbnRsbighKHt7OTMsIHsxMDAsIDUzfSwgNTgsIDc5fSwgezYzLCA5NCwgNTl9LCB7OSwgezU1LCA0OH19LCB7NDAsIDEwLCAzMn19KSkKcHJpbnRsbighKHt7MjAsIDEwLCB7e3s4OSwgMjIsIDc3LCAxMH0sIDU1fSwgezI0LCAyOCwgMzAsIDYzfX19LCB7ezQ5LCAzMX19LCAxNywgNTZ9KSkKcHJpbnRsbighKHswfSkp&input=" rel="nofollow noreferrer">Try it online!


问:
Child Genotypes
The Challenge

Everybody loves genetics, right? In this challenge, you will be given the genotypes of two parents. You must find each possible genotype of a child produced by the parents. You must account for dominant and recessive alleles as well as incomplete dominance and codominance.

An example input for the parents could be:

```<code>R'RxRr
</code>```

Parent one (on the left) has a incompletely dominant R allele and a dominant R allele. Parent two (on the right) has a dominant R allele and a recessive allele.

Each parent is separated from the other by an x. The input will not contain an x allele.

An incompletely dominant allele will be followed by an apostrophe ('). Codominant alleles just refers to multiple different types of alleles combined together (A and W for example).

Rules

Shortest code wins (measured in bytes).

Each possibly genotype must be separated from the other genotypes by a comma.

Phenotypes don't matter.

Any letter can be used in the input except for x (which differentiates the parents).

Duplicate genotypes should only be printed once.

Duplicates contain the exact same letters of the same case and type of allele. IF you have WY and YW in your answer, they are considered duplicates.

No more than three different letters will be used in one input.

The order of the letters in the output does not matter.

Answer can be in the form of a string or an array.

Examples

Input 1 (the previous example):

```<code>R'RxRr
</code>```

Output 1:

```<code>R'R,R'r,RR,Rr
</code>```

Alternate output 1 (array):

```<code>{R'R,R'r,RR,Rr}
</code>```

Input 2:

```<code>RWxRR
</code>```

Output 2:

```<code>RR,WR
//Or an array, whichever you want
</code>```

Input 3:

```<code>WYxY'y
</code>```

Output 3:

```<code>WY',Wy,YY',Yy
//Once again, an array is fine
</code>```

答:
Python 3.5 - 196 bytes:

```<code>def b(r):import itertools,re;r=[];[r.append(h)for h in itertools.permutations(re.sub("(?<=[a-zA-Z'])(?=[a-zA-Z])",' ',r.replace('x','')).split(' '),2)if h[::-1]not in r and h not in r];return r
</code>```

A nice one liner, using some regular expressions.

Note: Around each letter with an apostrophe are double quotes, and I hope that's okay (e.g., in the output, R' would come out as "R'"). Also, for the last test case, it returns [('W', "Y'"), ('W', 'y'), ('Y', 'W'), ('Y', "Y'"), ('Y', 'y'), ('y', "Y'")] instead of just WY',Wy,YY',Yy. I also hope that is okay. If any of these conditions are an issue, just let me know, and I will fix them.

Title: Child Genotypes

Body:
Python 3.5 - 196 bytes:

def b(r):import itertools,re;r=[];[r.append(h)for h in itertools.permutations(re.sub("(?<=[a-zA-Z'])(?=[a-zA-Z])",' ',r.replace('x','')).split(' '),2)if h[::-1]not in r and h not in r];return r

A nice one liner, using some regular expressions.

Note: Around each letter with an apostrophe are double quotes, and I hope that's okay (e.g., in the output, R' would come out as "R'"). Also, for the last test case, it returns [('W', "Y'"), ('W', 'y'), ('Y', 'W'), ('Y', "Y'"), ('Y', 'y'), ('y', "Y'")] instead of just WY',Wy,YY',Yy. I also hope that is okay. If any of these conditions are an issue, just let me know, and I will fix them.


问:
Final Fantasy XV UNCOVERED!
Since I am INSANELY hyped for the Final Fantasy XV Uncovered event, I want you to write me a program to tell me when it is!!!

The input

Your take input in the form of HH:MM XDT, where HH is a number in the range 1-12, MM is a number between 0-60, and XDT is a time zone, with X being one of E (eastern, UTC-4), C (central, UTC-5), P (pacific, UTC-7), or M (mountain, UTC-6). This is a time assumed to be PM. Valid inputs include:

```<code>1:00 EDT (1 PM Eastern Daylight Time)
4:05 MDT (4:05 PM Mountain Daylight Time)
12:23 PDT (12:23 PM Pacific Daylight Time)
1:10 CDT (1:10 PM Central Daylight Time)
</code>```

The input may be assumed to be valid.

The output

Your program must do the following:

Convert the given time to PDT and output It is XX:XX PM PDT., where XX:XX is the converted time. Note that you do not need to handle any case where converting the time would cross the AM/PM boundary.

Print one of the following:

If the converted time is before 6:00 PM PDT, print X minutes until the pre-show!, replacing X with the number of minutes until 6:00 PM PDT.

If the converted time is after or equal to 6:00 PM PDT and before 7:00 PM PDT, print Pre-show started X minutes ago; UNCOVERED is starting in Y minutes!, where X is the number of minutes that have passed since 6:00 PM PDT, and Y is the number of minutes until 7:00 PM PDT.

If the converted time is after or equal to 7:00 PM PDT, print UNCOVERED started X minutes ago!, where X is the number of minutes that have passed since 7:00 PM PDT.

Each string printed must be followed by a newline.

Scoring

This is code golf, so the shortest program wins.

答:
PowerShell 292 Bytes

$r,$i,$s,$u="re-show"," minutes"," start","UNCOVERED";$h,$m,$z=$args[0]-split":| ";$h=+$h-"PMCE".IndexOf($z[0]);"It is $h`:$m PM PDT.";if(($t=$h*60+$m-360)-lt0){"$($t*-1)$i until the p$r!"}else{if($t-gt59){"$u$s`ed $($t-60)$i ago!"}else{"P$r$s`ed $t$i ago; $u is$s`ing in $(($t-60)*-1)$i!"}}
```
<hr />
<p><strong>Less Golfed Explanation</strong></p>
<pre class="lang-ps prettyprint-override"><code># Some string literals.
$r,$i,$s,$u,$g="re-show"," minutes"," start","UNCOVERED"," ago"
# Get the hours, minutes and zone into variables.
$h,$m,$z=$args[0]-split":| "
# Offset the time based on the passed timezone.
$h=+$h - "PMCE".IndexOf($z[0])
# Display current PDT time.
"It is $h`:$m PM PDT."

# Based on adjusted time value for PDT determine what string to show.
# Several string literals were used to save space.
if(($t=$h*60+$m-360)-lt0){
    # Show has not started yet
    "$($t*-1)$i until the p$r!"
}else{
    if($t-gt59){
        # Between 6 and 7
        "$u$s`ed $($t-60)$i$g!"
    }else{
        # It's after 7. Should have check more often.
        "P$r$s`ed $t$i$g; $u is$s`ing in $(($t-60)*-1)$i!"
    }
}
</code>```

The literal for " ago" was removed in code but for now left in explanation in case of other changes.

Title: Final Fantasy XV UNCOVERED!

Body:
PowerShell 292 Bytes

$r,$i,$s,$u="re-show"," minutes"," start","UNCOVERED";$h,$m,$z=$args[0]-split":| ";$h=+$h-"PMCE".IndexOf($z[0]);"It is $h`:$m PM PDT.";if(($t=$h*60+$m-360)-lt0){"$($t*-1)$i until the p$r!"}else{if($t-gt59){"$u$s`ed $($t-60)$i ago!"}else{"P$r$s`ed $t$i ago; $u is$s`ing in $(($t-60)*-1)$i!"}}

Less Golfed Explanation

# Some string literals.
$r,$i,$s,$u,$g="re-show"," minutes"," start","UNCOVERED"," ago"
# Get the hours, minutes and zone into variables.
$h,$m,$z=$args[0]-split":| "
# Offset the time based on the passed timezone.
$h=+$h - "PMCE".IndexOf($z[0])
# Display current PDT time.
"It is $h`:$m PM PDT."

# Based on adjusted time value for PDT determine what string to show.
# Several string literals were used to save space.
if(($t=$h*60+$m-360)-lt0){
    # Show has not started yet
    "$($t*-1)$i until the p$r!"
}else{
    if($t-gt59){
        # Between 6 and 7
        "$u$s`ed $($t-60)$i$g!"
    }else{
        # It's after 7. Should have check more often.
        "P$r$s`ed $t$i$g; $u is$s`ing in $(($t-60)*-1)$i!"
    }
}

The literal for " ago" was removed in code but for now left in explanation in case of other changes.


问:
Count up forever
Write a program that counts up forever, starting from one.

Rules:

Your program must log to STDOUT or an acceptable alternative, if STDOUT is not available.

Your program must be a full, runnable program, and not a function or snippet.

Your program must output each number with a separating character in between (a newline, space, tab or comma), but this must be consistent for all numbers.

You may print the numbers in decimal, in unary or in base 256 where each digit is represented by a byte value.

Your program must count at least as far as 2128 (inclusive) without problems and without running out of memory on a reasonable desktop PC. In particular, this means if you're using unary, you cannot store a unary representation of the current number in memory.

Unlike our usual rules, feel free to use a language (or language version) even if it's newer than this challenge. Languages specifically written to submit a 0-byte answer to this challenge are fair game but not particularly interesting.

Note that there must be an interpreter so the submission can be tested. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language.

This is not about finding the language with the shortest solution for this (there are some where the empty program does the trick) - this is about finding the shortest solution in every language. Therefore, no answer will be marked as accepted.

Catalogue

The Stack Snippet at the bottom of this post generates the catalogue from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.

To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:

```<code>## Language Name, N bytes
</code>```

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:

```<code>## Ruby, <s>104</s> <s>101</s> 96 bytes
</code>```

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:

```<code>## Perl, 43 + 2 (-p flag) = 45 bytes
</code>```

You can also make the language name a link which will then show up in the snippet:

```<code>## [><>](http://esolangs.org/wiki/Fish), 121 bytes
</code>```

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

```

答:
Pylongolf2, 6 bytes

```<code>0>1+~<
</code>```

Have a zero in the stack and continously add up to it.

I could give a more detailed explanation.

Pylongolf2, 20 bytes (bonus)

```<code>cn:A0>1+~_A@1=?t¿d<
</code>```

Only works in beta 6, but this version asks for what number to count to.

Title: Count up forever

Body:
Pylongolf2, 6 bytes

0>1+~<

Have a zero in the stack and continously add up to it.

I could give a more detailed explanation.

Pylongolf2, 20 bytes (bonus)

cn:A0>1+~_A@1=?t¿d<

Only works in beta 6, but this version asks for what number to count to.


答:
PHP, 368 bytes

```<code>$str = "pa55 w0rd";
$str = str_replace(" ","_",$str);
$output AND $numStr = "";
$numArray = ['0','1','2','3','4','5','6','7','8','9'];
for($i=0;$i<strlen($str);$i++){
    in_array($str[$i],$numArray)?($numStr = $numStr.$str[$i]):((rand(10,100)%2==0)?$str[$i] = strtoupper($str[$i]) AND $output = $output.$str[$i]:$output = $output.$str[$i]);
}
echo $output = $output.$numStr;
</code>```

Ungolfed Code:

```<code>$str = "pa55 w0rd";
$str = str_replace(" ","_",$str);
$len = strlen($str);
$output = "";
$numStr = "";
$numArray = ['0','1','2','3','4','5','6','7','8','9'];
for($i=0;$i<$len;$i++){
  if(in_array($str[$i],$numArray)){
    $numStr = $numStr.$str[$i];
  }else {
      if(rand(10,100)%2==0)
      {
        $str[$i] = strtoupper($str[$i]);
      }
      $output = $output.$str[$i];
  }
}
$output = $output.$numStr;
echo $output;
</code>```

Title: Passwordify the string

Body:
Your challenge is to passwordify the string! What is passwordifying, you ask?

Take a string as input. This string will only contain uppercase letters, lowercase letters, digits, and spaces.

You must replace all spaces with underscores and move all numbers to the end of the string in the order that they appear from left to right. Then, for every letter in the string, randomly change it to uppercase or lowercase.

Examples (case of characters should vary every time):

```<code>Input
Hello world
Output
HElLo_wORld

Input
pa55 w0rd
Output
pA_Wrd550

Input
14 35
Output
_1435

Input
0971
Output
0971

Input
[space]
Output
_
</code>```

Shortest code in bytes wins!

Whoever asks on Information Security SE if this is a good hashing algorithm wins!--Don't worry SE overlords, I'm just kidding.

Body:
PHP, 368 bytes

$str = "pa55 w0rd";
$str = str_replace(" ","_",$str);
$output AND $numStr = "";
$numArray = ['0','1','2','3','4','5','6','7','8','9'];
for($i=0;$i<strlen($str);$i++){
    in_array($str[$i],$numArray)?($numStr = $numStr.$str[$i]):((rand(10,100)%2==0)?$str[$i] = strtoupper($str[$i]) AND $output = $output.$str[$i]:$output = $output.$str[$i]);
}
echo $output = $output.$numStr;

Ungolfed Code:

$str = "pa55 w0rd";
$str = str_replace(" ","_",$str);
$len = strlen($str);
$output = "";
$numStr = "";
$numArray = ['0','1','2','3','4','5','6','7','8','9'];
for($i=0;$i<$len;$i++){
  if(in_array($str[$i],$numArray)){
    $numStr = $numStr.$str[$i];
  }else {
      if(rand(10,100)%2==0)
      {
        $str[$i] = strtoupper($str[$i]);
      }
      $output = $output.$str[$i];
  }
}
$output = $output.$numStr;
echo $output;


问:
Implement a Truth-Machine
A truth-machine (credits goes to this guy for coming up with it) is a very simple program designed to demonstrate the I/O and control flow of a language. Here's what a truth-machine does:

Gets a number (either 0 or 1) from STDIN.

If that number is 0, print out 0 and terminate.

If that number is 1, print out 1 forever.

Challenge

Write a truth-machine as described above in your language of choice. The truth-machine must be a full program that follows these rules:

take input from STDIN or an acceptable alternative

If your language cannot take input from STDIN, it may take input from a hardcoded variable or suitable equivalent in the program

must output to STDOUT or an acceptable alternative

If your language is incapable of outputting the characters 0 or 1, byte or unary I/O is acceptable.

when the input is 1, it must continually print 1s and only stop if the program is killed or runs out of memory

the output must only be either a 0 followed by either one or no newline or space, or infinite 1s with each 1 followed by either one or no newline or space. No other output can be generated, except constant output of your language's interpreter that cannot be suppressed (such as a greeting, ANSI color codes or indentation). Your usage of newlines or spaces must be consistent: for example, if you choose to output 1 with a newline after it all 1s must have a newline after them.

if and only if your language cannot possibly terminate on an input of 0 it is acceptable for the code to enter an infinite loop in which nothing is outputted.

Since this is a catalog, languages created after this challenge are allowed to compete. Note that there must be an interpreter so the submission can be tested. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language. Other than that, all the standard rules of code-golf must be obeyed. Submissions in most languages will be scored in bytes in an appropriate preexisting encoding (usually UTF-8).

Catalog

The Stack Snippet at the bottom of this post generates the catalog from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.

To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:

```<code>## Language Name, N bytes
</code>```

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:

```<code>## Ruby, <s>104</s> <s>101</s> 96 bytes
</code>```

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:

```<code>## Perl, 43 + 2 (-p flag) = 45 bytes
</code>```

You can also make the language name a link which will then show up in the snippet:

```<code>## [><>](http://esolangs.org/wiki/Fish), 121 bytes
</code>```

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

```

答:
Pylongolf2, 11 bytes

```<code>1r1=?1>~<¿
</code>```

Explanations:

```<code>1           push 1 to the stack
 r          pick a random number between 0 and 1
  0=        push 1 to the stack and compare them
    ?1>~<¿  if true, push 1 to the stack then print it forever.
            terminate
</code>```

Title: Implement a Truth-Machine

Body:
Pylongolf2, 11 bytes

1r1=?1>~<¿

Explanations:

1           push 1 to the stack
 r          pick a random number between 0 and 1
  0=        push 1 to the stack and compare them
    ?1>~<¿  if true, push 1 to the stack then print it forever.
            terminate