答:
R, 35 bytes

This statistician's language also has a scan() function, but requires information about how many characters it will receive, and providing a value for that would either limit the highest possible x, or require a very, very long argument.

for(x in 1:readline()){cat(x,'\n')}

Title: Count up folks!

Body:
Introduction

It may sound strange, but we haven't got ONE challenge for counting from 1 to n, inclusive.

This is not the same thing. That one is a (closed) not well-explained challenge.

This is not the same thing. That one is about counting up indefinitely.

Challenge

Write a program or function that prints every integer from 1 to n inclusive.

Rules

You can get n any way.

You can assume that n will always be a positive integer.

You can get n in any base, but you should always output in decimal.

Output must be separated by any character (or pattern) not in 0123456789. Non-decimal leading or trailing characters are allowed (for example when using arrays such as [1, 2, 3, 4, 5, 6]).

Standard loopholes are denied.

We want to find the shortest approach in each language, not the shortest language, so I will not accept any answer.

You must update your answer(s) after this edit, answers posted before the last edit must comply with the change rule about standard loopholes (I didn't want to deny them, but I didn't want to make the community roar, so I denied them).

You can use any post-dating language version (or language). You cannot use any language or language version made just for this challenge.

Bonuses

20%

Your program must be able to count at least up to 18446744073709551615 (2^64-1). For example, if a new datatype is the only way to support big integers, you must construct it. If your language does not have any way to support huge integers up to 2^64-1, the upper limit of that particular language must be supported instead.

EDIT: I've changed the limit from 2^64 to 2^64-1 to allow more answers.

EDIT: I made the 2^64-1 rule a bonus, since there has not been much interest in this challenge. If your answer supports 2^64-1, you can now edit it to include the bonus. Also, you can post an answer not supporting it, if it is shorter.


问:
Interlace strings
Your challenge is to write a program or function that, when given two strings of equal length, swaps every other character and outputs/returns the resulting strings in either order.

Examples

```<code>"Hello," "world!" --> "Hollo!" "werld,"
"code" "golf" --> "codf" "gole"
"happy" "angry" --> "hnpry" "aagpy"
"qwerty" "dvorak" --> "qvertk" "dworay"
"1, 2, 3" "a, b, c" --> "1, b, 3" "a, 2, c"
"3.141592653589" "2.718281828459" --> "3.111291623489" "2.748582858559"
"DJMcMayhem" "trichoplax" --> "DrMcMoylex" "tJichapham"
"Doorknob" "Downgoat" --> "Doonkoot" "Dowrgnab"
"Halloween" "Challenge" --> "Hhlloeegn" "Caallwnee"
</code>```

Rules

The strings will only contain ASCII chars (32-126).

The strings will always be the same length, and will never be empty.

You may accept input in any suitable format: separate parameters, items in an array, separated by one or more newlines, even concatenated. The only restriction is that one string must come fully before the other (e.g. a1\nb2\nc3 for "abc", "123" is invalid).

The output may be in either order (i.e. you can start swapping from the first or the second char), and in any valid format mentioned above. (2-item array, separated by newline(s), concatenated, etc.)

Scoring

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

答:
Octave, <s>64</s> 61 bytes

```<code>@(x)reshape(x((t=1:end)+(2*mod(t,2)-1).*(mod(t-1,4)>1)),2,[])
</code>```

Anonymous function that inputs a 2D char array with each string in a row, and produces the output in the same format.

Try it at Ideone.

ContentLicense: CC BY-SA 3.0

Title: Interlace strings

Body:
Octave, <s>64</s> 61 bytes

@(x)reshape(x((t=1:end)+(2*mod(t,2)-1).*(mod(t-1,4)>1)),2,[])

Anonymous function that inputs a 2D char array with each string in a row, and produces the output in the same format.

Try it at Ideone.


问:
The Versatile Integer Printer
Write a piece of code that is executable in at least three different languages. The code must output the integer 1 in language number one, 2 in language number two, 3 in language number three etc.

Rules:

The output must be only the integer, but trailing newlines are OK.

The code can't take input of any kind

Different major versions of the same language are considered unique. So, your code can be executable in Python 2 and Python 3, however Python 2.5 and Python 2.7 are not considered unique.

You may use a new language if and only if it has an esolang/wiki article, available interpreter and documentation, and has been used by at least two users on PPCG prior to using it in this challenge. It must also adhere to these 4 rules.

The score of your submission is the number of bytes in your code divided by the number of languages it can run in cubed. So, a 54 byte solution that is executable in 3 languages will have a score of 2:

```<code>54 / 3^3 = 2
</code>```

Lower score is better.

答:
C, Python 2, Python 3, 99 bytes / 3 languages ^ 3 = 3.666677 points

Python 2 and 3 both use a version string, and the first character is the major version number. C prints 1, Python 2 prints 2, and Python 3 prints 3.

```<code>#include <stdio.h>/*
import sys
print(sys.version[0])
#*/
#define pass main(){printf("%d",1);}
pass
</code>```

ContentLicense: CC BY-SA 4.0

Title: The Versatile Integer Printer

Body:
C, Python 2, Python 3, 99 bytes / 3 languages ^ 3 = 3.666677 points

Python 2 and 3 both use a version string, and the first character is the major version number. C prints 1, Python 2 prints 2, and Python 3 prints 3.

#include <stdio.h>/*
import sys
print(sys.version[0])
#*/
#define pass main(){printf("%d",1);}
pass


答:
Racket 208 bytes

```<code>(let((sl string->list)(ls list->string)(r reverse))(let p((s(sl s))(t(sl t))(u'())(v'())(g #t))(if(null? s)
(list(ls(r u))(ls(r v)))(p(cdr s)(cdr t)(cons(car(if g s t))u)(cons(car(if g t s))v)(if g #f #t)))))
</code>```

Ungolfed:

```<code>(define (f s t)
  (let ((sl string->list)                ; create short names of fns
        (ls list->string)
        (r reverse))
    (let loop ((s (sl s))                ; convert string to lists
               (t (sl t))
               (u '())                   ; create empty new lists
               (v '())
               (g #t))                   ; a boolean flag
      (if (null? s)                      ; if done, return new lists converted back to strings
          (list (ls (r u))
                (ls (r v)))
          (loop (rest s)
                (rest t)                 ; keep adding chars to new lists alternately
                (cons (first (if g s t)) u)
                (cons (first (if g t s)) v)
                (if g #f #t))            ; alternate the boolean flag
          ))))
</code>```

Testing:

```<code>(f "abcdef" "123456")
</code>```

Output:

```<code>'("a2c4e6" "1b3d5f")
</code>```

Above is recursive version.

Iterative version:

```<code>(let*((sl string->list)(ls list->string)(r reverse)(s(sl s))(t(sl t))(l'())(k'())(p(λ(a b g)(set! l(cons(if g a b)l))
(set! k(cons(if g b a)k)))))(for((i s)(j t)(n(in-naturals)))(p i j(if(= 0(modulo n 2)) #t #f)))(list(ls(r l))(ls(r k))))
</code>```

Ungolfed:

```<code>(define (f s t)
  (let* ((sl string->list)              ; create short form of fn names
         (ls list->string)
         (r reverse)

         (s (sl s))                     ; convert strings to lists
         (t (sl t))

         (l '())                        ; create empty lists for new sequences
         (k '())

         (p (λ(a b g)                   ; fn to add chars to one or other list
              (set! l (cons (if g a b) l))
              (set! k (cons (if g b a) k)))))

    (for ((i s)(j t)(n (in-naturals)))  ; loop with both strings
          (p i j                        ; add to new lists alternately
             (if (= 0 (modulo n 2)) #t #f)))

    (list (ls (r l))                  ; convert reversed lists to strings
          (ls (r k)))))
</code>```

Title: Interlace strings

Body:
Your challenge is to write a program or function that, when given two strings of equal length, swaps every other character and outputs/returns the resulting strings in either order.

Examples

```<code>"Hello," "world!" --> "Hollo!" "werld,"
"code" "golf" --> "codf" "gole"
"happy" "angry" --> "hnpry" "aagpy"
"qwerty" "dvorak" --> "qvertk" "dworay"
"1, 2, 3" "a, b, c" --> "1, b, 3" "a, 2, c"
"3.141592653589" "2.718281828459" --> "3.111291623489" "2.748582858559"
"DJMcMayhem" "trichoplax" --> "DrMcMoylex" "tJichapham"
"Doorknob" "Downgoat" --> "Doonkoot" "Dowrgnab"
"Halloween" "Challenge" --> "Hhlloeegn" "Caallwnee"
</code>```

Rules

The strings will only contain ASCII chars (32-126).

The strings will always be the same length, and will never be empty.

You may accept input in any suitable format: separate parameters, items in an array, separated by one or more newlines, even concatenated. The only restriction is that one string must come fully before the other (e.g. a1\nb2\nc3 for "abc", "123" is invalid).

The output may be in either order (i.e. you can start swapping from the first or the second char), and in any valid format mentioned above. (2-item array, separated by newline(s), concatenated, etc.)

Scoring

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

Body:
Racket 208 bytes

(let((sl string->list)(ls list->string)(r reverse))(let p((s(sl s))(t(sl t))(u'())(v'())(g #t))(if(null? s)
(list(ls(r u))(ls(r v)))(p(cdr s)(cdr t)(cons(car(if g s t))u)(cons(car(if g t s))v)(if g #f #t)))))

Ungolfed:

(define (f s t)
  (let ((sl string->list)                ; create short names of fns
        (ls list->string)
        (r reverse))
    (let loop ((s (sl s))                ; convert string to lists
               (t (sl t))
               (u '())                   ; create empty new lists
               (v '())
               (g #t))                   ; a boolean flag
      (if (null? s)                      ; if done, return new lists converted back to strings
          (list (ls (r u))
                (ls (r v)))
          (loop (rest s)
                (rest t)                 ; keep adding chars to new lists alternately
                (cons (first (if g s t)) u)
                (cons (first (if g t s)) v)
                (if g #f #t))            ; alternate the boolean flag
          ))))

Testing:

(f "abcdef" "123456")

Output:

'("a2c4e6" "1b3d5f")

Above is recursive version.

Iterative version:

(let*((sl string->list)(ls list->string)(r reverse)(s(sl s))(t(sl t))(l'())(k'())(p(λ(a b g)(set! l(cons(if g a b)l))
(set! k(cons(if g b a)k)))))(for((i s)(j t)(n(in-naturals)))(p i j(if(= 0(modulo n 2)) #t #f)))(list(ls(r l))(ls(r k))))

Ungolfed:

(define (f s t)
  (let* ((sl string->list)              ; create short form of fn names
         (ls list->string)
         (r reverse)

         (s (sl s))                     ; convert strings to lists
         (t (sl t))

         (l '())                        ; create empty lists for new sequences
         (k '())

         (p (λ(a b g)                   ; fn to add chars to one or other list
              (set! l (cons (if g a b) l))
              (set! k (cons (if g b a) k)))))

    (for ((i s)(j t)(n (in-naturals)))  ; loop with both strings
          (p i j                        ; add to new lists alternately
             (if (= 0 (modulo n 2)) #t #f)))

    (list (ls (r l))                  ; convert reversed lists to strings
          (ls (r k)))))


问:
Draw an asterisk triangle
Inspired by a task for Programming 101, here's a challenge that hopefully isn't too easy (or a duplicate).

Input:

A positive integer n >= 1.

Output:

n lines of asterisks, where every new line has one asterisk more than the line before, and starting with one asterisk in the first line.

Test case (n=5):

```<code>    *
    **
    ***
    ****
    *****
</code>```

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

答:
Python 2, <s>38</s> 37 bytes

There are only 36 characters shown, but a trailing newline is needed to avoid an EOF-related error raised by the interpreter. 1 byte knocked off for Flp.Tkc's observation.

for n in range(input()+1):print'*'*n
```

<h3>Output for n=5</h3>

```# leading newline here
*
**
***
****
*****
```

<h1>Python 3, 45 bytes</h1>

<p>The actual list comprehension is never assigned or printed, but if it were, it would be full of <code>None</code>s, as <code>None</code> is the default return value of <code>print()</code>.
</p>

```[print('*'*n)for n in range(int(input())+1)]
```

Title: Draw an asterisk triangle

Body:
Python 2, <s>38</s> 37 bytes

There are only 36 characters shown, but a trailing newline is needed to avoid an EOF-related error raised by the interpreter. 1 byte knocked off for Flp.Tkc's observation.

for n in range(input()+1):print'*'*n

Output for n=5

# leading newline here
*
**
***
****
*****

Python 3, 45 bytes

The actual list comprehension is never assigned or printed, but if it were, it would be full of Nones, as None is the default return value of print().

[print('*'*n)for n in range(int(input())+1)]


问:
Produce Dürer's magic square

The challenge

Output an array or string representation of Dürer's famous magic square:

that is,

```<code>16  3  2 13
 5 10 11  8
 9  6  7 12
 4 15 14  1
</code>```

Some properties of this square, which can perhaps be exploited, are:

It contains each integer from 1 to 16 exactly once

The sum of each column or row, as well as the the sum of each of the two diagonals, is the same. This is the defining property of a magic square. The sum is the magic constant of the square.

In addition, for this particular square, the sum of each of the four quadrants also equals the magic constant, as do the sum of the center four squares and the sum of the corner four squares.

Rules

Bultins that generate magic squares are not allowed (such as Matlab's magic or Mathematica's MagicSquare). Any other builtin can be used.

The code can be a program or a function.

There is no input.

The numbers must be in base 10. The output format is flexible as usual. Some possibilities are:

A nested array (either function output, or its string representation, with or without separators, any type of matching brackets):

```<code>[[16, 3, 2, 13], [5, 10, 11, 8], [9, 6, 7, 12], [4, 15, 14, 1]]
</code>```

A 2D array:

```<code>{16, 3, 2, 13; 5, 10, 11, 8; 9, 6, 7, 12; 4, 15, 14, 1}
</code>```

An array of four strings, or a string consisting of four lines. The numbers may be right-aligned

```<code>16  3  2 13
 5 10 11  8
 9  6  7 12
 4 15 14  1
</code>```

or left-aligned

```<code>16 3  2  13
5  10 11  8
9  6  7  12
4  15 14  1
</code>```

A string with two different separators for row and column, such as

```<code>16,3,2,13|5,10,11,8|9,6,7,12|4,15,14,1
</code>```

The output format should clearly differentiate rows and columns. For example, it is not allowed to output a flat array, or a string with all numbers separated by spaces.

Code golf. Shortest wins.

答:
Jelly, <s>16</s> 15 bytes

```<code>4Œ!.ịm0µZḂÞ’×4+
</code>```

Try it online!

Background

If we subtract 1 from the numbers in the square and divide them by 4 (computing quotient and remainder), a pattern becomes apparent.

```<code>quotients and remainders    quotients    remainders

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

The remainder matrix follows an obvious pattern and is easy to generate. The quotient matrix can be obtained by transposing the remainder matrix and swapping the middle rows.

How it works

```<code>4Œ!.ịm0µZḂÞ’×4+  Main link. No arguments.

4Œ!              Compute the array of all permutations of [1, 2, 3, 4], in
                 lexicographical order.
   .ị            Take the permutations at the indices adjacent to 0.5, i.e., the
                 ones at indices 0 ([4, 3, 2, 1]) and 1 ([1, 2, 3, 4]).
     m0          Concatenate the resulting [[4, 3, 2, 1], [1, 2, 3, 4]] with a
                 reversed copy, yielding the matrix
                 M := [[4, 3, 2, 1], [1, 2, 3, 4], [1, 2, 3, 4], [4, 3, 2, 1]].
       µ         Begin a new, monadic chain. Argument: M
        Z        Zip/transpose M, yielding the matrix
                 [[4, 1, 1, 4], [3, 2, 2, 3], [2, 3, 3, 2], [1, 4, 4, 1]].
         ḂÞ      Sort the rows by the lexicographical order of their parities,
                 yielding [[4, 1, 1, 4], [2, 3, 3, 2], [3, 2, 2, 3], [1, 4, 4, 1]].
           ’     Subtract 1 to yield the matrix of quotients, i.e.,
                 [[3, 0, 0, 3], [1, 2, 2, 1], [2, 1, 1, 2], [0, 3, 3, 0]].
            ×4+  Multiply the quotient by 4 and add the result to M (remainders).
</code>```

Title: Produce Dürer's magic square

Body:
Jelly, <s>16</s> 15 bytes

4Œ!.ịm0µZḂÞ’×4+

Try it online!

Background

If we subtract 1 from the numbers in the square and divide them by 4 (computing quotient and remainder), a pattern becomes apparent.

quotients and remainders    quotients    remainders

   3 3  0 2  0 1  3 0        3 0 0 3      3 2 1 0
   1 0  2 1  2 2  1 3        1 2 2 1      0 1 2 3
   2 0  1 1  1 2  2 3        2 1 1 2      0 1 2 3
   0 3  3 2  3 1  0 0        0 3 3 0      3 2 1 0

The remainder matrix follows an obvious pattern and is easy to generate. The quotient matrix can be obtained by transposing the remainder matrix and swapping the middle rows.

How it works

4Œ!.ịm0µZḂÞ’×4+  Main link. No arguments.

4Œ!              Compute the array of all permutations of [1, 2, 3, 4], in
                 lexicographical order.
   .ị            Take the permutations at the indices adjacent to 0.5, i.e., the
                 ones at indices 0 ([4, 3, 2, 1]) and 1 ([1, 2, 3, 4]).
     m0          Concatenate the resulting [[4, 3, 2, 1], [1, 2, 3, 4]] with a
                 reversed copy, yielding the matrix
                 M := [[4, 3, 2, 1], [1, 2, 3, 4], [1, 2, 3, 4], [4, 3, 2, 1]].
       µ         Begin a new, monadic chain. Argument: M
        Z        Zip/transpose M, yielding the matrix
                 [[4, 1, 1, 4], [3, 2, 2, 3], [2, 3, 3, 2], [1, 4, 4, 1]].
         ḂÞ      Sort the rows by the lexicographical order of their parities,
                 yielding [[4, 1, 1, 4], [2, 3, 3, 2], [3, 2, 2, 3], [1, 4, 4, 1]].
           ’     Subtract 1 to yield the matrix of quotients, i.e.,
                 [[3, 0, 0, 3], [1, 2, 2, 1], [2, 1, 1, 2], [0, 3, 3, 0]].
            ×4+  Multiply the quotient by 4 and add the result to M (remainders).


答:
Javascript ES6, <s>66</s> <s>65</s> 55 bytes

Yes, it isn't the shortest one. And yes, it can be reduced.

```<code>_=>`f21c
49a7
856b
3ed0`.replace(/./g,_=>'0x'+_-~0+' ')
</code>```

For now, it isn't perfect. But is something!

Thanks to @Neil's suggestion that could save 5-8 bytes, and that inspired @ETHproductions suggestion that saves 10 bytes!

This makes the answer only 12 bytes longer than his 43 bytes solution.

Title: Produce Dürer's magic square

Body:
The challenge

Output an array or string representation of Dürer's famous magic square:

that is,

```<code>16  3  2 13
 5 10 11  8
 9  6  7 12
 4 15 14  1
</code>```

Some properties of this square, which can perhaps be exploited, are:

It contains each integer from 1 to 16 exactly once

The sum of each column or row, as well as the the sum of each of the two diagonals, is the same. This is the defining property of a magic square. The sum is the magic constant of the square.

In addition, for this particular square, the sum of each of the four quadrants also equals the magic constant, as do the sum of the center four squares and the sum of the corner four squares.

Rules

Bultins that generate magic squares are not allowed (such as Matlab's magic or Mathematica's MagicSquare). Any other builtin can be used.

The code can be a program or a function.

There is no input.

The numbers must be in base 10. The output format is flexible as usual. Some possibilities are:

A nested array (either function output, or its string representation, with or without separators, any type of matching brackets):

```<code>[[16, 3, 2, 13], [5, 10, 11, 8], [9, 6, 7, 12], [4, 15, 14, 1]]
</code>```

A 2D array:

```<code>{16, 3, 2, 13; 5, 10, 11, 8; 9, 6, 7, 12; 4, 15, 14, 1}
</code>```

An array of four strings, or a string consisting of four lines. The numbers may be right-aligned

```<code>16  3  2 13
 5 10 11  8
 9  6  7 12
 4 15 14  1
</code>```

or left-aligned

```<code>16 3  2  13
5  10 11  8
9  6  7  12
4  15 14  1
</code>```

A string with two different separators for row and column, such as

```<code>16,3,2,13|5,10,11,8|9,6,7,12|4,15,14,1
</code>```

The output format should clearly differentiate rows and columns. For example, it is not allowed to output a flat array, or a string with all numbers separated by spaces.

Code golf. Shortest wins.

Body:
Javascript ES6, <s>66</s> <s>65</s> 55 bytes

Yes, it isn't the shortest one. And yes, it can be reduced.

_=>`f21c
49a7
856b
3ed0`.replace(/./g,_=>'0x'+_-~0+' ')

For now, it isn't perfect. But is something!

Thanks to @Neil's suggestion that could save 5-8 bytes, and that inspired @ETHproductions suggestion that saves 10 bytes!

This makes the answer only 12 bytes longer than his 43 bytes solution.


问:
Don't google "google"
We all know that if you google the word "google" it will break the internet.

Your task is to create a function that accepts one string and returns its length, in the fewest possible Unicode characters.

However, if the given string is google (lowercase), it will cause an error.

For example, g('bing') will return 4 but g('google') will cause an error.

Please provide an example of usage, and the error if possible.

答:
Python 2, 46 bytes

```<code>a=raw_input()
print len(a)if a!='google'else b
</code>```

Errors out on input of "google" because b is an undefined identifier, but succeeds on other strings since control never reaches b in those cases.

Title: Don't google "google"

Body:
Python 2, 46 bytes

a=raw_input()
print len(a)if a!='google'else b

Errors out on input of "google" because b is an undefined identifier, but succeeds on other strings since control never reaches b in those cases.


答:
DASH, 24 bytes

```<code><|>4tc"................"
</code>```

Replace the periods with the characters of charcodes 16, 3, 2, 13, 5, 10, 11, 8, 9, 6, 7, 12, 4, 15, 14, and 1 respectively.

Explanation

Simply converts the characters to an array of charcodes and chunks by 4.

Title: Produce Dürer's magic square

Body:
DASH, 24 bytes

<|>4tc"................"

Replace the periods with the characters of charcodes 16, 3, 2, 13, 5, 10, 11, 8, 9, 6, 7, 12, 4, 15, 14, and 1 respectively.

Explanation

Simply converts the characters to an array of charcodes and chunks by 4.


答:
Mathematica, 51 bytes

Takes input as an array of two arrays of characters, with output in the same format. The function simply constructs the new array using a (mod 2) operation.

```<code>Table[#[[Mod[j+i,2]+1,j]],{i,2},{j,Length@#[[1]]}]&
</code>```

Title: Interlace strings

Body:
Mathematica, 51 bytes

Takes input as an array of two arrays of characters, with output in the same format. The function simply constructs the new array using a (mod 2) operation.

Table[#[[Mod[j+i,2]+1,j]],{i,2},{j,Length@#[[1]]}]&


问:
Encode the column cipher
Given a string to encode, and a number of columns (the key), encode the string as follows:

I will be using the example Hello, world! and the key 3

First, write out the number of columns:

```<code>1 2 3
</code>```

Next, write the text starting from the upper left, one character per column, and when you run out of columns, go to the next line.

```<code>1 2 3
H e l
l o ,
  w o
r l d
!
</code>```

Now, to get your encoded text, read the text starting from the top left corner, but this time, first read one column, and then the next, and so on. If there is not a character in the slot, put a space.

```<code>Hl r!eowl l,od
</code>```

Note that here, there is a trailing space.

This is your encoded text.

Another test case is Programming Puzzles and Code Golf SE with key 5:

```<code>1 2 3 4 5
P r o g r
a m m i n
g   P u z
z l e s
a n d   C
o d e   G
o l f   S
E
</code>```

The encoded text is PagzaooErm lndl omPedef gius    rnz CGS.

More test cases

```<code>"abcdefghijklmnopqrstuvwxyz", 2 -> "acegikmoqsuwybdfhjlnprtvxz"
"codegolf.stackexchange.com", 4 -> "cg.ccgoooskhemdltea. efaxnc "
"Pen Pineapple Apple Pen!!!", 7 -> "PeAeeapnnpp! pl!Ple!ie  n P "
"1,1,2,3,5,8,13,21,34,55,89", 10 -> "18,,,5115,3,2,8,2931 ,, 53 ,4 "
</code>```

Remember, this is code-golf, so the code with the fewest bytes wins.

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

Thanks to miles for saving three bytes!

```<code>Join@@Thread@Partition[##,#2,{1,1}," "]&
</code>```

Unnamed function taking two arguments, an array of characters and an integer; returns an array of characters.
Most of the heavy lifting is done by the Thread function, which (in this context) exchanges rows and columns. Partition needs to be called with a couple of useless arguments so that it will pad with the fifth argument " ".

Title: Encode the column cipher

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

Thanks to miles for saving three bytes!

Join@@Thread@Partition[##,#2,{1,1}," "]&

Unnamed function taking two arguments, an array of characters and an integer; returns an array of characters.
Most of the heavy lifting is done by the Thread function, which (in this context) exchanges rows and columns. Partition needs to be called with a couple of useless arguments so that it will pad with the fifth argument " ".


答:
QBasic 4.5, 172 bytes

Ouch, this one gets painful with the ol' QBasic...

```<code>DEFSTR A-D:INPUT A,B
IF LEN(A)MOD 2=1 THEN A=A+" ":B=B+" "
FOR x=1 TO LEN(A) STEP 2
C=C+MID$(A,x,1)+MID$(B,x+1,1):D=D+MID$(B,x,1)+MID$(A,x+1,1):NEXT:?RTRIM$(C),RTRIM$(D)
</code>```

Fun fact: Using DEFSTR saved more bytes than it cost because now I could use A instead of a$.

Title: Interlace strings

Body:
QBasic 4.5, 172 bytes

Ouch, this one gets painful with the ol' QBasic...

DEFSTR A-D:INPUT A,B
IF LEN(A)MOD 2=1 THEN A=A+" ":B=B+" "
FOR x=1 TO LEN(A) STEP 2
C=C+MID$(A,x,1)+MID$(B,x+1,1):D=D+MID$(B,x,1)+MID$(A,x+1,1):NEXT:?RTRIM$(C),RTRIM$(D)

Fun fact: Using DEFSTR saved more bytes than it cost because now I could use A instead of a$.


答:
Actually, 22 bytes

```<code>4"►♥☻♪♣◙♂◘○♠•♀♦☼♫☺"♂┘╪
</code>```

Try it online!

Explanation:

```<code>4"►♥☻♪♣◙♂◘○♠•♀♦☼♫☺"♂┘╪
 "►♥☻♪♣◙♂◘○♠•♀♦☼♫☺"     push a string containing the numbers in the magic square, encoded as CP437 characters
                   ♂┘   convert to ordinals
4                    ╪  chunk into length-4 slices
</code>```

Title: Produce Dürer's magic square

Body:
Actually, 22 bytes

4"►♥☻♪♣◙♂◘○♠•♀♦☼♫☺"♂┘╪

Try it online!

Explanation:

4"►♥☻♪♣◙♂◘○♠•♀♦☼♫☺"♂┘╪
 "►♥☻♪♣◙♂◘○♠•♀♦☼♫☺"     push a string containing the numbers in the magic square, encoded as CP437 characters
                   ♂┘   convert to ordinals
4                    ╪  chunk into length-4 slices


问:
Reconstruct a zigzagified matrix
As part of its compression algorithm, the JPEG standard unrolls a matrix into a vector along antidiagonals of alternating direction:

Your task is to take the unrolled vector along with the matrix dimensions and reconstruct the corresponding matrix. As an example:

```<code>[1, 2, 5, 9, 6, 3, 4, 7, 1, 2, 8, 3], 4, 3
</code>```

should yield

```<code>[1 2 3 4
 5 6 7 8
 9 1 2 3]
</code>```

whereas dimensions 6, 2 would give

```<code>[1 2 6 3 1 2
 5 9 4 7 8 3]
</code>```

Rules

You may choose to take only one of the dimensions as input. The individual inputs can be taken in any order. You may assume that the width and height are positive and valid for the given vector length.

You may assume that the vector elements are positive integers less than 10.

You may write a program or function, taking input via STDIN (or closest alternative), command-line argument or function argument and outputting the result via STDOUT (or closest alternative), function return value or function (out) parameter.

The input vector may be given in any convenient, unambiguous, flat list or string format.

The output matrix may be in any convenient, unambiguous, nested list or string format, or as a flat list along with both matrix dimensions. (Or, of course, as a matrix type if your language has those.)

Standard code-golf rules apply.

Test Cases

Each test case is of the form vector width height => matrix.

```<code>[1] 1 1                        => [[1]]
[1 2 3 1] 2 2                  => [[1 2] [3 1]]
[1 2 3 1] 4 1                  => [[1 2 3 1]]
[1 2 5 9 6 3 4 7 1 2 8 3] 3 4  => [[1 2 3] [5 6 4] [9 7 8] [1 2 3]]
[1 2 5 9 6 3 4 7 1 2 8 3] 4 3  => [[1 2 3 4] [5 6 7 8] [9 1 2 3]]
[1 2 5 9 6 3 4 7 1 2 8 3] 6 2  => [[1 2 6 3 1 2] [5 9 4 7 8 3]]
[1 2 5 9 6 3 4 7 1 2 8 3] 12 1 => [[1 2 5 9 6 3 4 7 1 2 8 3]]
[1 2 5 9 6 3 4 7 1 2 8 3] 1 12 => [[1] [2] [5] [9] [6] [3] [4] [7] [1] [2] [8] [3]]
</code>```

Related Challenges

Zigzagify a Matrix (the somewhat simpler inverse transformation)

Rotate the anti-diagonals

答:
J, 24 bytes

```<code>]$({~[:/:@;[:<@|.`</.i.)
</code>```

Also uses the oblique adverb /. to perform zigzagify as in the J answer from that challenge.

Usage

Input is with the array on the LHS and the dimensions [height, width] on the RHS.

```<code>   f =: ]$({~[:/:@;[:<@|.`</.i.)
   1 f 1 1
1
   1 2 3 1 f 2 2
1 2
3 1
   1 2 5 9 6 3 4 7 1 2 8 3 f 4 3
1 2 3
5 6 4
9 7 8
1 2 3
   1 2 5 9 6 3 4 7 1 2 8 3 f 3 4
1 2 3 4
5 6 7 8
9 1 2 3
   1 2 5 9 6 3 4 7 1 2 8 3 f 2 6
1 2 6 3 1 2
5 9 4 7 8 3
   1 2 5 9 6 3 4 7 1 2 8 3 f 1 12
1 2 5 9 6 3 4 7 1 2 8 3
   1 2 5 9 6 3 4 7 1 2 8 3 f 12 1
1
2
5
9
6
3
4
7
1
2
8
3
</code>```

Explanation

```<code>]$({~[:/:@;[:<@|.`</.i.)  Input: list A (LHS), dimensions D (RHS)
                     i.   Range shaped to D
           [:<@|.`</.     Zigzagify that matrix
     [:   ;               Raze the boxes to get a zigzagify permutation
       /:@                Invert that permutation to get an unzigzagify permutation
   {~                     Apply that permutation to A
]                         Get D
 $                        Shape that permutation to D and return
</code>```

Title: Reconstruct a zigzagified matrix

Body:
J, 24 bytes

]$({~[:/:@;[:<@|.`</.i.)

Also uses the oblique adverb /. to perform zigzagify as in the J answer from that challenge.

Usage

Input is with the array on the LHS and the dimensions [height, width] on the RHS.

   f =: ]$({~[:/:@;[:<@|.`</.i.)
   1 f 1 1
1
   1 2 3 1 f 2 2
1 2
3 1
   1 2 5 9 6 3 4 7 1 2 8 3 f 4 3
1 2 3
5 6 4
9 7 8
1 2 3
   1 2 5 9 6 3 4 7 1 2 8 3 f 3 4
1 2 3 4
5 6 7 8
9 1 2 3
   1 2 5 9 6 3 4 7 1 2 8 3 f 2 6
1 2 6 3 1 2
5 9 4 7 8 3
   1 2 5 9 6 3 4 7 1 2 8 3 f 1 12
1 2 5 9 6 3 4 7 1 2 8 3
   1 2 5 9 6 3 4 7 1 2 8 3 f 12 1
1
2
5
9
6
3
4
7
1
2
8
3

Explanation

]$({~[:/:@;[:<@|.`</.i.)  Input: list A (LHS), dimensions D (RHS)
                     i.   Range shaped to D
           [:<@|.`</.     Zigzagify that matrix
     [:   ;               Raze the boxes to get a zigzagify permutation
       /:@                Invert that permutation to get an unzigzagify permutation
   {~                     Apply that permutation to A
]                         Get D
 $                        Shape that permutation to D and return


答:
Perl, 40 bytes

Includes +1 for -n

Give strings as lines on STDIN

```<code>interlace.pl
hello
world
^D
</code>```

interlace.pl

```<code>#!/usr/bin/perl -n
s/./${1&$.+pos}[pos]=$&/seg}{print@0,@1
</code>```

Title: Interlace strings

Body:
Perl, 40 bytes

Includes +1 for -n

Give strings as lines on STDIN

interlace.pl
hello
world
^D

interlace.pl

#!/usr/bin/perl -n
s/./${1&$.+pos}[pos]=$&/seg}{print@0,@1


问:
Output a googol copies of a string
I am interested in seeing programs which don't ask for any input, print a googol copies of some nonempty string, no less, no more, and then stop. A googol is defined as \$10^{100}\$, i.e., 1 followed by a hundred 0's in decimal.

Example output:

```<code>111111111111111111111111111111111111111111111111111111111111111111111111...
</code>```

or

```<code>Hello world
Hello world
Hello world
Hello world
Hello world
Hello world
...
</code>```

The string can also be entirely composed of white space or special symbols. The only exception to identical copies of a fixed string is if your language decorates the output in some way that can not be prevented, but could be trivially undone in a wrapper script, like prepending a line number to each line. The wrapper script in such cases need not be provided.

You can assume your computer will never run out of time, but other than that, your program must have a reasonable demand of resources. Also, you must respect any restrictions that the programming language of your choice poses, for example, you can not exceed a maximum value allowed for its integer types, and at no point more than 4 GB of memory must be needed.

In other words, the program should in principle be testable by running it on your computer. But because of the extent of this number you will be expected to prove that the number of copies of the string it outputs is exactly 10^100 and that the program stops afterwards. Stopping can be exiting or halting or even terminating due to an error, but if so, the error must not produce any output that could not easily be separated from the program's output.

This is code-golf,  so the solution with the fewest bytes wins.

Example solution (C, ungolfed, 3768 bytes)

```<code>#include <stdio.h>

int main() {
  int a00, a01, a02, a03, ..., a99;
  for(a00 = 0; a00 < 10; a00++)
  for(a01 = 0; a01 < 10; a01++)
  for(a02 = 0; a02 < 10; a02++)
  for(a03 = 0; a03 < 10; a03++)
  ...
  for(a99 = 0; a99 < 10; a99++)
    puts("1");
  return 0;
}
</code>```

答:
PHP, <s>39</s> 38 bytes

```<code>for($a=str_pad(e,99,0);T^$a++;)echo!0;
</code>```

Run like this:

```<code>php -r 'for($a=str_pad(e,99,0);T^$a++;)echo!0;' 2>/dev/null
</code>```

STDERR (34 bytes)

If a variant with output to STDERR is valid, then this outputs PHP Notice:  Use of undefined constant T - assumed 'T' in Command line code on line 1 a googol times.

```<code>php -r 'for($a=str_pad(@e,99,0);T^++$a;);'
</code>```

Explanation

```<code>for (
    $a = str_pad("e", 99, "0"); // Creates a string "e000" (98 zeroes).
    "T" ^ $a++;                 // Increment the string, binary XOR with
                                // "T": when the alphabetic part of the
                                // string becomes "da" this results in
                                // falsy "0", ending the loop.
)
    echo!0;                     // Print a single "1".
</code>```

Note that the alphabetic part iterates from e..z (22), aa..az (26), ba..bz (26), ca..cz (26) for a total of 100, or a 1 with 2 zeroes. So only 98 zeroes need to be added to arrive at 1E100. The loop stops only when the alphabetic part is 2 digits and the second digit becomes  d. The d is conveniently skipped when it's only 1 digit (since it starts at e).

Perf

This doesn't consume a ridiculous amount of resources (in fact very little) and runs fast.

Tweaks

Saved a byte by using 2 alphabetic chars so less padding characters (99 vs 101)

Added a variant using STDERR, saving 5 bytes

Title: Output a googol copies of a string

Body:
PHP, <s>39</s> 38 bytes

for($a=str_pad(e,99,0);T^$a++;)echo!0;

Run like this:

php -r 'for($a=str_pad(e,99,0);T^$a++;)echo!0;' 2>/dev/null

STDERR (34 bytes)

If a variant with output to STDERR is valid, then this outputs PHP Notice:  Use of undefined constant T - assumed 'T' in Command line code on line 1 a googol times.

php -r 'for($a=str_pad(@e,99,0);T^++$a;);'

Explanation

for (
    $a = str_pad("e", 99, "0"); // Creates a string "e000" (98 zeroes).
    "T" ^ $a++;                 // Increment the string, binary XOR with
                                // "T": when the alphabetic part of the
                                // string becomes "da" this results in
                                // falsy "0", ending the loop.
)
    echo!0;                     // Print a single "1".

Note that the alphabetic part iterates from e..z (22), aa..az (26), ba..bz (26), ca..cz (26) for a total of 100, or a 1 with 2 zeroes. So only 98 zeroes need to be added to arrive at 1E100. The loop stops only when the alphabetic part is 2 digits and the second digit becomes  d. The d is conveniently skipped when it's only 1 digit (since it starts at e).

Perf

This doesn't consume a ridiculous amount of resources (in fact very little) and runs fast.

Tweaks

Saved a byte by using 2 alphabetic chars so less padding characters (99 vs 101)

Added a variant using STDERR, saving 5 bytes


问:
Is it a pangram?
Write a function or program that takes as its input a string and prints a truthy value if the string is a pangram (a sequence of letters containing at least one of each letter in the English alphabet) and a falsey value otherwise.

Case of letters should be ignored; If the string is abcdefghijklmnopqrstuvwXYZ, then the function should still return a truthy value. Note that the string can contain any other characters in it, so 123abcdefghijklm NOPQRSTUVWXYZ321 would return a truthy value. An empty input should return a falsey value.

Test cases

```<code>AbCdEfGhIjKlMnOpQrStUvWxYz

==> True

ACEGIKMOQSUWY
BDFHJLNPRTVXZ

==> True

public static void main(String[] args)

==> False

The quick brown fox jumped over the lazy dogs. BOING BOING BOING

==> True
</code>```

This is code golf. Standard rules apply. Shortest code in bytes wins.

答:
2sable, <s>6</s> 5 bytes

6 byte version:

```<code>AIl-g_
</code>```

Try it online!

Explanation:

```<code>A        Push alphabet
 Il      Push lowercase input
   -     Remove all chars of input from alphabet
    g    Get length of the remainder
     _   Print negative bool, where length < 1 = 1 (true), length > 0 = 0 (false)
</code>```

5 byte version, inspired by carusocomputing's 05AB1E answer:

```<code>lÙ{Aå
</code>```

Try it online!

Explanation:

```<code>l        Push lowercase input
 Ù{      Push sorted uniquified input
   A     Push alphabet
    å    Is alphabet in sorted, uniquified input?
</code>```

Title: Is it a pangram?

Body:
2sable, <s>6</s> 5 bytes

6 byte version:

AIl-g_

Try it online!

Explanation:

A        Push alphabet
 Il      Push lowercase input
   -     Remove all chars of input from alphabet
    g    Get length of the remainder
     _   Print negative bool, where length < 1 = 1 (true), length > 0 = 0 (false)

5 byte version, inspired by carusocomputing's 05AB1E answer:

lÙ{Aå

Try it online!

Explanation:

l        Push lowercase input
 Ù{      Push sorted uniquified input
   A     Push alphabet
    å    Is alphabet in sorted, uniquified input?


答:
JavaScript (ES6), 221

A non recursive function returning an array of strings (still using a recursive subfunction inside)

a=>[...(R=(a,l)=>a[r[l]='',0]&&a[0].map?'O'+a.map(v=>R(v,l+1))+'C':a.join` `)([a],l=-1,r=[],m='')].map(c=>r=r.map(x=>x+v[(k<0)*2+!k--],k=l,1/c?v='-- ':(v='-+|',c>'C'?k=++l:c>','&&--l,c='|'),m+=c))&&[...r,m,...r.reverse()]
```

<p>This works in 2 steps.</p>

<p>Step 1: recursively build a string representation of the nested input array. Example:</p>

<p><code>[[[1, 2, 3], [],[4, 5]], [6, 7, 8]]</code> -> <code>"OOO1 2 3,,4 5C,6 7 8CC"</code></p>

<p><code>O</code> and <code>C</code> mark open and close subarray. Simple numeric subarrays are rendered with the elements separated by space, while if array members are subarrays they are separated by commas. This string keeps track of the multilevel structure of the input array, while I can get the middle row of the output just replacing <code>OC,</code> with <code>|</code>. While recursively building this temp string, I also find the max depth level and initialize an array of empty strings that will contain the half top part of the output.<br>
Note: the outer box is tricky, I nest the input inside another outer array, then I have drop the first row of output that is not needed</p>

<p>Step 2: scan the temp string and build the output</p>

<p>Now I have an array of empty strings, one for each level. I scan the temp string, keeping track of the current level, that increases for each <code>O</code> and decreases for each <code>C</code>. I visualize this like that:</p>

<pre class="lang-js prettyprint-override"><code>[[[1, 2, 3], [],[4, 5]], [6, 7, 8]]

OOO1 2 3,,4 5C,6 7 8CC
+                    +
 +            +     +
  +     ++   +
|||1 2 3||4 5||6 7 8||
</code>```

The plus the goes up and down follow the current level

For each char, I add a character to every row of output,  following the rules:

- if digit or space, put a '-' at the current level and below, put a space above

- else, put a '+' at the current level, put a '-' if below and put a '|' if above

OOO1 2 3,,4 5C,6 7 8CC
+--------------------+
|+------------+-----+|
||+-----++---+|     ||
|||1 2 3||4 5||6 7 8||
```

<p>During the temp scan, I also build the middle row replacing <code>OC,</code> with <code>|</code></p>

<p>At the end of this step, I have the top half and the middle row, I only have to mirror the top to get the bottom half and I'm done</p>

<p><em>Less golfed, commented code</em></p>

<pre class="lang-js prettyprint-override"><code>a=>{
   r = []; // output array
   R = ( // recursive scan function
     a, // current subarray
     l  // current level
   ) => (
     r[l] = '', // element of r at level r, init to ""
     a[0] && a[0].map // check if it is a flat (maybe empty) array or an array of arrays
     ? 'O'+a.map(v=>R(v,l+1))+'C' // mark Open and Close, recurse
     : a.join` ` // just put the elements space separated
   );
   T = R([a],-1)]; // build temp string
   // pass the input nested in another array
   // and start with level -1 , so that the first row of r will not be visible to .map

   // prepare the final output
   m = '' // middle row, built upon the chars in T
   l = -1 // starting level
   [...T].map(c => // scan the temp string
         {
            k = l; // current level
            1/c // check if numeric or space
             ? v = '-- ' // use '-','-',' '
             : (
                 v = '-+|', // use '-','+','|'
                 c > 'C'
                   ? k=++l // if c=='O', increment level and assign to k
                   : c>'A'&&--l, // if c=='C', decrement level (but k is not changed)
                 c='|' // any of O,C,comma must be mapped to '|'
               );
            m += c; // add to middle row
            r = r.map( (x,i) => // update each output row
                       // based on comparation between row index and level
                       // but in golfed code I don't use the i index
                       // and decrement l at each step
                       x + v[(k<i)*2+!(k-i)]
                     )
         })
   // almost done!
   return [...r,m,...r.reverse()]
</code>```

)

Test

F=
a=>[...(R=(a,l)=>a[r[l]='',0]&&a[0].map?'O'+a.map(v=>R(v,l+1))+'C':a.join` `)([a],l=-1,r=[],m='')].map(c=>r=r.map(x=>x+v[(k<0)*2+!k--],k=l,1/c?v='-- ':(v='-+|',c>'C'?k=++l:c>','&&--l,c='|'),m+=c))&&[...r,m,...r.reverse()]

out=x=>O.textContent = x+'\n'+O.textContent

;[[1,2,3]
,[[[1, 2, 3], [4, 5]], [6, 7, 8]]
,[]
,[[], []]
,[[], [1], [], [2], [], [3], []]
,[[[[[0]]]]]
,[[[[[4, 3, 2, 1]]]], [[[3, 2, 1]]], [[2, 1]], [1]]
].forEach(t=>
  out(JSON.stringify(t)+'\n'+F(t).join`\n`+'\n')
)

function update()
{
  var i=eval(I.value)
  out(JSON.stringify(i)+'\n'+F(i).join`\n`+'\n')
}

update()```
<pre class="snippet-code-css lang-css prettyprint-override"><code>#I { width:90%}</code>```

<input id=I value='[[[1, 2, 3], [],[4, 5]], [6, 7, 8]]' oninput='update()'>

```</code>```

Title: Visualize an Array

Body:
Given an array of any depth, draw its contents with borders of +-| around each subarray. Those are the ASCII characters for plus, minus, and vertical pipe.

For example, if the array is [1, 2, 3], draw

```<code>+-----+
|1 2 3|
+-----+
</code>```

For a nested array such as [[1, 2, 3], [4, 5], [6, 7, 8]], draw

```<code>+-----------------+
|+-----+---+-----+|
||1 2 3|4 5|6 7 8||
|+-----+---+-----+|
+-----------------+
</code>```

For a ragged array such as [[[1, 2, 3], [4, 5]], [6, 7, 8]], draw

```<code>+-------------------+
|+-----------+-----+|
||+-----+---+|6 7 8||
|||1 2 3|4 5||     ||
||+-----+---+|     ||
|+-----------+-----+|
+-------------------+
</code>```

Notice that there is more space after drawing [6, 7, 8]. You may either draw the contents on the top-most, center, or bottom-most line, but whichever you choose, you must remain consistent.

This challenge was inspired by the box verb < from J.

Rules

This is code-golf so the shortest code wins.

Builtins that solve this are not allowed.

The input array will contain only nonnegative integer values or arrays. Each array will be homogenous, meaning that its elements will either by only arrays or only integers, but never a mix of both.

Each subarray may be nested to any depth.

The output may either by as a string or as an array of strings where each string is a line of output.

Test Cases

```<code>[]
++
||
++

[[], []]
+---+
|+++|
|||||
|+++|
+---+

[[], [1], [], [2], [], [3], []]
+-----------+
|++-++-++-++|
|||1||2||3|||
|++-++-++-++|
+-----------+

[[[[[0]]]]]
+---------+
|+-------+|
||+-----+||
|||+---+|||
||||+-+||||
|||||0|||||
||||+-+||||
|||+---+|||
||+-----+||
|+-------+|
+---------+

[[[[[4, 3, 2, 1]]]], [[[3, 2, 1]]], [[2, 1]], [1]]
+---------------------------------+
|+-------------+---------+-----+-+|
||+-----------+|+-------+|+---+|1||
|||+---------+|||+-----+|||2 1|| ||
||||+-------+|||||3 2 1|||+---+| ||
|||||4 3 2 1|||||+-----+||     | ||
||||+-------+|||+-------+|     | ||
|||+---------+||         |     | ||
||+-----------+|         |     | ||
|+-------------+---------+-----+-+|
+---------------------------------+
</code>```

Body:
JavaScript (ES6), 221

A non recursive function returning an array of strings (still using a recursive subfunction inside)

a=>[...(R=(a,l)=>a[r[l]='',0]&&a[0].map?'O'+a.map(v=>R(v,l+1))+'C':a.join` `)([a],l=-1,r=[],m='')].map(c=>r=r.map(x=>x+v[(k<0)*2+!k--],k=l,1/c?v='-- ':(v='-+|',c>'C'?k=++l:c>','&&--l,c='|'),m+=c))&&[...r,m,...r.reverse()]

This works in 2 steps.

Step 1: recursively build a string representation of the nested input array. Example:

[[[1, 2, 3], [],[4, 5]], [6, 7, 8]] -> "OOO1 2 3,,4 5C,6 7 8CC"

O and C mark open and close subarray. Simple numeric subarrays are rendered with the elements separated by space, while if array members are subarrays they are separated by commas. This string keeps track of the multilevel structure of the input array, while I can get the middle row of the output just replacing OC, with |. While recursively building this temp string, I also find the max depth level and initialize an array of empty strings that will contain the half top part of the output.

Note: the outer box is tricky, I nest the input inside another outer array, then I have drop the first row of output that is not needed

Step 2: scan the temp string and build the output

Now I have an array of empty strings, one for each level. I scan the temp string, keeping track of the current level, that increases for each O and decreases for each C. I visualize this like that:

[[[1, 2, 3], [],[4, 5]], [6, 7, 8]]

OOO1 2 3,,4 5C,6 7 8CC
+                    +
 +            +     +
  +     ++   +
|||1 2 3||4 5||6 7 8||

The plus the goes up and down follow the current level

For each char, I add a character to every row of output,  following the rules:

- if digit or space, put a '-' at the current level and below, put a space above

- else, put a '+' at the current level, put a '-' if below and put a '|' if above

OOO1 2 3,,4 5C,6 7 8CC
+--------------------+
|+------------+-----+|
||+-----++---+|     ||
|||1 2 3||4 5||6 7 8||

During the temp scan, I also build the middle row replacing OC, with |

At the end of this step, I have the top half and the middle row, I only have to mirror the top to get the bottom half and I'm done

Less golfed, commented code

a=>{
   r = []; // output array
   R = ( // recursive scan function
     a, // current subarray
     l  // current level
   ) => (
     r[l] = '', // element of r at level r, init to ""
     a[0] && a[0].map // check if it is a flat (maybe empty) array or an array of arrays
     ? 'O'+a.map(v=>R(v,l+1))+'C' // mark Open and Close, recurse
     : a.join` ` // just put the elements space separated
   );
   T = R([a],-1)]; // build temp string
   // pass the input nested in another array
   // and start with level -1 , so that the first row of r will not be visible to .map

   // prepare the final output
   m = '' // middle row, built upon the chars in T
   l = -1 // starting level
   [...T].map(c => // scan the temp string
         {
            k = l; // current level
            1/c // check if numeric or space
             ? v = '-- ' // use '-','-',' '
             : (
                 v = '-+|', // use '-','+','|'
                 c > 'C'
                   ? k=++l // if c=='O', increment level and assign to k
                   : c>'A'&&--l, // if c=='C', decrement level (but k is not changed)
                 c='|' // any of O,C,comma must be mapped to '|'
               );
            m += c; // add to middle row
            r = r.map( (x,i) => // update each output row
                       // based on comparation between row index and level
                       // but in golfed code I don't use the i index
                       // and decrement l at each step
                       x + v[(k<i)*2+!(k-i)]
                     )
         })
   // almost done!
   return [...r,m,...r.reverse()]

)

Test

F=
a=>[...(R=(a,l)=>a[r[l]='',0]&&a[0].map?'O'+a.map(v=>R(v,l+1))+'C':a.join` `)([a],l=-1,r=[],m='')].map(c=>r=r.map(x=>x+v[(k<0)*2+!k--],k=l,1/c?v='-- ':(v='-+|',c>'C'?k=++l:c>','&&--l,c='|'),m+=c))&&[...r,m,...r.reverse()]

out=x=>O.textContent = x+'\n'+O.textContent

;[[1,2,3]
,[[[1, 2, 3], [4, 5]], [6, 7, 8]]
,[]
,[[], []]
,[[], [1], [], [2], [], [3], []]
,[[[[[0]]]]]
,[[[[[4, 3, 2, 1]]]], [[[3, 2, 1]]], [[2, 1]], [1]]
].forEach(t=>
  out(JSON.stringify(t)+'\n'+F(t).join`\n`+'\n')
)

function update()
{
  var i=eval(I.value)
  out(JSON.stringify(i)+'\n'+F(i).join`\n`+'\n')
}

update()

#I { width:90%}

<input id=I value='[[[1, 2, 3], [],[4, 5]], [6, 7, 8]]' oninput='update()'>
<pre id=O></pre>


问:
Decode Baby-talk!
When babies open their mouths, they're not just spewing gibberish. They're actually talking in a highly advanced, adult-proof cipher...

The Baby-talk Cipher

When a baby talks, it could look something like gogooa gagooook aagaaoooy
Each single-space separated section represents a character (so the example above represents 3 characters).

To decipher a section, we must count number of As and Os it contains. However, we only count those which are adjacent to another vowel. For example, the A in 'gag' would not count, but both the A and O in 'gaog' would.

Counting the example above would look like this:

```<code>Section    | Num Os | Num As

gogooa     | 2      | 1
gagooook   | 4      | 0
aagaaoooy  | 3      | 4
</code>```

We then use these values to convert the input into plaintext on a Polybius square. This is a 5x5 representation of the English alphabet, omitting 'J' (please note that, in baby-talk, 0-counting rules apply to the table):

```<code>  0 1 2 3 4
0 A B C D E
1 F G H I K
2 L M N O P
3 Q R S T U
4 V W X Y Z
</code>```

Using the number of Os as the column, and number of As as the row, we find which character each section represents:

```<code>Section    | Num Os | Num As | Character

gogooa     | 2      | 1      | (2,1) -> H
gagooook   | 4      | 0      | (4,0) -> E
aagaaoooy  | 3      | 4      | (3,4) -> Y
</code>```

Which tells us that the baby was just saying "HEY".

Notes:

- If a section representing a character has more than 4 As or Os, ignore the extras, because 4 is the maximum value on the table.
- For this task, Y is not a vowel - only A, E, I, O and U.

The Challenge

Your task is to create a full program which takes one input, a word in baby-speak, and prints it in plaintext.

Your program must be able to take input in uppercase, lowercase, and a mix of both.

The input will only contain ASCII alphabet letters (A-Z and a-z), with single spaces to seperate the baby words.

The output text can be in any case.

You should the take the input from STDIN and print the plaintext on STDOUT. If your language does not have these, use the nearest equivalent.

This is code-golf, so the shortest code in bytes wins - but any solution is welcome.

Test Cases

```<code>'GLOOG KAKAAOOO ARGOOO OOOOOGUGUU' -> CODE
'oaka pooopaa gaau augu' -> GOLF
'Aoao U oOOAoa oaoAoo aoAoAOa' -> NAPPY
'GUG gAGaA gOougOou' -> ALE
'OOaGOG GoGOOoGoU gAA bLAA GOUGoOUgAIGAI' -> HELLO
</code>```

答:
PHP, 163 bytes

```<code><?php for(;$c=preg_replace('/(?<![AEIOU]).(?![AEIOU])/','',strtoupper($argv[++$i]));$j=min($d[79],4)+5*min($d[65],4),print range(A,Z)[$j+($j>8)])$d=count_chars($c);
</code>```

More readable version:

```<code><?php
for (
    ;
    $c = preg_replace(
        '/(?<![AEIOU]).(?![AEIOU])/',
        '',
        strtoupper($argv[++$i])
    );
    $j = min($d[79], 4) + 5 * min($d[65], 4),
    print range(A, Z)[$j + ($j > 8)]
)
    $d = count_chars($c);
</code>```

Tests:

```<code>$ php babytalk.php GLOOG KAKAAOOO ARGOOO OOOOOGUGUU
CODE
$ php babytalk.php oaka pooopaa gaau augu
GOLF
$ php babytalk.php Aoao U oOOAoa oaoAoo aoAoAOa
NAPPY
$ php babytalk.php GUG gAGaA gOougOou
ALE
$ php babytalk.php OOaGOG GoGOOoGoU gAA bLAA GOUGoOUgAIGAI
HELLO
</code>```

Title: Decode Baby-talk!

Body:
PHP, 163 bytes

<?php for(;$c=preg_replace('/(?<![AEIOU]).(?![AEIOU])/','',strtoupper($argv[++$i]));$j=min($d[79],4)+5*min($d[65],4),print range(A,Z)[$j+($j>8)])$d=count_chars($c);

More readable version:

<?php
for (
    ;
    $c = preg_replace(
        '/(?<![AEIOU]).(?![AEIOU])/',
        '',
        strtoupper($argv[++$i])
    );
    $j = min($d[79], 4) + 5 * min($d[65], 4),
    print range(A, Z)[$j + ($j > 8)]
)
    $d = count_chars($c);

Tests:

$ php babytalk.php GLOOG KAKAAOOO ARGOOO OOOOOGUGUU
CODE
$ php babytalk.php oaka pooopaa gaau augu
GOLF
$ php babytalk.php Aoao U oOOAoa oaoAoo aoAoAOa
NAPPY
$ php babytalk.php GUG gAGaA gOougOou
ALE
$ php babytalk.php OOaGOG GoGOOoGoU gAA bLAA GOUGoOUgAIGAI
HELLO


问:
Next Friday the 13th
What is the shortest program that can predict the next time Friday will fall on the 13th day of the month?

Must be an complete functioning program (not just a function/subroutine)

Must print out date in the following format: YYYY-MM-DD

Allow user to provide a start date either as a command line argument or through STDIN

If user provides no start date, use today as the start date.

If the start date is a Friday the 13th, the program should find the next Friday the 13th.

If I were to run the program today (Feb 16 2011) I should get the following output.

```<code>$ ./fr13th 2013-05-09
2013-09-13
$ ./fr13th 2007-06-29
2007-07-13
$ ./fr13th 2007-07-13
2008-06-13
$ ./fr13th
2011-05-13
</code>```

答:
Windows PowerShell, 74

```<code>for($d="date $args"|iex;($d+='1').day*$d.dayofweek-65){}'{0:yyy-MM-d}'-f$d
</code>```

Fairly straightforward. One perhaps confusing bit is the use of "Get-Date $args" | Invoke-Expression to get either the current date (if $args is empty) or the date specified in $args without raising an error.

72-byte variant:

```<code>for($d="date $args"|iex;($d+=9).day*$d.dayofweek-65){}'{0:yyy-MM-d}'-f$d
</code>```

Takes ages, though ... this doesn't increment the datetime by a whole day each iteration but instead only 900 nanoseconds. But two bytes shorter.

67-byte variant:

```<code>for($d="date $args"|iex;($d+='1').day*$d.dayofweek-65){}'{0:d}'-f$d
</code>```

This is a bit locale-sensitive; if it fails on your machine, try setting your date format to ISO-8601 beforehand. :-)

Oh, and it can be made into 65 bytes just like the 72-byte version.

History:

2011-02-17 00:33 (92) First attempt.

2011-02-17 00:35 (85) Improved getting an initial date.

2011-02-17 00:37 (79) Compared the product instead of day and day of week individually. Admittedly stolen from Ventero.

2011-02-17 00:40 (76) Pulled the first line into the for. Comparison just as subtraction instead of -eq which saves another two bytes.

2011-02-17 00:53 (75) Unix date format string is a bit shorter.

2011-02-17 11:42 (74) Reverted to the default date pattern but yyy-MM-d suffices (since the year is always longer than three characters and the day is always 13. Thanks to Ty Auvil for this.

ContentLicense: CC BY-SA 2.5

Title: Next Friday the 13th

Body:
Windows PowerShell, 74

for($d="date $args"|iex;($d+='1').day*$d.dayofweek-65){}'{0:yyy-MM-d}'-f$d

Fairly straightforward. One perhaps confusing bit is the use of "Get-Date $args" | Invoke-Expression to get either the current date (if $args is empty) or the date specified in $args without raising an error.

72-byte variant:

for($d="date $args"|iex;($d+=9).day*$d.dayofweek-65){}'{0:yyy-MM-d}'-f$d

Takes ages, though ... this doesn't increment the datetime by a whole day each iteration but instead only 900 nanoseconds. But two bytes shorter.

67-byte variant:

for($d="date $args"|iex;($d+='1').day*$d.dayofweek-65){}'{0:d}'-f$d

This is a bit locale-sensitive; if it fails on your machine, try setting your date format to ISO-8601 beforehand. :-)

Oh, and it can be made into 65 bytes just like the 72-byte version.

History:

2011-02-17 00:33 (92) First attempt.

2011-02-17 00:35 (85) Improved getting an initial date.

2011-02-17 00:37 (79) Compared the product instead of day and day of week individually. Admittedly stolen from Ventero.

2011-02-17 00:40 (76) Pulled the first line into the for. Comparison just as subtraction instead of -eq which saves another two bytes.

2011-02-17 00:53 (75) Unix date format string is a bit shorter.

2011-02-17 11:42 (74) Reverted to the default date pattern but yyy-MM-d suffices (since the year is always longer than three characters and the day is always 13. Thanks to Ty Auvil for this.


问:
Animate Adve the Adventurer

The challenge

Your task is to animate Adve the Adventurer moving through a creepy (i.e. Halloween) maze. Adve is a •; he's character fluid, though, so he does not mind being represented by a different character.

To animate Adve, you print out each frame; a frame is the map with his current location in it. Adve moves one space forward every turn and never backtracks. He starts in the first row and ends in the last.

Input

Any reasonable format like a string with a delimiter or string array. You can assume the input will be a map greater than 3*3, containing only one possible path. The only characters present will be # and .

Output

The frames.

Example maze (ok... labyrinth)

Here is a map without Adve in it; the first and last frames are this empty map (this map is 9x15):

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

This is code-golf, so shortest code in bytes wins!

The exact output for this can be found here (37 frames).

This is code-golf, so shortest code in bytes wins!

答:
Perl, 84 bytes

Thanks @Ton Hospel for guiding me to the right direction to golf out around 30 bytes!

Bytecount includes 82 bytes of code and -0p flags.

/.*/;say y/A/ /r;s/&(.{@{+}})? /A$1&/s||s/ (.{@{+}})?&/&$1A/s||s/ /&/?redo:y;A&;
```
<p>Note that there are two final spaces, and no final newline (it won't work otherwise).</p>
<p>Takes the maze as input as outputs all the needed frames for Adve to get out of it. Note that Adve is a <code>&</code> rather than a <code>•</code>, since the latter isn't utf8 (and perl doesn't use utf8 by default). Run it with <code>-0pE</code> flags :</p>
```perl -0pE '/.*/;say y/A/ /r;s/&(.{@{+}})? /A$1&/s||s/ (.{@{+}})?&/&$1A/s||s/ /&/?redo:y;A&;  ' <<< "### #####
##  #####
## ######
##      #
####### #
#   ### #
# # #   #
# #   ###
# #######
#    ####
#### ####
####  ###
##### ###
##### ###"
```
<hr>
<p><em>Just for the eyes</em>, I also made this animated version, that is a little bit longer, but will clear the terminal between each print and sleep 0.15 sec, so it will look like Adve is actually moving :</p>
```perl -0nE 'system(clear);/.*/;say y/A/ /r;select($,,$,,$,,0.15);s/&(.{@{+}})? /A$1&/s||s/ (.{@{+}})?&/&$1A/s||s/ /&/?redo:say"\e[H",y/A&/  /r' <<< "### #####
##  #####
## ######
##      #
####### #
#   ### #
# # #   #
# #   ###
# #######
#    ####
#### ####
####  ###
##### ###
##### ###"
```

Title: Animate Adve the Adventurer

Body:
Perl, 84 bytes

Thanks @Ton Hospel for guiding me to the right direction to golf out around 30 bytes!

Bytecount includes 82 bytes of code and -0p flags.

/.*/;say y/A/ /r;s/&(.{@{+}})? /A$1&/s||s/ (.{@{+}})?&/&$1A/s||s/ /&/?redo:y;A&;

Note that there are two final spaces, and no final newline (it won't work otherwise).

Takes the maze as input as outputs all the needed frames for Adve to get out of it. Note that Adve is a & rather than a •, since the latter isn't utf8 (and perl doesn't use utf8 by default). Run it with -0pE flags :

perl -0pE '/.*/;say y/A/ /r;s/&(.{@{+}})? /A$1&/s||s/ (.{@{+}})?&/&$1A/s||s/ /&/?redo:y;A&;  ' <<< "### #####
##  #####
## ######
##      #
####### #
#   ### #
# # #   #
# #   ###
# #######
#    ####
#### ####
####  ###
##### ###
##### ###"

Just for the eyes, I also made this animated version, that is a little bit longer, but will clear the terminal between each print and sleep 0.15 sec, so it will look like Adve is actually moving :

perl -0nE 'system(clear);/.*/;say y/A/ /r;select($,,$,,$,,0.15);s/&(.{@{+}})? /A$1&/s||s/ (.{@{+}})?&/&$1A/s||s/ /&/?redo:say"\e[H",y/A&/  /r' <<< "### #####
##  #####
## ######
##      #
####### #
#   ### #
# # #   #
# #   ###
# #######
#    ####
#### ####
####  ###
##### ###
##### ###"


Title: Produce Dürer's magic square

Body:
The challenge

Output an array or string representation of Dürer's famous magic square:

that is,

```<code>16  3  2 13
 5 10 11  8
 9  6  7 12
 4 15 14  1
</code>```

Some properties of this square, which can perhaps be exploited, are:

It contains each integer from 1 to 16 exactly once

The sum of each column or row, as well as the the sum of each of the two diagonals, is the same. This is the defining property of a magic square. The sum is the magic constant of the square.

In addition, for this particular square, the sum of each of the four quadrants also equals the magic constant, as do the sum of the center four squares and the sum of the corner four squares.

Rules

Bultins that generate magic squares are not allowed (such as Matlab's magic or Mathematica's MagicSquare). Any other builtin can be used.

The code can be a program or a function.

There is no input.

The numbers must be in base 10. The output format is flexible as usual. Some possibilities are:

A nested array (either function output, or its string representation, with or without separators, any type of matching brackets):

```<code>[[16, 3, 2, 13], [5, 10, 11, 8], [9, 6, 7, 12], [4, 15, 14, 1]]
</code>```

A 2D array:

```<code>{16, 3, 2, 13; 5, 10, 11, 8; 9, 6, 7, 12; 4, 15, 14, 1}
</code>```

An array of four strings, or a string consisting of four lines. The numbers may be right-aligned

```<code>16  3  2 13
 5 10 11  8
 9  6  7 12
 4 15 14  1
</code>```

or left-aligned

```<code>16 3  2  13
5  10 11  8
9  6  7  12
4  15 14  1
</code>```

A string with two different separators for row and column, such as

```<code>16,3,2,13|5,10,11,8|9,6,7,12|4,15,14,1
</code>```

The output format should clearly differentiate rows and columns. For example, it is not allowed to output a flat array, or a string with all numbers separated by spaces.

Code golf. Shortest wins.

Body:
Groovy, 57 bytes / 46 bytes

"F21C49A7856B3ED0".collect{Eval.me("0x$it")+1}.collate(4)

Parse each as hexidecimal digit and add 1, collate by 4 into a 2D array.

[[16, 3, 2, 13], [5, 10, 11, 8], [9, 6, 7, 12], [4, 15, 14, 1]]

Shorter, but also lamer:

print '16,3,2,13|5,10,11,8|9,6,7,12|4,15,14,1'


答:
05AB1E, 4 bytes

```<code>lêAå
</code>```

Try it online!

```<code>l    # Push lowercase input.
 ê   # Push sorted, uniquified lowercase input.
  A  # Push lowercase alphabet.
   å # Is lowercase alphabet in sorted, uniquified, lowercase input?
     # True if panagram, false if not.
</code>```

Title: Is it a pangram?

Body:
Write a function or program that takes as its input a string and prints a truthy value if the string is a pangram (a sequence of letters containing at least one of each letter in the English alphabet) and a falsey value otherwise.

Case of letters should be ignored; If the string is abcdefghijklmnopqrstuvwXYZ, then the function should still return a truthy value. Note that the string can contain any other characters in it, so 123abcdefghijklm NOPQRSTUVWXYZ321 would return a truthy value. An empty input should return a falsey value.

Test cases

```<code>AbCdEfGhIjKlMnOpQrStUvWxYz

==> True

ACEGIKMOQSUWY
BDFHJLNPRTVXZ

==> True

public static void main(String[] args)

==> False

The quick brown fox jumped over the lazy dogs. BOING BOING BOING

==> True
</code>```

This is code golf. Standard rules apply. Shortest code in bytes wins.

Body:
05AB1E, 4 bytes

lêAå

Try it online!

l    # Push lowercase input.
 ê   # Push sorted, uniquified lowercase input.
  A  # Push lowercase alphabet.
   å # Is lowercase alphabet in sorted, uniquified, lowercase input?
     # True if panagram, false if not.


答:
Groovy, 90 Bytes

```<code>{s,n->(s.padRight((int)(s.size()/n+1)*n) as List).collate(n).transpose().flatten().join()}
</code>```

Pad the input by the ceiling of the size divided into n chunks.

Get the padded string as a list of characters.

Collate into n chunks and transpose.

```<code>({s,n->(s.padRight((int)(s.size()/n+1)*n) as List).collate(n).transpose().flatten().join()})("Programming Puzzles and Code Golf SE",5)
</code>```

Results in:

```<code>PagzaooErm lndl omPedef gius    rnz CGS
</code>```

Title: Encode the column cipher

Body:
Given a string to encode, and a number of columns (the key), encode the string as follows:

I will be using the example Hello, world! and the key 3

First, write out the number of columns:

```<code>1 2 3
</code>```

Next, write the text starting from the upper left, one character per column, and when you run out of columns, go to the next line.

```<code>1 2 3
H e l
l o ,
  w o
r l d
!
</code>```

Now, to get your encoded text, read the text starting from the top left corner, but this time, first read one column, and then the next, and so on. If there is not a character in the slot, put a space.

```<code>Hl r!eowl l,od
</code>```

Note that here, there is a trailing space.

This is your encoded text.

Another test case is Programming Puzzles and Code Golf SE with key 5:

```<code>1 2 3 4 5
P r o g r
a m m i n
g   P u z
z l e s
a n d   C
o d e   G
o l f   S
E
</code>```

The encoded text is PagzaooErm lndl omPedef gius    rnz CGS.

More test cases

```<code>"abcdefghijklmnopqrstuvwxyz", 2 -> "acegikmoqsuwybdfhjlnprtvxz"
"codegolf.stackexchange.com", 4 -> "cg.ccgoooskhemdltea. efaxnc "
"Pen Pineapple Apple Pen!!!", 7 -> "PeAeeapnnpp! pl!Ple!ie  n P "
"1,1,2,3,5,8,13,21,34,55,89", 10 -> "18,,,5115,3,2,8,2931 ,, 53 ,4 "
</code>```

Remember, this is code-golf, so the code with the fewest bytes wins.

Body:
Groovy, 90 Bytes

{s,n->(s.padRight((int)(s.size()/n+1)*n) as List).collate(n).transpose().flatten().join()}

Pad the input by the ceiling of the size divided into n chunks.

Get the padded string as a list of characters.

Collate into n chunks and transpose.

({s,n->(s.padRight((int)(s.size()/n+1)*n) as List).collate(n).transpose().flatten().join()})("Programming Puzzles and Code Golf SE",5)

Results in:

PagzaooErm lndl omPedef gius    rnz CGS


问:
Trick or Treat polyglot
Since Halloween is coming up I thought I might start a fun little code golf challenge!

The challenge is quite simple. You have to write a program that outputs either trick or treat.

"The twist?" you may ask. Well let me explain:

Your program has to do the following:

Be compilable/runnable in two different languages. Different versions of the same language don't count.

When you run the program in one language it should output trick and the other should output treat. The case is irrelevant and padding the string with whitespace characters are allowed (see examples).

This is code-golf,  so the solution with the fewest bytes wins.

A few explanations:

Valid outputs (Just for the words not for running the code in the two languages. Also adding quotes to signalize the beginning or end of the output. Do not include them in your solution!):

```<code>"trick"

"Treat"

"    TReAt"

"
     tRICk          "
</code>```

Invalid outputs:

```<code>"tri ck"

"tr
eat"

"trck"
</code>```

I'm interested to see what you can come up with! Happy Golfing!

I'd like to note that this is my first challenge so if you have suggestions on this question please leave them in the form of a comment.

Leaderboards

Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.

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

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

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

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

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

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

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

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

var QUESTION_ID=97472,OVERRIDE_USER=23417;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,TAGS_REG = /(<([^>]+)>)/ig;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;width:400px;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

```

答:
Perl / Ruby : 41 bytes

```<code>#line 9
print __LINE__==2?"treat":"trick"
</code>```

Lines beginning with # are comments in both Ruby and Perl. Except that lines following (roughly) the regex #\s*line\s+\d+ are executed by Perl's compiler and change the line number as the compiler sees it (see the doc : Plain Old Comments (Not!)).

So when arriving to the second line, Perl thinks it the 9th while Ruby thinks it's the second. Hence Ruby will print treat while Perl will print trick.

Title: Trick or Treat polyglot

Body:
Perl / Ruby : 41 bytes

#line 9
print __LINE__==2?"treat":"trick"

Lines beginning with # are comments in both Ruby and Perl. Except that lines following (roughly) the regex #\s*line\s+\d+ are executed by Perl's compiler and change the line number as the compiler sees it (see the doc : Plain Old Comments (Not!)).

So when arriving to the second line, Perl thinks it the 9th while Ruby thinks it's the second. Hence Ruby will print treat while Perl will print trick.


问:
Positional Bathroom Etiquette

Background

Bathroom Etiquette, when pertaining to the available urinals, states that the next urinal to be filled in should be the one that minimizes the total discomfort. The total discomfort equation is given by the following set of equations:

```
<b>dist(x,y)</b> = linear distance between person x and person y in Urinal Units
<b>discomfort(x)</b> = sum(1/(dist(x,y)*dist(x,y))) for all persons y excluding person x
<b>total_Discomfort</b> = sum(discomfort(x)) for all x
```

A more in depth paper dealing with a similar (not the exact same) problem can be found here: (Thanks to @Lembik for alerting me to this amazing whitepaper!)

Input/Output

Given an input of a empty and full urinals, output the resulting set of urinals with the addition of one person. If there is a tie for a position the urinals should fill in left to right. The output should be in the same format as the input.

If given a case with full urinals, return the input.

The input will always have at least one urinal defined.

Test Cases

```
<b>INPUT     -> OUTPUT</b>
1000001   -> 1001001
101010101 -> 111010101
100       -> 101
00000     -> 10000
1111111   -> 1111111
0100      -> 0101
101000    -> 101001
```

Rules

This is code-golf, so shortest code in bytes wins. Standard loop-holes are forbidden.

答:
R, <s>83</s> <s>76</s> 67 bytes

Just realized that I can save several bytes by not bothering to check if the candidate urinals are empty. Non-empty urinals will always return an Inf discomfort value, so they're excluded in the course of the calculation. Also, just using direct indexing rather than replace, so it's shorter but less elegant.

```<code>x=scan()
x[which.min(rowSums(outer(seq(x),which(!!x),`-`)^-2))]=1
x
</code>```

Explanation

```<code>x=scan()
</code>```

We read the current state from stdin and call it x. We assume that the input is a sequence of 1s and 0s separated by spaces or newlines. For the purposes of the explanation, let's say we input 1 0 0 0 0 0 1.

```<code>x[which.min(rowSums(outer(seq(x),which(!!x),`-`)^-2))]=1
</code>```

We replace a value of x at a particular index with 1. Everything between the [ ] is figuring out what the best index is.

Since the existing urinals are immutable, we don't need to consider the distances between them. We only need to consider the distances between the occupied urinals and the possible new one. So we determine the indices of the occupied urinals. We use which, a function to return the indices of a logical vector which are TRUE. All numbers in R, when coerced to type logical, are TRUE if nonzero and FALSE if zero. Simply doing which(x) will result in a type error, argument to 'which' is not logical, as x is a numeric vector. We therefore have to coerce it to logical. ! is R's logical negation function, which automatically coerces to logical. Applying it twice, !!x, yields a vector of TRUE and FALSE indicating which urinals are occupied. (Alternative byte-equivalent coercions to logical involve the logical operators & and | and the builtins T and F, e.g. F|x or T&x and so on. !!x looks more exclamatory so we'll use that.)

```<code>                                 which(!!x)
</code>```

This is paired with seq(x), which returns the integer sequence from 1 to the length of x, i.e. all urinal locations (and thus all possible locations to consider).

```<code>                          seq(x)
</code>```

Now we have the indices of our occupied urinals: 1 7 and our empty urinals 1 2 3 4 5 6 7. We pass `-`, the subtraction function, to the outer function to get the "outer subtraction", which is the following matrix of distances between all urinals and the occupied urinals:

[,1] [,2]

[1,]    0   -6

[2,]    1   -5

[3,]    2   -4

[4,]    3   -3

[5,]    4   -2

[6,]    5   -1

[7,]    6    0

```<code>                    outer(seq(x),which(!!x),`-`)
</code>```

We raise this to the -2th power. (For those who are a little lost, in the OP, "discomfort" is defined as 1 / (distance(x, y) * distance(x, y)), which simplifies to 1/d(x,y)^2, i.e. d(x,y)^-2.)

```<code>                    outer(seq(x),which(!!x),`-`)^-2
</code>```

Take the sum of each row in the matrix.

```<code>            rowSums(outer(seq(x),which(!!x),`-`)^-2)
</code>```

Get the index of the smallest value, i.e. the optimal urinal. In the case of multiple smallest values, the first (i.e. leftmost) one is returned.

```<code>  which.min(rowSums(outer(seq(x),which(!!x),`-`)^-2))
</code>```

And voilà, we have the index of the optimal urinal. We replace the value at this index in x with 1. In the case of 1111 as input, it doesn't matter which one we replace, we'll still have a valid output.

```<code>x[which.min(rowSums(outer(seq(x),which(!!x),`-`)^-2))]=1
</code>```

Return the modified input.

```<code>x
</code>```

Title: Positional Bathroom Etiquette

Body:
R, <s>83</s> <s>76</s> 67 bytes

Just realized that I can save several bytes by not bothering to check if the candidate urinals are empty. Non-empty urinals will always return an Inf discomfort value, so they're excluded in the course of the calculation. Also, just using direct indexing rather than replace, so it's shorter but less elegant.

x=scan()
x[which.min(rowSums(outer(seq(x),which(!!x),`-`)^-2))]=1
x

Explanation

x=scan()

We read the current state from stdin and call it x. We assume that the input is a sequence of 1s and 0s separated by spaces or newlines. For the purposes of the explanation, let's say we input 1 0 0 0 0 0 1.

x[which.min(rowSums(outer(seq(x),which(!!x),`-`)^-2))]=1

We replace a value of x at a particular index with 1. Everything between the [ ] is figuring out what the best index is.

Since the existing urinals are immutable, we don't need to consider the distances between them. We only need to consider the distances between the occupied urinals and the possible new one. So we determine the indices of the occupied urinals. We use which, a function to return the indices of a logical vector which are TRUE. All numbers in R, when coerced to type logical, are TRUE if nonzero and FALSE if zero. Simply doing which(x) will result in a type error, argument to 'which' is not logical, as x is a numeric vector. We therefore have to coerce it to logical. ! is R's logical negation function, which automatically coerces to logical. Applying it twice, !!x, yields a vector of TRUE and FALSE indicating which urinals are occupied. (Alternative byte-equivalent coercions to logical involve the logical operators & and | and the builtins T and F, e.g. F|x or T&x and so on. !!x looks more exclamatory so we'll use that.)

                                 which(!!x)

This is paired with seq(x), which returns the integer sequence from 1 to the length of x, i.e. all urinal locations (and thus all possible locations to consider).

                          seq(x)

Now we have the indices of our occupied urinals: 1 7 and our empty urinals 1 2 3 4 5 6 7. We pass `-`, the subtraction function, to the outer function to get the "outer subtraction", which is the following matrix of distances between all urinals and the occupied urinals:

[,1] [,2]

[1,]    0   -6

[2,]    1   -5

[3,]    2   -4

[4,]    3   -3

[5,]    4   -2

[6,]    5   -1

[7,]    6    0

                    outer(seq(x),which(!!x),`-`)

We raise this to the -2th power. (For those who are a little lost, in the OP, "discomfort" is defined as 1 / (distance(x, y) * distance(x, y)), which simplifies to 1/d(x,y)^2, i.e. d(x,y)^-2.)

                    outer(seq(x),which(!!x),`-`)^-2

Take the sum of each row in the matrix.

            rowSums(outer(seq(x),which(!!x),`-`)^-2)

Get the index of the smallest value, i.e. the optimal urinal. In the case of multiple smallest values, the first (i.e. leftmost) one is returned.

  which.min(rowSums(outer(seq(x),which(!!x),`-`)^-2))

And voilà, we have the index of the optimal urinal. We replace the value at this index in x with 1. In the case of 1111 as input, it doesn't matter which one we replace, we'll still have a valid output.

x[which.min(rowSums(outer(seq(x),which(!!x),`-`)^-2))]=1

Return the modified input.

x


Title: Visualize an Array

Body:
PHP, 404 Bytes

All solutions works with maximum depth of the array lesser then 10.
for greater values the depth must store in an array and not in a string.

<?foreach(str_split(json_encode($_GET[a]))as$j){$j!="]"?:$c--;$r=($j==",")?($l=="]"?"":" "):$j;$r=$r=="]"?"|":$r;$r=$r=="["?($v=="]"?"":"|"):$r;if($r!=""){$n.=$r;$d.=+$c;}$v=$l;$l=$j;$j!="["?:$c++;$m>=$c?:$m=$c;}for($x=0;$x<strlen($n);$x++)for($y=0;$y<$m;$y++)$z[$y].=$y==$d[$x]&&$n[$x]=="|"?"+":($y<$d[$x]?"-":($y>$d[$x]&&$n[$x]=="|"?"|":" "));echo join("\n",$z),"\n$n\n".(join("\n",array_reverse($z)));

Expanded

foreach(str_split(json_encode($_GET[a]))as$j){ # split JSON representation of the array
    $j!="]"?:$c--;
    $r=($j==",")?($l=="]"?"":" "):$j;
    $r=$r=="]"?"|":$r;
    $r=$r=="["?($v=="]"?"":"|"):$r;
    if($r!=""){
      $n.=$r;  # concanate middle string
      $d.=+$c; # concanate depth position
    }
    $v=$l;
    $l=$j;
    $j!="["?:$c++;
    $m>=$c?:$m=$c; # maximum depth of the array
}
for($x=0;$x<strlen($n);$x++)for($y=0;$y<$m;$y++)
$z[$y].=$y==$d[$x]&&$n[$x]=="|"?"+":($y<$d[$x]?"-":($y>$d[$x]&&$n[$x]=="|"?"|":" "));
# Build the strings before the middle string dependent of value middle string and depth
echo join("\n",$z),"\n$n\n".(join("\n",array_reverse($z))); #Output

for 425 Bytes we can make this with REGEX

<?$n=($p=preg_filter)("#\]|\[#","|",$r=$p("#\],\[#","|",$p("#,(\d)#"," $1",json_encode($_GET[a]))));preg_match_all("#.#",$r,$e,256);foreach($e[0] as$f){$f[0]!="]"&&$f[0]!="|"?:$c--;$d.=+$c;$f[0]!="|"&&$f[0]!="["?:$c++;$m>=$c?:$m=$c;}for($x=0;$x<strlen($n);$x++)for($y=0;$y<$m;$y++)$z[$y].=$y==$d[$x]&&$n[$x]=="|"?"+":($y<$d[$x]?"-":($y>$d[$x]&&$n[$x]=="|"?"|":" "));echo join("\n",$z),"\n$n\n".(join("\n",array_reverse($z)));

Expanded

$r=preg_filter("#\],\[#","|",preg_filter("#,(\d)#"," $1",json_encode($_GET[a])));
preg_match_all("#.#",$r,$e,256);
$n=preg_filter("#\]|\[#","|",$r); # concanate middle string
foreach($e[0] as$f){
    $f[0]!="]"&&$f[0]!="|"?:$c--;
    $d.=+$c; concanate depth position
    $f[0]!="|"&&$f[0]!="["?:$c++;
    $m>=$c?:$m=$c; # maximum depth of the array
}
# similar to the other ways
for($x=0;$x<strlen($n);$x++)
for($y=0;$y<$m;$y++)
$z[$y].=$y==$d[$x]&&$n[$x]=="|"?"+":($y<$d[$x]?"-":($y>$d[$x]&&$n[$x]=="|"?"|":" "));
echo join("\n",$z),"\n$n\n".(join("\n",array_reverse($z)));

455 Bytes for a recursive solution

<?function v($x,$t=0,$l=1){global$d;$d.=$t;$s="|";$c=count($x);foreach($x as$k=>$v){if(is_array($v))$e=v($v,$t+1,$k+1==$c);else{$e=$v." "[$k+1==$c];$d.=str_pad("",strlen($e),$t+1);}$s.=$e;}$d.=$l?$t:"";$s.=$l?"|":"";return$s;}$n=v($_GET[a]);$m=max(str_split($d));for($x=0;$x<strlen($n);$x++)for($y=0;$y<$m;$y++)$z[$y].=$y==$d[$x]&&$n[$x]=="|"?"+":($y<$d[$x]?"-":($y>$d[$x]&&$n[$x]=="|"?"|":" "));echo join("\n",$z),"\n$n\n".(join("\n",array_reverse($z)));

Expanded

function v($x,$t=0,$l=1){
    global$d; # concanate depth position
    $d.=$t;
    $s="|";
    $c=count($x);
    foreach($x as$k=>$v){
        if(is_array($v)){$e=v($v,$t+1,$k+1==$c);}
        else{$e=$v." "[$k+1==$c];$d.=str_pad("",strlen($e),$t+1);}
        $s.=$e;
    }
    $d.=$l?$t:"";
    $s.=$l?"|":"";
    return$s;
}
$n=v($_GET[a]); # concanate middle string
$m=max(str_split($d)); # maximum depth of the array
# similar to the other ways
for($x=0;$x<strlen($n);$x++)
for($y=0;$y<$m;$y++)
$z[$y].=$y==$d[$x]&&$n[$x]=="|"?"+":($y<$d[$x]?"-":($y>$d[$x]&&$n[$x]=="|"?"|":" "));
echo join("\n",$z),"\n$n\n".(join("\n",array_reverse($z)));


答:
Java 8, <s>272</s> <s>266</s> <s>251</s> 249 bytes

```<code>interface M{static void main(String[]i){String z="(?=[AEIOU])|(?<=[AEIOU])";for(String s:i[0].split(" ")){int a=s.split("(?i)A"+z+"A",-1).length-1,o=s.split("(?i)O"+z+"O",-1).length-1,t=(a>4?4:a)*5+(o>4?4:o);System.out.printf("%c",t>9?t+66:t+65);}}}
</code>```

-6 bytes thanks to @Joba.

-1 byte converting from Java 7 to 8, and <s>14</s> 16 additional bytes saved by changing the print-part.

Explanation:

Try it here.

```<code>interface M{                   // Class:
  static void main(String[]i){ //  Main method:
    String z="(?=[AEIOU])|(?<=[AEIOU])";
                               //   Regex-part for look-ahead or look-behind of vowels
    for(String s:i[0].split(" ")){
                               //    Loop over the program-arguments
      int a=s.split("(?i)A"+z+"A",-1).length-1,
                               //     The amount of A's with adjacent vowels
          o=s.split("(?i)O"+z+"O",-1).length-1,
                               //     The amount of O's with adjacent vowels
          t=(a>4?4:a)          //     If `a` is larger than 4, just take 4, else take `a`
            *5                 //     Multiply it by 5
            +(o>4?4:o);        //     And add 4 if `o` is larger than 4, else take `o`
       System.out.printf("%c", //     Print a character:
        t>9?                   //      If `t` is larger than 9 (index of J)
         t+66                  //       Take character unicode (skipping J)
        :                      //      Else:
         t+65);                //       Take character unicode (prior to J)
    }                          //   End of loop
  }                            //  End of main-method
}                              // End of program
</code>```

Title: Decode Baby-talk!

Body:
When babies open their mouths, they're not just spewing gibberish. They're actually talking in a highly advanced, adult-proof cipher...

The Baby-talk Cipher

When a baby talks, it could look something like gogooa gagooook aagaaoooy
Each single-space separated section represents a character (so the example above represents 3 characters).

To decipher a section, we must count number of As and Os it contains. However, we only count those which are adjacent to another vowel. For example, the A in 'gag' would not count, but both the A and O in 'gaog' would.

Counting the example above would look like this:

```<code>Section    | Num Os | Num As

gogooa     | 2      | 1
gagooook   | 4      | 0
aagaaoooy  | 3      | 4
</code>```

We then use these values to convert the input into plaintext on a Polybius square. This is a 5x5 representation of the English alphabet, omitting 'J' (please note that, in baby-talk, 0-counting rules apply to the table):

```<code>  0 1 2 3 4
0 A B C D E
1 F G H I K
2 L M N O P
3 Q R S T U
4 V W X Y Z
</code>```

Using the number of Os as the column, and number of As as the row, we find which character each section represents:

```<code>Section    | Num Os | Num As | Character

gogooa     | 2      | 1      | (2,1) -> H
gagooook   | 4      | 0      | (4,0) -> E
aagaaoooy  | 3      | 4      | (3,4) -> Y
</code>```

Which tells us that the baby was just saying "HEY".

Notes:

- If a section representing a character has more than 4 As or Os, ignore the extras, because 4 is the maximum value on the table.
- For this task, Y is not a vowel - only A, E, I, O and U.

The Challenge

Your task is to create a full program which takes one input, a word in baby-speak, and prints it in plaintext.

Your program must be able to take input in uppercase, lowercase, and a mix of both.

The input will only contain ASCII alphabet letters (A-Z and a-z), with single spaces to seperate the baby words.

The output text can be in any case.

You should the take the input from STDIN and print the plaintext on STDOUT. If your language does not have these, use the nearest equivalent.

This is code-golf, so the shortest code in bytes wins - but any solution is welcome.

Test Cases

```<code>'GLOOG KAKAAOOO ARGOOO OOOOOGUGUU' -> CODE
'oaka pooopaa gaau augu' -> GOLF
'Aoao U oOOAoa oaoAoo aoAoAOa' -> NAPPY
'GUG gAGaA gOougOou' -> ALE
'OOaGOG GoGOOoGoU gAA bLAA GOUGoOUgAIGAI' -> HELLO
</code>```

Body:
Java 8, <s>272</s> <s>266</s> <s>251</s> 249 bytes

interface M{static void main(String[]i){String z="(?=[AEIOU])|(?<=[AEIOU])";for(String s:i[0].split(" ")){int a=s.split("(?i)A"+z+"A",-1).length-1,o=s.split("(?i)O"+z+"O",-1).length-1,t=(a>4?4:a)*5+(o>4?4:o);System.out.printf("%c",t>9?t+66:t+65);}}}

-6 bytes thanks to @Joba.

-1 byte converting from Java 7 to 8, and <s>14</s> 16 additional bytes saved by changing the print-part.

Explanation:

<a href="https://tio.run/##jY9NaxsxEIbv@hWDoLDyVxpIArXrLDoUYZIy0LCHYHyYbuSNkuzOstIGEte/fTN220BzqkDvzOh9RiM90DNNufXNw93jMIQm@W5LpYfvu5gohRKeOdxBTaHJblIXmmq9CWb3O4XXpc7y5dp@W2GxMb@y/Ot7oRdb7v60QJyH9efNLLZPIWUatDE7mQS0jH/PsjwYq8evY231ZHpqZk@@qdL99HTC/0J4hPADlJYZXZ7lZ3Myo/NxxseczeLmJSZfz7hPs1ZekraZ/lTqSbr8kqfxxcVc5Nws9vv9cDJS6pZ7KKmBktuXaUvSCuneA4t0kHxM4kYfYdtxLU6IQta1l58kPpLUVf17LfxcKXeN6ODKXlmLiGB/uEPAw3KFKwrF9EjQMnNLBBVRD9RXvbJMDAUwomQghWWGg1okJZ1QWUcWKuT@sBUiORnkWO5nx4X4Fn5eizgsHGNR2ZWzK6VGJ8Pwn/Ab" rel="nofollow noreferrer">Try it here.

interface M{                   // Class:
  static void main(String[]i){ //  Main method:
    String z="(?=[AEIOU])|(?<=[AEIOU])";
                               //   Regex-part for look-ahead or look-behind of vowels
    for(String s:i[0].split(" ")){
                               //    Loop over the program-arguments
      int a=s.split("(?i)A"+z+"A",-1).length-1,
                               //     The amount of A's with adjacent vowels
          o=s.split("(?i)O"+z+"O",-1).length-1,
                               //     The amount of O's with adjacent vowels
          t=(a>4?4:a)          //     If `a` is larger than 4, just take 4, else take `a`
            *5                 //     Multiply it by 5
            +(o>4?4:o);        //     And add 4 if `o` is larger than 4, else take `o`
       System.out.printf("%c", //     Print a character:
        t>9?                   //      If `t` is larger than 9 (index of J)
         t+66                  //       Take character unicode (skipping J)
        :                      //      Else:
         t+65);                //       Take character unicode (prior to J)
    }                          //   End of loop
  }                            //  End of main-method
}                              // End of program


答:
PowerShell v2+, 40 bytes

```<code>'16,3,2,13
5,10,11,8
9,6,7,12
4,15,14,1'
</code>```

A literal multiline string, left on the pipeline. Output via implicit Write-Output happens at program completion. Nice and boring.

Constructed version, 77 bytes

```<code>'f21c59a7856b3dc0'-split'(....)'-ne''|%{([char[]]$_|%{"0x$_+1"|iex})-join','}
</code>```

Takes the string, -splits it every four elements, loops on them, changes each to a hex 0x$_ and adds 1, pipes that to iex (short for Invoke-Expression and similar to eval), then -joins the result into a string with , as the separator. Outputs four strings onto the pipeline, with implicit printing.

Title: Produce Dürer's magic square

Body:
PowerShell v2+, 40 bytes

'16,3,2,13
5,10,11,8
9,6,7,12
4,15,14,1'

A literal multiline string, left on the pipeline. Output via implicit Write-Output happens at program completion. Nice and boring.

Constructed version, 77 bytes

'f21c59a7856b3dc0'-split'(....)'-ne''|%{([char[]]$_|%{"0x$_+1"|iex})-join','}

Takes the string, -splits it every four elements, loops on them, changes each to a hex 0x$_ and adds 1, pipes that to iex (short for Invoke-Expression and similar to eval), then -joins the result into a string with , as the separator. Outputs four strings onto the pipeline, with implicit printing.


答:
Rust, 64 bytes

```<code>|s:&str|(65u8..91).all(|c|s.to_uppercase().contains(c as char))
</code>```

You can take a range over chars in Rust,

```<code>'a'..'{'
</code>```

but it's presently useless since you can't iterate over it or collect it or do anything with it. They say arithmetic with characters doesn't make sense, so they won't implement the Add and One traits for it.

Still, lambdas and iterators and type inference keeps it reasonably small.

Title: Is it a pangram?

Body:
Rust, 64 bytes

|s:&str|(65u8..91).all(|c|s.to_uppercase().contains(c as char))

You can take a range over chars in Rust,

'a'..'{'

but it's presently useless since you can't iterate over it or collect it or do anything with it. They say arithmetic with characters doesn't make sense, so they won't implement the Add and One traits for it.

Still, lambdas and iterators and type inference keeps it reasonably small.


答:
Perl, 82 bytes

Includes +1 for -a

Give input on STDIN:

```<code>perl -M5.010 baby.pl <<< "OOaGOG GoGOOoGoU gAA bLAA GOUGoOUgAIGAI"
</code>```

baby.pl:

```<code>#!/usr/bin/perl -a
say map{$A=$O=$_=uc;y/AEIOU/@/c;s/(\B.|.\B)/$$1+=$$1<4/eg;(A..I,K..Z)[5*$A+$O]}@F
</code>```

This assumes a recent enough perl version where -a implies -n. If your perl is too old you will need to add an explicit -n option.

It also assumes babies can't say general ASCII strings that start with digits like 1 this will not work

Title: Decode Baby-talk!

Body:
Perl, 82 bytes

Includes +1 for -a

Give input on STDIN:

perl -M5.010 baby.pl <<< "OOaGOG GoGOOoGoU gAA bLAA GOUGoOUgAIGAI"

baby.pl:

#!/usr/bin/perl -a
say map{$A=$O=$_=uc;y/AEIOU/@/c;s/(\B.|.\B)/$$1+=$$1<4/eg;(A..I,K..Z)[5*$A+$O]}@F

This assumes a recent enough perl version where -a implies -n. If your perl is too old you will need to add an explicit -n option.

It also assumes babies can't say general ASCII strings that start with digits like 1 this will not work


答:
JavaScript (ES6), 145 bytes

```<code>alert(prompt().replace(/\S+ ?/g,x=>(g=r=>(q=(x.match(/[aeiou]{2,}/gi)+"").split(r).length-1)>4?4:q,(g(/a/i)*5+g(/o/i)+10)*20/19|0).toString(36)))
</code>```

Replaces each word (and the following space) with its corresponding letter.

s.split` `.map().join`` is 3 bytes longer:

```<code>alert(prompt().split` `.map(x=>(g=r=>(q=(x.match(/[aeiou]{2,}/gi)+"").split(r).length-1)>4?4:q,(g(/a/i)*5+g(/o/i)+10)*20/19|0).toString(36)).join``)
</code>```

Title: Decode Baby-talk!

Body:
JavaScript (ES6), 145 bytes

alert(prompt().replace(/\S+ ?/g,x=>(g=r=>(q=(x.match(/[aeiou]{2,}/gi)+"").split(r).length-1)>4?4:q,(g(/a/i)*5+g(/o/i)+10)*20/19|0).toString(36)))

Replaces each word (and the following space) with its corresponding letter.

s.split` `.map().join`` is 3 bytes longer:

alert(prompt().split` `.map(x=>(g=r=>(q=(x.match(/[aeiou]{2,}/gi)+"").split(r).length-1)>4?4:q,(g(/a/i)*5+g(/o/i)+10)*20/19|0).toString(36)).join``)