答:
APL, 87

```<code>t[3]←(1+3⌷t←137 91 4 100⊤⍎2⍕⎕÷864)⌷'Looplab' 'Sevit' 'Hexteria' 'Sinpad'
'  '⎕R'-'⍕t
</code>```

APL has an advantage in these time system conversion challenges due to the built-in encode function, at the cost of expensive string manipuation

Explanation

(using 1357510372 as example)

⎕÷864 takes user input from screen, divide by 864 (1571192.56018519)

⍎2⍕ and round to 2 dp.  (1571192.56)

137 91 4 100⊤ Then, converts to Noxu Time System (43 14 3 92.56)

t← and assign that to variable t.

1+3⌷ take the 3rd item from t, add 1 to account for 1-based indexing, (4)

(...)⌷'Looplab' 'Sevit' 'Hexteria' 'Sinpad' convert to Skizzle name, (Sinpad)

t[3]← and finally plug back into the 3rd item of t.

⍕t Convert t to a string representation, (43 14  Sinpad  92.56)

'  '⎕R'-' and replaces 2 spaces with a dash (43 14-Sinpad-92.56)

Title: Gregorian to Noxu Time System Conversion

Body:
The world's changing to a new time system!  We need to update our computer programs.  Given an input of epoch time (number of seconds since January 1st, 1970 00:00), print out a time in the new Noxu date-time format.

864 seconds make one Fluffster.  100 Fluffsters make a Skizzle.  There are 4 Skizzles in one Zestpond.  Their names are Looplab, Sevit, Hexteria, and Sinpad.  There are 91 Zestponds in one Lulerain.

The format is Lulerain Zestpond-Skizzle-Fluffster.  Fluffsters are rounded to two decimal places.  An example would be 50 13-Sevit-40.90.

Given that epoch 0 was 0 0-Looplab-00.00, create a program that takes input either via stdin or as a command line argument of any epoch time between 0 and 2^32, and prints out the Noxu equivalent.

Time of edit:

```<code>1357510372 -> 43 14-Sinpad-92.56
</code>```

Random test data:

```<code>675416077 -> 21 43-Sevit-31.57
330585453 -> 10 46-Hexteria-22.05
1328127085 -> 42 20-Sinpad-84.13
837779784 -> 26 58-Looplab-52.53
1240280676 -> 39 39-Sinpad-10.04
122646385 -> 3 81-Sinpad-51.83
1311245658 -> 41 63-Looplab-45.44
57792972 -> 1 76-Looplab-90.01
788388068 -> 25 6-Looplab-86.19
304341865 -> 9 61-Hexteria-47.53
417857784 -> 13 26-Looplab-31.69
671276878 -> 21 31-Sevit-40.83
1259758896 -> 40 5-Looplab-54.28
604286664 -> 19 19-Hexteria-5.86
646395018 -> 20 50-Sevit-42.38
563025133 -> 17 82-Looplab-49.46
96133144 -> 3 5-Looplab-65.21
101542552 -> 3 20-Sinpad-26.10
1006825856 -> 32 1-Sevit-7.70
928867348 -> 29 48-Hexteria-77.95
1235022079 -> 39 24-Hexteria-23.70
439505287 -> 13 88-Hexteria-86.67
99686711 -> 3 15-Sevit-78.14
379859609 -> 12 7-Looplab-52.33
1167091685 -> 37 10-Looplab-0.56
612032437 -> 19 41-Sinpad-70.88
503040778 -> 15 90-Hexteria-23.12
1084809411 -> 34 44-Sinpad-66.45
1105664386 -> 35 14-Sevit-4.15
197303893 -> 6 24-Sinpad-60.99
368559287 -> 11 65-Sevit-73.25
686824300 -> 21 76-Sevit-35.53
196468204 -> 6 22-Sevit-93.75
673542185 -> 21 37-Sinpad-62.71
993063782 -> 31 52-Sevit-79.38
270951743 -> 8 56-Looplab-1.55
1074506753 -> 34 15-Looplab-42.08
198143696 -> 6 27-Sevit-32.98
539601298 -> 17 14-Sevit-38.54
110090607 -> 3 45-Hexteria-19.68
276492708 -> 8 72-Looplab-14.71
113389138 -> 3 55-Looplab-37.43
571578220 -> 18 15-Sinpad-48.87
1238516450 -> 39 34-Hexteria-68.11
742293312 -> 23 54-Sinpad-35.78
1031929490 -> 32 73-Sinpad-62.84
503091914 -> 15 90-Hexteria-82.31
264094386 -> 8 36-Looplab-64.80
483820698 -> 15 34-Sinpad-77.66
548410387 -> 17 39-Sinpad-34.24
</code>```

Body:
APL, 87

t[3]←(1+3⌷t←137 91 4 100⊤⍎2⍕⎕÷864)⌷'Looplab' 'Sevit' 'Hexteria' 'Sinpad'
'  '⎕R'-'⍕t

APL has an advantage in these time system conversion challenges due to the built-in encode function, at the cost of expensive string manipuation

Explanation

(using 1357510372 as example)

⎕÷864 takes user input from screen, divide by 864 (1571192.56018519)

⍎2⍕ and round to 2 dp.  (1571192.56)

137 91 4 100⊤ Then, converts to Noxu Time System (43 14 3 92.56)

t← and assign that to variable t.

1+3⌷ take the 3rd item from t, add 1 to account for 1-based indexing, (4)

(...)⌷'Looplab' 'Sevit' 'Hexteria' 'Sinpad' convert to Skizzle name, (Sinpad)

t[3]← and finally plug back into the 3rd item of t.

⍕t Convert t to a string representation, (43 14  Sinpad  92.56)

'  '⎕R'-' and replaces 2 spaces with a dash (43 14-Sinpad-92.56)


问:
Is it an Odd Word?

Challenge

Given a single word as input, determine if the word is odd or even.

Odd and Even words

Assume the general rules:

```<code>odd + odd = even
even + odd = odd
odd + even = odd
even + even = even
</code>```

In the alphabet, the odd letters are:

```<code>aeiou
</code>```

And the even letters are:

```<code>bcdfghjklmnpqrstvwxyz
</code>```

The same applies to capital letters (AEIOU are odd and BCDFGHJKLMNPQRSTVWXYZ are even).

You then 'add' each of the letters in the word together. For example, the word cats is equivalent to:

```<code>even + odd + even + even
</code>```

Which simplifies to:

```<code>odd + even
</code>```

Which simplifies further to:

```<code>odd
</code>```

So the word cats is odd.

Examples

```<code>Input:  trees
Output: even
</code>```

```<code>Input:  brush
Output: odd
</code>```

```<code>Input:  CAts
Output: odd
</code>```

```<code>Input:  Savoie
Output: even
</code>```

```<code>Input:  rhythm
Output: even
</code>```

Rules

All input will be a single word which will only contain alphabetical characters.

If the word is odd, output a truthy value. If the word is even, output a falsey value.

Winning

The shortest code in bytes wins.

答:
Dyalog APL, 17 bytes

2|≢⍞∩'aeiouAEIOU'
```

TryAPL online!

ContentLicense: CC BY-SA 3.0

Title: Is it an Odd Word?

Body:
Dyalog APL, 17 bytes

2|≢⍞∩'aeiouAEIOU'

TryAPL online!


问:
Find the largest number that's adjacent to a zero
Challenge:

Take a vector / list of integers as input, and output the largest number that's adjacent to a zero.

Specifications:

As always, optional input and output format

You may assume that there will be at least one zero, and at least one non-zero element.

Test cases:

```<code>1 4 3 6 0 3 7 0
7

9 4 9 0 9 0 9 15 -2
9

-4 -6 -2 0 -9
-2

-11 0 0 0 0 0 -12 10
0

0 20
20
</code>```

Good luck and happy golfing!

Body:
Ruby, 51 bytes

->a{a.each_cons(2).map{|a,b|a*b!=0?-1.0/0:a+b}.max}

usage

f=->a{a.each_cons(2).map{|a,b|a*b!=0?-1.0/0:a+b}.max}
p f[gets.split.map(&:to_i)]


答:
Mathematica, <s>46</s> 43 bytes

Saved 3 bytes due to @MartinEnder.

```<code>Max[Tr/@Partition[#,2,1]~Select~MemberQ@0]&
</code>```

Anonymous function. Takes a list of integers as input and returns an integer as output. Based off of the Ruby solution.

Title: Find the largest number that's adjacent to a zero

Body:
Challenge:

Take a vector / list of integers as input, and output the largest number that's adjacent to a zero.

Specifications:

As always, optional input and output format

You may assume that there will be at least one zero, and at least one non-zero element.

Test cases:

```<code>1 4 3 6 0 3 7 0
7

9 4 9 0 9 0 9 15 -2
9

-4 -6 -2 0 -9
-2

-11 0 0 0 0 0 -12 10
0

0 20
20
</code>```

Good luck and happy golfing!

Body:
Mathematica, <s>46</s> 43 bytes

Saved 3 bytes due to @MartinEnder.

Max[Tr/@Partition[#,2,1]~Select~MemberQ@0]&

Anonymous function. Takes a list of integers as input and returns an integer as output. Based off of the Ruby solution.


答:
Python 2, 74 Bytes

```<code>def f(x):x=[9]+x;print max(x[i]for i in range(len(x)) if 0in x[i-1:i+2:2])
</code>```

Cycle through every element, if there's a 0 in the position of either the left or the right of the current element, include it in the generator, and then run it through max. We need to pad the list with some non-0 number. It'll never be included because the slice [-1:2:2] won't include anything.

Body:
Python 2, 74 Bytes

def f(x):x=[9]+x;print max(x[i]for i in range(len(x)) if 0in x[i-1:i+2:2])

Cycle through every element, if there's a 0 in the position of either the left or the right of the current element, include it in the generator, and then run it through max. We need to pad the list with some non-0 number. It'll never be included because the slice [-1:2:2] won't include anything.


答:
JavaScript (ES6), 53 bytes

```<code>a=>(m=-1/0,a.reduce((l,r)=>(m=l*r||l+r<m?m:l+r,r)),m)
</code>```

Because I like using reduce. Alternative solution, also 53 bytes:

```<code>a=>Math.max(...a.map((e,i)=>e*a[++i]==0?e+a[i]:-1/0))
</code>```

Body:
JavaScript (ES6), 53 bytes

a=>(m=-1/0,a.reduce((l,r)=>(m=l*r||l+r<m?m:l+r,r)),m)

Because I like using reduce. Alternative solution, also 53 bytes:

a=>Math.max(...a.map((e,i)=>e*a[++i]==0?e+a[i]:-1/0))


答:
C# <s>76</s> 74 bytes

```<code>using System.Linq;i=>i.Zip(i.Skip(1),(a,b)=>a*b==0?1<<31:a+b).Max();
</code>```

Explanation:

Use zip to join the array with itself but skipping the first value in the 2nd reference so that item zero joins to item one.  Multiply a times b, if the result is zero, one of them must be zero and output a + b.  Otherwise, output the minimum possible integer in the language.  Given the assumption that we will always have a zero and a non-zero, this minimum value will never be output as the max.

Usage:

```<code>[TestMethod]
public void LargestFriend()
{
    Assert.AreEqual(7, F(new int[] { 1, 4, 3, 6, 0, 3, 7, 0 }));
    Assert.AreEqual(9, F(new int[] { 9, 4, 9, 0, 9, 0, 9, 15, -2 }));
    Assert.AreEqual(-2, F(new int[] { -4, -6, -2, 0, -9 }));
    Assert.AreEqual(0, F(new int[] { -11, 0, 0, 0, 0, 0, -12, 10 }));
    Assert.AreEqual(20, F(new int[] { 0, 20 }));
}
</code>```

Body:
C# <s>76</s> 74 bytes

using System.Linq;i=>i.Zip(i.Skip(1),(a,b)=>a*b==0?1<<31:a+b).Max();

Explanation:

Use zip to join the array with itself but skipping the first value in the 2nd reference so that item zero joins to item one.  Multiply a times b, if the result is zero, one of them must be zero and output a + b.  Otherwise, output the minimum possible integer in the language.  Given the assumption that we will always have a zero and a non-zero, this minimum value will never be output as the max.

Usage:

[TestMethod]
public void LargestFriend()
{
    Assert.AreEqual(7, F(new int[] { 1, 4, 3, 6, 0, 3, 7, 0 }));
    Assert.AreEqual(9, F(new int[] { 9, 4, 9, 0, 9, 0, 9, 15, -2 }));
    Assert.AreEqual(-2, F(new int[] { -4, -6, -2, 0, -9 }));
    Assert.AreEqual(0, F(new int[] { -11, 0, 0, 0, 0, 0, -12, 10 }));
    Assert.AreEqual(20, F(new int[] { 0, 20 }));
}


问:
Cops and Robbers bowling (Cops)

Cops' Thread

In this challenge, your goal is to write a function that accepts a integer N, and that function will return the first N primes.  However, you must do this in the most characters possible.

You may use any method you wish to produce the primes.

You are not allowed to modify your code after posting.

Only printable ASCII characters are allowed.

A character cannot appear in your code more than 100 times.

However, after posting your answer, the robbers will have the opportunity to crack your code by posting a modified version of your code.  Your code is considered cracked if:

The modified code has a maximum levenshtein-distance of 10 from yours, and has fewer characters.

The function, given the same valid input, will produce the same output in the same language of the same version

The robber posted the modified version within 168 hours (1 week) of your post.

If a robber failed to crack your code within 168 hours, your code is considered safe.  The winner of this challenge is the cop with the longest safe code.

The title of your thread should contain the language, the number of characters, and the current status (Open, Cracked, Safe) of your code.

The accompanying robbers thread can be found here

Relevant tools

Frequency counter

Character counter

Levenshtein distance

You can also use this snippet to calculate the Levenshtein distance:

var f=document.getElementById("f"),g=document.getElementById("s"); function h(){var a=f.value,e=g.value;if(128<a.length)a="First program is too long!";else if(128<e.length)a="Second program is too long!";else{if(0===a.length)a=e.length;else if(0===e.length)a=a.length;else{var d=[],b;for(b=0;b<=e.length;b++)d[b]=[b];var c;for(c=0;c<=a.length;c++)d[0][c]=c;for(b=1;b<=e.length;b++)for(c=1;c<=a.length;c++)d[b][c]=e.charAt(b-1)===a.charAt(c-1)?d[b-1][c-1]:Math.min(d[b-1][c-1]+1,Math.min(d[b][c-1]+1,d[b-1][c]+ 1));a=d[e.length][a.length]}a="Distance = "+a+""}document.getElementById("d").innerHTML=a}f.onkeyup=h;g.onkeyup=h;```
<pre class="snippet-code-html lang-html prettyprint-override"><code><h3 id=ft>First program</h3>
<textarea id=f rows=7 cols=80 style="width:100%"></textarea>
<h3 id=st>Second program</h3>
<textarea id=s rows=7 cols=80 style="width:100%"></textarea>
<p id=d></p></code>```

Credits to Doorknob!

答:
Haskell, 924 bytes (Safe)

```<code>import Data.Numbers.Primes
f n=take n$id=<<id=<<fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)id[[primes]]
</code>```

That's a total of 192 fmaps. If you had enough memory to actually compile this (you don't), ghc would factorize it to fmap.fmap.fmap. You crack my answer if you can prove that a (<$>) can be replaced with a (.).

I could make this longer, but I'm just going for the best Haskell answer really..

Edit:

Safe! I might come back to this actually. This is the same kind of problem as RSA; it is provably possible to factorize, it just takes silly amounts of computational power.

Title: Cops and Robbers bowling (Cops)

Body:
Haskell, 924 bytes (Safe)

import Data.Numbers.Primes
f n=take n$id=<<id=<<fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)fmap(<$>)id[[primes]]

That's a total of 192 fmaps. If you had enough memory to actually compile this (you don't), ghc would factorize it to fmap.fmap.fmap. You crack my answer if you can prove that a (<$>) can be replaced with a (.).

I could make this longer, but I'm just going for the best Haskell answer really..

Edit:

Safe! I might come back to this actually. This is the same kind of problem as RSA; it is provably possible to factorize, it just takes silly amounts of computational power.


问:
Jimmy these arrays down
My coworker, Jimmy is kinda new to C/C++. He's also kind of a slow learner. Now, to be fair, his code always compiles, but he has some really sloppy habits. For example, everybody knows that you can define an array like this:

```<code>int spam[] = {4, 8, 15, 16, 23, 42};
</code>```

Everybody that is, except for Jimmy. He is convinced that the only way to make an array is like this:

```<code>int spam[6];
spam[0] = 4;
spam[1] = 8;
spam[2] = 15;
spam[3] = 16;
spam[4] = 23;
spam[5] = 42;
</code>```

I keep fixing this for him in code-review, but he won't learn. So I need you to write a tool that automagically does this for him when he commits¹.

The challenge

I want you to write either a full program or a function that takes in a multiline string as input, and outputs the more compact version of the C array. The input will always follow this format, whitespace included:

```<code>identifier_one identifier_two[some_length];
identifier_two[0] = some_number;
identifier_two[1] = some_number;
identifier_two[2] = some_number;
...
identifier_two[some_length - 1] = some_number;
</code>```

In short, the input will always be valid and well defined C. In more detail:

All of the identifiers will be made up of just letters and underscores. The length will always be at least one, and there will never be any missing or out of bounds indexes. You may also assume that the indexes are in order. For example:

```<code>foo bar[3];
bar[0] = 1
bar[2] = 9;
</code>```

<s></s>

```<code>foo bar[1];
bar[0] = 1;
bar[1] = 3;
</code>```

and

```<code>foo bar[3];
bar[2] = 9;
bar[0] = 1
bar[1] = 3
</code>```

are all invalid inputs, and may cause undefined behavior in your submission. You may also assume that all of the numbers will be valid decimal numbers, negative or positive. The input will not have extraneous spaces. The output should always follow this format, whitespace included:

```<code>identifier_one identifier_two[] = {n1, n2, n3, ...};
</code>```

Here is some sample data:

```<code>Input:
spam eggs[10];
eggs[0] = 0;
eggs[1] = 4;
eggs[2] = 8;
eggs[3] = -3;
eggs[4] = 3;
eggs[5] = 7;
eggs[6] = 888;
eggs[7] = 555;
eggs[8] = 0;
eggs[9] = -2;

Output:
spam eggs[] = {0, 4, 8, -3, 3, 7, 888, 555, 0, -2};

Input:
char ans[2];
ans[0] = 52;
ans[1] = 50;

Output:
char ans[] = {52, 50};

Input:
blah_blah quux[1];
quux[0] = 105;

Output:
blah_blah quux[] = {105};
</code>```

You may take your input and output in any reasonable format, such as STDIN/STDOUT, function arguments and return value, reading and writing files etc. Standard loopholes apply. The shortest answer in bytes wins!

¹This is passive-aggressive and a terrible idea. You did not get this idea from me.

Title: Jimmy these arrays down

Body:
Ruby, 64 bytes

->{gets.split(?[)[0]+"[]={"+$<.map{|s|s.scan /\ -?\d+/}*?,+"};"}


答:
R, 49 bytes

```<code>f=function(x)nchar(gsub("[^aeiou]","",x,i=T))%%2==0
</code>```

Examples:

```<code>> f("cats")
[1] FALSE

> f("Savoie")
[1] TRUE
</code>```

If it doesn't need a function and I can assume x is the input:

36 bytes:

```<code>!nchar(gsub("[^aeiou]","",x,i=T))%%2
</code>```

If I can allow an output of 0 for even and 1 for odd:

35 bytes:

```<code>nchar(gsub("[^aeiou]","",x,i=T))%%2
</code>```

Explanation

I'm substituting all vowels with blank character, ignoring case (i=T). This works because the i is enough to unambigiously identify the ignore.case argument and T is short for TRUE. Then count the odd characters and see if there's a remainder. If a number isn't a good response, I use ! (not) to coerce the 0/1 to TRUE/FALSE.

Title: Is it an Odd Word?

Body:
Challenge

Given a single word as input, determine if the word is odd or even.

Odd and Even words

Assume the general rules:

```<code>odd + odd = even
even + odd = odd
odd + even = odd
even + even = even
</code>```

In the alphabet, the odd letters are:

```<code>aeiou
</code>```

And the even letters are:

```<code>bcdfghjklmnpqrstvwxyz
</code>```

The same applies to capital letters (AEIOU are odd and BCDFGHJKLMNPQRSTVWXYZ are even).

You then 'add' each of the letters in the word together. For example, the word cats is equivalent to:

```<code>even + odd + even + even
</code>```

Which simplifies to:

```<code>odd + even
</code>```

Which simplifies further to:

```<code>odd
</code>```

So the word cats is odd.

Examples

```<code>Input:  trees
Output: even
</code>```

```<code>Input:  brush
Output: odd
</code>```

```<code>Input:  CAts
Output: odd
</code>```

```<code>Input:  Savoie
Output: even
</code>```

```<code>Input:  rhythm
Output: even
</code>```

Rules

All input will be a single word which will only contain alphabetical characters.

If the word is odd, output a truthy value. If the word is even, output a falsey value.

Winning

The shortest code in bytes wins.

Body:
R, 49 bytes

f=function(x)nchar(gsub("[^aeiou]","",x,i=T))%%2==0

Examples:

> f("cats")
[1] FALSE

> f("Savoie")
[1] TRUE

If it doesn't need a function and I can assume x is the input:

36 bytes:

!nchar(gsub("[^aeiou]","",x,i=T))%%2

If I can allow an output of 0 for even and 1 for odd:

35 bytes:

nchar(gsub("[^aeiou]","",x,i=T))%%2

Explanation

I'm substituting all vowels with blank character, ignoring case (i=T). This works because the i is enough to unambigiously identify the ignore.case argument and T is short for TRUE. Then count the odd characters and see if there's a remainder. If a number isn't a good response, I use ! (not) to coerce the 0/1 to TRUE/FALSE.


问:
print 1 to 100 without using recursion and conditions
can we print 1 to 100 without using any if conditions and loops in c&c++?

Conditon:
main point is you must not use recursion...and doesnt hardcode code in it
for e.g

print(1 2 3..etc);

答:
Pygmy, (18 characters)

```<code>alert|[1 100].fill
</code>```

Body:
Pygmy, (18 characters)

alert|[1 100].fill


答:
Java 7, <s>118</s> <s>105</s> 106 bytes

```<code>int d(int[]a){int i=0,m=1<<31,c;for(;++i<a.length;m=a[i]*a[i-1]==0&(c=a[i]+a[i-1])>m?c:m);return m;}
</code>```

13 bytes saved thanks to @cliffroot by using an arithmetic approach instead. 1 additional byte thank to @mrco after he discovered a bug (the added test case 2, 1, 0 would return 2 instead of 1).

Ungolfed & test code:

Try it here.

```<code>class M{
  static int c(int[] a){
    int i,
        m = a[i=0],
        c;
    for(; ++i < a.length; m = a[i] * a[i-1] == 0 & (c = a[i] + a[i - 1]) > m)
                           ? c
                           : m);
    return m;
  }

  public static void main(String[] a){
    System.out.println(c(new int[]{ 1, 4, 3, 6, 0, 3, 7, 0 }));
    System.out.println(c(new int[]{ 9, 4, 9, 0, 9, 0, 9, 15, -2 }));
    System.out.println(c(new int[]{ -4, -6, -2, 0, -9 }));
    System.out.println(c(new int[]{ -11, 0, 0, 0, 0, 0, -12, 10 }));
    System.out.println(c(new int[]{ 0, 20 }));
    System.out.println(c(new int[]{ 2, 1, 0 }));
  }
}
</code>```

Output:

```<code>7
9
-2
0
20
1
</code>```

Body:
Java 7, <s>118</s> <s>105</s> 106 bytes

int d(int[]a){int i=0,m=1<<31,c;for(;++i<a.length;m=a[i]*a[i-1]==0&(c=a[i]+a[i-1])>m?c:m);return m;}

13 bytes saved thanks to @cliffroot by using an arithmetic approach instead. 1 additional byte thank to @mrco after he discovered a bug (the added test case 2, 1, 0 would return 2 instead of 1).

Ungolfed & test code:

Try it here.

class M{
  static int c(int[] a){
    int i,
        m = a[i=0],
        c;
    for(; ++i < a.length; m = a[i] * a[i-1] == 0 & (c = a[i] + a[i - 1]) > m)
                           ? c
                           : m);
    return m;
  }

  public static void main(String[] a){
    System.out.println(c(new int[]{ 1, 4, 3, 6, 0, 3, 7, 0 }));
    System.out.println(c(new int[]{ 9, 4, 9, 0, 9, 0, 9, 15, -2 }));
    System.out.println(c(new int[]{ -4, -6, -2, 0, -9 }));
    System.out.println(c(new int[]{ -11, 0, 0, 0, 0, 0, -12, 10 }));
    System.out.println(c(new int[]{ 0, 20 }));
    System.out.println(c(new int[]{ 2, 1, 0 }));
  }
}

Output:

7
9
-2
0
20
1


答:
Jelly, 8 bytes

```<code>ṡ2ẠÐḟS€Ṁ
</code>```

Try it online!

```<code>ṡ2            Overlapping pairs
  ẠÐḟ         Remove pairs without zeroes
     S€       Sum of each pair
       Ṁ      Maximum
</code>```

Body:
Jelly, 8 bytes

ṡ2ẠÐḟS€Ṁ

Try it online!

ṡ2            Overlapping pairs
  ẠÐḟ         Remove pairs without zeroes
     S€       Sum of each pair
       Ṁ      Maximum


答:
R, 48 47 bytes

EDIT:
Fixed an error thanks to @Vlo and changed it to read input from stdins, saved one byte by assigning w and skipping parantheses.

```<code>function(v)sort(v[c(w<-which(v==0)-1,w+1)],T)[1]
</code>```

```<code>v=scan();w=which(v==0);sort(v[c(w-1,w+1)],T)[1]
</code>```

Unnested explanation

Find indices for which the vector v takes on the values 0: w <- which(v == 0)

Create new vector which contains the indices +-1: w-1 and w+1

Extract elements that match the indices w-1 and w+1

Sort in descending order and extract fist element

Note that if the last or first element of v is a zero, w+-1 will effectively fetch an index outside of the length of the vector which implies that v[length(v)+1] returns NA. This is generally no problem but the max() functions inconveniently returns NA if there are any occurrences in the vector unless one specifies the option na.rm=T. Thus it is 2 bytes shorter to sort and extract first element than to use max(), e.g.:

```<code>max(x,na.rm=T)
sort(x,T)[1]
</code>```

Body:
R, 48 47 bytes

EDIT:
Fixed an error thanks to @Vlo and changed it to read input from stdins, saved one byte by assigning w and skipping parantheses.

function(v)sort(v[c(w<-which(v==0)-1,w+1)],T)[1]

v=scan();w=which(v==0);sort(v[c(w-1,w+1)],T)[1]

Unnested explanation

Find indices for which the vector v takes on the values 0: w <- which(v == 0)

Create new vector which contains the indices +-1: w-1 and w+1

Extract elements that match the indices w-1 and w+1

Sort in descending order and extract fist element

Note that if the last or first element of v is a zero, w+-1 will effectively fetch an index outside of the length of the vector which implies that v[length(v)+1] returns NA. This is generally no problem but the max() functions inconveniently returns NA if there are any occurrences in the vector unless one specifies the option na.rm=T. Thus it is 2 bytes shorter to sort and extract first element than to use max(), e.g.:

max(x,na.rm=T)
sort(x,T)[1]


问:
Substring Chainification

Introduction

For this example, let's take the string Hello, World! and the array [3, 2, 3]. To find the substring chain, we go through the following process:

The first number of the array is 3, so we get the substring [0 - 3], which is Hel. After that, we remove the first 3 characters from the initial string, which leaves us with lo, World!.

The second number of the array is 2, so we get the substring [0 - 2] from our new string, which gives us lo. The leftover string becomes , World!.

The last number is a 3, which gives us , W. The substring chain is all of the substrings combined, which gives us:

```<code>['Hel', 'lo', ', W']
</code>```

For a more visual example:

```<code>[3, 2, 3], 'Hello, World!'
3 -> Hel
2 ->    lo
3 ->      , W
</code>```

The task

Given a non-empty string and a non-empty array only consisting of positive integers (> 0), output the substring chain. You may assume that the sum of all integers in the array does not exceed the length of the string.

You can also assume that the strings will never contain any newlines.

Test cases

```<code>Input: abcdefghijk, [2, 1, 3]
Output: ['ab', 'c', 'def']

Input: Code Golf, [4, 1]
Output: ['Code', ' ']

Input: Ayyy, [3]
Output: ['Ayy']

Input: lexicographically, [2, 2, 2, 7, 4]
Output: ['le', 'xi', 'co', 'graphic', 'ally']
</code>```

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

答:
Dyalog APL 16.0, 15 characters  (non-competing); 15.0, 17 bytes

16.0 solution

{⍵⊆⍨(⍴⍵)↑⍺/+\⍺}
```
<p>Dyalog APL 16.0 adds APL2's partition primitive, <code>⊂</code>, with the glyph <code>⊆</code>.</p>
<h3>15.0 solution:</h3>
<pre class="lang-apl prettyprint-override"><code>{(-⍺)↑¨(+\⍺)↑¨⊂⍵}
</code>```

TryAPL online!

Title: Substring Chainification

Body:
Dyalog APL 16.0, 15 characters  (non-competing); 15.0, 17 bytes

16.0 solution

{⍵⊆⍨(⍴⍵)↑⍺/+\⍺}

Dyalog APL 16.0 adds APL2's partition primitive, ⊂, with the glyph ⊆.

15.0 solution:

{(-⍺)↑¨(+\⍺)↑¨⊂⍵}

TryAPL online!


答:
Jelly, 27 bytes

```<code>Ỵ©ḢḟØDṖ“ = {”®Ḳ€Ṫ€Ṗ€j⁾, ⁾};
</code>```

Try it online!

Explanation

```<code>Ỵ         Split into lines
 ©Ḣ       Take the first one, store the others in ®
   ḟØD    Remove digits
      Ṗ   Remove trailing ;

“ = {”    Print a literal string

®         Recall the remaining lines
 Ḳ€       Split each into words
   Ṫ€     Keep each last word
     Ṗ€   Remove each trailing ;

j⁾,       Join by “, ”
    ⁾};   Literal “};”
</code>```

Title: Jimmy these arrays down

Body:
My coworker, Jimmy is kinda new to C/C++. He's also kind of a slow learner. Now, to be fair, his code always compiles, but he has some really sloppy habits. For example, everybody knows that you can define an array like this:

```<code>int spam[] = {4, 8, 15, 16, 23, 42};
</code>```

Everybody that is, except for Jimmy. He is convinced that the only way to make an array is like this:

```<code>int spam[6];
spam[0] = 4;
spam[1] = 8;
spam[2] = 15;
spam[3] = 16;
spam[4] = 23;
spam[5] = 42;
</code>```

I keep fixing this for him in code-review, but he won't learn. So I need you to write a tool that automagically does this for him when he commits¹.

The challenge

I want you to write either a full program or a function that takes in a multiline string as input, and outputs the more compact version of the C array. The input will always follow this format, whitespace included:

```<code>identifier_one identifier_two[some_length];
identifier_two[0] = some_number;
identifier_two[1] = some_number;
identifier_two[2] = some_number;
...
identifier_two[some_length - 1] = some_number;
</code>```

In short, the input will always be valid and well defined C. In more detail:

All of the identifiers will be made up of just letters and underscores. The length will always be at least one, and there will never be any missing or out of bounds indexes. You may also assume that the indexes are in order. For example:

```<code>foo bar[3];
bar[0] = 1
bar[2] = 9;
</code>```

<s></s>

```<code>foo bar[1];
bar[0] = 1;
bar[1] = 3;
</code>```

and

```<code>foo bar[3];
bar[2] = 9;
bar[0] = 1
bar[1] = 3
</code>```

are all invalid inputs, and may cause undefined behavior in your submission. You may also assume that all of the numbers will be valid decimal numbers, negative or positive. The input will not have extraneous spaces. The output should always follow this format, whitespace included:

```<code>identifier_one identifier_two[] = {n1, n2, n3, ...};
</code>```

Here is some sample data:

```<code>Input:
spam eggs[10];
eggs[0] = 0;
eggs[1] = 4;
eggs[2] = 8;
eggs[3] = -3;
eggs[4] = 3;
eggs[5] = 7;
eggs[6] = 888;
eggs[7] = 555;
eggs[8] = 0;
eggs[9] = -2;

Output:
spam eggs[] = {0, 4, 8, -3, 3, 7, 888, 555, 0, -2};

Input:
char ans[2];
ans[0] = 52;
ans[1] = 50;

Output:
char ans[] = {52, 50};

Input:
blah_blah quux[1];
quux[0] = 105;

Output:
blah_blah quux[] = {105};
</code>```

You may take your input and output in any reasonable format, such as STDIN/STDOUT, function arguments and return value, reading and writing files etc. Standard loopholes apply. The shortest answer in bytes wins!

¹This is passive-aggressive and a terrible idea. You did not get this idea from me.

Body:
Jelly, 27 bytes

Ỵ©ḢḟØDṖ“ = {”®Ḳ€Ṫ€Ṗ€j⁾, ⁾};

Try it online!

Explanation

Ỵ         Split into lines
 ©Ḣ       Take the first one, store the others in ®
   ḟØD    Remove digits
      Ṗ   Remove trailing ;

“ = {”    Print a literal string

®         Recall the remaining lines
 Ḳ€       Split each into words
   Ṫ€     Keep each last word
     Ṗ€   Remove each trailing ;

j⁾,       Join by “, ”
    ⁾};   Literal “};”


答:
T-SQL, 182 bytes

Golfed:

```<code>DECLARE @x varchar(max)='1 5 4 3 6 1 3 17 1 -8 0 -7'

DECLARE @a INT, @b INT, @ INT WHILE @x>''SELECT @a=@b,@b=LEFT(@x,z),@x=STUFF(@x,1,z,''),@=IIF(@a=0,IIF(@b<@,@,@b),IIF(@b<>0 or @>@a,@,@a))FROM(SELECT charindex(' ',@x+' ')z)z PRINT @
</code>```

Ungolfed:

```<code>DECLARE @x varchar(max)='1 5 4 3 6 1 3 17 1 -8 0 -7'

DECLARE @a INT, @b INT, @ INT
WHILE @x>''
  SELECT
   @a=@b,
   @b=LEFT(@x,z),
   @x=STUFF(@x,1,z,''),
   @=IIF(@a=0,IIF(@b<@,@,@b),IIF(@b<>0 or @>@a,@,@a))
  FROM(SELECT charindex(' ',@x+' ')z)z
PRINT @
</code>```

Fiddle

Body:
T-SQL, 182 bytes

Golfed:

DECLARE @x varchar(max)='1 5 4 3 6 1 3 17 1 -8 0 -7'

DECLARE @a INT, @b INT, @ INT WHILE @x>''SELECT @a=@b,@b=LEFT(@x,z),@x=STUFF(@x,1,z,''),@=IIF(@a=0,IIF(@b<@,@,@b),IIF(@b<>0 or @>@a,@,@a))FROM(SELECT charindex(' ',@x+' ')z)z PRINT @

Ungolfed:

DECLARE @x varchar(max)='1 5 4 3 6 1 3 17 1 -8 0 -7'

DECLARE @a INT, @b INT, @ INT
WHILE @x>''
  SELECT
   @a=@b,
   @b=LEFT(@x,z),
   @x=STUFF(@x,1,z,''),
   @=IIF(@a=0,IIF(@b<@,@,@b),IIF(@b<>0 or @>@a,@,@a))
  FROM(SELECT charindex(' ',@x+' ')z)z
PRINT @

Fiddle


问:
Connect the pixels
Given a text like this:

```<code># #### ## #
## #  ##  #
   ####  ##
</code>```

Output the same text but by connecting the pixels with the characters ─│┌┐└┘├┤┬┴┼. If a pixel doesn't have any neighbours, don't change it.

So the output of the last text is:

```<code>│ ─┬── ┌─ │
└─ │  ┌┘  │
   └──┘  ─┘
</code>```

You can take input as a boolean array.

The input will always contain at least 1 pixel.

You can count box-drawing chars as 1 byte.

You can assume the input is padded with spaces.

Test cases

```<code>## #
=>
── #
</code>```

```<code>###
 #
=>
─┬─
 │
</code>```

```<code>##### ##
 # #  #
########
=>
─┬─┬─ ┌─
 │ │  │
─┴─┴──┴─
</code>```

```<code> # #
#####
 # #
=>
 │ │
─┼─┼─
 │ │
</code>```

```<code># # # # #
 # # # #
# # # # #
 # # # #
# # # # #
=>
# # # # #
 # # # #
# # # # #
 # # # #
# # # # #
</code>```

```<code>#####
#####
#####
#####
#####
=>
┌┬┬┬┐
├┼┼┼┤
├┼┼┼┤
├┼┼┼┤
└┴┴┴┘
</code>```

Since this is code-golf, the shortest code wins.

答:
MATL, 102 characters

I assign a neighbour a value (1, 2, 4 or 8); their sum will match a character in a string containing the drawing characters. I think there is still lots of room for improvements, but for a rough draft:

```<code>' #│││─┌└├─┐┘┤─┬┴┼' % String to be indexed
wt0J1+t4$(          % Get input, and append zeros at end of matrix (solely to avoid
                    %  indexing a non-existent second row/column for small inputs)
ttttt               % Get a whole load of duplicates to work on
3LXHY)              % Select rows 2:end from original matrix (one of the many dupes)
      w4LXIY)       % Select rows 1:end-1 from the 'destination' summing matrix)
             +HY(   % Add the neighbors below, store in 'destination' matrix
tIY)b3LY)2*+IY(     % +2* the neighbors above    +-------------------------------+
tHZ)b4LZ)4*+HZ(     % +4* the neighbors right    |(note: H and I contain 1:end-1 |
tIZ)b3LZ)8*+IZ(     % +8* the neighbors left     |  and 2:end respectively)      |
HH3$)               % Select the original matrix +-------------------------------+
*                % Make sure only cells that originally had a # get replaced
  1+)            % Add one because the original string is one-indexed. Index using ).
</code>```

Improvements to be made:

Possibly replace the whole summing part with some kind of loop working on rotated copies of the matrix

Ditch the entire thing and make something based on a single loop working through the matrix

Use modular indexing to work on a flattened vector from the original array (?)

Try it Online! (may not have box drawing characters support)

Title: Connect the pixels

Body:
MATL, 102 characters

I assign a neighbour a value (1, 2, 4 or 8); their sum will match a character in a string containing the drawing characters. I think there is still lots of room for improvements, but for a rough draft:

' #│││─┌└├─┐┘┤─┬┴┼' % String to be indexed
wt0J1+t4$(          % Get input, and append zeros at end of matrix (solely to avoid
                    %  indexing a non-existent second row/column for small inputs)
ttttt               % Get a whole load of duplicates to work on
3LXHY)              % Select rows 2:end from original matrix (one of the many dupes)
      w4LXIY)       % Select rows 1:end-1 from the 'destination' summing matrix)
             +HY(   % Add the neighbors below, store in 'destination' matrix
tIY)b3LY)2*+IY(     % +2* the neighbors above    +-------------------------------+
tHZ)b4LZ)4*+HZ(     % +4* the neighbors right    |(note: H and I contain 1:end-1 |
tIZ)b3LZ)8*+IZ(     % +8* the neighbors left     |  and 2:end respectively)      |
HH3$)               % Select the original matrix +-------------------------------+
*                % Make sure only cells that originally had a # get replaced
  1+)            % Add one because the original string is one-indexed. Index using ).

Improvements to be made:

Possibly replace the whole summing part with some kind of loop working on rotated copies of the matrix

Ditch the entire thing and make something based on a single loop working through the matrix

Use modular indexing to work on a flattened vector from the original array (?)

Try it Online! (may not have box drawing characters support)


答:
Dyalog APL, 14 bytes

⌈/∊2(+↑⍨0∊,)/⎕
```

⌈/ largest of

∊ the flattened ("enlisted"

2(...)/ pairwise

 + sum (zero plus something is something)

 ↑⍨ taken if

 0 zero

 ∊ is a member of

 , the pair (lit. the concatenation of the left-hand number and the right-hand number)

TryAPL online!

Body:
Challenge:

Take a vector / list of integers as input, and output the largest number that's adjacent to a zero.

Specifications:

As always, optional input and output format

You may assume that there will be at least one zero, and at least one non-zero element.

Test cases:

```<code>1 4 3 6 0 3 7 0
7

9 4 9 0 9 0 9 15 -2
9

-4 -6 -2 0 -9
-2

-11 0 0 0 0 0 -12 10
0

0 20
20
</code>```

Good luck and happy golfing!

Body:
Dyalog APL, 14 bytes

⌈/∊2(+↑⍨0∊,)/⎕

⌈/ largest of

∊ the flattened ("enlisted"

2(...)/ pairwise

 + sum (zero plus something is something)

 ↑⍨ taken if

 0 zero

 ∊ is a member of

 , the pair (lit. the concatenation of the left-hand number and the right-hand number)

TryAPL online!


答:
Ruby, <s>114</s> 112

```<code>x=gets.to_f
puts'%d %d-%s-%.2f'%[x/d=91*c=4*b=86400,(x%=d)/c,%w[Looplab Sevit Hexteria Sinpad][x%c/b],x%c%b/864]
</code>```

Meh. Basically grc's solution but with inline assignments.

Edit: Saved 2 chars by changing to_i to to_f so I don't need the float literal later.

Body:
The world's changing to a new time system!  We need to update our computer programs.  Given an input of epoch time (number of seconds since January 1st, 1970 00:00), print out a time in the new Noxu date-time format.

864 seconds make one Fluffster.  100 Fluffsters make a Skizzle.  There are 4 Skizzles in one Zestpond.  Their names are Looplab, Sevit, Hexteria, and Sinpad.  There are 91 Zestponds in one Lulerain.

The format is Lulerain Zestpond-Skizzle-Fluffster.  Fluffsters are rounded to two decimal places.  An example would be 50 13-Sevit-40.90.

Given that epoch 0 was 0 0-Looplab-00.00, create a program that takes input either via stdin or as a command line argument of any epoch time between 0 and 2^32, and prints out the Noxu equivalent.

Time of edit:

```<code>1357510372 -> 43 14-Sinpad-92.56
</code>```

Random test data:

```<code>675416077 -> 21 43-Sevit-31.57
330585453 -> 10 46-Hexteria-22.05
1328127085 -> 42 20-Sinpad-84.13
837779784 -> 26 58-Looplab-52.53
1240280676 -> 39 39-Sinpad-10.04
122646385 -> 3 81-Sinpad-51.83
1311245658 -> 41 63-Looplab-45.44
57792972 -> 1 76-Looplab-90.01
788388068 -> 25 6-Looplab-86.19
304341865 -> 9 61-Hexteria-47.53
417857784 -> 13 26-Looplab-31.69
671276878 -> 21 31-Sevit-40.83
1259758896 -> 40 5-Looplab-54.28
604286664 -> 19 19-Hexteria-5.86
646395018 -> 20 50-Sevit-42.38
563025133 -> 17 82-Looplab-49.46
96133144 -> 3 5-Looplab-65.21
101542552 -> 3 20-Sinpad-26.10
1006825856 -> 32 1-Sevit-7.70
928867348 -> 29 48-Hexteria-77.95
1235022079 -> 39 24-Hexteria-23.70
439505287 -> 13 88-Hexteria-86.67
99686711 -> 3 15-Sevit-78.14
379859609 -> 12 7-Looplab-52.33
1167091685 -> 37 10-Looplab-0.56
612032437 -> 19 41-Sinpad-70.88
503040778 -> 15 90-Hexteria-23.12
1084809411 -> 34 44-Sinpad-66.45
1105664386 -> 35 14-Sevit-4.15
197303893 -> 6 24-Sinpad-60.99
368559287 -> 11 65-Sevit-73.25
686824300 -> 21 76-Sevit-35.53
196468204 -> 6 22-Sevit-93.75
673542185 -> 21 37-Sinpad-62.71
993063782 -> 31 52-Sevit-79.38
270951743 -> 8 56-Looplab-1.55
1074506753 -> 34 15-Looplab-42.08
198143696 -> 6 27-Sevit-32.98
539601298 -> 17 14-Sevit-38.54
110090607 -> 3 45-Hexteria-19.68
276492708 -> 8 72-Looplab-14.71
113389138 -> 3 55-Looplab-37.43
571578220 -> 18 15-Sinpad-48.87
1238516450 -> 39 34-Hexteria-68.11
742293312 -> 23 54-Sinpad-35.78
1031929490 -> 32 73-Sinpad-62.84
503091914 -> 15 90-Hexteria-82.31
264094386 -> 8 36-Looplab-64.80
483820698 -> 15 34-Sinpad-77.66
548410387 -> 17 39-Sinpad-34.24
</code>```

Body:
Ruby, <s>114</s> 112

x=gets.to_f
puts'%d %d-%s-%.2f'%[x/d=91*c=4*b=86400,(x%=d)/c,%w[Looplab Sevit Hexteria Sinpad][x%c/b],x%c%b/864]

Meh. Basically grc's solution but with inline assignments.

Edit: Saved 2 chars by changing to_i to to_f so I don't need the float literal later.


Body:
PowerShell v3+, 62 bytes

param($n)($n[(0..$n.count|?{0-in$n[$_-1],$n[$_+1]})]|sort)[-1]

A bit longer than the other answers, but a nifty approach.

Takes input $n. Then loops through the indices 0..$n.count, uses the Where-Object (|?{...}) to pull out those indices where the previous or next item in the array is 0, and feeds those back into array slice $n[...]. We then |sort those elements, and take the biggest [-1].

Examples

PS C:\Tools\Scripts\golfing> @(1,4,3,6,0,3,7,0),@(9,4,9,0,9,0,9,15,-2),@(-4,-6,-2,0,-9),@(-11,0,0,0,0,0,-12,10)|%{""+$_+" --> "+(.\largest-number-beside-a-zero.ps1 $_)}
1 4 3 6 0 3 7 0 --> 7
9 4 9 0 9 0 9 15 -2 --> 9
-4 -6 -2 0 -9 --> -2
-11 0 0 0 0 0 -12 10 --> 0

PS C:\Tools\Scripts\golfing> @(0,20),@(20,0),@(0,7,20),@(7,0,20),@(7,0,6,20),@(20,0,6)|%{""+$_+" --> "+(.\largest-number-beside-a-zero.ps1 $_)}
0 20 --> 20
20 0 --> 20
0 7 20 --> 7
7 0 20 --> 20
7 0 6 20 --> 7
20 0 6 --> 20


答:
PHP, 82 Bytes

```<code><?php for($s=$argv[++$i],$j=-1;$n=$argv[++$i];){for(;$n--;)echo$s[++$j];echo"
";}
</code>```

Takes input as a string and then a list of numbers, output is separated by new lines. e.g.

```<code>php chainify.php lexicographically 2 2 2 7 4
</code>```

If you're one of those people able to use $argv with -r you can save the 6 bytes used for the opening tag.

Title: Substring Chainification

Body:
Introduction

For this example, let's take the string Hello, World! and the array [3, 2, 3]. To find the substring chain, we go through the following process:

The first number of the array is 3, so we get the substring [0 - 3], which is Hel. After that, we remove the first 3 characters from the initial string, which leaves us with lo, World!.

The second number of the array is 2, so we get the substring [0 - 2] from our new string, which gives us lo. The leftover string becomes , World!.

The last number is a 3, which gives us , W. The substring chain is all of the substrings combined, which gives us:

```<code>['Hel', 'lo', ', W']
</code>```

For a more visual example:

```<code>[3, 2, 3], 'Hello, World!'
3 -> Hel
2 ->    lo
3 ->      , W
</code>```

The task

Given a non-empty string and a non-empty array only consisting of positive integers (> 0), output the substring chain. You may assume that the sum of all integers in the array does not exceed the length of the string.

You can also assume that the strings will never contain any newlines.

Test cases

```<code>Input: abcdefghijk, [2, 1, 3]
Output: ['ab', 'c', 'def']

Input: Code Golf, [4, 1]
Output: ['Code', ' ']

Input: Ayyy, [3]
Output: ['Ayy']

Input: lexicographically, [2, 2, 2, 7, 4]
Output: ['le', 'xi', 'co', 'graphic', 'ally']
</code>```

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

Body:
PHP, 82 Bytes

<?php for($s=$argv[++$i],$j=-1;$n=$argv[++$i];){for(;$n--;)echo$s[++$j];echo"
";}

Takes input as a string and then a list of numbers, output is separated by new lines. e.g.

php chainify.php lexicographically 2 2 2 7 4

If you're one of those people able to use $argv with -r you can save the 6 bytes used for the opening tag.


问:
No strings (or numbers) attached
If you like this, consider participating in:

The Official Dyalog APL 2016 Year Game

The monthly Dyalog APL 2017 Code Golf Challenge

Make 12 snippets/expressions, in the same language, that result in the numbers 0 through 10, and 42 respectively, but without writing any literal numeric, string, or character data.

Build-in data, like PI() and ALPHABET(), are fine, and so are e.g. CJam's U, X, Y, Z, and A constants, and Processing's BLEND, CHORD, CENTER, BREAK, and  LINES.

Every snippet must be able to stand on its own, i.e. they may not be interdependent. However, inside a single snippet, you may assign a variable and use it freely, as long as you refer to it directly by name, and not through a string containing its name.

All the snippets must be valid on the submitter’s computer at the time of submission (as reported by SE), but may not rely on unusual local conditions like number of files in a directory, the exact date or time, or specific input from the user.

Examples of valid snippets

3: INT(LOG10(YEAR(TODAY())))   because it remains true in the foreseeable future

4: CUBICROOT(LEN(CHARACTERSET()))   because a 256 letter character set is very common

8: SQRT(SYSTEMTYPE())   because 64-bit systems are very common

Examples of invalid snippets

5: LEN(USERNAME())   because most people do not use “Admin” as login :-)

9: LOG10(SYSTEMMEMORY())   because it only works on systems with exactly 1 GB of memory

42: CODE("*")   because it contains a string/character literal

The result of each snippet must result in an actual number (value, int, float, etc.) that can be used for further calculations using the same language as the snippet, i.e not a text string representing that number.

Only character based languages allowed.

Score is total byte count of all the 12 snippets combined. Newlines separating the snippets are not counted in.

Note that the above rules may prevent some languages from participating, even if they are Turing complete.

FAQ

Q Can the programs accept any input?

A Yes, but you may not just ask for input and enter the relevant number.

Q Are physical digits (non-data) digits allowed?

A Yes, e.g. LOG10().

Q Do Symbols in Ruby count as literals?

A Yes.

Q Does score include newlines between each snippet?

A No.

Q Is TI-BASIC "character based" enough to be valid?

A Yes.

Q Do false and true count as number literals?

A No, they are acceptable.

Q Can we use a number literal to call a function if that's the only way and the number doesn't influence the output of the function?

A Yes, if that is the normal way to write code in your language.

Q My language assumes there is a [something] at the start of each program/expression. Must I include it, or should my snippets just work if placed in the middle of a program/expression?

A They should just work in the middle of a program/expression.

Q What about regex literals?

A Forbidden, except for languages that only do regexes.

Q Is one piece of code that could print all the specified numbers acceptable?

A No, they have to be separate and mutually independent.

Q May I assume a boilerplate like int main() {}... or equivalent?

A Yes.

Q What output datatypes are allowed?

A Any numeric datatype, like int, float, etc.

Q Do I need to print the result of each snippet?

A No, making the result available for subsequent use is enough.

Q Are pre-set variables allowed?

A Yes, and they become reset (if changed) for every snippet.

Q Are π and e considered number literals?

A No, you may use them.

Q May I return 4 and 2 in different cells for 42?

A No, they must be connected as one number.

Q Bytes or characters?

A Bytes, but you may choose any desired codepage.

Q May constant functions and preset variables like J's 9:, Actually's 9, and Pretzel's 9 be used?

A Yes, if the vocabulary is finite (19 for J, 10 for Actually and Pretzel).

答:
Jelly, 26 bytes (non-competing)

```<code>00:
01: ‘
02: ‘‘
03: ‘‘‘
04: ‘‘Ḥ
05: ⁵H
06: ⁵H‘
07: ⁴H’
08: ⁴H
09: ⁵’
10: ⁵
42: ⁴Ḥ+⁵
</code>```

Try it online! (paste each one of the snippets in the 'Code' field.)

Title: No strings (or numbers) attached

Body:
Jelly, 26 bytes (non-competing)

00:
01: ‘
02: ‘‘
03: ‘‘‘
04: ‘‘Ḥ
05: ⁵H
06: ⁵H‘
07: ⁴H’
08: ⁴H
09: ⁵’
10: ⁵
42: ⁴Ḥ+⁵

Try it online! (paste each one of the snippets in the 'Code' field.)


问:
Telegraphy Golf: Decode Baudot Code

Background

In 1870 Émile Baudot invented Baudot Code, a fixed-length character
encoding for telegraphy. He designed the code to be entered from a
manual keyboard with just five keys; two operated with the left hand and
three with the right:

The right index, middle and ring fingers operate the I, II, and
III keys, respectively, and the left index and middle fingers operate
IV and Ⅴ. (Henceforth I'll use the more familiar numerals 1–5.) Characters are entered as chords. To enter the letter
"C," for example, the operator presses the 1, 3, and 4 keys
simultaneously, whereupon a rotating brush arm reads each key in
sequence and transmits a current or, for keys not depressed, no current.
In modern terms, this is a 5-bit least-significant-bit-first
binary encoding, in which our example, "C," is encoded as 10110.

5 bits??

You might be thinking that 5 bits, which can express at most 32 unique
symbols, isn't enough for even all of the English letters and numerals,
to say nothing of punctuation. Baudot had a trick up his sleeve, though:
His character set is actually two distinct sets: Letters and
Figures, and he defined two special codes to switch between them.
Letter Shift (LS), which switches to Letters mode, is activated by pressing
the 5 key alone (00001), and Figure Shift (FS) is activated with the
4 key (00010).

Challenge

Your challenge is to write a program or function that decodes Baudot
Code transmissions.

A real transmission would begin with some initialization bits, plus a
start and stop bit before and after each character, but we're going to
skip those and only worry about the 5 unique bits for each character.
Input and output formats are discussed below.

Baudot's Code

There are two different versions of Baudot Code: Continental and U.K.
We're going use the U.K. version, which doesn't include characters
like "É" from Baudot's native French. We're also going to leave out all
of the symbols in the U.K. version that aren't among the printable ASCII
characters. You will only have to decode the characters in the table
below, all of which are printable ASCII characters except the final three control characters that are explained below the table.

The "Ltr" column shows the characters in Letter mode and "Fig" shows the
Figure mode characters:

        Encoding             Encoding
Ltr Fig  12345       Ltr Fig  12345
--- --- --------     --- --- --------
 A   1   10000        P   +   11111
 B   8   00110        Q   /   10111
 C   9   10110        R   -   00111
 D   0   11110        S       00101
 E   2   01000        T       10101
 F       01110        U   4   10100
 G   7   01010        V   '   11101
 H       11010        W   ?   01101
 I       01100        X       01001
 J   6   10010        Y   3   00100
 K   (   10011        Z   :   11001
 L   =   11011        -   .   10001
 M   )   01011        ER  ER  00011
 N       01111        FS  SP  00010
 O   5   11100        SP  LS  00001
 /       11000
```
<p>The last three rows in the right column are control characters:</p>
<ul>
<li><p><strong><code>ER</code></strong> is <em>Erasure</em>. Baudot's telegraphy machines would print an
asterisk-like symbol for this character to tell the reader that the
preceding character should be ignored, but we're going to be even
nicer to the reader and <em>actually omit (do not print) the preceding
character</em>. It acts the same in both Letter and Figure mode.</p>
</li>
<li><p><strong><code>FS</code></strong> is <em>Figure Shift</em>. This switches the character set from
Letters to Figures. If the decoder is <em>already</em> in Figure mode,
FS is treated as a <em>Space</em> (ergo <code>SP</code> in the "Ltr" column). When the decoder is in Figure mode it stays in Figure mode until an LS character is received.</p>
</li>
<li><p><strong><code>LS</code></strong> is <em>Letter Shift</em>. It switches the character set from
Figures to Letters. If the decoder is already in Letter mode, LS is treated as a <em>Space</em>. When in Letter mode the decoder stays in Letter mode until an FS character is received.</p>
</li>
</ul>
<p>The decoder always starts in Letter mode.</p>
<p>Here's an example with Figure Shift, Letter Shift, and Space:</p>
<pre class="lang-none prettyprint-override"><code>01011 10000 00100 00001 00010 10000 11100 00001 10101 11010
  M     A     Y   LS/SP FS/SP   1     5   LS/SP   T     H
</code>```

This yields the message MAY 15TH. As you can see, the first 00001 (Letter Shift/Space) character acts as a space, because the decoder is already in Letter mode. The next character, 00010 (Figure Shift/Space) switches the decoder to Figure mode to print 15. Then 00001 appears again, but this time it acts as Letter Shift to put the decoder back in Letter mode.

For your convenience, here are the characters in a format that's perhaps
easier to digest in an editor, sorted by code:

A,1,10000|E,2,01000|/,,11000|Y,3,00100|U,4,10100|I,,01100|O,5,11100|FS,SP,00010|J,6,10010|G,7,01010|H,,11010|B,8,00110|C,9,10110|F,,01110|D,0,11110|SP,LS,00001|-,.,10001|X,,01001|Z,:,11001|S,,00101|T,,10101|W,?,01101|V,',11101|ER,ER,00011|K,(,10011|M,),01011|L,=,11011|R,-,00111|Q,/,10111|N,,01111|P,+,11111
```
<h2>Input</h2>
<p>Input will be a string, array, or list of bits in
least-significant-bit-first order. Each character will be represented by a quintet of 5 bits. Bits may be in any reasonable format, e.g. a
binary string, an array of <code>0</code>s and <code>1</code>s, a string of <code>"0"</code> and <code>"1"</code>
characters, a single very large number, etc., as long as it maps
directly to the bits of the transmission.</p>
<p>Every transmission will have at least one printable quintet and at most
255 quintets (printable or otherwise), i.e. 5–1,275 bits inclusive.</p>
<p>The input can contain <em>only</em> the bits of the transmission, with two
allowed exceptions: Any number of leading or trailing <code>0</code> bits and/or,
for string input, a single trailing newline may be added to the
transmission. Leading or trailing bits or characters <em>cannot</em> be added
before or after each quintet, i.e. you cannot pad each quintet to 8 bits (or take each quintet as a single number in an array—unless your language has a 5-bit integer type)
or separate quintets with any additional bits, e.g. <code>"01111\n11100"</code>.</p>
<h3>Notes & edge cases</h3>
<ol>
<li><p>The transmission will contain only the characters in the "Ltr" and
"Fig" columns in the table above. You will never receive e.g.
<code>01110</code> in Figure mode, because it is absent from the "Fig" column.</p>
</li>
<li><p>It is assumed that the decoder will always be in Letter mode at the
beginning of a transmission. However, the first character <em>may</em> be an
FS character to switch to Figure mode immediately.</p>
</li>
<li><p>When the decoder is in Letter mode, it may receive an LS character, and when it is in Figure mode it may receive an FS character. In either event a Space character must be printed (see Output).</p>
</li>
<li><p>The ER character will never be the first character in a transmission, nor will it ever immediately follow an LS, FS, or another ER.</p>
</li>
<li><p>An FS character may immediately follow an LS character and vice versa.</p>
</li>
<li><p>Neither the LS nor FS character will be the last character in any transmission.</p>
</li>
<li><p>The <code>/</code> and <code>-</code> characters may be received in either Letter mode
(codes <code>11000</code> and <code>10001</code>, respectively) or Figure mode (<code>10111</code>
and <code>00111</code>).</p>
</li>
</ol>
<h2>Output</h2>
<p>Output may be in any reasonable format, the most reasonable being ASCII
(or UTF-8, for which all of the represented characters are the same as
ASCII). Please indicate in your answer if your output is in another
encoding or format.</p>
<h3>Notes</h3>
<ul>
<li>The space character (see 3. above) should be an ASCII space (0x20)
or your encoding's equivalent, i.e. what you get when you press the
space bar.</li>
</ul>
<h1>Winning</h1>
<p>This is code-golf. The shortest code in bytes wins.</p>
<h1>Restrictions</h1>
<ul>
<li><p>Standard loopholes are forbidden.</p>
</li>
<li><p>Trailing spaces and/or a single trailing newline are allowed. Leading spaces or other characters (that are not part of the transmission) are disallowed.</p>
</li>
<li><p>You may not use any built-in or library functions that decode Baudot Code (or any of its descendants, e.g. Murray Code, ITA-1, etc.).</p>
</li>
</ul>
<h1>Test Cases</h1>
<pre class="lang-none prettyprint-override"><code>Input: 001101000010100111101110010101
Output: BAUDOT
</code>```

Input: 11010010001001100011110111101111100
Output: HELLO
```

<pre class="lang-none prettyprint-override"><code>Input: 01011100000010000001000101000011100000011010111010
Output: MAY 15TH
</code>```

Input: 0001000100010000001000001011101110011100101010010110101010001111100101
Output: 32 FOOTSTEPS
```

<pre class="lang-none prettyprint-override"><code>Input: 10110000110101011100111100001111011010000001101110
Output: GOLF
</code>```

Input: 000100011000001111100000100010110111001100010110010000111111
Output: 8D =( :P
```

<pre class="lang-none prettyprint-override"><code>Input: 0000100001000010000100010001111011111011000011100010001
Output (4 leading spaces):     -/=/-
</code>```

ContentLicense: CC BY-SA 4.0

Title: Telegraphy Golf: Decode Baudot Code

Body:
JavaScript (ES6), <s> 160 158 153 </s> 149 bytes

s=>s.replace(m=/.{5}/g,s=>["? !YSBREXGMIWFNA-JKUTCQ/ZHLOVDP? ?!3 8-2 7) ?  1.6(4 9/ : =5'0+"[(n='0b'+s-1)<2?m^n?~(m^=1):1:m<<5|n]]).replace(/.!/g,'')

Try it online!


答:
Java, 119 Bytes

```<code>String[] substringChainification(String s, int[] i) {
    String[] r = new String[i.length];
    int j = 0, f = 0;
    for (int t : i)
        r[j++] = s.substring(f, f += t);
    return r;
}
</code>```

Golfed:

```<code>String[]s(String s,int[]i){String[]r=new String[i.length];int j=0,f=0;for(int t:i)r[j++]=s.substring(f,f+=t);return r;}
</code>```

I modified Roman Gräf's answer(https://codegolf.stackexchange.com/a/93992/59935), but i don't have enough rep to comment.

I changed the loop implementation and instead of setting the source string to another substring in every iteration, i just change the indices with which i get the substring.

Title: Substring Chainification

Body:
Java, 119 Bytes

String[] substringChainification(String s, int[] i) {
    String[] r = new String[i.length];
    int j = 0, f = 0;
    for (int t : i)
        r[j++] = s.substring(f, f += t);
    return r;
}

Golfed:

String[]s(String s,int[]i){String[]r=new String[i.length];int j=0,f=0;for(int t:i)r[j++]=s.substring(f,f+=t);return r;}

I modified Roman Gräf's answer(https://codegolf.stackexchange.com/a/93992/59935), but i don't have enough rep to comment.

I changed the loop implementation and instead of setting the source string to another substring in every iteration, i just change the indices with which i get the substring.


答:
Racket 183 bytes

```<code>(λ(k)(let*((lr(λ(l i)(list-ref l i)))(l(append(list 1)k(list 1)))(m(for/list((i(range 1(sub1(length l))))
#:when(or(= 0(lr l(sub1 i)))(= 0(lr l(add1 i)))))(lr l i))))(apply max m)))
</code>```

Detailed version:

```<code>(define f
 (λ(k)
    (let* ((lr (λ(l i)(list-ref l i)))
           (l (append (list 1) k (list 1)))
           (m (for/list ((i (range 1 (sub1(length l))))
                         #:when (or (= 0 (lr l (sub1 i)))
                                    (= 0 (lr l (add1 i))) ))
                (lr l i) )))
      (apply max m) )))
</code>```

Testing:

```<code>(f (list 1 4 3 6 0 3 7 0))
(f (list 9 4 9 0 9 0 9 15 -2))
(f (list -4 -6 -2 0 -9))
(f (list -11 0 0 0 0 0 -12 10))
(f (list 0 20 ))
</code>```

Output:

```<code>7
9
-2
0
20
</code>```

Body:
Racket 183 bytes

(λ(k)(let*((lr(λ(l i)(list-ref l i)))(l(append(list 1)k(list 1)))(m(for/list((i(range 1(sub1(length l))))
#:when(or(= 0(lr l(sub1 i)))(= 0(lr l(add1 i)))))(lr l i))))(apply max m)))

Detailed version:

(define f
 (λ(k)
    (let* ((lr (λ(l i)(list-ref l i)))
           (l (append (list 1) k (list 1)))
           (m (for/list ((i (range 1 (sub1(length l))))
                         #:when (or (= 0 (lr l (sub1 i)))
                                    (= 0 (lr l (add1 i))) ))
                (lr l i) )))
      (apply max m) )))

Testing:

(f (list 1 4 3 6 0 3 7 0))
(f (list 9 4 9 0 9 0 9 15 -2))
(f (list -4 -6 -2 0 -9))
(f (list -11 0 0 0 0 0 -12 10))
(f (list 0 20 ))

Output:

7
9
-2
0
20


答:
T-SQL (SQL Server 2014), 217 bytes

Golfed

```<code>declare @ table(a char)declare @i int=1while @i<=len(@a)begin insert into @ values(SUBSTRING(@a,@i,1))set @i=@i+1 end select count(*)%2from @ where a in('a','e','i','o','u')
</code>```

Usage

First declare the variable @a as a char of some sort and assign the input like so

```<code>declare @a varchar(max) = 'CAts'
</code>```

Output will either be 1 for odd, or 0 for even

Ungolfed

```<code>declare @input varchar(max) = 'rhythm'

declare @temp table ( letter char(1) ) -- table to hold each letter of the word

declare @i int = 1

while @i <= len(@input) -- split each letter, and each row in @temp will have one letter
begin
    insert into @temp values (SUBSTRING(@input, @i, 1))
    set @i = @i + 1
end

-- count the vowels and mod two to get if there's an even number of vowels or an odd number
select count(*) % 2
from @temp
where letter in ('a', 'e', 'i', 'o', 'u') -- use sql's case insensitive strings
</code>```

Title: Is it an Odd Word?

Body:
Challenge

Given a single word as input, determine if the word is odd or even.

Odd and Even words

Assume the general rules:

```<code>odd + odd = even
even + odd = odd
odd + even = odd
even + even = even
</code>```

In the alphabet, the odd letters are:

```<code>aeiou
</code>```

And the even letters are:

```<code>bcdfghjklmnpqrstvwxyz
</code>```

The same applies to capital letters (AEIOU are odd and BCDFGHJKLMNPQRSTVWXYZ are even).

You then 'add' each of the letters in the word together. For example, the word cats is equivalent to:

```<code>even + odd + even + even
</code>```

Which simplifies to:

```<code>odd + even
</code>```

Which simplifies further to:

```<code>odd
</code>```

So the word cats is odd.

Examples

```<code>Input:  trees
Output: even
</code>```

```<code>Input:  brush
Output: odd
</code>```

```<code>Input:  CAts
Output: odd
</code>```

```<code>Input:  Savoie
Output: even
</code>```

```<code>Input:  rhythm
Output: even
</code>```

Rules

All input will be a single word which will only contain alphabetical characters.

If the word is odd, output a truthy value. If the word is even, output a falsey value.

Winning

The shortest code in bytes wins.

Body:
T-SQL (SQL Server 2014), 217 bytes

Golfed

declare @ table(a char)declare @i int=1while @i<=len(@a)begin insert into @ values(SUBSTRING(@a,@i,1))set @i=@i+1 end select count(*)%2from @ where a in('a','e','i','o','u')

Usage

First declare the variable @a as a char of some sort and assign the input like so

declare @a varchar(max) = 'CAts'

Output will either be 1 for odd, or 0 for even

Ungolfed

declare @input varchar(max) = 'rhythm'

declare @temp table ( letter char(1) ) -- table to hold each letter of the word

declare @i int = 1

while @i <= len(@input) -- split each letter, and each row in @temp will have one letter
begin
    insert into @temp values (SUBSTRING(@input, @i, 1))
    set @i = @i + 1
end

-- count the vowels and mod two to get if there's an even number of vowels or an odd number
select count(*) % 2
from @temp
where letter in ('a', 'e', 'i', 'o', 'u') -- use sql's case insensitive strings


Title: Jimmy these arrays down

Body:
My coworker, Jimmy is kinda new to C/C++. He's also kind of a slow learner. Now, to be fair, his code always compiles, but he has some really sloppy habits. For example, everybody knows that you can define an array like this:

```<code>int spam[] = {4, 8, 15, 16, 23, 42};
</code>```

Everybody that is, except for Jimmy. He is convinced that the only way to make an array is like this:

```<code>int spam[6];
spam[0] = 4;
spam[1] = 8;
spam[2] = 15;
spam[3] = 16;
spam[4] = 23;
spam[5] = 42;
</code>```

I keep fixing this for him in code-review, but he won't learn. So I need you to write a tool that automagically does this for him when he commits¹.

The challenge

I want you to write either a full program or a function that takes in a multiline string as input, and outputs the more compact version of the C array. The input will always follow this format, whitespace included:

```<code>identifier_one identifier_two[some_length];
identifier_two[0] = some_number;
identifier_two[1] = some_number;
identifier_two[2] = some_number;
...
identifier_two[some_length - 1] = some_number;
</code>```

In short, the input will always be valid and well defined C. In more detail:

All of the identifiers will be made up of just letters and underscores. The length will always be at least one, and there will never be any missing or out of bounds indexes. You may also assume that the indexes are in order. For example:

```<code>foo bar[3];
bar[0] = 1
bar[2] = 9;
</code>```

<s></s>

```<code>foo bar[1];
bar[0] = 1;
bar[1] = 3;
</code>```

and

```<code>foo bar[3];
bar[2] = 9;
bar[0] = 1
bar[1] = 3
</code>```

are all invalid inputs, and may cause undefined behavior in your submission. You may also assume that all of the numbers will be valid decimal numbers, negative or positive. The input will not have extraneous spaces. The output should always follow this format, whitespace included:

```<code>identifier_one identifier_two[] = {n1, n2, n3, ...};
</code>```

Here is some sample data:

```<code>Input:
spam eggs[10];
eggs[0] = 0;
eggs[1] = 4;
eggs[2] = 8;
eggs[3] = -3;
eggs[4] = 3;
eggs[5] = 7;
eggs[6] = 888;
eggs[7] = 555;
eggs[8] = 0;
eggs[9] = -2;

Output:
spam eggs[] = {0, 4, 8, -3, 3, 7, 888, 555, 0, -2};

Input:
char ans[2];
ans[0] = 52;
ans[1] = 50;

Output:
char ans[] = {52, 50};

Input:
blah_blah quux[1];
quux[0] = 105;

Output:
blah_blah quux[] = {105};
</code>```

You may take your input and output in any reasonable format, such as STDIN/STDOUT, function arguments and return value, reading and writing files etc. Standard loopholes apply. The shortest answer in bytes wins!

¹This is passive-aggressive and a terrible idea. You did not get this idea from me.

Body:
sed 51

1s,\[.*,[] = {,
:
N
s,\n.*= ,,
s/;/, /
$s/, $/};/
t


答:
Python, 49 bytes

lambda a:max(sum(x)for x in zip(a,a[1:])if 0in x)
```

Tests are at ideone

Zips through the pairs, sums the ones containing any zero, returns the maximum.

Body:
Python, 49 bytes

lambda a:max(sum(x)for x in zip(a,a[1:])if 0in x)

Tests are at ideone

Zips through the pairs, sums the ones containing any zero, returns the maximum.


问:
Determine which of two ImageMagick .TXT images is more saturated
You have two images (64x64 pixels each):

Your program must take the file names of each of them as command line arguments and determine which has more average saturation among their pixels.

The images are in ImageMagick .txt format.  You can download and convert these images using convert pic.png pic.txt or download the raw text (saturated, desaturated)

Ignore the first line of the file (required).

Solutions in Assembly get 50% of their characters for free.  Brainfuck, whitespace, and close variants, get 25% of their characters for free.  (e.g. if it takes 200 characters in Brainfuck; mark it as 200-50=150.)

Describe your output.  It could be the name of the more saturated image; the index of it (0 for first, 1 for second); true for the first, false for the second, etc.  Just let us know.

It should be able to take either the saturated or desaturated image first, and accurately report the more saturated (test both ways).  The filenames shouldn't be considered when evaluating saturation (e.g. no if filename contains 'desaturated'...)

Shortest answer wins.  Happy coding :-)

答:
bash etc. and Image Magick (136 chars)

```<code>for x in "$@";do convert "$x" -colorspace HSL -channel G -separate -scale 1x1 t.txt
echo `sed "1d;s%.*#\(..\).*%\1%" t.txt` $x;done|sort
</code>```

The way I see it, the easiest way to deal with the complexities of the Image Magick file format is to let Image Magick do it. t.txt seems to be the shortest possible filename which guarantees the correct output file format. The first 4 " could arguably be removed, but that would decrease robustness in the face of filenames with spaces in.

Sample output:

```<code>$ ./cmpsat.sh img-sat.txt img-desat.txt rose:
24 img-desat.txt
69 rose:
FE img-sat.txt
</code>```

Body:
bash etc. and Image Magick (136 chars)

for x in "$@";do convert "$x" -colorspace HSL -channel G -separate -scale 1x1 t.txt
echo `sed "1d;s%.*#\(..\).*%\1%" t.txt` $x;done|sort

The way I see it, the easiest way to deal with the complexities of the Image Magick file format is to let Image Magick do it. t.txt seems to be the shortest possible filename which guarantees the correct output file format. The first 4 " could arguably be removed, but that would decrease robustness in the face of filenames with spaces in.

Sample output:

$ ./cmpsat.sh img-sat.txt img-desat.txt rose:
24 img-desat.txt
69 rose:
FE img-sat.txt


答:
Pyth, <s>98</s> <s>97</s> <s>95</s> <s>93</s> <s>90</s> <s>83</s> 80 bytes

The code contains unprintable characters, so here is a reversible xxd hexdump:

```<code>00000000: 753f 7133 4a69 4832 5047 2b47 3f3c 334a  u?q3JiH2PG+G?<3J
00000010: 4040 6332 2e22 275a 75ae 5751 fb4e 3cd7  @@c2."'Zu.WQ.N<.
00000020: 02ce 8719 aac1 e0e0 fe1f 09e5 85bc a767  ...............g
00000030: 8e0c 1f47 508a cad1 1acb b26f 951e e5d6  ...GP......o....
00000040: 225a 4a2a 5c20 715a 3d5a 744a 637a 356b  "ZJ*\ qZ=ZtJcz5k
</code>```

Try it online. Test suite.

Quite long, but the lookup table does take up <s>most</s> half of the space.

For 117 bytes, here's the same thing without unprintables (needs ISO-8859-1, though):

```<code>u?q3JiH2PG+G?<3J@@c2."'Zu®WQûN<×\x02Î\x87\x19ªÁààþ\x1f\tå\x85¼§g\x8e\x0c\x1fGP\x8aÊÑ\x1aË²o\x95\x1eåÖ"ZJ*\ qZ=ZtJcz5k
</code>```

Or, for 93 bytes, with no compression on the lookup table:

```<code>u?q3JiH2PG+G?<3J@@c2"OVDPYSBREXGMIWFNA-JKUTCQ/ZHL5'0+3;8-2;7);?;;1.6(4;9/;:;="ZJ*\ qZ=ZtJcz5k
</code>```

Title: Telegraphy Golf: Decode Baudot Code

Body:
Background

In 1870 Émile Baudot invented Baudot Code, a fixed-length character
encoding for telegraphy. He designed the code to be entered from a
manual keyboard with just five keys; two operated with the left hand and
three with the right:

The right index, middle and ring fingers operate the I, II, and
III keys, respectively, and the left index and middle fingers operate
IV and Ⅴ. (Henceforth I'll use the more familiar numerals 1–5.) Characters are entered as chords. To enter the letter
"C," for example, the operator presses the 1, 3, and 4 keys
simultaneously, whereupon a rotating brush arm reads each key in
sequence and transmits a current or, for keys not depressed, no current.
In modern terms, this is a 5-bit least-significant-bit-first
binary encoding, in which our example, "C," is encoded as 10110.

5 bits??

You might be thinking that 5 bits, which can express at most 32 unique
symbols, isn't enough for even all of the English letters and numerals,
to say nothing of punctuation. Baudot had a trick up his sleeve, though:
His character set is actually two distinct sets: Letters and
Figures, and he defined two special codes to switch between them.
Letter Shift (LS), which switches to Letters mode, is activated by pressing
the 5 key alone (00001), and Figure Shift (FS) is activated with the
4 key (00010).

Challenge

Your challenge is to write a program or function that decodes Baudot
Code transmissions.

A real transmission would begin with some initialization bits, plus a
start and stop bit before and after each character, but we're going to
skip those and only worry about the 5 unique bits for each character.
Input and output formats are discussed below.

Baudot's Code

There are two different versions of Baudot Code: Continental and U.K.
We're going use the U.K. version, which doesn't include characters
like "É" from Baudot's native French. We're also going to leave out all
of the symbols in the U.K. version that aren't among the printable ASCII
characters. You will only have to decode the characters in the table
below, all of which are printable ASCII characters except the final three control characters that are explained below the table.

The "Ltr" column shows the characters in Letter mode and "Fig" shows the
Figure mode characters:

        Encoding             Encoding
Ltr Fig  12345       Ltr Fig  12345
--- --- --------     --- --- --------
 A   1   10000        P   +   11111
 B   8   00110        Q   /   10111
 C   9   10110        R   -   00111
 D   0   11110        S       00101
 E   2   01000        T       10101
 F       01110        U   4   10100
 G   7   01010        V   '   11101
 H       11010        W   ?   01101
 I       01100        X       01001
 J   6   10010        Y   3   00100
 K   (   10011        Z   :   11001
 L   =   11011        -   .   10001
 M   )   01011        ER  ER  00011
 N       01111        FS  SP  00010
 O   5   11100        SP  LS  00001
 /       11000
```
<p>The last three rows in the right column are control characters:</p>
<ul>
<li><p><strong><code>ER</code></strong> is <em>Erasure</em>. Baudot's telegraphy machines would print an
asterisk-like symbol for this character to tell the reader that the
preceding character should be ignored, but we're going to be even
nicer to the reader and <em>actually omit (do not print) the preceding
character</em>. It acts the same in both Letter and Figure mode.</p>
</li>
<li><p><strong><code>FS</code></strong> is <em>Figure Shift</em>. This switches the character set from
Letters to Figures. If the decoder is <em>already</em> in Figure mode,
FS is treated as a <em>Space</em> (ergo <code>SP</code> in the "Ltr" column). When the decoder is in Figure mode it stays in Figure mode until an LS character is received.</p>
</li>
<li><p><strong><code>LS</code></strong> is <em>Letter Shift</em>. It switches the character set from
Figures to Letters. If the decoder is already in Letter mode, LS is treated as a <em>Space</em>. When in Letter mode the decoder stays in Letter mode until an FS character is received.</p>
</li>
</ul>
<p>The decoder always starts in Letter mode.</p>
<p>Here's an example with Figure Shift, Letter Shift, and Space:</p>
<pre class="lang-none prettyprint-override"><code>01011 10000 00100 00001 00010 10000 11100 00001 10101 11010
  M     A     Y   LS/SP FS/SP   1     5   LS/SP   T     H
</code>```

This yields the message MAY 15TH. As you can see, the first 00001 (Letter Shift/Space) character acts as a space, because the decoder is already in Letter mode. The next character, 00010 (Figure Shift/Space) switches the decoder to Figure mode to print 15. Then 00001 appears again, but this time it acts as Letter Shift to put the decoder back in Letter mode.

For your convenience, here are the characters in a format that's perhaps
easier to digest in an editor, sorted by code:

A,1,10000|E,2,01000|/,,11000|Y,3,00100|U,4,10100|I,,01100|O,5,11100|FS,SP,00010|J,6,10010|G,7,01010|H,,11010|B,8,00110|C,9,10110|F,,01110|D,0,11110|SP,LS,00001|-,.,10001|X,,01001|Z,:,11001|S,,00101|T,,10101|W,?,01101|V,',11101|ER,ER,00011|K,(,10011|M,),01011|L,=,11011|R,-,00111|Q,/,10111|N,,01111|P,+,11111
```
<h2>Input</h2>
<p>Input will be a string, array, or list of bits in
least-significant-bit-first order. Each character will be represented by a quintet of 5 bits. Bits may be in any reasonable format, e.g. a
binary string, an array of <code>0</code>s and <code>1</code>s, a string of <code>"0"</code> and <code>"1"</code>
characters, a single very large number, etc., as long as it maps
directly to the bits of the transmission.</p>
<p>Every transmission will have at least one printable quintet and at most
255 quintets (printable or otherwise), i.e. 5–1,275 bits inclusive.</p>
<p>The input can contain <em>only</em> the bits of the transmission, with two
allowed exceptions: Any number of leading or trailing <code>0</code> bits and/or,
for string input, a single trailing newline may be added to the
transmission. Leading or trailing bits or characters <em>cannot</em> be added
before or after each quintet, i.e. you cannot pad each quintet to 8 bits (or take each quintet as a single number in an array—unless your language has a 5-bit integer type)
or separate quintets with any additional bits, e.g. <code>"01111\n11100"</code>.</p>
<h3>Notes & edge cases</h3>
<ol>
<li><p>The transmission will contain only the characters in the "Ltr" and
"Fig" columns in the table above. You will never receive e.g.
<code>01110</code> in Figure mode, because it is absent from the "Fig" column.</p>
</li>
<li><p>It is assumed that the decoder will always be in Letter mode at the
beginning of a transmission. However, the first character <em>may</em> be an
FS character to switch to Figure mode immediately.</p>
</li>
<li><p>When the decoder is in Letter mode, it may receive an LS character, and when it is in Figure mode it may receive an FS character. In either event a Space character must be printed (see Output).</p>
</li>
<li><p>The ER character will never be the first character in a transmission, nor will it ever immediately follow an LS, FS, or another ER.</p>
</li>
<li><p>An FS character may immediately follow an LS character and vice versa.</p>
</li>
<li><p>Neither the LS nor FS character will be the last character in any transmission.</p>
</li>
<li><p>The <code>/</code> and <code>-</code> characters may be received in either Letter mode
(codes <code>11000</code> and <code>10001</code>, respectively) or Figure mode (<code>10111</code>
and <code>00111</code>).</p>
</li>
</ol>
<h2>Output</h2>
<p>Output may be in any reasonable format, the most reasonable being ASCII
(or UTF-8, for which all of the represented characters are the same as
ASCII). Please indicate in your answer if your output is in another
encoding or format.</p>
<h3>Notes</h3>
<ul>
<li>The space character (see 3. above) should be an ASCII space (0x20)
or your encoding's equivalent, i.e. what you get when you press the
space bar.</li>
</ul>
<h1>Winning</h1>
<p>This is code-golf. The shortest code in bytes wins.</p>
<h1>Restrictions</h1>
<ul>
<li><p>Standard loopholes are forbidden.</p>
</li>
<li><p>Trailing spaces and/or a single trailing newline are allowed. Leading spaces or other characters (that are not part of the transmission) are disallowed.</p>
</li>
<li><p>You may not use any built-in or library functions that decode Baudot Code (or any of its descendants, e.g. Murray Code, ITA-1, etc.).</p>
</li>
</ul>
<h1>Test Cases</h1>
<pre class="lang-none prettyprint-override"><code>Input: 001101000010100111101110010101
Output: BAUDOT
</code>```

Input: 11010010001001100011110111101111100
Output: HELLO
```

<pre class="lang-none prettyprint-override"><code>Input: 01011100000010000001000101000011100000011010111010
Output: MAY 15TH
</code>```

Input: 0001000100010000001000001011101110011100101010010110101010001111100101
Output: 32 FOOTSTEPS
```

<pre class="lang-none prettyprint-override"><code>Input: 10110000110101011100111100001111011010000001101110
Output: GOLF
</code>```

Input: 000100011000001111100000100010110111001100010110010000111111
Output: 8D =( :P
```

<pre class="lang-none prettyprint-override"><code>Input: 0000100001000010000100010001111011111011000011100010001
Output (4 leading spaces):     -/=/-
</code>```

Body:
Pyth, <s>98</s> <s>97</s> <s>95</s> <s>93</s> <s>90</s> <s>83</s> 80 bytes

The code contains unprintable characters, so here is a reversible xxd hexdump:

00000000: 753f 7133 4a69 4832 5047 2b47 3f3c 334a  u?q3JiH2PG+G?<3J
00000010: 4040 6332 2e22 275a 75ae 5751 fb4e 3cd7  @@c2."'Zu.WQ.N<.
00000020: 02ce 8719 aac1 e0e0 fe1f 09e5 85bc a767  ...............g
00000030: 8e0c 1f47 508a cad1 1acb b26f 951e e5d6  ...GP......o....
00000040: 225a 4a2a 5c20 715a 3d5a 744a 637a 356b  "ZJ*\ qZ=ZtJcz5k

<a href="http://pyth.herokuapp.com/?code=u%3Fq3JiH2PG%2BG%3F%3C3J%40%40c2.%22%27Zu%C2%AEWQ%C3%BBN%3C%C3%97%02%C3%8E%C2%87%19%C2%AA%C3%81%C3%A0%C3%A0%C3%BE%1F%09%C3%A5%C2%85%C2%BC%C2%A7g%C2%8E%0C%1FGP%C2%8A%C3%8A%C3%91%1A%C3%8B%C2%B2o%C2%95%1E%C3%A5%C3%96%22ZJ*%5C%20qZ%3DZtJcz5k&input=001101000010100111101110010101&test_suite_input=001101000010100111101110010101%0A11010010001001100011110111101111100%0A01011100000010000001000101000011100000011010111010%0A00010001000001000001011101110011100101010010110101010001111100101%0A10110000110101011100111100001111011010000001101110%0A000100011000001111100000100010110111001100010110010000111111%0A0000100001000010000100010001111011111011000011100010001&debug=0" rel="nofollow noreferrer">Try it online. <a href="http://pyth.herokuapp.com/?code=u%3Fq3JiH2PG%2BG%3F%3C3J%40%40c2.%22%27Zu%C2%AEWQ%C3%BBN%3C%C3%97%02%C3%8E%C2%87%19%C2%AA%C3%81%C3%A0%C3%A0%C3%BE%1F%09%C3%A5%C2%85%C2%BC%C2%A7g%C2%8E%0C%1FGP%C2%8A%C3%8A%C3%91%1A%C3%8B%C2%B2o%C2%95%1E%C3%A5%C3%96%22ZJ*%5C%20qZ%3DZtJcz5k&input=001101000010100111101110010101&test_suite=1&test_suite_input=001101000010100111101110010101%0A11010010001001100011110111101111100%0A01011100000010000001000101000011100000011010111010%0A00010001000001000001011101110011100101010010110101010001111100101%0A10110000110101011100111100001111011010000001101110%0A000100011000001111100000100010110111001100010110010000111111%0A0000100001000010000100010001111011111011000011100010001&debug=0" rel="nofollow noreferrer">Test suite.

Quite long, but the lookup table does take up <s>most</s> half of the space.

For 117 bytes, here's the same thing without unprintables (needs ISO-8859-1, though):

u?q3JiH2PG+G?<3J@@c2."'Zu®WQûN<×\x02Î\x87\x19ªÁààþ\x1f\tå\x85¼§g\x8e\x0c\x1fGP\x8aÊÑ\x1aË²o\x95\x1eåÖ"ZJ*\ qZ=ZtJcz5k

Or, for 93 bytes, with no compression on the lookup table:

u?q3JiH2PG+G?<3J@@c2"OVDPYSBREXGMIWFNA-JKUTCQ/ZHL5'0+3;8-2;7);?;;1.6(4;9/;:;="ZJ*\ qZ=ZtJcz5k


答:
C 132 bytes

Outputs using main's return code:

```<code>int main(int a,char**_){int i,m=0;_[0]=_[a]="1";for(i=1;i<a;++i){m=(*_[i-1]-48||*_[i+1]-48?m>atoi(_[i])?m:atoi(_[i]):m);}return m;}
</code>```

I feel like I should be able to save a few bytes by saving one of the atoi calls, but I couldn't find an efficient way. (,t plus t= plus , plus t twice is too long). Also this technically uses undefined behaviour (setting _[a] to "1") but every compiler I know of allows it by default.

Strategy: pad the start and end of the array with 1, then loop over the internal section checking each neighbor.

Body:
Challenge:

Take a vector / list of integers as input, and output the largest number that's adjacent to a zero.

Specifications:

As always, optional input and output format

You may assume that there will be at least one zero, and at least one non-zero element.

Test cases:

```<code>1 4 3 6 0 3 7 0
7

9 4 9 0 9 0 9 15 -2
9

-4 -6 -2 0 -9
-2

-11 0 0 0 0 0 -12 10
0

0 20
20
</code>```

Good luck and happy golfing!

Body:
C 132 bytes

Outputs using main's return code:

int main(int a,char**_){int i,m=0;_[0]=_[a]="1";for(i=1;i<a;++i){m=(*_[i-1]-48||*_[i+1]-48?m>atoi(_[i])?m:atoi(_[i]):m);}return m;}

I feel like I should be able to save a few bytes by saving one of the atoi calls, but I couldn't find an efficient way. (,t plus t= plus , plus t twice is too long). Also this technically uses undefined behaviour (setting _[a] to "1") but every compiler I know of allows it by default.

Strategy: pad the start and end of the array with 1, then loop over the internal section checking each neighbor.


问:
The shortest code to invert bit-wise a binary string
Me thinks there aren't enough easy questions on here that beginners can attempt!

The challenge: Given a random input string of 1's and 0's such as:

```<code>10101110101010010100010001010110101001010
</code>```

Write the shortest code that outputs the bit-wise inverse like so:

```<code>01010001010101101011101110101001010110101
</code>```

答:
Reticular, 13 bytes

```<code>iSBl[:0Eo]~*;
</code>```

Try it online!

Explanation

```<code>iSBl[:0Eo]~*;
i              take one line of input
 S             convert string to array of chars
  B            merge array with stack
   l           push the length
    [    ]~*   active the inside (length) times
     :0        push the string "0"
       E       check for equality
        o      output
            ;  terminate program
</code>```

Body:
Reticular, 13 bytes

iSBl[:0Eo]~*;

Try it online!

Explanation

iSBl[:0Eo]~*;
i              take one line of input
 S             convert string to array of chars
  B            merge array with stack
   l           push the length
    [    ]~*   active the inside (length) times
     :0        push the string "0"
       E       check for equality
        o      output
            ;  terminate program


问:
String Distance

Challenge

Given an input of an all-lowercase string [a-z], output the total distance between the letters.

Example

```<code>Input: golf

Distance from g to o : 8
Distance from o to l : 3
Distance from l to f : 6

Output: 17
</code>```

Rules

Standard loopholes forbidden

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

The alphabet can be traversed from either direction. You must always use the shortest path. (i.e the distance between x and c is 5).

Test cases

```<code>Input: aa
Output: 0

Input: stack
Output: 18

Input: zaza
Output: 3

Input: valleys
Output: 35
</code>```

答:
Actually, 21 bytes

Based partially on cia_rana's Ruby answer.

There was a bug with O (in this case, map ord() over a string) where it would not work with d (dequeue bottom element) and p (pop first element) without first converting the map to a list with #. This bug has been fixed, but as that fix is newer than this challenge, so I've kept # in.

Edit: And the byte count has been wrong since September. Whoops.

Golfing suggestions welcome. Try it online!

```<code>O#;dX@pX♀-`A;úl-km`MΣ
</code>```

Ungolfing

```<code>         Implicit input string.
          The string should already be enclosed in quotation marks.
O#       Map ord() over the string and convert the map to a list. Call it ords.
;        Duplicate ords.
dX       Dequeue the last element and discard it.
@        Swap the with the duplicate ords.
pX       Pop the last element and discard it. Stack: ords[:-1], ords[1:]
♀-       Subtract each element of the second list from each element of the first list.
          This subtraction is equivalent to getting the first differences of ords.
`...`M   Map the following function over the first differences. Variable i.
  A;       abs(i) and duplicate.
  úl       Push the lowercase alphabet and get its length. A golfy way to push 26.
  -        26-i
  k        Pop all elements from stack and convert to list. Stack: [i, 26-i]
  m        min([i, 26-i])
Σ        Sum the result of the map.
         Implicit return.
</code>```

Title: String Distance

Body:
Actually, 21 bytes

Based partially on cia_rana's Ruby answer.

There was a bug with O (in this case, map ord() over a string) where it would not work with d (dequeue bottom element) and p (pop first element) without first converting the map to a list with #. This bug has been fixed, but as that fix is newer than this challenge, so I've kept # in.

Edit: And the byte count has been wrong since September. Whoops.

Golfing suggestions welcome. Try it online!

O#;dX@pX♀-`A;úl-km`MΣ

Ungolfing

         Implicit input string.
          The string should already be enclosed in quotation marks.
O#       Map ord() over the string and convert the map to a list. Call it ords.
;        Duplicate ords.
dX       Dequeue the last element and discard it.
@        Swap the with the duplicate ords.
pX       Pop the last element and discard it. Stack: ords[:-1], ords[1:]
♀-       Subtract each element of the second list from each element of the first list.
          This subtraction is equivalent to getting the first differences of ords.
`...`M   Map the following function over the first differences. Variable i.
  A;       abs(i) and duplicate.
  úl       Push the lowercase alphabet and get its length. A golfy way to push 26.
  -        26-i
  k        Pop all elements from stack and convert to list. Stack: [i, 26-i]
  m        min([i, 26-i])
Σ        Sum the result of the map.
         Implicit return.


问:
How can I get a repdigit?
In honor of how much rep I had several hours ago, when I first thought of this challenge:

Numbers like this that are made up of a single digit repeating are called repdigits. Repdigits are fun! Every body would be more happy if the amount of rep they had was a repdigit¹, but I am impatient, so you need to help me find out the fastest way to get to a repdigit.

Here is your challenge:

Given a positive integers representing reputation, output the minimum amount of rep they need to gain to get to a repdigit. For example, at the time of writing this challenge, user Martin Ender had 102,856 rep. The nearest rep-digit is 111,111, so he would need to gain: 8255 rep to be at a repdigit.

Since people dislike losing rep, we will only consider non-negative changes. This means that, for example, if someone is at 12 rep, rather than losing 1 rep, the solution is to gain 10 rep. This allows '0' to be a valid output, since anyone who has 111 rep is already at a repdigit.

Input and output can be in any reasonable format, and since it is impossible to have less than 1 rep on any Stack Exchange site, you can assume no inputs will be less than 1.

One cornercase to note:

If a user has less than 10 rep, they are already at a repdigit, and so they also need '0'.

Test IO:

```<code>#Input      #Ouput
8           0
100         11
113         109
87654321    1234567
42          2
20000       2222
11132       11090
</code>```

Standard loopholes apply, and the shortest solution in bytes wins!

Title: How can I get a repdigit?

Body:
Prolog, 120 bytes

r([H|T]):-r(H,[H|T]).
r(H,[H|T]):-r(H,T).
r(_,[]).
g(N,0):-number_chars(N,L),r(L).
g(N,X):-N1 is N+1,g(N1,X1),X is X1+1.

Try it online!


答:
PHP <s>69</s> 64 bytes

Some bytes on and off from Jörg Hülsermann and Titus. = (-5)

Requires register_globals enabled. Usage: http://localhost/notnull.php?i[]=9&i[]=-5i[]=...

```<code>$x=$_GET['i'];
$y=0;
foreach($x as $j){
if($y<abs($j)){
$y=$j;
}
}
echo $y;
</code>```

Golfed:

```<code>$x=$_GET['i'];$y=0;foreach($x as $j)if($y<abs($j))$y=$j;echo $y;
</code>```

Body:
PHP <s>69</s> 64 bytes

Some bytes on and off from Jörg Hülsermann and Titus. = (-5)

Requires register_globals enabled. Usage: http://localhost/notnull.php?i[]=9&i[]=-5i[]=...

$x=$_GET['i'];
$y=0;
foreach($x as $j){
if($y<abs($j)){
$y=$j;
}
}
echo $y;

Golfed:

$x=$_GET['i'];$y=0;foreach($x as $j)if($y<abs($j))$y=$j;echo $y;


答:
q, 38 bytes

```<code>{max x where 0 in'x,'(next x),'prev x}
</code>```

Body:
q, 38 bytes

{max x where 0 in'x,'(next x),'prev x}


答:
PHP, 41 bytes

```<code><?=count(spliti("[aeiou]",$argv[1]))%2-1;
</code>```

This outputs -1 for truthy and 0 for falsey.

Title: Is it an Odd Word?

Body:
PHP, 41 bytes

<?=count(spliti("[aeiou]",$argv[1]))%2-1;

This outputs -1 for truthy and 0 for falsey.


问:
Shortest program that throws StackOverflow Error
Write a program that throws a StackOverflow Error or the equivalent in the language used. For example, in java, the program should throw java.lang.StackOverflowError.

You are not allowed to define a function that calls itself or a new class(except the one containing main in java). It should use the classes of the selected programming language.

And it should not throw the error explicitly.

答:
C -- 34 characters, no libraries

Though competative with Job's answer,

```<code>o(){O();}
O(){o();o();}
main(){o();}
</code>```

violates the spirt of the challenge by showing how to evade the restriction on constructing a simple recursion. You can save 4 character by removing one call from O, but gcc is smart enough to recongnise that if you use -O3.1

The trick is quite general and can be done in fortran 77, too (142 characters):

```<code>      program o
      i=j()
      stop
      end
      function j()
      j=k()
      end
      function k()
      k=j()
      k=j()
      end
</code>```

Again, gcc can optimize away a single call in each.

1 I suppose it inlines one of them and then applys tail recursion elimination. How cool is that!?!.

Body:
C -- 34 characters, no libraries

Though competative with Job's answer,

o(){O();}
O(){o();o();}
main(){o();}

violates the spirt of the challenge by showing how to evade the restriction on constructing a simple recursion. You can save 4 character by removing one call from O, but gcc is smart enough to recongnise that if you use -O3.1

The trick is quite general and can be done in fortran 77, too (142 characters):

      program o
      i=j()
      stop
      end
      function j()
      j=k()
      end
      function k()
      k=j()
      k=j()
      end

Again, gcc can optimize away a single call in each.

1 I suppose it inlines one of them and then applys tail recursion elimination. How cool is that!?!.


问:
Close-Knit Words

Introduction

According to Rand Al'Thor's post in the Puzzling SE, a close-knit word is any word that contains three alphabetically consecutive letters (in any order).

Words like education, foghorn and cabaret are all considered close-knit words whereas words like learning, klaxon and perform are not close-knit words.

Challenge

The challenge is to code-golf a program capable of taking a single word as input (assumed lower case, for all intents and purposes) and to return output that (if available) lists all consecutive letter sets (also in lower case) if it is a close-knit word, and empty output if it is not a close-knit word.

Examples

```<code>Input: education
Output: cde

Input: foghorn
Output: fgh

Input: cabaret
Output: abc

Input: hijacking
Output: ghi, hij, ijk

Input: pneumonia
Output: mno, nop

Input: klaxon
Output: <<no output>>

Input: perform
Output: <<no output>>

Input: learning
Output: <<no output>>
</code>```

Rules

Whereas input is to be assumed to be a single lower-case word and output must be lower-case, the nature of the output will vary according to the choice of your coding language. Please select a form of output that will best suit the nature of the challenge, whether it be STDOUT, file output, array, etc.

Because this is code-golf, it will be a case of lowest number of bytes being the clear winner.

No silly loopholes.

I will not accept answers that have the consecutive letters in non-alphabetical order... So cab will not be deemed a suitable output for cabaret, for example.

Special note, while the "triplets" don't necessarily have to be in alphabetical order, but the characters within the triplets must be... so in the case of the word "performance", for example, the output mno,nop will be accepted, as will nop,mno. In the case of the word "hijacking", there are six ways that the triplets of ghi, hij and ijk could be arranged in a list, and all six permutations are acceptable as output.

Other than that, on your marks, get set, golf!

答:
C, <s>175</s> 174 bytes

```<code>main(_,a,m,n)char**a;{char*s=a[1],*t=s;while(*++s)while(s>t&&(n=s[-1])>=*s){m=(*s^n)?*s:0;*s=n;*--s=m;!*t&&++t;}for(;t[1]&t[2];++t)*t==t[1]-1&&*t==t[2]-2&&printf("%.3s ",t);}
</code>```

indented:

```<code>main(_,a,m,n)char**a;
{
  char*s=a[1],*t=s;
  while(*++s)
    while(s>t&&(n=s[-1])>=*s){
      m=(*s^n)?*s:0;
      *s=n;
      *--s=m;
      !*t&&++t;
    }
  for(;t[1]&t[2];++t)
    *t==t[1]-1&&*t==t[2]-2&&printf("%.3s ",t);
}
</code>```

While doing the sort it replaces duplicate values with 0s, these 0s get sorted to the beginning of the word. Looking for the consecutive values is then trivial.

Title: Close-Knit Words

Body:
C, <s>175</s> 174 bytes

main(_,a,m,n)char**a;{char*s=a[1],*t=s;while(*++s)while(s>t&&(n=s[-1])>=*s){m=(*s^n)?*s:0;*s=n;*--s=m;!*t&&++t;}for(;t[1]&t[2];++t)*t==t[1]-1&&*t==t[2]-2&&printf("%.3s ",t);}

indented:

main(_,a,m,n)char**a;
{
  char*s=a[1],*t=s;
  while(*++s)
    while(s>t&&(n=s[-1])>=*s){
      m=(*s^n)?*s:0;
      *s=n;
      *--s=m;
      !*t&&++t;
    }
  for(;t[1]&t[2];++t)
    *t==t[1]-1&&*t==t[2]-2&&printf("%.3s ",t);
}

While doing the sort it replaces duplicate values with 0s, these 0s get sorted to the beginning of the word. Looking for the consecutive values is then trivial.