答:
MATL, <s>55</s> <s>53</s> <s>52</s> 51 bytes

```<code>|95cy4*Y"DXytPEt0*yvG0>?P_]!'\/ 'w)95JG|G0<yEq:++&(
</code>```

Try it online!

Explanation

Let N denote the input. The code proceeds in three steps.

First, the first line of  4*N underscores is built as a string and is displayed (which removes it from the stack).

Second, the "frame" of the tent is built using the two types of slashes. To do this, a numerical 2D array is created which contains 1 and 2 corresponding to the two types of slashes, and 0 for space.

This is done concatenating four matrices:

An identity matrix of size abs (N);

A matrix of the same size containing 2 in the antidiagonal;

A null matrix of the same size;

A copy of matrix 2.

Concatenating these four matrices vertically gives, using N=3 as an example, the following 4*N × N matrix:

```<code>1 0 0
0 1 0
0 0 1
0 0 2
0 2 0
2 0 0
0 0 0
0 0 0
0 0 0
0 0 2
0 2 0
2 0 0
</code>```

(which, transposed, begins to look like the tent).

We now take care of the sign of the input. If it is positive we simply transpose the above matrix and index into the string '\/ '. Indexing is 1-based and modular, so 1 becomes '\', 2 becomes '/' and 0 becomes ' ', producing the 2D char array

```<code>\    /     /
 \  /     /
  \/     /
</code>```

On the other hand, if the input is negative we vertically flip and arithmetically negate the 4*N × N matrix, producing

```<code>-2  0  0
 0 -2  0
 0  0 -2
 0  0  0
 0  0  0
 0  0  0
-2  0  0
 0 -2  0
 0  0 -2
 0  0 -1
 0 -1  0
-1  0  0
</code>```

Index -1 now refers to '/' and -2 to '\'. That is, the two types of slashes have been interchanged, as required. Again transposing and indexing into the string '\/ ' thus gives the reversed tent:

```<code>\     \    /
 \     \  /
  \     \/
</code>```

Third, underscores need to be filled into part of the last row of the 2D char array. The horizontal position of this line depends on the sign of the input, and its lenght is abs(N).

Once the corresponding spaces have been replaced by underscores, the result is implicitly displayed, below the initial line of underscores that was already displayed in the first step.

Title: Output an upside-down tent

Body:
MATL, <s>55</s> <s>53</s> <s>52</s> 51 bytes

|95cy4*Y"DXytPEt0*yvG0>?P_]!'\/ 'w)95JG|G0<yEq:++&(

Try it online!

Explanation

Let N denote the input. The code proceeds in three steps.

First, the first line of  4*N underscores is built as a string and is displayed (which removes it from the stack).

Second, the "frame" of the tent is built using the two types of slashes. To do this, a numerical 2D array is created which contains 1 and 2 corresponding to the two types of slashes, and 0 for space.

This is done concatenating four matrices:

An identity matrix of size abs (N);

A matrix of the same size containing 2 in the antidiagonal;

A null matrix of the same size;

A copy of matrix 2.

Concatenating these four matrices vertically gives, using N=3 as an example, the following 4*N × N matrix:

1 0 0
0 1 0
0 0 1
0 0 2
0 2 0
2 0 0
0 0 0
0 0 0
0 0 0
0 0 2
0 2 0
2 0 0

(which, transposed, begins to look like the tent).

We now take care of the sign of the input. If it is positive we simply transpose the above matrix and index into the string '\/ '. Indexing is 1-based and modular, so 1 becomes '\', 2 becomes '/' and 0 becomes ' ', producing the 2D char array

\    /     /
 \  /     /
  \/     /

On the other hand, if the input is negative we vertically flip and arithmetically negate the 4*N × N matrix, producing

-2  0  0
 0 -2  0
 0  0 -2
 0  0  0
 0  0  0
 0  0  0
-2  0  0
 0 -2  0
 0  0 -2
 0  0 -1
 0 -1  0
-1  0  0

Index -1 now refers to '/' and -2 to '\'. That is, the two types of slashes have been interchanged, as required. Again transposing and indexing into the string '\/ ' thus gives the reversed tent:

\     \    /
 \     \  /
  \     \/

Third, underscores need to be filled into part of the last row of the 2D char array. The horizontal position of this line depends on the sign of the input, and its lenght is abs(N).

Once the corresponding spaces have been replaced by underscores, the result is implicitly displayed, below the initial line of underscores that was already displayed in the first step.


问:
Decode the chmod

Challenge

Given a three digit octal permissions number, output the permissions that it grants.

chmod

On UNIX OSes file permissions are changed using the chmod command. There are few different ways of using chmod, but the one we will focus on today is using octal permissions.

The three digits in the permissions number represent a different person:

The first digit represents the permissions for the user

The second digit represents the permissions for the group

The last digit represents the permissions for others

Next, each digit represents a permission as shown below in:

```<code>Key: number | permission

7 | Read Write and Execute
6 | Read and Write
5 | Read and Execute
4 | Read only
3 | Write and Execute
2 | Write only
1 | Execute only
0 | None
</code>```

Input

The input will be the three digit number as a string, e.g.:

```<code>133
</code>```

or

```<code>007
</code>```

This will be passed either via STDIN or via function arguments.

Output

Your output should be the different permissions for each of the user, the group and the others. You must display this information like so:

```<code>User:   ddd
Group:  ddd
Others: ddd
</code>```

Where there are three spaces after User, two spaces after Group and one space after Others. You replace ddd with the permissions information.

Your output may be to STDOUT or as a returned string.

Examples

Input: 666

Output:

```<code>User:   Read and Write
Group:  Read and Write
Others: Read and Write
</code>```

Input: 042

Output:

```<code>User:   None
Group:  Read only
Others: Write only
</code>```

Input: 644

Output:

```<code>User:   Read and Write
Group:  Read only
Others: Read only
</code>```

Winning

The shortest code in bytes wins.

答:
F#, <s>204</s> 203 Bytes

my first golf, so do please forgive any mistakes ;)

The golfed version (based 1:1 on pinkfloydx33's answer):

```<code>fun(y:string)->let e,r,w,o,a="Execute ","Read ","Write ","only","and ";let z=["None";e+o;w+o;w+a+e;r+o;r+a+e;r+a+w;r+w+a+e;];let(!-)a=z.[int y.[a]-48];sprintf"User:   %s\nGroup:  %s\nOthers: %s"!-0!-1!-2
</code>```

The ungolfed version:

```<code>fun (y : string) ->
    let e, r, w, o, a = "Execute ", "Read ", "Write ", "only", "and "
    let z = [
                "None";
                e + o;
                w + o;
                w + a + e;
                r + o;
                r + a + e;
                r + a + w;
                r + w + a + e;
            ]
    let (!-) a = z.[int(y.[a]) - 48]
    sprintf "User:   %s\nGroup:  %s\nOthers: %s" !-0 !-1 !-2
</code>```

Example usage:

```<code>let k =  ...... // function definition goes here

printf"%s"<|k"755"
printf"%s"<|k"042"
// etc ...
</code>```

This is solely to check, whether I could 'improve' pinkfloydx33's answer - I do not take any credit for the algorithm

ContentLicense: CC BY-SA 3.0

Title: Decode the chmod

Body:
F#, <s>204</s> 203 Bytes

my first golf, so do please forgive any mistakes ;)

The golfed version (based 1:1 on pinkfloydx33's answer):

fun(y:string)->let e,r,w,o,a="Execute ","Read ","Write ","only","and ";let z=["None";e+o;w+o;w+a+e;r+o;r+a+e;r+a+w;r+w+a+e;];let(!-)a=z.[int y.[a]-48];sprintf"User:   %s\nGroup:  %s\nOthers: %s"!-0!-1!-2

The ungolfed version:

fun (y : string) ->
    let e, r, w, o, a = "Execute ", "Read ", "Write ", "only", "and "
    let z = [
                "None";
                e + o;
                w + o;
                w + a + e;
                r + o;
                r + a + e;
                r + a + w;
                r + w + a + e;
            ]
    let (!-) a = z.[int(y.[a]) - 48]
    sprintf "User:   %s\nGroup:  %s\nOthers: %s" !-0 !-1 !-2

Example usage:

let k =  ...... // function definition goes here

printf"%s"<|k"755"
printf"%s"<|k"042"
// etc ...

This is solely to check, whether I could 'improve' pinkfloydx33's answer - I do not take any credit for the algorithm


问:
Do the auto-super-logarithm
Given a positive integer n and a number a, the n-th tetration of a is defined as a^(a^(a^(...^a))), where ^ denotes exponentiation (or power) and the expression contains the number a exactly n times.

In other words, tetration is right-associative iterated exponentiation. For n=4 and a=1.6 the tetration is 1.6^(1.6^(1.6^1.6)) ≈ 3.5743.

The inverse function of tetration with respect to n is the super-logarithm. In the previous example, 4 is the super-logarithm of 3.5743 with "super-base" 1.6.

The challenge

Given a positive integer n, find x such that n is the super-logarithm of itself in super-base x. That is, find x such that x^(x^(x^(...^x))) (with x appearing n times) equals n.

Rules

Program or function allowed.

Input and output formats are flexible as usual.

The algorithm should theoretically work for all positive integers. In practice, input may be limited to a maximum value owing to memory, time or data-type restrictions. However, the code must work for inputs up to 100 at least in less than a minute.

The algorithm should theoretically give the result with 0.001 precision. In practice, the output precision may be worse because of accumulated errors in numerical computations. However, the output must be accurate up to 0.001 for the indicated test cases.

Shortest code wins.

Test cases

```<code>1    ->  1
3    ->  1.635078
6    ->  1.568644
10   ->  1.508498
25   ->  1.458582
50   ->  1.448504
100  ->  1.445673
</code>```

Reference implementation

Here's a reference implementation in Matlab / Octave (try it at Ideone).

```<code>N = 10; % input
t = .0001:.0001:2; % range of possible values: [.0001 .0002 ... 2]
r = t;
for k = 2:N
    r = t.^r; % repeated exponentiation, element-wise
end
[~, ind] = min(abs(r-N)); % index of entry of r that is closest to N
result = t(ind);
disp(result)
</code>```

For N = 10 this gives result =  1.5085.

The following code is a check of the output precision, using variable-precision arithmetic:

```<code>N = 10;
x = 1.5085; % result to be tested for that N. Add or subtract 1e-3 to see that
            % the obtained y is farther from N
s = num2str(x); % string representation
se = s;
for n = 2:N;
    se = [s '^(' se ')']; % build string that evaluates to iterated exponentiation
end
y = vpa(se, 1000) % evaluate with variable-precision arithmetic
</code>```

This gives:

For x = 1.5085: y = 10.00173...

For x = 1.5085 + .001: y = 10.9075

For x = 1.5085 - .001 it gives y = 9.23248.

so 1.5085 is a valid solution with .001 precision.

Title: Do the auto-super-logarithm

Body:
Python, 184 bytes

def s(n):
 def j(b,i):
  if i<0.1**12:
   return b
  m = b+i
  try:
   v = reduce(lambda a,b:b**a,[m]*n)
  except:
   v = n+1
  return j(m,i/2) if v<n else j(b,i/2)
 return j(1.0,0.5)

Test output (skipping the actual print statements):

   s(1) 1.0
   s(3) 1.63507847464
   s(6) 1.5686440646
  s(10) 1.50849792026
  s(25) 1.45858186605
  s(50) 1.44850389566
 s(100) 1.44567285047


问:
Shuffle a mapping
We define a map as a set of key-value pairs.  For this challenge, you need to take each of the values and assign them to a randomly chosen key.

You must randomly shuffle the values, and output the resulting map.  This means that each time we run your program, we have a chance of getting a different output

Each possible permutation of the values must have a non-zero chance of appearing.

All of the original keys and original values must appear in the resulting array.  Repeated values must appear the same number of times in the resulting array.

For example, if your map was:

```<code>[0:10, 1:10, 5:5]
</code>```

all of the following must have a chance of appearing:

```<code>[0:10, 1:10, 5:5]  (original map)
[0:10, 1:5,  5:10]
[0:10, 1:10, 5:5]  (technically the same map, but I swapped the two tens)
[0:10, 1:5,  5:10]
[0:5,  1:10, 5:10]
[0:5,  1:10, 5:10]
</code>```

Acceptable input/outputs:

Your languages' native map

You can input an array of key-value pairs.  You may not input 2 arrays, one with keys, the other with values.

You can use a string representation of any the above

If you input an array or a map, you can modify the original object instead of returning

The input type must match the output type

If you input an array, the order of the keys must be maintained.

You can assume that the keys are unique, but you cannot assume that values are unique.

This is a code-golf, so answer as short as possible

答:
Perl 6, 28 bytes

{%(.keys.pick(*)Z=>.values)}
```

<p>Input is a Hash<br>
( Technically any value with a <code>.keys</code> method and a <code>.values</code> method would work, but the output is a Hash )</p>

<h2>Explanation:</h2>

<pre class="lang-perl6 prettyprint-override"><code># bare block lambda with implicit parameter ｢$_｣
{

  # turn the list of key => value Pairs into a Hash
  %(
      # get the keys from ｢$_｣ ( implicit method call on ｢$_｣ )
      .keys

      # get all of the keys in random order
      .pick(*)

    # zip using ｢&infix:« => »｣ the Pair constructor
    Z[=>]

      # the values from ｢$_｣ ( implicit method call on ｢$_｣ )
      .values
  )
}
</code>```

A variant that would work for the other built in Hash like object types is:

{.WHAT.(.keys.pick(*)Z=>.values)}
```

.WHAT on an object returns the type.

Title: Shuffle a mapping

Body:
Perl 6, 28 bytes

{%(.keys.pick(*)Z=>.values)}

Input is a Hash

( Technically any value with a .keys method and a .values method would work, but the output is a Hash )

Explanation:

# bare block lambda with implicit parameter ｢$_｣
{

  # turn the list of key => value Pairs into a Hash
  %(
      # get the keys from ｢$_｣ ( implicit method call on ｢$_｣ )
      .keys

      # get all of the keys in random order
      .pick(*)

    # zip using ｢&infix:« => »｣ the Pair constructor
    Z[=>]

      # the values from ｢$_｣ ( implicit method call on ｢$_｣ )
      .values
  )
}

A variant that would work for the other built in Hash like object types is:

{.WHAT.(.keys.pick(*)Z=>.values)}

.WHAT on an object returns the type.


答:
Python 2, <s>240</s> <s>239</s> <s>238</s> <s>237</s> 228 bytes

I thought I’d finally give this cold golf thing a go. <s>Hopefully trailing whitespace is allowed.</s> (fixed, and in the process saved a byte)

i=0
def a(b):
 for d in 4,2,1:
    if b&d:yield('Execute','Write','Read')[d/2]
for k in raw_input():
 b,q=list(a(int(k))),' and';e=len(b)
 if e:b[~e/2]+=(' only',q,q)[e-1]
 print'UGOsrteohrue:pr :s  :'[i::3],' '.join(b)or None;i+=1
```

Title: Decode the chmod

Body:
Challenge

Given a three digit octal permissions number, output the permissions that it grants.

chmod

On UNIX OSes file permissions are changed using the chmod command. There are few different ways of using chmod, but the one we will focus on today is using octal permissions.

The three digits in the permissions number represent a different person:

The first digit represents the permissions for the user

The second digit represents the permissions for the group

The last digit represents the permissions for others

Next, each digit represents a permission as shown below in:

```<code>Key: number | permission

7 | Read Write and Execute
6 | Read and Write
5 | Read and Execute
4 | Read only
3 | Write and Execute
2 | Write only
1 | Execute only
0 | None
</code>```

Input

The input will be the three digit number as a string, e.g.:

```<code>133
</code>```

or

```<code>007
</code>```

This will be passed either via STDIN or via function arguments.

Output

Your output should be the different permissions for each of the user, the group and the others. You must display this information like so:

```<code>User:   ddd
Group:  ddd
Others: ddd
</code>```

Where there are three spaces after User, two spaces after Group and one space after Others. You replace ddd with the permissions information.

Your output may be to STDOUT or as a returned string.

Examples

Input: 666

Output:

```<code>User:   Read and Write
Group:  Read and Write
Others: Read and Write
</code>```

Input: 042

Output:

```<code>User:   None
Group:  Read only
Others: Write only
</code>```

Input: 644

Output:

```<code>User:   Read and Write
Group:  Read only
Others: Read only
</code>```

Winning

The shortest code in bytes wins.


答:
Dyalog APL, <s>33</s> 25 bytes

Needs ⎕IO←0 which is default on many systems.

⌈/⎕(⊢×⊣≥(*/⍴)¨)(1+⍳÷⊢)1E4
```

Theoretically calculates for all integers, but practically limited to very small one only.

TryAPL online!

Title: Do the auto-super-logarithm

Body:
Given a positive integer n and a number a, the n-th tetration of a is defined as a^(a^(a^(...^a))), where ^ denotes exponentiation (or power) and the expression contains the number a exactly n times.

In other words, tetration is right-associative iterated exponentiation. For n=4 and a=1.6 the tetration is 1.6^(1.6^(1.6^1.6)) ≈ 3.5743.

The inverse function of tetration with respect to n is the super-logarithm. In the previous example, 4 is the super-logarithm of 3.5743 with "super-base" 1.6.

The challenge

Given a positive integer n, find x such that n is the super-logarithm of itself in super-base x. That is, find x such that x^(x^(x^(...^x))) (with x appearing n times) equals n.

Rules

Program or function allowed.

Input and output formats are flexible as usual.

The algorithm should theoretically work for all positive integers. In practice, input may be limited to a maximum value owing to memory, time or data-type restrictions. However, the code must work for inputs up to 100 at least in less than a minute.

The algorithm should theoretically give the result with 0.001 precision. In practice, the output precision may be worse because of accumulated errors in numerical computations. However, the output must be accurate up to 0.001 for the indicated test cases.

Shortest code wins.

Test cases

```<code>1    ->  1
3    ->  1.635078
6    ->  1.568644
10   ->  1.508498
25   ->  1.458582
50   ->  1.448504
100  ->  1.445673
</code>```

Reference implementation

Here's a reference implementation in Matlab / Octave (try it at Ideone).

```<code>N = 10; % input
t = .0001:.0001:2; % range of possible values: [.0001 .0002 ... 2]
r = t;
for k = 2:N
    r = t.^r; % repeated exponentiation, element-wise
end
[~, ind] = min(abs(r-N)); % index of entry of r that is closest to N
result = t(ind);
disp(result)
</code>```

For N = 10 this gives result =  1.5085.

The following code is a check of the output precision, using variable-precision arithmetic:

```<code>N = 10;
x = 1.5085; % result to be tested for that N. Add or subtract 1e-3 to see that
            % the obtained y is farther from N
s = num2str(x); % string representation
se = s;
for n = 2:N;
    se = [s '^(' se ')']; % build string that evaluates to iterated exponentiation
end
y = vpa(se, 1000) % evaluate with variable-precision arithmetic
</code>```

This gives:

For x = 1.5085: y = 10.00173...

For x = 1.5085 + .001: y = 10.9075

For x = 1.5085 - .001 it gives y = 9.23248.

so 1.5085 is a valid solution with .001 precision.

Body:
Dyalog APL, <s>33</s> 25 bytes

Needs ⎕IO←0 which is default on many systems.

⌈/⎕(⊢×⊣≥(*/⍴)¨)(1+⍳÷⊢)1E4

Theoretically calculates for all integers, but practically limited to very small one only.

<a href="http://tryapl.org/?a=%u2206%u21901%20%u22C4%20%u2308/%u2206%28%u22A2%D7%u22A3%u2265%28*/%u2374%29%A8%29%281+%u2373%F7%u22A2%291E4%20%u22C4%20%u2206%u21902%20%u22C4%20%u2308/%u2206%28%u22A2%D7%u22A3%u2265%28*/%u2374%29%A8%29%281+%u2373%F7%u22A2%291E4%20%u22C4%20%u2206%u21903%20%u22C4%20%u2308/%u2206%28%u22A2%D7%u22A3%u2265%28*/%u2374%29%A8%29%281+%u2373%F7%u22A2%291E4%20%u22C4%20%u2206%u21904%20%u22C4%20%u2308/%u2206%28%u22A2%D7%u22A3%u2265%28*/%u2374%29%A8%29%281+%u2373%F7%u22A2%291E4&run" rel="nofollow noreferrer">TryAPL online!


问:
Cambridge Transposition
I'm sure most, if not all, of you have come across this at some point or another:

Aoccdrnig to a rscheeachr at Cmabrigde Uinervtisy, it deosn't mttaer
in waht oredr the ltteers in a wrod are, the olny iprmoetnt tihng is
taht the frist and lsat ltteer be at the rghit pclae. The rset can be
a toatl mses and you can sitll raed it wouthit porbelm. Tihs is
bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the
wrod as a wlohe.

Create a program that inputs any amount of text. For testing purposes, use the unscrambled version of the above text, found below.

The program must then randomly transpose the letters of each word with a length of 4 or more letters, except the first and last letter of each word.

All other formatting must remain the same (capitalization and punctuation, etc.).

Testing text:

According to a researcher at Cambridge University, it doesn't matter
in what order the letters in a word are, the only important thing is
that the first and last letter be at the right place. The rest can be
a total mess and you can still read it without problem. This is
because the human mind does not read every letter by itself but the
word as a whole.

As usual, this is a code-golf. Shortest code wins.

答:
R, 179

Using the function I wrote for the randomize letters in a word problem:

Input:

```<code>s <- "According to a researcher at Cambridge University, it doesn't matter in what order the letters in a word are, the only important thing is that the first and last letter be at the right place. The rest can be a total mess and you can still read it without problem. This is because the human mind does not read every letter by itself but the word as a whole."
</code>```

Solution:

```<code>f=function(w){l=length;s=strsplit(w,"")[[1]];ifelse(l(s)<3,w,paste(c(s[1],sample(s[2:(l(s)-1)]),s[l(s)]),collapse=""))}
g=Vectorize(f)
paste(g(strsplit(s," ")[[1]]), collapse=" ")
</code>```

Result:

```<code>[1] "Arioccdng to a reehaecrsr at Cabrgimde Uveirisnyt, it des'not mttear in waht odrer the lttrees in a wrod are, the olny inpotmart thnig is that the fsrit and lsat letetr be at the right palce. The rset can be a toatl mses and you can stlil raed it wutioht pmrlebo. This is bsuceae the hmuan mnid deos not read ervey lteetr by iesltf but the word as a wleho."
</code>```

ContentLicense: CC BY-SA 4.0

Title: Cambridge Transposition

Body:
R, 179

Using the function I wrote for the randomize letters in a word problem:

Input:

s <- "According to a researcher at Cambridge University, it doesn't matter in what order the letters in a word are, the only important thing is that the first and last letter be at the right place. The rest can be a total mess and you can still read it without problem. This is because the human mind does not read every letter by itself but the word as a whole."

Solution:

f=function(w){l=length;s=strsplit(w,"")[[1]];ifelse(l(s)<3,w,paste(c(s[1],sample(s[2:(l(s)-1)]),s[l(s)]),collapse=""))}
g=Vectorize(f)
paste(g(strsplit(s," ")[[1]]), collapse=" ")

Result:

[1] "Arioccdng to a reehaecrsr at Cabrgimde Uveirisnyt, it des'not mttear in waht odrer the lttrees in a wrod are, the olny inpotmart thnig is that the fsrit and lsat letetr be at the right palce. The rset can be a toatl mses and you can stlil raed it wutioht pmrlebo. This is bsuceae the hmuan mnid deos not read ervey lteetr by iesltf but the word as a wleho."


问:
Output an upside-down tent
Given an integer, output an upside-down tent.

The input determines both the size of the tent (absolute value) and whether the entrance is on the left side (negative numbers) or the right side (positive numbers).

```<code>If input = -1:
____
\/_/

If input = -2:
________
\  /   /
 \/___/

If input = -3:
____________
\    /     /
 \  /     /
  \/_____/

If input = 1:
____
\_\/

If input = 2:
________
\   \  /
 \___\/

If input = 3:
____________
\     \    /
 \     \  /
  \_____\/

et cetera
</code>```

Note that the top of the tent (i.e. the last line) has 2 * abs(input) - 1 underscores.

There can be no leading spaces, such that the first line directly starts with an underscore.

Assume that the input will never be 0.

Your code should be as short as possible.

This challenge is based on a chat mini challenge by Helka Homba, which is allowed to be used in real challenges under the conditions of Calvin's Hobbies Public License.

答:
V, 66 bytes

```<code>é /ä
"aDoÀñá_>ñ^hr\A\/ò^hÄX$2é_Ó_/ òÄÒ_ñ/-
ddÍÜ¨[ _]*©Ü¨ *©/Ü²¯±
</code>```

Try it online!

This is a pretty naive approach, so I'll try to golf it down further later today. This solution contains unprintable characters, so here is a hexdump:

```<code>0000000: e920 2fe4 0a22 6144 6f1b c0f1 e15f 3ef1  . /.."aDo...._>.
0000010: 5e68 725c 415c 2f1b f25e 68c4 5824 32e9  ^hr\A\/..^h.X$2.
0000020: 5fd3 5f2f 20f2 c4d2 5ff1 2f2d 0a64 64cd  _._/ ..._./-.dd.
0000030: dca8 5b20 5f5d 2aa9 dca8 202a a92f dcb2  ..[ _]*... *./..
0000040: afb1                                     ..
</code>```

Title: Output an upside-down tent

Body:
V, 66 bytes

é /ä
"aDoÀñá_>ñ^hr\A\/ò^hÄX$2é_Ó_/ òÄÒ_ñ/-
ddÍÜ¨[ _]*©Ü¨ *©/Ü²¯±

Try it online!

This is a pretty naive approach, so I'll try to golf it down further later today. This solution contains unprintable characters, so here is a hexdump:

0000000: e920 2fe4 0a22 6144 6f1b c0f1 e15f 3ef1  . /.."aDo...._>.
0000010: 5e68 725c 415c 2f1b f25e 68c4 5824 32e9  ^hr\A\/..^h.X$2.
0000020: 5fd3 5f2f 20f2 c4d2 5ff1 2f2d 0a64 64cd  _._/ ..._./-.dd.
0000030: dca8 5b20 5f5d 2aa9 dca8 202a a92f dcb2  ..[ _]*... *./..
0000040: afb1                                     ..


问:
Noah's (upgraded) ark
As preparation for the nth Exodus, Noah decides to write a program that will decide If he will let animals on his ark.  However, Noah wants to go back to grass roots. Thus he decides that the program should be as small and as simple as possible.

GOAL:

Recreate the Contrabulous Choosematron, in a way that follows evangelical stories.

INPUT:

The program is simple, and elegant, and takes in 2 inputs:

The species of animal [String]

and The animal's gender [boolean]

OUTPUT:

The program then puts out Either 'Y' or 'N', Which determines whether or not the given  animal is allowed onto the ark.

RULES:

Only one Animal of each species and gender is allowed on the ark. No more.

Your output can be any set of boolean values (true false, yes no, y n, yin yang) so long as they're easily distinguishable.

If your program should want to accept a list of input, rather than use STDIN, that's fine. However, each output has to be in corresponding order of the input (FIFO), as well as be in the exact same format as the input.

This is a golf, so the lowest byte count wins, good luck!!!!

EXAMPLE:

"Monkey" true<

y

"Monkey" false<

y

"Monkey" false<

n

"Monkey with symbols" false<

y

"monkey" true<

n

This is valid, as your program doesn't need to distinguish that Monkey, and monkey with symbols are the same thing species, however, Monkey and monkey are very much the same thing, and so the last critter would be denied.

答:
Swift 2.2 169 bytes

I did not accept input from standard in I just passed an array of dictionaries to function x.

Golfed

```<code>var a=[String]();let x={(d:[[String:Bool]]) in for r in d{for(s,t)in r{let y=s.lowercaseString+t.description;a.append(y);print(a.indexOf(y)==(a.count-1) ? true:false)}}}
</code>```

UnGolfed

```<code>var a=[String]();
let x={(d:[[String:Bool]]) in
    for r in d{
        for(s,t)in r{
            let y=s.lowercaseString+t.description;
            a.append(y);
            print(a.indexOf(y)==(a.count-1) ? true:false)
        }
    }
}
</code>```

Input

```<code>x([["Monkey":true],["Monkey":false],["monkey":true],["Zebra":true]])
</code>```

Also just for giggles did a crappy javascript version since I did not see anyone else do a javascript one.

JS (ES6) 125 bytes

Golfed

```<code>a=[],i=0,j=0;y=(r)=>{for(;j<r.length;j+=2){var y=r[j].toLowerCase()+r[j+1];a[i]=y;console.log(a.indexOf(y)==i++?true:false)}}a=[],i=0,j=0;y=(r)=>{for(;j<r.length;j+=2){var y=r[j].toLowerCase()+r[j+1];a[i]=y;console.log(a.indexOf(y)==i++?true:false)}}
</code>```

UnGolfed

```<code>a=[],i=0,j=0;
y=(r)=>{
  for(;j<r.length;j+=2){
    var y=r[j].toLowerCase()+r[j+1];
    a[i]=y;
    console.log(a.indexOf(y)==i++?true:false)
  }
}
</code>```

Input

```<code>y(["Monkey", true, "Monkey", false, "monkey",true,"zebra",false])
</code>```

Title: Noah's (upgraded) ark

Body:
Swift 2.2 169 bytes

I did not accept input from standard in I just passed an array of dictionaries to function x.

Golfed

var a=[String]();let x={(d:[[String:Bool]]) in for r in d{for(s,t)in r{let y=s.lowercaseString+t.description;a.append(y);print(a.indexOf(y)==(a.count-1) ? true:false)}}}

UnGolfed

var a=[String]();
let x={(d:[[String:Bool]]) in
    for r in d{
        for(s,t)in r{
            let y=s.lowercaseString+t.description;
            a.append(y);
            print(a.indexOf(y)==(a.count-1) ? true:false)
        }
    }
}

Input

x([["Monkey":true],["Monkey":false],["monkey":true],["Zebra":true]])

Also just for giggles did a crappy javascript version since I did not see anyone else do a javascript one.

JS (ES6) 125 bytes

Golfed

a=[],i=0,j=0;y=(r)=>{for(;j<r.length;j+=2){var y=r[j].toLowerCase()+r[j+1];a[i]=y;console.log(a.indexOf(y)==i++?true:false)}}a=[],i=0,j=0;y=(r)=>{for(;j<r.length;j+=2){var y=r[j].toLowerCase()+r[j+1];a[i]=y;console.log(a.indexOf(y)==i++?true:false)}}

UnGolfed

a=[],i=0,j=0;
y=(r)=>{
  for(;j<r.length;j+=2){
    var y=r[j].toLowerCase()+r[j+1];
    a[i]=y;
    console.log(a.indexOf(y)==i++?true:false)
  }
}

Input

y(["Monkey", true, "Monkey", false, "monkey",true,"zebra",false])


答:
C, <s>240</s> <s>207</s> 193 Bytes

```<code>#define P putchar
a,j,l,m;g(x,y,z){for(m=y+z+1;m--;P(m^z?l?32:95:x));}f(n){g(32,(a=abs(n))*4,0);for(P(10),j=2*(l=a)-1;l--;){for(m=a;--m>l;P(32));P(92);m=n>0?g(92,j,l*2):g(47,l*2,j);puts("/");}}
</code>```

This time I optimized the function g(...) to use a single for loop.

```<code>#define P putchar
a,j,l,m;g(x,y,z){for(;y--;P(l?32:95));for(P(x);z--;P(l?32:95));}f(n){g(32,(a=abs(n))*4,0);l=a;j=2*a-1;P(10);for(;l--;){for(m=a;--m>l;P(32));P(92);m=n>0?g(92,j,l*2):g(47,l*2,j);puts("/");}}
</code>```

This time macro X is better off as a function g(...) and since y and z are parameters in a new scope I can just decrement them in the scope of g.

```<code>#define P putchar
#define X(x,y,z){for(k=0;k++<y;P(l?32:95));P(x);for(k=0;k++<z;P(l?32:95));}
a,i,j,k,l,m;f(n){for(l=a=abs(n);i++<a*4;P(95));j=2*a-1;P(10);while(l--){for(m=a;--m>l;P(32));P(92);if(n>0)X(92,j,l*2)else X(47,l*2,j)puts("/");}}
</code>```

Test with this main function;  This should golf down much smaller.

```<code>main(c,v)char**v;
{
    f(atoi(v[1]));
}
</code>```

Title: Output an upside-down tent

Body:
Given an integer, output an upside-down tent.

The input determines both the size of the tent (absolute value) and whether the entrance is on the left side (negative numbers) or the right side (positive numbers).

```<code>If input = -1:
____
\/_/

If input = -2:
________
\  /   /
 \/___/

If input = -3:
____________
\    /     /
 \  /     /
  \/_____/

If input = 1:
____
\_\/

If input = 2:
________
\   \  /
 \___\/

If input = 3:
____________
\     \    /
 \     \  /
  \_____\/

et cetera
</code>```

Note that the top of the tent (i.e. the last line) has 2 * abs(input) - 1 underscores.

There can be no leading spaces, such that the first line directly starts with an underscore.

Assume that the input will never be 0.

Your code should be as short as possible.

This challenge is based on a chat mini challenge by Helka Homba, which is allowed to be used in real challenges under the conditions of Calvin's Hobbies Public License.

Body:
C, <s>240</s> <s>207</s> 193 Bytes

#define P putchar
a,j,l,m;g(x,y,z){for(m=y+z+1;m--;P(m^z?l?32:95:x));}f(n){g(32,(a=abs(n))*4,0);for(P(10),j=2*(l=a)-1;l--;){for(m=a;--m>l;P(32));P(92);m=n>0?g(92,j,l*2):g(47,l*2,j);puts("/");}}

This time I optimized the function g(...) to use a single for loop.

#define P putchar
a,j,l,m;g(x,y,z){for(;y--;P(l?32:95));for(P(x);z--;P(l?32:95));}f(n){g(32,(a=abs(n))*4,0);l=a;j=2*a-1;P(10);for(;l--;){for(m=a;--m>l;P(32));P(92);m=n>0?g(92,j,l*2):g(47,l*2,j);puts("/");}}

This time macro X is better off as a function g(...) and since y and z are parameters in a new scope I can just decrement them in the scope of g.

#define P putchar
#define X(x,y,z){for(k=0;k++<y;P(l?32:95));P(x);for(k=0;k++<z;P(l?32:95));}
a,i,j,k,l,m;f(n){for(l=a=abs(n);i++<a*4;P(95));j=2*a-1;P(10);while(l--){for(m=a;--m>l;P(32));P(92);if(n>0)X(92,j,l*2)else X(47,l*2,j)puts("/");}}

Test with this main function;  This should golf down much smaller.

main(c,v)char**v;
{
    f(atoi(v[1]));
}


问:
Produce the number 2014 without any numbers in your source code

Note to challenge writers as per meta consensus:
This question was well-received when it was posted, but challenges
like this, asking answerers to Do X without using
Y
are likely to be poorly received. Try using the
sandbox
to get feedback on if you want to post a similar challenge.

It's <s>2017</s> <s>2018</s> <s>2019</s> <s>2020</s> <s>2021</s> <s>2022</s> 2023 already, folks, go home.

So, now that it's 2014, it's time for a code question involving the number 2014.

Your task is to make a program that prints the number 2014, without using any of the characters 0123456789 in your code, and independently of any external variables such as the date or time or a random seed.

The shortest code (counting in bytes) to do so in any language in which numbers are valid tokens wins.

Leaderboard:

var QUESTION_ID=17005,OVERRIDE_USER=7110;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
Straw, 13 bytes

```<code>(…………………σ)«$>
</code>```

« sum the codepoint of all characters in a string, $ convert from unary to decimal and > is the print operator.

Try it online

Body:
Straw, 13 bytes

(…………………σ)«$>

« sum the codepoint of all characters in a string, $ convert from unary to decimal and > is the print operator.

Try it online


答:
Mathematica, <s>40</s> 33 bytes

Thanks to murphy for an almost 20% savings!

```<code>1//.x_:>x+.001/;Nest[x^#&,1,#]<#&
</code>```

Nest[x^#&,1,n] produces the nth tetration of x. So Nest[x^#&,1,#]<# tests whether the (input)th tetration of x is less than (input). We simply start at x=1 and add 0.001 repeatedly until the tetration is too large, then output the last x value (so the answer is guaranteed to be larger than the exact value, but within 0.001).

As I'm slowly learning: //.x_:>y/;z or //.x_/;z:>y means "look for anything that matches the template x, but only things for which the test z returns true; and then operate on x by the rule y; repeatedly until nothing changes". Here the template x_ is just "any number I see", although in other contexts it could be further constrained.

When the input is at least 45, the tetration increases so rapidly that that last step causes an overflow error; but the value of x is still updated and output correctly. Decreasing the step-size from 0.001 to 0.0001 fixes this problem for inputs up to 112, and gives a more precise answer to boot (and still runs quickly, in about a quarter second). But that's one extra byte, so forget that!

Original version:

```<code>x=1;(While[Nest[x^#&,1,#]<#,x+=.001];x)&
</code>```

Title: Do the auto-super-logarithm

Body:
Mathematica, <s>40</s> 33 bytes

Thanks to murphy for an almost 20% savings!

1//.x_:>x+.001/;Nest[x^#&,1,#]<#&

Nest[x^#&,1,n] produces the nth tetration of x. So Nest[x^#&,1,#]<# tests whether the (input)th tetration of x is less than (input). We simply start at x=1 and add 0.001 repeatedly until the tetration is too large, then output the last x value (so the answer is guaranteed to be larger than the exact value, but within 0.001).

As I'm slowly learning: //.x_:>y/;z or //.x_/;z:>y means "look for anything that matches the template x, but only things for which the test z returns true; and then operate on x by the rule y; repeatedly until nothing changes". Here the template x_ is just "any number I see", although in other contexts it could be further constrained.

When the input is at least 45, the tetration increases so rapidly that that last step causes an overflow error; but the value of x is still updated and output correctly. Decreasing the step-size from 0.001 to 0.0001 fixes this problem for inputs up to 112, and gives a more precise answer to boot (and still runs quickly, in about a quarter second). But that's one extra byte, so forget that!

Original version:

x=1;(While[Nest[x^#&,1,#]<#,x+=.001];x)&


答:
PHP, 143 bytes

```<code>$t=str_repeat;echo$t(_,4*$s=$k=abs($n=$argv[1]));for(;$k--;$p.=" "){$f=$t("  ",$k);$r=$t($k?" ":_,2*$s-1);echo"
$p\\",$n<0?"$f/$r/":"$r\\$f/";}
</code>```

run with php -r '' <parameter>

breakdown

```<code>$t=str_repeat;  // function name to variable saves 10-1 bytes
echo$t(_,4*$s=$k=abs($n=$argv[1])); // print bottom
for(
    ;
    $k--;   // $k from abs($n-1) to 0
    $p.=" "                 // create padding
)
{
    $f=$t("  ",$k);         // create front
    $r=$t($k?" ":_,2*$s-1); // create side/roof
    echo"\n$p\\",$n<0
        ?"$f/$r/"   // print, entrance left
        :"$r\\$f/"  // print, entrance right
    ;
}
</code>```

Title: Output an upside-down tent

Body:
PHP, 143 bytes

$t=str_repeat;echo$t(_,4*$s=$k=abs($n=$argv[1]));for(;$k--;$p.=" "){$f=$t("  ",$k);$r=$t($k?" ":_,2*$s-1);echo"
$p\\",$n<0?"$f/$r/":"$r\\$f/";}

run with php -r '<code>' <parameter>

breakdown

$t=str_repeat;  // function name to variable saves 10-1 bytes
echo$t(_,4*$s=$k=abs($n=$argv[1])); // print bottom
for(
    ;
    $k--;   // $k from abs($n-1) to 0
    $p.=" "                 // create padding
)
{
    $f=$t("  ",$k);         // create front
    $r=$t($k?" ":_,2*$s-1); // create side/roof
    echo"\n$p\\",$n<0
        ?"$f/$r/"   // print, entrance left
        :"$r\\$f/"  // print, entrance right
    ;
}


问:
Test if given number is a Keith number
Since Fibonacci numbers and sequences seems like a popular subject for code golf I thought that it might be a fun challenge to code golf with Keith numbers.

So I propose a challenge that is to create a function that takes an integer and gives back a true or false depending on the number is a Keith number or not.

More about Keith numbers

In recreational mathematics, a Keith number or repfigit number (short for repetitive Fibonacci-like digit) is a number in the following integer sequence:
  14, 19, 28, 47, 61, 75, 197, 742, 1104, 1537, 2208, 2580, …

Numberphile has a video explaining how to calculate a Keith number. But basically you take the digits of a number. Add them together and then take the last digits of the original number and add them to the sum of the calculation, rinse and repeat. And example to make it clear.

14
1 + 4 = 5

  4 + 5 = 9

  5 + 9 = 14

Input

An integer.

Output

True if the number is a Keith number. False if it's not..

答:
GolfScript, 32 29 characters

```<code>...[10base\{.{+}*+(\}*]&,\9>&
</code>```

A GolfScript implementation which can be tested online. Input is given as top element on the stack and it returns 0 (i.e. false) or 1 respectively.

Title: Test if given number is a Keith number

Body:
GolfScript, 32 29 characters

...[10base\{.{+}*+(\}*]&,\9>&

A GolfScript implementation which can be tested online. Input is given as top element on the stack and it returns 0 (i.e. false) or 1 respectively.


答:
05AB1E, 52 bytes

```<code>Ä©'_4®*×,FNð×'\®·<N>®Qi'_ëð}×®N>-·ð×®¹Qi'\ës'/}s'/J,
</code>```

Explanation

```<code>                                                     # implicit input, call this A
Ä©                                                   # store abs(A) in register for later use
  '_4®*×,                                            # print 4*A underscores (tent floor)
         F                                           # for each non-floor section in range(N)
          Nð×'\                                      # push N spaces at the beginning of the
                                                     # row followed by a backslash
                  N>®Qi'_ëð}                         # if we're on the last row push an
                                                     # underscore, else a space
               ®·<          ×                        # repeat that char abs(A)*2-1 times
                             ®N>-·ð×                 # push 2*(abs(A)-(N+1)) spaces
                                    ®¹Qi'\ës'/}      # if input is positive push backslash
                                                     # else push a slash
                                               s'/   # move that char between the 2 sections
                                                     # of spaces
                                                  J, # join the row and print
</code>```

Try it online!

Title: Output an upside-down tent

Body:
05AB1E, 52 bytes

Ä©'_4®*×,FNð×'\®·<N>®Qi'_ëð}×®N>-·ð×®¹Qi'\ës'/}s'/J,

Explanation

                                                     # implicit input, call this A
Ä©                                                   # store abs(A) in register for later use
  '_4®*×,                                            # print 4*A underscores (tent floor)
         F                                           # for each non-floor section in range(N)
          Nð×'\                                      # push N spaces at the beginning of the
                                                     # row followed by a backslash
                  N>®Qi'_ëð}                         # if we're on the last row push an
                                                     # underscore, else a space
               ®·<          ×                        # repeat that char abs(A)*2-1 times
                             ®N>-·ð×                 # push 2*(abs(A)-(N+1)) spaces
                                    ®¹Qi'\ës'/}      # if input is positive push backslash
                                                     # else push a slash
                                               s'/   # move that char between the 2 sections
                                                     # of spaces
                                                  J, # join the row and print

Try it online!


答:
Jelly, 3 bytes

```<code>⁽¥Æ
</code>```

Try it online!

Title: Produce the number 2014 without any numbers in your source code

Body:
Note to challenge writers as per meta consensus:
This question was well-received when it was posted, but challenges
like this, asking answerers to Do X without using
Y
are likely to be poorly received. Try using the
sandbox
to get feedback on if you want to post a similar challenge.

It's <s>2017</s> <s>2018</s> <s>2019</s> <s>2020</s> <s>2021</s> <s>2022</s> 2023 already, folks, go home.

So, now that it's 2014, it's time for a code question involving the number 2014.

Your task is to make a program that prints the number 2014, without using any of the characters 0123456789 in your code, and independently of any external variables such as the date or time or a random seed.

The shortest code (counting in bytes) to do so in any language in which numbers are valid tokens wins.

Leaderboard:

var QUESTION_ID=17005,OVERRIDE_USER=7110;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
Jelly, 3 bytes

⁽¥Æ

Try it online!


问:
Simplify a continued fraction
Continued fractions are expressions that describe fractions iteratively. They can be represented graphically:

$$
a_0 +\cfrac 1
 {a_1 + \cfrac 1
  {a_2 + \cfrac 1
   {\ddots + \cfrac 1
    {a_n}
   }
  }
 }
$$

Or they can be represented as a list of values: \$[a_0 ; a_1, a_2, \dots, a_n]\$

The challenge:

take a base number: \$a_0\$ and a list of denominator values: \$[a_1, a_2, \dots, a_n]\$ and simplify the continued fraction to a simplified rational fraction: return or print numerator and denominator separately.

Examples:

\$\sqrt 19\$: [4;2,1,3,1,2]: 170/39

\$e\$: [1;0,1,1,2,1,1]: 19/7

\$\pi\$: [3;7,15,1,292,1]: 104348/33215

\$ϕ\$: [1;1,1,1,1,1]: 13/8

Example implementation: (python)

def foo(base, sequence):
    numerator = 1
    denominator = sequence[-1]
    for d in sequence[-2::-1]:
        temp = denominator
        denominator = d * denominator + numerator
        numerator = temp
    return numerator + base * denominator, denominator```

Winning:
 shortest code in bytes: --no builtins that do the entire problem allowed--

答:
GolfScript, 13 bytes

```<code>~]-1%{\-1?+}*
</code>```

Try it online!

Yay for GolfScript's hidden rationals. :)

Explanation

GolfScript's only "official" number type is integers. But the exponentiation operator doesn't cast its result to integer and conveniently the native result of an integer exponentiation in Ruby (the language of GolfScript's interpreter) is a rational number. So we can easily get fractions by raising something to the power of -1. Conveniently, we want reciprocals anyway...

```<code>~]     # Evaluate input and wrap all a_i in a list.
-1%    # Reverse the list so that a_n is at the start and a_0 at the end.
{      # Fold... (apply this block to each element from a_n-1 down to a_0, with
       # the previous result on the stack)
  \    #   Swap previous result with current a_i.
  -1?  #   Raise previous result to the power of -1, computing its reciprocal
       #   as a rational number.
  +    #   Add a_i.
}*
</code>```

Title: Simplify a continued fraction

Body:
GolfScript, 13 bytes

~]-1%{\-1?+}*

Try it online!

Yay for GolfScript's hidden rationals. :)

Explanation

GolfScript's only "official" number type is integers. But the exponentiation operator doesn't cast its result to integer and conveniently the native result of an integer exponentiation in Ruby (the language of GolfScript's interpreter) is a rational number. So we can easily get fractions by raising something to the power of -1. Conveniently, we want reciprocals anyway...

~]     # Evaluate input and wrap all a_i in a list.
-1%    # Reverse the list so that a_n is at the start and a_0 at the end.
{      # Fold... (apply this block to each element from a_n-1 down to a_0, with
       # the previous result on the stack)
  \    #   Swap previous result with current a_i.
  -1?  #   Raise previous result to the power of -1, computing its reciprocal
       #   as a rational number.
  +    #   Add a_i.
}*


答:
Haskell, <s>37</s> <s>36</s> 18 bytes

```<code>foldr1$(.(1/)).(+)
</code>```

This function expects Haskell's Ratio type as input. Usage example:

```<code>Prelude Data.Ratio> ( foldr1$(.(1/)).(+) )  [4%1,2,1,3,1,2]
170 % 39
</code>```

Note: one explicit Ratio in the input list (4%1) is enough, the type systems figures out that the others have to be Ratios, too.

Edit: @Lynn saved a byte. Thanks!

Edit II: removed the import (see this discussion on meta).

Title: Simplify a continued fraction

Body:
Continued fractions are expressions that describe fractions iteratively. They can be represented graphically:

$$
a_0 +\cfrac 1
 {a_1 + \cfrac 1
  {a_2 + \cfrac 1
   {\ddots + \cfrac 1
    {a_n}
   }
  }
 }
$$

Or they can be represented as a list of values: \$[a_0 ; a_1, a_2, \dots, a_n]\$

The challenge:

take a base number: \$a_0\$ and a list of denominator values: \$[a_1, a_2, \dots, a_n]\$ and simplify the continued fraction to a simplified rational fraction: return or print numerator and denominator separately.

Examples:

\$\sqrt 19\$: [4;2,1,3,1,2]: 170/39

\$e\$: [1;0,1,1,2,1,1]: 19/7

\$\pi\$: [3;7,15,1,292,1]: 104348/33215

\$ϕ\$: [1;1,1,1,1,1]: 13/8

Example implementation: (python)

def foo(base, sequence):
    numerator = 1
    denominator = sequence[-1]
    for d in sequence[-2::-1]:
        temp = denominator
        denominator = d * denominator + numerator
        numerator = temp
    return numerator + base * denominator, denominator```

Winning:
 shortest code in bytes: --no builtins that do the entire problem allowed--

Body:
Haskell, <s>37</s> <s>36</s> 18 bytes

foldr1$(.(1/)).(+)

This function expects Haskell's Ratio type as input. Usage example:

Prelude Data.Ratio> ( foldr1$(.(1/)).(+) )  [4%1,2,1,3,1,2]
170 % 39

Note: one explicit Ratio in the input list (4%1) is enough, the type systems figures out that the others have to be Ratios, too.

Edit: @Lynn saved a byte. Thanks!

Edit II: removed the import (see this discussion on meta).


答:
Mathematica, <s>23</s> 22 bytes

```<code>Fold[#2+1/#&]@*Reverse
</code>```

Essentially a port of my GolfScript answer. Here are some alternatives:

For 24 bytes, we can write a recursive variadic function:

```<code>f@n_=n
n_~f~m__:=n+1/f@m
</code>```

For 21 bytes, we can even define a "variadic operator", but its calling convention would be so weird, that I'm reluctant to count this one:

```<code>±n_=n
n_ ±m__:=n+1/±m
</code>```

You would have to call this with a sequence of the input values, e.g. ±Sequence[3, 7, 15, 1, 292, 1] or ±##&[3, 7, 15, 1, 292, 1].

And also for 21 bytes, there would be the (forbidden) built-in:

```<code>FromContinuedFraction
</code>```

Title: Simplify a continued fraction

Body:
Mathematica, <s>23</s> 22 bytes

Fold[#2+1/#&]@*Reverse

Essentially a port of my GolfScript answer. Here are some alternatives:

For 24 bytes, we can write a recursive variadic function:

f@n_=n
n_~f~m__:=n+1/f@m

For 21 bytes, we can even define a "variadic operator", but its calling convention would be so weird, that I'm reluctant to count this one:

±n_=n
n_ ±m__:=n+1/±m

You would have to call this with a sequence of the input values, e.g. ±Sequence[3, 7, 15, 1, 292, 1] or ±##&[3, 7, 15, 1, 292, 1].

And also for 21 bytes, there would be the (forbidden) built-in:

FromContinuedFraction


问:
Let's get Animated!

The Challenge

GIFs are the most common image format for animation, and are used pretty heavily in today's social media. For the purpose of this challenge, I'm going to redefine what a GIF can be. This challenge will require you to take in a 3D array containing some sort of representation of a 2D 'image' and iterate through them, displaying an animation. This animation can be done anywhere, in a GIF, in your console, in a GUI, etc; the delivery doesn't matter, so long as it is animated.

The Input

A 3D array where the data inside somehow represents a 2D image.

The array may contain RGB data, true/false data or anything else you see fit.

I'm also fine with you dumbing it down to a 2D array of strings or something similar, but the animation must be a 2D animation.

The time between each frame in a format of your choosing (Seconds, Milliseconds, etc...).

People have been asking me whether or not they HAVE to include the duration length. My answer is "meh", as long as you are able to show animation. I'm more concerned that you adhere to the "Array" parameter than this one, meaning no random animations.

The Output

A seamlessly iterated sequence of output that looks like a 2D animation with the correct delay on each transition based on the value input.

The Rules

Output can be, but is not limited to:

GIF image.

GUI animation (my example).

In-console animation.

Honestly, any "animation" that you see fit, as long as it follows the below rules.

When outputting your image you must clear the console before showing the next frame, you cannot just print them sequentially.

Emulating a console "clear" is also acceptable, as long as it looks like a seamless animation (see the hint under my example for more information on what I mean).

Regardless of implementation, your animation should loop forever, or until stopped.

The "looping" can be as simple as while(true){} or infinite recursion, you may assume the user wants to view this masterpiece until they hit "ctrl+c".

You must be able to handle any size 2D 'images', if your language is limited by buffer sizes, this is acceptable and you may state this in your explanation.

Standard loopholes are disallowed.

Example I/O

Input (3D Array, Delay)

```<code>f([
  [[1,0,0],
   [0,0,0],
   [0,0,0]],
  [[0,0,0],
   [0,1,0],
   [0,0,0]],
  [[0,0,0],
   [0,0,0],
   [0,0,1]],
], 1)
</code>```

Output (Example, 2020 Bytes - Java)

```<code>import javax.swing.JFrame;
import javax.swing.JTextArea;

/**
 * Simple GIF class to animate a 3D integer array in a swing text area.
 * (Clearing the console in java isn't something you really do, so I chose
 * java on purpose to make it an extremely ungolf-able answer that someone
 * wouldn't bother to steal).
 */
public class Gif implements Runnable {
    /**
     * The output area.
     */
    private final JTextArea area;

    /**
     * The list of images.
     */
    private final int[][][] images;

    /**
     * The delay between image transitions.
     */
    private final long transitionDelay;

    /**
     * Main method, instantiates a GIF object and runs it.
     * @param args Does absolutely nothing.
     */
    public static void main(String[] args) {
        final int[][][] images = {{{1,0,0},{0,0,0},{0,0,0}},{{0,0,0},{0,1,0},{0,0,0}},{{0,0,0},{0,0,0},{0,0,1}}};
        final long transitionDelay = 1000L;
        new Thread(new Gif(images, transitionDelay)).start();
    }

    /**
     * Constructor for a GIF, takes in a 3D array of images and a transition
     * delay to wait between transitioning the images.
     * @param images The list of images.
     * @param delay The delay between each image.
     */
    public Gif(int[][][] images, long transitionDelay) {
        this.images = images;
        this.transitionDelay = transitionDelay;
        this.area = new JTextArea();
        final JFrame frame = new JFrame("It's a GIF!");
        frame.setSize(10,100);
        frame.add(area);
        frame.setVisible(true);
    }

    /**
     * When run, it will alter the area to imitate an animated GIF.
     */
    @Override
    public void run() {
        while (true) {
            for (int i = 0; i < images.length; i++) {
                final StringBuffer frame = new StringBuffer();
                for (int j = 0; j < images[i].length; j++) {
                    for (int k = 0; k < images[i][j].length; k++) {
                        frame.append("" + images[i][j][k]);
                    }
                    frame.append("\n");
                }
                this.area.setText(frame.toString());
                try{Thread.sleep(transitionDelay);}catch(Exception e){}
                this.area.setText("");
            }
        }
    }
}
</code>```

This results in a swing GUI popping up, animating the array:

HINT HINT: Use a language where console clearing is possible, or specify why what you are doing will end up with a result that looks like an animation in the language you chose. I think some languages have default buffer sizes on their consoles, you may use this to your advantage, but I expect an explanation or example. Just because I output my animation as a string, you don't have to; I could've just as easily used 0 for black and 1 for white and made a real GIF.

Judging

This is code-golf, lowest byte count wins (inputs excluded).

I'll +1 anyone who uses a language in a cool or unexpected way as well.

答:
Octave, <s>56</s> <s>54</s> 47 bytes

Removed the possibility to input the pausing time as part of the input matrix. I was very satisfied with it, so have a look in the edit history if you want to have a look. This solution is 7 bytes shorter.

```<code>n=input('');while(any(n=~n))spy(n);pause(1);end

n=input('');  % Takes input as a matrix of zeros and ones

k=n(1);       % maximum of the input matrix is the desired pause time. Have to store
              % this, because n is soon to be messed with
              % NOTE: k=n(1); is not needed anymore, since the pause time can be hardcoded!

any(n=~n)     % Check if there are any truthy values in `n` (there is), and at the
              % same time negate it, thus creating a matrix where all elements
              % alternates between 1 and 0.
while(any(n=~n))   % Loop as long as there are any non-zero elements (always some)
spy(n)        % Create a spy-plot where all non-zero elements are shown as a dot
pause(1)      % Pauses for k seconds
end           % ends the loop (will never happen, since it's infinite).
</code>```

The input will be something like this: [4 0 0 4;0 4 4 0;4 0 0 0], where this will be a matrix of dimensions 3x4, and the desired pause time is 4 seconds.

It displays a plot like the one below, but alternates between showing the true and the false values of the input. So all the blue dots will become white in the next iteration, and all the white will become blue.

In the below plot, I used the input rand(10,10)>0.6*2. This means it will have dimensions 10x10, and all elements of the random matrix that are larger than 0.6 will be true. After that I multiply it by the desired pausing time, 2 seconds. I used a random matrix here, but I could have created the matrix manually too.

I don't have Octave installed on this computer, so I made a minor alteration to make this work in MATLAB. It's the exact same principle, but n=~n doesn't work in MATLAB.

Title: Let's get Animated!

Body:
Octave, <s>56</s> <s>54</s> 47 bytes

Removed the possibility to input the pausing time as part of the input matrix. I was very satisfied with it, so have a look in the edit history if you want to have a look. This solution is 7 bytes shorter.

n=input('');while(any(n=~n))spy(n);pause(1);end

n=input('');  % Takes input as a matrix of zeros and ones

k=n(1);       % maximum of the input matrix is the desired pause time. Have to store
              % this, because n is soon to be messed with
              % NOTE: k=n(1); is not needed anymore, since the pause time can be hardcoded!

any(n=~n)     % Check if there are any truthy values in `n` (there is), and at the
              % same time negate it, thus creating a matrix where all elements
              % alternates between 1 and 0.
while(any(n=~n))   % Loop as long as there are any non-zero elements (always some)
spy(n)        % Create a spy-plot where all non-zero elements are shown as a dot
pause(1)      % Pauses for k seconds
end           % ends the loop (will never happen, since it's infinite).

The input will be something like this: [4 0 0 4;0 4 4 0;4 0 0 0], where this will be a matrix of dimensions 3x4, and the desired pause time is 4 seconds.

It displays a plot like the one below, but alternates between showing the true and the false values of the input. So all the blue dots will become white in the next iteration, and all the white will become blue.

In the below plot, I used the input rand(10,10)>0.6*2. This means it will have dimensions 10x10, and all elements of the random matrix that are larger than 0.6 will be true. After that I multiply it by the desired pausing time, 2 seconds. I used a random matrix here, but I could have created the matrix manually too.

I don't have Octave installed on this computer, so I made a minor alteration to make this work in MATLAB. It's the exact same principle, but n=~n doesn't work in MATLAB.


问:
The Letter A without A
Your task is to display the letter "A" alone, without anything else, except any form of trailing newlines if you cannot avoid them, doing so in a program and/or snippet. Code that returns (instead of printing) is allowed.

Both the lowercase and uppercase versions of the letter "A" are acceptable (that is, unicode U+0061 or unicode U+0041. Other character encodings that aren't Unicode are allowed, but either way, the resulting output of your code must be the latin letter "A", and not any lookalikes or homoglyphs)

You must not use any of the below characters in your code, regardless of the character encoding that you pick:

"A", whether uppercase or lowercase.

"U", whether lowercase or uppercase.

X, whether uppercase or lowercase.

+

&

#

0

1

4

5

6

7

9

Cheating, loopholes, etc, are not allowed.

Since this is code-golf, the shortest solution, in bytes, that follows all the rules, is the winner.

Validity Checker

This Stack Snippet checks to make sure your code doesn't use the restricted characters. It might not work properly for some character encodings.

var t = prompt("Input your code.");

if (/[AaUuXx+&#0145679]/.test(t)) {
  alert("Contains a disallowed character!");
} else {
  alert("No disallowed characters");
}```
</div>
</div>
</p>

<p><em>This Stack Snippet that makes sure you don't have a disallowed character is also available on JSFiddle.</em></p>

<h3>Leaderboard</h3>

<p><div class="snippet" data-lang="js" data-hide="true" data-console="false" data-babel="false">
<div class="snippet-code snippet-currently-hidden">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var QUESTION_ID=90349,OVERRIDE_USER=58717;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;</code>```

body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td>Link</td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td>Link</td></tr></tbody> </table></code>```

答:
JavaScript, Node console, 23

Shortest JavaScript I can do for a capital A.

This only works in the Node REPL console.

```<code>Object.keys(this)[2][3]
</code>```

This only works in Firefox REPL (27)

```<code>Object.keys(this)[8*3][2*3]
</code>```

Title: The Letter A without A

Body:
JavaScript, Node console, 23

Shortest JavaScript I can do for a capital A.

This only works in the Node REPL console.

Object.keys(this)[2][3]

This only works in Firefox REPL (27)

Object.keys(this)[8*3][2*3]


答:
Python (<s>78</s> 75)

```<code>a=input()
n=map(int,`a`)
while a>n[0]:n=n[1:]+[sum(n)]
print(a==n[0])&(a>9)
</code>```

n=n[1:]+[sum(n)] does all the magic. It takes every item but the first item of n, sticks on the sum of n (with the first item), then sets that to n.

I wish you could call list on an integer and have the digits seperated.

Returns False on all inputs below 10. Can be 8 characters shorter if it returned True.

Title: Test if given number is a Keith number

Body:
Since Fibonacci numbers and sequences seems like a popular subject for code golf I thought that it might be a fun challenge to code golf with Keith numbers.

So I propose a challenge that is to create a function that takes an integer and gives back a true or false depending on the number is a Keith number or not.

More about Keith numbers

In recreational mathematics, a Keith number or repfigit number (short for repetitive Fibonacci-like digit) is a number in the following integer sequence:
  14, 19, 28, 47, 61, 75, 197, 742, 1104, 1537, 2208, 2580, …

Numberphile has a video explaining how to calculate a Keith number. But basically you take the digits of a number. Add them together and then take the last digits of the original number and add them to the sum of the calculation, rinse and repeat. And example to make it clear.

14
1 + 4 = 5

  4 + 5 = 9

  5 + 9 = 14

Input

An integer.

Output

True if the number is a Keith number. False if it's not..

Body:
Python (<s>78</s> 75)

a=input()
n=map(int,`a`)
while a>n[0]:n=n[1:]+[sum(n)]
print(a==n[0])&(a>9)

n=n[1:]+[sum(n)] does all the magic. It takes every item but the first item of n, sticks on the sum of n (with the first item), then sets that to n.

I wish you could call list on an integer and have the digits seperated.

Returns False on all inputs below 10. Can be 8 characters shorter if it returned True.


答:
Julia (53 Bytes)

This is my first time ever using Julia, if I overlooked an iterator I could have used to lose some more bytes, let me know. Here's a hint to anyone who doesn't know what language to choose for this specific challenge: https://en.wikipedia.org/wiki/Rational_data_type

```<code>f(x,c)=(a=0;for b in x[end:-1:1];a=1//(b+a);end;a+c;)
</code>```

Reverse the input array.

Iterate through it with rational division.

Add c to the decimal result.

Title: Simplify a continued fraction

Body:
Julia (53 Bytes)

This is my first time ever using Julia, if I overlooked an iterator I could have used to lose some more bytes, let me know. Here's a hint to anyone who doesn't know what language to choose for this specific challenge: https://en.wikipedia.org/wiki/Rational_data_type

f(x,c)=(a=0;for b in x[end:-1:1];a=1//(b+a);end;a+c;)

Reverse the input array.

Iterate through it with rational division.

Add c to the decimal result.


答:
Haskell, <s>187</s> <s>184</s> 183 bytes

```<code>f x=unlines$[(n*4)%'_']++((' '#)<$>[0..n-2])++['_'#(n-1)]where m#i=i%' '++'\\':m!i++"/";m!i|x>0=(2*n-1)%m++'\\':(2*(n-i-1))%' '|q<-2*(n-i-1)=q%' '++'/':(2*n-1)%m;n=abs x;m%c=c<$[1..m]
</code>```

I feel like this is not a great score for Haskell, so any ideas for improvement are welcome.

3 bytes saved thanks to @Myridium

1 byte saved thanks to @nimi

Ungolfed

```<code>tent :: Int -> String
tent x = unlines $ [replicate (n*4) '_'] ++ (row ' '<$>[0..n-2]) ++ [row '_' (n-1)]
    where row m i = replicate i ' ' ++ "\\" ++ dir m i ++ "/"
          -- direction selector
          dir m i | x > 0 = side m ++ "\\" ++ entrance i ' '
                  | 1 > 0 = entrance i ' ' ++ "/" ++ side m
          side = replicate (2*n-1)
          entrance i = replicate (2*(n-i-1))
          n = abs x
</code>```

Title: Output an upside-down tent

Body:
Given an integer, output an upside-down tent.

The input determines both the size of the tent (absolute value) and whether the entrance is on the left side (negative numbers) or the right side (positive numbers).

```<code>If input = -1:
____
\/_/

If input = -2:
________
\  /   /
 \/___/

If input = -3:
____________
\    /     /
 \  /     /
  \/_____/

If input = 1:
____
\_\/

If input = 2:
________
\   \  /
 \___\/

If input = 3:
____________
\     \    /
 \     \  /
  \_____\/

et cetera
</code>```

Note that the top of the tent (i.e. the last line) has 2 * abs(input) - 1 underscores.

There can be no leading spaces, such that the first line directly starts with an underscore.

Assume that the input will never be 0.

Your code should be as short as possible.

This challenge is based on a chat mini challenge by Helka Homba, which is allowed to be used in real challenges under the conditions of Calvin's Hobbies Public License.

Body:
Haskell, <s>187</s> <s>184</s> 183 bytes

f x=unlines$[(n*4)%'_']++((' '#)<$>[0..n-2])++['_'#(n-1)]where m#i=i%' '++'\\':m!i++"/";m!i|x>0=(2*n-1)%m++'\\':(2*(n-i-1))%' '|q<-2*(n-i-1)=q%' '++'/':(2*n-1)%m;n=abs x;m%c=c<$[1..m]

I feel like this is not a great score for Haskell, so any ideas for improvement are welcome.

3 bytes saved thanks to @Myridium

1 byte saved thanks to @nimi

Ungolfed

tent :: Int -> String
tent x = unlines $ [replicate (n*4) '_'] ++ (row ' '<$>[0..n-2]) ++ [row '_' (n-1)]
    where row m i = replicate i ' ' ++ "\\" ++ dir m i ++ "/"
          -- direction selector
          dir m i | x > 0 = side m ++ "\\" ++ entrance i ' '
                  | 1 > 0 = entrance i ' ' ++ "/" ++ side m
          side = replicate (2*n-1)
          entrance i = replicate (2*(n-i-1))
          n = abs x


答:
05AB1E, <s>19</s> 17 bytes

```<code>R¬V¦vyY*X+YUV}YX)
</code>```

Explanation

Input taken as a list of numbers

```<code>                     # variable X is initialized as 1
R¬V¦                 # reverse the list, remove the first item and store it in variable Y
    v        }       # for each item N left in list
     yY*X+  V        # store N*Y+X in Y
          YU         # store Y in X
              YX)    # wrap X and Y in a list
</code>```

Try it online!

Title: Simplify a continued fraction

Body:
05AB1E, <s>19</s> 17 bytes

R¬V¦vyY*X+YUV}YX)

Explanation

Input taken as a list of numbers

                     # variable X is initialized as 1
R¬V¦                 # reverse the list, remove the first item and store it in variable Y
    v        }       # for each item N left in list
     yY*X+  V        # store N*Y+X in Y
          YU         # store Y in X
              YX)    # wrap X and Y in a list

Try it online!


Title: Let's get Animated!

Body:
The Challenge

GIFs are the most common image format for animation, and are used pretty heavily in today's social media. For the purpose of this challenge, I'm going to redefine what a GIF can be. This challenge will require you to take in a 3D array containing some sort of representation of a 2D 'image' and iterate through them, displaying an animation. This animation can be done anywhere, in a GIF, in your console, in a GUI, etc; the delivery doesn't matter, so long as it is animated.

The Input

A 3D array where the data inside somehow represents a 2D image.

The array may contain RGB data, true/false data or anything else you see fit.

I'm also fine with you dumbing it down to a 2D array of strings or something similar, but the animation must be a 2D animation.

The time between each frame in a format of your choosing (Seconds, Milliseconds, etc...).

People have been asking me whether or not they HAVE to include the duration length. My answer is "meh", as long as you are able to show animation. I'm more concerned that you adhere to the "Array" parameter than this one, meaning no random animations.

The Output

A seamlessly iterated sequence of output that looks like a 2D animation with the correct delay on each transition based on the value input.

The Rules

Output can be, but is not limited to:

GIF image.

GUI animation (my example).

In-console animation.

Honestly, any "animation" that you see fit, as long as it follows the below rules.

When outputting your image you must clear the console before showing the next frame, you cannot just print them sequentially.

Emulating a console "clear" is also acceptable, as long as it looks like a seamless animation (see the hint under my example for more information on what I mean).

Regardless of implementation, your animation should loop forever, or until stopped.

The "looping" can be as simple as while(true){} or infinite recursion, you may assume the user wants to view this masterpiece until they hit "ctrl+c".

You must be able to handle any size 2D 'images', if your language is limited by buffer sizes, this is acceptable and you may state this in your explanation.

Standard loopholes are disallowed.

Example I/O

Input (3D Array, Delay)

```<code>f([
  [[1,0,0],
   [0,0,0],
   [0,0,0]],
  [[0,0,0],
   [0,1,0],
   [0,0,0]],
  [[0,0,0],
   [0,0,0],
   [0,0,1]],
], 1)
</code>```

Output (Example, 2020 Bytes - Java)

```<code>import javax.swing.JFrame;
import javax.swing.JTextArea;

/**
 * Simple GIF class to animate a 3D integer array in a swing text area.
 * (Clearing the console in java isn't something you really do, so I chose
 * java on purpose to make it an extremely ungolf-able answer that someone
 * wouldn't bother to steal).
 */
public class Gif implements Runnable {
    /**
     * The output area.
     */
    private final JTextArea area;

    /**
     * The list of images.
     */
    private final int[][][] images;

    /**
     * The delay between image transitions.
     */
    private final long transitionDelay;

    /**
     * Main method, instantiates a GIF object and runs it.
     * @param args Does absolutely nothing.
     */
    public static void main(String[] args) {
        final int[][][] images = {{{1,0,0},{0,0,0},{0,0,0}},{{0,0,0},{0,1,0},{0,0,0}},{{0,0,0},{0,0,0},{0,0,1}}};
        final long transitionDelay = 1000L;
        new Thread(new Gif(images, transitionDelay)).start();
    }

    /**
     * Constructor for a GIF, takes in a 3D array of images and a transition
     * delay to wait between transitioning the images.
     * @param images The list of images.
     * @param delay The delay between each image.
     */
    public Gif(int[][][] images, long transitionDelay) {
        this.images = images;
        this.transitionDelay = transitionDelay;
        this.area = new JTextArea();
        final JFrame frame = new JFrame("It's a GIF!");
        frame.setSize(10,100);
        frame.add(area);
        frame.setVisible(true);
    }

    /**
     * When run, it will alter the area to imitate an animated GIF.
     */
    @Override
    public void run() {
        while (true) {
            for (int i = 0; i < images.length; i++) {
                final StringBuffer frame = new StringBuffer();
                for (int j = 0; j < images[i].length; j++) {
                    for (int k = 0; k < images[i][j].length; k++) {
                        frame.append("" + images[i][j][k]);
                    }
                    frame.append("\n");
                }
                this.area.setText(frame.toString());
                try{Thread.sleep(transitionDelay);}catch(Exception e){}
                this.area.setText("");
            }
        }
    }
}
</code>```

This results in a swing GUI popping up, animating the array:

HINT HINT: Use a language where console clearing is possible, or specify why what you are doing will end up with a result that looks like an animation in the language you chose. I think some languages have default buffer sizes on their consoles, you may use this to your advantage, but I expect an explanation or example. Just because I output my animation as a string, you don't have to; I could've just as easily used 0 for black and 1 for white and made a real GIF.

Judging

This is code-golf, lowest byte count wins (inputs excluded).

I'll +1 anyone who uses a language in a cool or unexpected way as well.

Body:
Ruby, <s>89</s> 45 bytes

f=->h,t{h.cycle{|x|puts"^[[2J",x.map(&:join)}}

The ^[ is an escape character.

Hexdump:

00000000: 663d 2d3e 682c 747b 682e 6379 636c 657b  f=->h,t{h.cycle{
00000010: 7c78 7c70 7574 7322 1b5b 324a 222c 782e  |x|puts".[2J",x.
00000020: 6d61 7028 263a 6a6f 696e 297d 7d         map(&:join)}}

Saved a lot of bytes thanks to @Jordan


问:
Write an interpreter for the untyped lambda calculus
The challenge is to write an interpreter for the untyped lambda calculus in as few characters as possible. We define the untyped lambda calculus as follows:

Syntax

There are the following three kinds of expressions:

A lambda expression has the form (λ x. e) where x could be any legal variable name and e any legal expression. Here x is called the parameter and e is called the function body.

For simplicity's sake we add the further restriction that there must not be a variable with the same name as x currently in scope. A variable starts to be in scope when its name appears between (λ and . and stops to be in scope at the corresponding ).

Function application has the form (f a) where f and a are legal expressions. Here f is called the function and a is called the argument.

A variable has the form x where x is a legal variable name.

Semantics

A function is applied by replacing each occurrence of the parameter in the functions body with its argument. More formally an expression of the form ((λ x. e) a), where x is a variable name and e and a are expressions, evaluates (or reduces) to the expression e' where e' is the result of replacing each occurrence of x in e with a.

A normal form is an expression which can not be evaluated further.

The Challenge

Your mission, should you choose to accept it, is to write an interpreter which takes as its input an expression of the untyped lambda calculus containing no free variables and produces as its output the expression's normal form (or an expression alpha-congruent to it). If the expression has no normal form or it is not a valid expression, the behaviour is undefined.

The solution with the smallest number of characters wins.

A couple of notes:

Input may either be read from stdin or from a filename given as a command line argument (you only need to implement one or the other - not both). Output goes to stdout.

Alternatively you may define a function which takes the input as a string and returns the output as a string.

If non-ASCII characters are problematic for you, you may use the backslash (\) character instead of λ.

We count the number of characters, not bytes, so even if your source file is encoded as unicode λ counts as one character.

Legal variable names consist of one or more lower case letters, i.e. characters between a and z (no need to support alphanumeric names, upper case letters or non-latin letters - though doing so will not invalidate your solution, of course).

As far as this challenge is concerned, no parentheses are optional. Each lambda expression and each function application will be surrounded by exactly one pair of parentheses. No variable name will be surrounded by parentheses.

Syntactic sugar like writing (λ x y. e) for (λ x. (λ y. e)) does not need to be supported.

If a recursion depth of more than 100 is required to evaluate a function, the behaviour is undefined. That should be more than low enough to be implemented without optimization in all languages and still large enough to be able to execute most expressions.

You may also assume that spacing will be as in the examples, i.e. no spaces at the beginning and end of the input or before a λ or . and exactly one space after a . and between a function and its argument and after a λ.

Sample Input and Output

Input: ((λ x. x) (λ y. (λ z. z)))

Output: (λ y. (λ z. z))

Input: (λ x. ((λ y. y) x))

Output: (λ x. x)

Input: ((λ x. (λ y. x)) (λ a. a))

Output: (λ y. (λ a. a))

Input: (((λ x. (λ y. x)) (λ a. a)) (λ b. b))

Output: (λ a. a)

Input: ((λ x. (λ y. y)) (λ a. a))

Output: (λ y. y)

Input: (((λ x. (λ y. y)) (λ a. a)) (λ b. b))

Output: (λ b. b)

Input: ((λx. (x x)) (λx. (x x)))

Output: anything (This is an example of an expression that has no normal form)

Input: (((λ x. (λ y. x)) (λ a. a)) ((λx. (x x)) (λx. (x x))))

Output: (λ a. a) (This is an example of an expression which does not normalize if you evaluate the arguments before the function call, and sadly an example for which my attempted solution fails)

Input: ((λ a. (λ b. (a (a (a b))))) (λ c. (λ d. (c (c d)))))

Output: `(λ a. (λ b. (a (a (a (a (a (a (a (a b))))))))))
This computes 2^3 in Church numerals.

Body:
C 1039 bytes

#define F for
#define R return
#define E if(i>=M||j>=M)R-1;
enum{O='(',C,M=3999};signed char Q[M],D[M],t[M],Z,v,*o=Q,*d=D,*T;int m,n,s,c,w,x,y;K(i,j,k){!Z&&(Z=t[O]=1)+(t[C]=-1);E;if(!o[i]){d[j]=0;R 0;}if((c=t[o[i]]+t[o[i+1]])!=2||o[i+2]!='\\'){d[j++]=o[i++];R K(i,j,i);}F(i+=2,y=w=0;i<M&&o[i]&&c;++i)c+=t[o[i]],!w&&c==1?w=i:0,!y&&o[i]=='.'?y=i+2:0;E;if(c){F(;d[j++]=o[i++];)E;R 0;}F(c=y;c<w;++c)if(o[c]=='\\')F(n=0,m=w+2;m<i;++m){if(o[m]==o[c+2]){F(x=0;o[m+x]&&isalpha(o[m+x])&&o[m+x]==o[c+2+x];++x);if(o[c+2+x]!='.'||isalpha(o[m+x]))continue;if(v>'Z')R-1;F(n=c+2;n<w;++n)if(o[n]==o[m]){F(x=0; o[m+x]&&isalpha(o[m+x])&&o[m+x]==o[n+x];++x);if(o[m+x]=='.'&&!isalpha(o[n+x]))F(;--x>=0;) o[n+x]=v;}++v;}}F(c=y;c<w&&j<M;++c){F(x=0;o[c+x]&&o[c+x]==o[k+4+x]&&isalpha(o[c+x]); ++x);if(o[k+4+x]=='.'&&!isalpha(o[c+x])){F(m=w+2;m<i-1&&j<M;++m)d[j++]=o[m];c+=x-1;}else d[j++]=o[c];}E;Z=2;R K(i,j,i);}char*L(char*a){F(s=n=0;n<M&&(o[n]=a[n]);++n);if(n==M)R 0;v='A';F(;++s<M;){Z=0;n=K(0,0,0);if(Z==2&&n!=-1)T=d,d=o,o=T;else break;}R n==-1||s>=M?0:d;}

Variables allow as input using lowercase letters [from a..z] the sys can generate variables using uppercase letters [from A..Z] if need in the output...
Assume ascii character configuration.

#define P printf
main()
{char  *r[]={ "((\\ abc. (\\ b. (abc (abc (abc b))))) (\\ cc. (\\ dd. (cc (cc dd)))))",
              "((\\ fa. (\\ abc. (fa abc))) (\\ yy. (\\ abc. yy)))",
              "((\\ x. x) z)",
              "((\\ x. x) (\\ y. (\\ z. z)))",
              "(\\ x. ((\\ y. y) x))",
              "((\\ x. (\\ y. x)) (\\ a. a))",
              "(((\\ x. (\\ y. x)) (\\ a. a)) (\\ b. b))",
              "((\\ x. (\\ y. y)) (\\ a. a))",
              "(((\\ x. (\\ y. y)) (\\ a. a)) (\\ b. b))",
              "((\\ x. (x x)) (\\ x. (x x)))",
              "(((\\ x. (\\ y. x)) (\\ a. a)) ((\\ x. (x x)) (\\ x. (x x))))",
             0}, *p;
 int    w;

 for(w=0; r[w] ;++w)
   {p=L(r[w]);
    P("o=%s d=%s\n", r[w], p==0?"Error ":p);
   }
 R  0;
}

/*1.039*/


答:
Dyalog APL, 10 bytes

Does not even use a build-in for rationals.

Takes {a0,a1,a2,a3,...} as argument, returns {denominator,numerator}.

1(,÷∨)+∘÷/
```

1(,÷∨) 1-prepended-to divided by the GCD of 1 and

+∘÷ plus-the-reciprocal-of

/ reduction over

TryAPL online!

Title: Simplify a continued fraction

Body:
Dyalog APL, 10 bytes

Does not even use a build-in for rationals.

Takes {a0,a1,a2,a3,...} as argument, returns {denominator,numerator}.

1(,÷∨)+∘÷/

1(,÷∨) 1-prepended-to divided by the GCD of 1 and

+∘÷ plus-the-reciprocal-of

/ reduction over

TryAPL online!