问:
Export The $PATH Variable, Line-By-Line
Inspired by this question on AskUbuntu.

Your job is extremely simple. Take the PATH environment variable (echo $PATH) and export it such that each entry (separated by the : character) is on its own line.

For example, if the PATH is /bin:/usr/bin:/usr/local/bin, your program should output:

```<code>/bin
/usr/bin
/usr/local/bin
</code>```

Your program may not return a leading newline, but it may return a single trailing newline. You do not need to check if the PATH is right, or that the directory exists. Your program should take no input, meaning that your program is responsible for getting the PATH itself. You may safely assume that objects in the PATH do not contain : or newlines. However, spaces are fair game.

Reference implementations are present in the answers to the question above.

Rules

This is (obviously) code-golf, so the shortest answer will win the prized green checkmark.

The accepted answer will be tested to make sure it's actually legit.

Both Windows and *nix entries are accepted.

However, if you don't explicitly specify Windows, I will try running it in Linux and fail. (If it's obvious (hi, Batch!), you don't need to specify explicitly.)

Only have one solution per answer. If you have both a Windows and *nix version, I will count the shorter one.

If two answers have the same length, I will give priority to the one with the higher vote total. If they have the same vote total, I will count the older one. If the time posted is the same, I will choose the one that executes faster. If they execute in the same amount of time, I don't know.

Leaderboard

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Title: Export The $PATH Variable, Line-By-Line

Body:
ELF/x86, 78 bytes

00000000  7f 45 4c 46 01 00 00 00  43 0f 00 00 43 5f eb 10  |.ELF....C...C_..|
00000010  02 00 03 00 0c 50 eb 10  0c 50 eb 10 04 00 00 00  |.....P...P......|
00000020  5f 5f b1 05 be 49 50 eb  10 3d 20 00 01 00 5f f3  |__...IP..= ..._.|
00000030  a6 75 ef 89 f9 80 3f 3a  75 03 80 2f 30 42 ae 75  |.u....?:u../0B.u|
00000040  f4 4a 04 04 cd 80 93 cd  80 50 41 54 48 3d        |.J.......PATH=|
0000004e

NASM source:

BITS 32                                         ;
ORG 0x10eb5000                                  ;
                                                ;   ELF HEADER    --   PROGRAM HEADER
; ELF HEADER                                    ; +-------------+
DB 0x7f,'E','L','F'                             ; | magic       |    +--------------------+
                                                ; |             |    |                    |
; PROGRAM HEADERS                               ; |             |    |                    |
DD 1                                            ; |*class   32b | -- | type: PT_LOAD      |
                                                ; |*data   none |    |                    |
                                                ; |*version   0 |    |                    |
                                                ; |*ABI    SysV |    |                    |
DD 0xf43        ; offset = vaddr & (PAGE_SIZE-1); |*ABI vers    | -- | offset             |
                                                ; |             |    |                    |
entry:  inc     ebx     ; STDOUT_FILENO         ; |*PADx7       | -- | vaddr = 0x10eb5f43 |
        pop     edi     ; discard argc          ; |             |    |                    |
        jmp     short skip                      ; |             |    |                    |
DW 2                                            ; | ET_EXEC     | -- |*paddr LO           |
DW 3                                            ; | EM_386      | -- |*paddr HI           |
DD 0x10eb500c                                   ; |*version     | -- | filesz             |
DD 0x10eb500c                                   ; | entry point | -- | memsz              |
DD 4                                            ; | ph offset   | -- | flags: RX          |
                                                ; |             |    |                    |
skip:   pop     edi     ; discard argv[0]       ; |*sh offset   | -- |*align              |
        pop     edi     ; discard argv[1]=NULL  ; |             |    |                    |
env:    mov     cl,5    ; \ strlen("PATH=")     ; |             |    |                    |
        mov     esi,PATH; > "PATH="             ; |*flags    /--|    |                    |
DB 0x3d         ; cmp eax,0x10020               ; |*ehsize      |    +--------------------+
DW 32                                           ; | phentsize   |
DW 1                                            ; | phnum       |
                                                ; |             |
        pop     edi     ; > envp                ; |*shentsize   |
        repe    cmpsb   ; > strcmp(envp,"PATH="); |*shnum       |
        jne     env     ; /                     ; |*shstrndx    |
        mov     ecx,edi                         ; +-------------+

nlcolon:cmp     byte[edi],58  ; \ if (char == ':')
        jne     nosub         ; >
        sub     byte[edi],48  ; >   char -= '0'
nosub:  inc     edx           ; > wlen++
        scasb                 ; >
        jne     nlcolon       ; / while(char != 0)

        dec     edx           ; wlen--
        add     al,4
        int     0x80          ; write(1, ecx, wlen)
        xchg    eax,ebx
        int     0x80          ; exit(...)

PATH: db "PATH="


问:
Compute the Eulerian number
The Eulerian number A(n, m) is the number of permutations of [1, 2, ..., n] in which exactly m elements are greater than the previous element. These are also called rises. For example, if n = 3, there are 3! = 6 permutations of [1, 2, 3]

```<code>1 2 3
 < <  2 elements are greater than the previous

1 3 2
 < >  1 ...

2 1 3
 > <  1 ...

2 3 1
 < >  1 ...

3 1 2
 > <  1 ...

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

So the outputs for A(3, m) for m in [0, 1, 2, 3] will be

```<code>A(3, 0) = 1
A(3, 1) = 4
A(3, 2) = 1
A(3, 3) = 0
</code>```

Also, this is the OEIS sequence A173018.

Rules

This is code-golf so the shortest code wins.

The input n will be a nonnegative integer and m will be a integer in the range [0, 1, ..., n].

Test Cases

```<code>n   m   A(n, m)
0   0   1
1   0   1
1   1   0
2   0   1
2   1   1
2   2   0
3   0   1
3   1   4
3   2   1
3   3   0
4   0   1
4   1   11
4   2   11
4   3   1
4   4   0
5   1   26
7   4   1191
9   5   88234
10  5   1310354
10  7   47840
10  10  0
12  2   478271
15  6   311387598411
17  1   131054
20  16  1026509354985
42  42  0
</code>```

答:
R, 72 bytes

Recursive function following the logic on OEIS.

```<code>A=function(n,m)if(!m)1 else if(m-n)0 else(n-m)*A(n-1,m-1)+(m+1)*A(n-1,m)
</code>```

This challenge turned out to be quite close between the different approaches I tried. For instance, using the wikipedia formula and looping over the sum resulted in 92 bytes:

```<code>function(n,m){s=0;if(!n)1 else for(k in -1:m+1)s=c(s,(-1)^k*choose(n+1,k)*(m+1-k)^n);sum(s)}
</code>```

or the vectorized version for 87 bytes:

```<code>function(n,m)if(!m)1 else sum(sapply(-1:m+1,function(k)(-1)^k*choose(n+1,k)*(m+1-k)^n))
</code>```

and finally the brute force solution (103 bytes) that generates a matrix of all permutations by using the permute package and the function allPerms. This approach only works up to n<8 though.

```<code>function(n,m){if(!m)1 else sum(apply(rbind(1:n,permute:::allPerms(n)),1,function(x)sum(diff(x)>0))==m)}
</code>```

ContentLicense: CC BY-SA 3.0

Title: Compute the Eulerian number

Body:
R, 72 bytes

Recursive function following the logic on OEIS.

A=function(n,m)if(!m)1 else if(m-n)0 else(n-m)*A(n-1,m-1)+(m+1)*A(n-1,m)

This challenge turned out to be quite close between the different approaches I tried. For instance, using the wikipedia formula and looping over the sum resulted in 92 bytes:

function(n,m){s=0;if(!n)1 else for(k in -1:m+1)s=c(s,(-1)^k*choose(n+1,k)*(m+1-k)^n);sum(s)}

or the vectorized version for 87 bytes:

function(n,m)if(!m)1 else sum(sapply(-1:m+1,function(k)(-1)^k*choose(n+1,k)*(m+1-k)^n))

and finally the brute force solution (103 bytes) that generates a matrix of all permutations by using the permute package and the function allPerms. This approach only works up to n<8 though.

function(n,m){if(!m)1 else sum(apply(rbind(1:n,permute:::allPerms(n)),1,function(x)sum(diff(x)>0))==m)}


答:
DOS .COM File, 52 bytes

```<code>00000000  31 f6 8b 16 2c 00 8e da  bf 2f 01 b9 05 00 f3 a6  |1...,..../......|
00000010  74 06 f7 d9 f2 ae eb f0  b4 02 ac 3c 3b 75 06 b2  |t..........<;u..|
00000020  0d cd 21 b0 0a 92 08 c0  74 04 cd 21 eb ea c3 50  |..!.....t..!...P|
00000030  41 54 48 3d                                       |ATH=|
00000034
</code>```

NASM Source:

```<code>BITS 16
ORG 0x100

                                ; we assume ax is zeroed on start
        xor     si,si
        mov     dx, [0x2c]
        mov     ds, dx          ; PSP:002C points to the environment segment

searchpath:
        mov     di, PATH
        mov     cx, 5
        repe    cmpsb           ; search for PATH= in environment
        je      loop            ; jump if found
        neg     cx
        repne   scasb           ; scan for '\0': skip to the next env var
        jmp     searchpath

loop:   mov     ah, 2           ; WRITE TO STDOUT; AH=02 DL=char
        lodsb                   ; load the next character from PATH
        cmp     al,59
        jne     nosemi
        mov     dl, 0x0d        ; \ if it is a semicolon,
        int     0x21            ; > output '\r',
        mov     al,0x0a         ; / and change it to '\n'
nosemi: xchg    dx,ax           ; 1 byte shorter than mov dl,al
        or      al,al
        je      end             ; if it is '\0', end
        int     0x21
        jmp     loop

end:    ret

PATH: db "PATH="
</code>```

On some older DOS versions (e.g: 3.3) SI is apparently zeroed at start, so 2 bytes can be saved. Newer DOS versions apparently set SI to 100h.

Title: Export The $PATH Variable, Line-By-Line

Body:
Inspired by this question on AskUbuntu.

Your job is extremely simple. Take the PATH environment variable (echo $PATH) and export it such that each entry (separated by the : character) is on its own line.

For example, if the PATH is /bin:/usr/bin:/usr/local/bin, your program should output:

```<code>/bin
/usr/bin
/usr/local/bin
</code>```

Your program may not return a leading newline, but it may return a single trailing newline. You do not need to check if the PATH is right, or that the directory exists. Your program should take no input, meaning that your program is responsible for getting the PATH itself. You may safely assume that objects in the PATH do not contain : or newlines. However, spaces are fair game.

Reference implementations are present in the answers to the question above.

Rules

This is (obviously) code-golf, so the shortest answer will win the prized green checkmark.

The accepted answer will be tested to make sure it's actually legit.

Both Windows and *nix entries are accepted.

However, if you don't explicitly specify Windows, I will try running it in Linux and fail. (If it's obvious (hi, Batch!), you don't need to specify explicitly.)

Only have one solution per answer. If you have both a Windows and *nix version, I will count the shorter one.

If two answers have the same length, I will give priority to the one with the higher vote total. If they have the same vote total, I will count the older one. If the time posted is the same, I will choose the one that executes faster. If they execute in the same amount of time, I don't know.

Leaderboard

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
DOS .COM File, 52 bytes

00000000  31 f6 8b 16 2c 00 8e da  bf 2f 01 b9 05 00 f3 a6  |1...,..../......|
00000010  74 06 f7 d9 f2 ae eb f0  b4 02 ac 3c 3b 75 06 b2  |t..........<;u..|
00000020  0d cd 21 b0 0a 92 08 c0  74 04 cd 21 eb ea c3 50  |..!.....t..!...P|
00000030  41 54 48 3d                                       |ATH=|
00000034

NASM Source:

BITS 16
ORG 0x100

                                ; we assume ax is zeroed on start
        xor     si,si
        mov     dx, [0x2c]
        mov     ds, dx          ; PSP:002C points to the environment segment

searchpath:
        mov     di, PATH
        mov     cx, 5
        repe    cmpsb           ; search for PATH= in environment
        je      loop            ; jump if found
        neg     cx
        repne   scasb           ; scan for '\0': skip to the next env var
        jmp     searchpath

loop:   mov     ah, 2           ; WRITE TO STDOUT; AH=02 DL=char
        lodsb                   ; load the next character from PATH
        cmp     al,59
        jne     nosemi
        mov     dl, 0x0d        ; \ if it is a semicolon,
        int     0x21            ; > output '\r',
        mov     al,0x0a         ; / and change it to '\n'
nosemi: xchg    dx,ax           ; 1 byte shorter than mov dl,al
        or      al,al
        je      end             ; if it is '\0', end
        int     0x21
        jmp     loop

end:    ret

PATH: db "PATH="

On some older DOS versions (e.g: 3.3) SI is apparently zeroed at start, so 2 bytes can be saved. Newer DOS versions apparently set SI to 100h.


问:
Sieve of Eratosthenes, Step by Step
Given a number N, draw a left aligned NxN board of numbers, leaving 1 blank (as a space) (I will show diagrams with N=5)

```<code>   2  3  4  5
6  7  8  9  10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
</code>```

Your job is to construct the Sieve of Eratosthenes, step by step. First, start with 2. It's prime, so leave it there, and replace all other numbers divisible by 2 with the proper number of spaces.

```<code>   2  3     5
   7     9
11    13    15
   17    19
21    23    25
</code>```

Next, go to the next unprinted number (3 in this case) and do the same.

```<code>   2  3     5
   7
11    13
   17    19
      23    25
</code>```

And so on, until you reach N.

You need to first print the complete grid, and every time you go to a new number, print the board with the multiples removed. Make sure you print a blank line in between!

Examples

Text in parenthesis () are just for reference, you don't need to print it

N = 2:

```<code>  2 (complete grid)
3 4

  2 (remove multiples of 2)
3
</code>```

N = 3:

```<code>  2 3 (complete grid)
4 5 6
7 8 9

  2 3 (remove multiples of 2)
  5
7   9

  2 3 (remove multiples of 3)
  5
7
</code>```

Remember, this is code-golf, so the code with the smallest number of bytes wins.

答:
Batch, 464 bytes

```<code>@echo off
set/an=%1,s=n*n,t=s,c=1
set p=
:l
set/ac+=1,t/=10
set p= %p%
if %t% gtr 0 goto l
for /l %%i in (1,1,%1)do call:i %%i
exit/b
:i
set l=
set/af=0
call:f %1 %1
if %f%==0 for /l %%j in (1,1,%s%)do call:j %1 %%j
exit/b
:j
set/am=%2,f=!(m-1),g=%2%%n
call:f %1 %2
if %f% gtr 0 set m=
set m=%m% %p%
call set l=%%l%%%%m:~0,%c%%%
if %g%==0 echo(%l%&set l=
if %2==%s% echo(
exit/b
:f
for /l %%l in (2,1,%1)do if %%l neq %2 set/af+=!(%2%%%%l)
</code>```

This was somewhat laborious. Explanation: Starts by squaring n so that it can calculate the desired column width c, and the appropriate amount of padding p, using the loop :l. The outer loop from 1 to n then runs once for each grid, calling the subroutine :i. First the value is checked to see whether it is 1 or prime; if not then that grid is skipped. The inner loop from 1 to n*n then handles the rows and columns of the grid, calling the subroutine :j. Each value is checked to see whether it is one of the prime numbers found so far, or if none of the prime numbers found so far divide it. If so then the value is concatenated to the output buffer, which is then padded to the desired column width. The buffer is printed and cleared every n lines, and an extra blank line is added at the end of the grid. The :f label denotes the factor-checking subroutine; f(x,y) adds 1 to f for each integer between 2 and x that divides y, excluding y itself.

Title: Sieve of Eratosthenes, Step by Step

Body:
Batch, 464 bytes

@echo off
set/an=%1,s=n*n,t=s,c=1
set p=
:l
set/ac+=1,t/=10
set p= %p%
if %t% gtr 0 goto l
for /l %%i in (1,1,%1)do call:i %%i
exit/b
:i
set l=
set/af=0
call:f %1 %1
if %f%==0 for /l %%j in (1,1,%s%)do call:j %1 %%j
exit/b
:j
set/am=%2,f=!(m-1),g=%2%%n
call:f %1 %2
if %f% gtr 0 set m=
set m=%m% %p%
call set l=%%l%%%%m:~0,%c%%%
if %g%==0 echo(%l%&set l=
if %2==%s% echo(
exit/b
:f
for /l %%l in (2,1,%1)do if %%l neq %2 set/af+=!(%2%%%%l)

This was somewhat laborious. Explanation: Starts by squaring n so that it can calculate the desired column width c, and the appropriate amount of padding p, using the loop :l. The outer loop from 1 to n then runs once for each grid, calling the subroutine :i. First the value is checked to see whether it is 1 or prime; if not then that grid is skipped. The inner loop from 1 to n*n then handles the rows and columns of the grid, calling the subroutine :j. Each value is checked to see whether it is one of the prime numbers found so far, or if none of the prime numbers found so far divide it. If so then the value is concatenated to the output buffer, which is then padded to the desired column width. The buffer is printed and cleared every n lines, and an extra blank line is added at the end of the grid. The :f label denotes the factor-checking subroutine; f(x,y) adds 1 to f for each integer between 2 and x that divides y, excluding y itself.


问:
A penny saved is a penny

...counted!

You will pass your program a variable which represents a quantity of money in dollars and/or cents and an array of coin values.  Your challenge is to output the number of possible combinations of the given array of coin values that would add up to the amount passed to the code.  If it is not possible with the coins named, the program should return 0.

Note on American numismatic terminology:

1-cent coin: penny

5-cent coin: nickel

10-cent coin: dime

25-cent coin: quarter (quarter dollar)

Example 1:

Program is passed:

```<code>12, [1, 5, 10]
</code>```

(12 cents)

Output:

```<code>4
</code>```

There are 4 possible ways of combining the coins named to produce 12 cents:

12 pennies

1 nickel and 7 pennies

2 nickels and 2 pennies

1 dime and 2 pennies

Example 2:

Program is passed:

```<code>26, [1, 5, 10, 25]
</code>```

(26 cents)

Output:

```<code>13
</code>```

There are 13 possible ways of combining the coins named to produce 26 cents:

26 pennies

21 pennies and 1 nickel

16 pennies and 2 nickels

11 pennies and 3 nickels

6 pennies and 4 nickels

1 penny and 5 nickels

16 pennies and 1 dime

6 pennies and 2 dimes

11 pennies, 1 dime, and 1 nickel

6 pennies, 1 dime, and 2 nickels

1 penny, 1 dime, and 3 nickels

1 penny, 2 dimes, and 1 nickel

1 quarter and 1 penny

Example 3:

Program is passed:

```<code>19, [2, 7, 12]
</code>```

Output:

```<code>2
</code>```

There are 2 possible ways of combining the coins named to produce 19 cents:

1 12-cent coin and 1 7-cent coin

1 7-cent coin and 6 2-cent coins

Example 4:

Program is passed:

```<code>13, [2, 8, 25]
</code>```

Output:

```<code>0
</code>```

There are no possible ways of combining the coins named to produce 13 cents.

This has been through the Sandbox.  Standard loopholes apply.  This is code golf, so the answer with the fewest bytes wins.

答:
Perl, 45 bytes

Byte count includes 44 bytes of code and -p flag.

s%\S+%(1{$&})*%g,(1x<>)=~/^$_$(?{$\++})^/x}{
```
<p>Takes the coin values on the first line, and the targeted amount on the second line :</p>
```$ perl -pE 's%\S+%(1{$&})*%g,(1x<>)=~/^$_$(?{$\++})^/x}{' <<< "1 5 10 25
26"
13
```
<p><strong>Short explanations:</strong></p>
```-p                        # Set $_ to the value of the input,
                          # and adds a print at the end of the code.
s%\S+%(1{$&})*%g,         # Converts each number n to (1{$&})* (to prepare the regex)
                          # This pattern does half the job.
(1x<>)                    # Converts the target to unary representation.
  =~                      # Match against.. (regex)
    /^ $_ $               # $_ contains the pattern we prepared with the first line.
     (?{$\++})            # Count the number of successful matches
     ^                    # Forces a fail in the regex since the begining can't be matched here.
    /x                    # Ignore white-spaces in the regex
                          # (needed since the available coins are space-separated)
 }{                       # End the code block to avoid the input being printed (because of -p flag)
                          # The print will still be executed, but $_ will be empty,
                          # and only $\ will be printed (this variable is added after every print)
```

Title: A penny saved is a penny

Body:
Perl, 45 bytes

Byte count includes 44 bytes of code and -p flag.

s%\S+%(1{$&})*%g,(1x<>)=~/^$_$(?{$\++})^/x}{

Takes the coin values on the first line, and the targeted amount on the second line :

$ perl -pE 's%\S+%(1{$&})*%g,(1x<>)=~/^$_$(?{$\++})^/x}{' <<< "1 5 10 25
26"
13

Short explanations:

-p                        # Set $_ to the value of the input,
                          # and adds a print at the end of the code.
s%\S+%(1{$&})*%g,         # Converts each number n to (1{$&})* (to prepare the regex)
                          # This pattern does half the job.
(1x<>)                    # Converts the target to unary representation.
  =~                      # Match against.. (regex)
    /^ $_ $               # $_ contains the pattern we prepared with the first line.
     (?{$\++})            # Count the number of successful matches
     ^                    # Forces a fail in the regex since the begining can't be matched here.
    /x                    # Ignore white-spaces in the regex
                          # (needed since the available coins are space-separated)
 }{                       # End the code block to avoid the input being printed (because of -p flag)
                          # The print will still be executed, but $_ will be empty,
                          # and only $\ will be printed (this variable is added after every print)


答:
JavaScript (ES6), <s>51</s> 48 bytes

```<code>f=(n,a,[c,...b]=a)=>n?n>0&&c?f(n-c,a)+f(n,b):0:1
</code>```

Accepts coins in any order. Tries both using and not using the first coin, recursively calculating the number of combinations either way. n==0 means a matching combination, n<0 means that the coins exceed the quantity while c==undefined means that there are no coins left. Note that the function is very slow and if you have a penny coin then the following function is faster (don't pass the penny coin in the array of coins):

```<code>f=(n,a,[c,...b]=a)=>c?(c<=n&&f(n-c,a))+f(n,b):1
</code>```

Title: A penny saved is a penny

Body:
...counted!

You will pass your program a variable which represents a quantity of money in dollars and/or cents and an array of coin values.  Your challenge is to output the number of possible combinations of the given array of coin values that would add up to the amount passed to the code.  If it is not possible with the coins named, the program should return 0.

Note on American numismatic terminology:

1-cent coin: penny

5-cent coin: nickel

10-cent coin: dime

25-cent coin: quarter (quarter dollar)

Example 1:

Program is passed:

```<code>12, [1, 5, 10]
</code>```

(12 cents)

Output:

```<code>4
</code>```

There are 4 possible ways of combining the coins named to produce 12 cents:

12 pennies

1 nickel and 7 pennies

2 nickels and 2 pennies

1 dime and 2 pennies

Example 2:

Program is passed:

```<code>26, [1, 5, 10, 25]
</code>```

(26 cents)

Output:

```<code>13
</code>```

There are 13 possible ways of combining the coins named to produce 26 cents:

26 pennies

21 pennies and 1 nickel

16 pennies and 2 nickels

11 pennies and 3 nickels

6 pennies and 4 nickels

1 penny and 5 nickels

16 pennies and 1 dime

6 pennies and 2 dimes

11 pennies, 1 dime, and 1 nickel

6 pennies, 1 dime, and 2 nickels

1 penny, 1 dime, and 3 nickels

1 penny, 2 dimes, and 1 nickel

1 quarter and 1 penny

Example 3:

Program is passed:

```<code>19, [2, 7, 12]
</code>```

Output:

```<code>2
</code>```

There are 2 possible ways of combining the coins named to produce 19 cents:

1 12-cent coin and 1 7-cent coin

1 7-cent coin and 6 2-cent coins

Example 4:

Program is passed:

```<code>13, [2, 8, 25]
</code>```

Output:

```<code>0
</code>```

There are no possible ways of combining the coins named to produce 13 cents.

This has been through the Sandbox.  Standard loopholes apply.  This is code golf, so the answer with the fewest bytes wins.

Body:
JavaScript (ES6), <s>51</s> 48 bytes

f=(n,a,[c,...b]=a)=>n?n>0&&c?f(n-c,a)+f(n,b):0:1

Accepts coins in any order. Tries both using and not using the first coin, recursively calculating the number of combinations either way. n==0 means a matching combination, n<0 means that the coins exceed the quantity while c==undefined means that there are no coins left. Note that the function is very slow and if you have a penny coin then the following function is faster (don't pass the penny coin in the array of coins):

f=(n,a,[c,...b]=a)=>c?(c<=n&&f(n-c,a))+f(n,b):1


问:
Compute the histogram entropy estimation of a string
Write a program or function that estimates the Shannon entropy of a given string.

If a string has n characters, d distinct characters, xi is the i th distinct character, and P(xi) is the probability of that character occuring in the string, then our Shannon entropy estimate for that string is given by:

For the estimation in this challenge we assume that the probability of a character occurring in a string is simply the number of times it occurs divided by the total number of characters.

Your answer must be accurate to at least 3 digits after the period.

Test cases:

```<code>"This is a test.", 45.094
"00001111", 8.000
"cwmfjordbankglyphsvextquiz", 122.211
"             ", 0.0
</code>```

答:
Groovy, 100 Bytes

```<code>{a->n=a.size();a.toList().unique().collect{p=a.count(it)/n;p*(Math.log(p)/Math.log(2.0f))}.sum()*-n}
</code>```

Tests:

```<code>This is a test. = 45.09358393449714
00001111 = 8.0
cwmfjordbankglyphsvextquiz = 122.21143275636976
aaaaaaaa = -0.0
</code>```

Body:
Groovy, 100 Bytes

{a->n=a.size();a.toList().unique().collect{p=a.count(it)/n;p*(Math.log(p)/Math.log(2.0f))}.sum()*-n}

Tests:

This is a test. = 45.09358393449714
00001111 = 8.0
cwmfjordbankglyphsvextquiz = 122.21143275636976
aaaaaaaa = -0.0


答:
Jelly, <s>10</s> 9 bytes

```<code>œċÐ€S€€Fċ
</code>```

Try it online!

How?

```<code>œċÐ€S€€Fċ - Main link: coins, target
  Ð€      - map over right argument, or for each n in [1,2,...,target]
œċ        - combinations with replacement, possible choices of each of n coins
    S€€   - sum for each for each (values of those selections)
       F  - flatten into one list
        ċ - count occurrences of right argument
</code>```

Title: A penny saved is a penny

Body:
Jelly, <s>10</s> 9 bytes

œċÐ€S€€Fċ

Try it online!

How?

œċÐ€S€€Fċ - Main link: coins, target
  Ð€      - map over right argument, or for each n in [1,2,...,target]
œċ        - combinations with replacement, possible choices of each of n coins
    S€€   - sum for each for each (values of those selections)
       F  - flatten into one list
        ċ - count occurrences of right argument


答:
Axiom, <s>63</s> 62 bytes

1 byte saved by @JonathanAllan

```<code>f(n,l)==coefficient(series(reduce(*,[1/(1-x^i)for i in l])),n)
</code>```

This approach uses generating functions. Probably that didn't help bring down the code size. I think this is the first time that in my playing with Axiom I went as far as defining my own function.

The first time the function is called it gives a horrendous warning, but still produces the correct result. After that, everything is fine as long as the list isn't empty.

Title: A penny saved is a penny

Body:
Axiom, <s>63</s> 62 bytes

1 byte saved by @JonathanAllan

f(n,l)==coefficient(series(reduce(*,[1/(1-x^i)for i in l])),n)

This approach uses generating functions. Probably that didn't help bring down the code size. I think this is the first time that in my playing with Axiom I went as far as defining my own function.

The first time the function is called it gives a horrendous warning, but still produces the correct result. After that, everything is fine as long as the list isn't empty.


答:
Pyth, 8 bytes

```<code>/sM{yS*E
</code>```

Raw brute force, too memory intensive for actual testing. This is O(2mn), where n is the number of coins and m is the target sum. Takes input as target\n[c,o,i,n,s].

```<code>/sM{yS*EQQ      (implicit Q's)
      *EQ       multiply coin list by target
     S          sort
    y           powerset (all subsequences)
   {            remove duplicates
 sM             sum all results
/        Q      count correct sums
</code>```

Title: A penny saved is a penny

Body:
Pyth, 8 bytes

/sM{yS*E

Raw brute force, too memory intensive for actual testing. This is O(2mn), where n is the number of coins and m is the target sum. Takes input as target\n[c,o,i,n,s].

/sM{yS*EQQ      (implicit Q's)
      *EQ       multiply coin list by target
     S          sort
    y           powerset (all subsequences)
   {            remove duplicates
 sM             sum all results
/        Q      count correct sums


问:
Sylvester's sequence
Sylvester's sequence, OEIS A000058, is an integer sequence defined as follows:

Each member is the product of all previous members plus one.  The first member of the sequence is 2.

Task

Create a program to calculate the nth term of Sylvester's Sequence.  Standard input, output and loopholes apply.

Standard sequence rules apply.

This is code-golf, so the goal is to minimize the size of your source code as measured in bytes.

Test Cases

You may use either zero or one indexing. (Here I use zero indexing)

```<code>>>0
2
>>1
3
>>2
7
>>3
43
>>4
1807
</code>```

答:
Groovy, 26 bytes

This answer was basically stolen from @Geobits.

```<code>a={n->n--?a(n)*~-a(n)+1:2}
</code>```

Took that answer and, using groovy shortcuts, optimized it further.

ContentLicense: CC BY-SA 4.0

Title: Sylvester's sequence

Body:
Groovy, 26 bytes

This answer was basically stolen from @Geobits.

a={n->n--?a(n)*~-a(n)+1:2}

Took that answer and, using groovy shortcuts, optimized it further.


问:
Let's draw some Atari ST bombs!

Introduction

The Atari ST was a rather popular personal computer from the mid 80's to early 90's era, powered by a Motorola 68000 microprocessor. On this machine, the default behavior of the operating system for uncaught CPU exceptions was to display a row of bombs on the screen, as shown in the following picture:

Source: https://commons.wikimedia.org/wiki/File:Row_of_bombs.png

NB: Depending on the OS version, the bomb graphics may vary slightly. But let's take this one as reference.

The number of bombs depends on the exception vector, the most common ones being:

($008) Bus Error : 2 bombs

($00c) Address Error : 3 bombs

($010) Illegal Instruction : 4 bombs

Goal

Your goal is to write a program or function that prints or outputs an ASCII art of such Atari ST bombs.

Input

An integer representing the number of bombs to display. Your code must support the most common values: 2, 3 and 4. Supporting less and/or more bombs is fine, but it is neither required nor subject to a bonus.

Output

The original bomb consists of a 16x16 pixel tile, represented here in both ASCII and binary:

```<code>....##..........    0000110000000000
.#.#..#.........    0101001000000000
.......#........    0000000100000000
#..#....#.......    1001000010000000
..#...#####.....    0010001111100000
......#####.....    0000001111100000
....#########...    0000111111111000
...###########..    0001111111111100
...###########..    0001111111111100
..#############.    0011111111111110
..########.####.    0011111111011110
...#######.###..    0001111111011100
...######.####..    0001111110111100
....#########...    0000111111111000
.....#######....    0000011111110000
.......###......    0000000111000000
</code>```

In this challenge, each ASCII bomb must be stretched to twice its original width for a better rendering. Therefore, it will consist of 16 rows of 32 characters, using ## for 'ON' pixels and two spaces for 'OFF' pixels. All bomb tiles must be put side by side. Leading spaces are forbidden. Trailing spaces are also forbidden, except the ones that are actually part of the bomb tile (i.e. the 31st and 32nd columns) which must be present. You may include no more than one leading line-break and no more than one trailing line-break.

Example

Below is the reference output for two bombs, where mandatory line-breaks are marked as \n and tolerated extra line-breaks are marked as (\n):

```<code>(\n)
        ####                            ####                    \n
  ##  ##    ##                    ##  ##    ##                  \n
              ##                              ##                \n
##    ##        ##              ##    ##        ##              \n
    ##      ##########              ##      ##########          \n
            ##########                      ##########          \n
        ##################              ##################      \n
      ######################          ######################    \n
      ######################          ######################    \n
    ##########################      ##########################  \n
    ################  ########      ################  ########  \n
      ##############  ######          ##############  ######    \n
      ############  ########          ############  ########    \n
        ##################              ##################      \n
          ##############                  ##############        \n
              ######                          ######            (\n)
</code>```

(Of course, other line-break formats such as \r or \r\n may be used just as well.)

Rules

This is code-golf, so the shortest answer in bytes wins. Standard loopholes are forbidden.

答:
///, <s>539</s> 532 + no. of bombs bytes

The first /// answer, displaying 4 bombs. The end four 1's can be replaced with any unary representation of the number of bombs you want to print (11 for 2, 111 for 3)

```<code>/-/?|X//y/\/X//xy|//|/\/\///+/%@!|$/bcd|%/efg|@/hij|!/klm|?/nop|b/Bxc/Cxd/Dxe/Exf/Fxg/Gxh/Hxi/Ixj/Jxk/Kxl/Lxm/Mxn/Nxo/Oxp/Pxq/ss|r/tt|s/SS|t/TT|S/  |T/##|1/AX$+-$+?AXyAX$+-cd+?by$+-d+?cycd+-+?dyd+-fg@!?ey+-g@!?fyfg@!-@!?gyg@!-ij!?hy@!-j!?iyij!-!?jyj!-lm?ky!-m?lylm-?mym-opny-poyop|AXA/AA|bB/BB|cC/CC|dD/DD|eE/EE|fF/FF|gG/GG|hH/HH|iI/II|jJ/JJ|kK/KK|lL/LL|mM/MM|nN/NN|oO/OO|pP/PP|A/qtqqs|B/STSTsTqqS|C/qsSTqq|D/TsTqTqsS|E/sTsSrTqS|F/qsrTqS|G/qrrTsS|H/sSrrtTs|I/sSrrtTs|J/srrrTS|K/srrSrS|L/sSrtTStTs|M/sSrtSrs|N/qrrTsS|O/qSrtTq|P/qsStTqs|X/
/1111
</code>```

Try it online!

If the input must be decimal, the following has <s>555</s> 548 bytes (where the last digit can be changed to 1, 2, 3 or 4):

```<code>/-/?|X//y/\/X//xy|//|/\/\///4/13|3/12|2/11|^/tT|&/rr|*/sS|+/%@!|$/bcd|%/efg|@/hij|!/klm|?/nop|b/Bxc/Cxd/Dxe/Exf/Fxg/Gxh/Hxi/Ixj/Jxk/Kxl/Lxm/Mxn/Nxo/Oxp/Pxq/ss|r/tt|s/SS|t/TT|S/  |T/##|1/AX$+-$+?AXyAX$+-cd+?by$+-d+?cycd+-+?dyd+-fg@!?ey+-g@!?fyfg@!-@!?gyg@!-ij!?hy@!-j!?iyij!-!?jyj!-lm?ky!-m?lylm-?mym-opny-poyop|AXA/AA|bB/BB|cC/CC|dD/DD|eE/EE|fF/FF|gG/GG|hH/HH|iI/II|jJ/JJ|kK/KK|lL/LL|mM/MM|nN/NN|oO/OO|pP/PP|A/qtqqs|B/STSTsTqqS|C/q*Tqq|D/TsTqTq*|E/sT*rTqS|F/qsrTqS|G/q&T*|H/*&^s|I/*&^s|J/s&rTS|K/s&SrS|L/*r^S^s|M/*rtSrs|N/q&T*|O/qSr^q|P/q*^qs|X/
/4
</code>```

Try it online!

The most important parts of the code are that:

| means //

ABCDEFGHIJKLMNOP mean each line of the bomb respectively

S means 2 spaces

s means 4 spaces

* means 6 spaces

q means 8 spaces

T means ## (2)

t means #### (4)

^ means ###### (6)

r means ######## (8)

& means ################ (16)

Most of the code is making sure that the bombs are printed side-by-side, not on top of each other.

Title: Let's draw some Atari ST bombs!

Body:
///, <s>539</s> 532 + no. of bombs bytes

The first /// answer, displaying 4 bombs. The end four 1's can be replaced with any unary representation of the number of bombs you want to print (11 for 2, 111 for 3)

/-/?|X//y/\/X//xy|//|/\/\///+/%@!|$/bcd|%/efg|@/hij|!/klm|?/nop|b/Bxc/Cxd/Dxe/Exf/Fxg/Gxh/Hxi/Ixj/Jxk/Kxl/Lxm/Mxn/Nxo/Oxp/Pxq/ss|r/tt|s/SS|t/TT|S/  |T/##|1/AX$+-$+?AXyAX$+-cd+?by$+-d+?cycd+-+?dyd+-fg@!?ey+-g@!?fyfg@!-@!?gyg@!-ij!?hy@!-j!?iyij!-!?jyj!-lm?ky!-m?lylm-?mym-opny-poyop|AXA/AA|bB/BB|cC/CC|dD/DD|eE/EE|fF/FF|gG/GG|hH/HH|iI/II|jJ/JJ|kK/KK|lL/LL|mM/MM|nN/NN|oO/OO|pP/PP|A/qtqqs|B/STSTsTqqS|C/qsSTqq|D/TsTqTqsS|E/sTsSrTqS|F/qsrTqS|G/qrrTsS|H/sSrrtTs|I/sSrrtTs|J/srrrTS|K/srrSrS|L/sSrtTStTs|M/sSrtSrs|N/qrrTsS|O/qSrtTq|P/qsStTqs|X/
/1111

<a href="http://slashes.tryitonline.net/#code=Ly0vP3xYLy95L1wvWC8veHl8Ly98L1wvXC8vL14vdFR8Ji9ycnwqL3NTfCsvJUAhfCQvYmNkfCUvZWZnfEAvaGlqfCEva2xtfD8vbm9wfGIvQnhjL0N4ZC9EeGUvRXhmL0Z4Zy9HeGgvSHhpL0l4ai9KeGsvS3hsL0x4bS9NeG4vTnhvL094cC9QeHEvc3N8ci90dHxzL1NTfHQvVFR8Uy8gIHxULyMjfDEvQVgkKy0kKz9BWHlBWCQrLWNkKz9ieSQrLWQrP2N5Y2QrLSs_ZHlkKy1mZ0AhP2V5Ky1nQCE_ZnlmZ0AhLUAhP2d5Z0AhLWlqIT9oeUAhLWohP2l5aWohLSE_anlqIS1sbT9reSEtbT9seWxtLT9teW0tb3BueS1wb3lvcHxBWEEvQUF8YkIvQkJ8Y0MvQ0N8ZEQvRER8ZUUvRUV8ZkYvRkZ8Z0cvR0d8aEgvSEh8aUkvSUl8akovSkp8a0svS0t8bEwvTEx8bU0vTU18bk4vTk58b08vT098cFAvUFB8QS9xdHFxc3xCL1NUU1RzVHFxU3xDL3EqVHFxfEQvVHNUcVRxKnxFL3NUKnJUcVN8Ri9xc3JUcVN8Ry9xJlQqfEgvKiZec3xJLyomXnN8Si9zJnJUU3xLL3MmU3JTfEwvKnJeU15zfE0vKnJ0U3JzfE4vcSZUKnxPL3FTcl5xfFAvcSpecXN8WC8KLzExMTE&input=" rel="nofollow">Try it online!

If the input must be decimal, the following has <s>555</s> 548 bytes (where the last digit can be changed to 1, 2, 3 or 4):

/-/?|X//y/\/X//xy|//|/\/\///4/13|3/12|2/11|^/tT|&/rr|*/sS|+/%@!|$/bcd|%/efg|@/hij|!/klm|?/nop|b/Bxc/Cxd/Dxe/Exf/Fxg/Gxh/Hxi/Ixj/Jxk/Kxl/Lxm/Mxn/Nxo/Oxp/Pxq/ss|r/tt|s/SS|t/TT|S/  |T/##|1/AX$+-$+?AXyAX$+-cd+?by$+-d+?cycd+-+?dyd+-fg@!?ey+-g@!?fyfg@!-@!?gyg@!-ij!?hy@!-j!?iyij!-!?jyj!-lm?ky!-m?lylm-?mym-opny-poyop|AXA/AA|bB/BB|cC/CC|dD/DD|eE/EE|fF/FF|gG/GG|hH/HH|iI/II|jJ/JJ|kK/KK|lL/LL|mM/MM|nN/NN|oO/OO|pP/PP|A/qtqqs|B/STSTsTqqS|C/q*Tqq|D/TsTqTq*|E/sT*rTqS|F/qsrTqS|G/q&T*|H/*&^s|I/*&^s|J/s&rTS|K/s&SrS|L/*r^S^s|M/*rtSrs|N/q&T*|O/qSr^q|P/q*^qs|X/
/4

<a href="http://slashes.tryitonline.net/#code=Ly0vP3xYLy95L1wvWC8veHl8Ly98L1wvXC8vLzQvMTN8My8xMnwyLzExfF4vdFR8Ji9ycnwqL3NTfCsvJUAhfCQvYmNkfCUvZWZnfEAvaGlqfCEva2xtfD8vbm9wfGIvQnhjL0N4ZC9EeGUvRXhmL0Z4Zy9HeGgvSHhpL0l4ai9KeGsvS3hsL0x4bS9NeG4vTnhvL094cC9QeHEvc3N8ci90dHxzL1NTfHQvVFR8Uy8gIHxULyMjfDEvQVgkKy0kKz9BWHlBWCQrLWNkKz9ieSQrLWQrP2N5Y2QrLSs_ZHlkKy1mZ0AhP2V5Ky1nQCE_ZnlmZ0AhLUAhP2d5Z0AhLWlqIT9oeUAhLWohP2l5aWohLSE_anlqIS1sbT9reSEtbT9seWxtLT9teW0tb3BueS1wb3lvcHxBWEEvQUF8YkIvQkJ8Y0MvQ0N8ZEQvRER8ZUUvRUV8ZkYvRkZ8Z0cvR0d8aEgvSEh8aUkvSUl8akovSkp8a0svS0t8bEwvTEx8bU0vTU18bk4vTk58b08vT098cFAvUFB8QS9xdHFxc3xCL1NUU1RzVHFxU3xDL3EqVHFxfEQvVHNUcVRxKnxFL3NUKnJUcVN8Ri9xc3JUcVN8Ry9xJlQqfEgvKiZec3xJLyomXnN8Si9zJnJUU3xLL3MmU3JTfEwvKnJeU15zfE0vKnJ0U3JzfE4vcSZUKnxPL3FTcl5xfFAvcSpecXN8WC8KLzQ&input=" rel="nofollow">Try it online!

The most important parts of the code are that:

| means //

ABCDEFGHIJKLMNOP mean each line of the bomb respectively

S means 2 spaces

s means 4 spaces

* means 6 spaces

q means 8 spaces

T means ## (2)

t means #### (4)

^ means ###### (6)

r means ######## (8)

& means ################ (16)

Most of the code is making sure that the bombs are printed side-by-side, not on top of each other.


问:
C# is the Main problem
This programming puzzle is inspired by another question which has been asked here yesterday but which was deleted by the author...

The challenge:

Create an executable binary (Windows .EXE or Linux binary) using Visual C# (or your favorite C# IDE) which prints the following text to the standard output:

```<code>Main() is the main method of C# programs!
</code>```

... without using the 4 consecutive letters M-A-I-N appearing in any source file!

Notes:

If your source code contains the text remainder (for example) it contains the 4 consecutive letters M-A-I-N, however if it contains mxain the 4 letters would not be consecutive any more so mxain would be allowed.

You are not allowed to run any programs but the C# IDE nor change the settings of the C# IDE to run other programs (but the ones it would normally run such as the C# compiler).

Otherwise you could simply say: "I write a Pascal program using the C# IDE and invoke the Pascal compiler in the 'pre-build' steps of my C# project".

This would be too simple.

Users of an IDE that can be extending using "plug-ins" (or similar) or that have built-in binary file editors (hex-editors) would have a too large advantage over users of other C# IDEs.

Therefore these featrues should also not be used.

Using the other non-ASCII-Editors (such as the dialog window editor) is explicitly allowed!

The user asking the original question proposed using the backslash in function names just like this: static void M\u0061in() Because this answer has already been read by other users it will not be accepted any more!

A user asked if it would be allowed to simply type in an .EXE file into the source code editor and to save the file as ".exe" instead of ".cs". Answer: I doub't that this is possible because both valid Windows and Linux binaries contain NUL bytes. However if you find a valid binary that can be created this way you have a valid solution.

The name of this site is "Programming Puzzles & Code Golf" - this is a "Programming Puzzle", not "Code Golf": The challenge is to find a working solution before all other users, not to find a solution shorter than all other solutions.

Therefore the first post describing a working solution wins!

Good luck!

By the way: I have a solution working under Visual C# Express 2010.

答:
WPF Application

Create a new WPF application.

Replace all instances of Main with Meow

Rename MainWindow.xaml to MeowWindow.xaml. This will automatically rename MainWindow.xaml.cs to MeowWindow.xaml.cs.

In project properties, change the Output type to Console Application so the console is created.

Add console write for the desired output string in your MeowWindow constructor

Ctrl+Shift+F to confirm there's no main anywhere in the source directory.

F5 / compile and run.

How it works

For WPF applications, Visual Studio generates obj\Debug\App.g.cs which contains the Main method. The generated Main creates an instance of your WPF app and starts it.

Title: C# is the Main problem


答:
J, 27 bytes

```<code>1#.[=](+/ .*~]#:,@i.)1+<.@%
</code>```

Usage

```<code>   f =: 1#.[=](+/ .*~]#:,@i.)1+<.@%
   12 f 1 5 10
4
   26 f 1 5 10 25
13
   19 f 2 7 12
2
   13 f 2 8 25
0
</code>```

Explanation

```<code>1#.[=](+/ .*~]#:,@i.)1+<.@%  Input: target T (LHS), denominations D (RHS)
                          %  Divide T by each in D
                       <.@   Floor each
                             These are the maximum number of each denomination
                     1+      Add 1 to each, call these B
                ,@i.         Forms the range 0 the the product of B
             ]               Get B
              #:             Convert each in the range to mixed radix B
     ]                       Get D
       +/ .*~                Dot product between D and each mixed radix number
                             These are all combinations of denominations up to T
   [                         Get T
    =                        Test if each sum is equal to T
1#.                          Convert as base 1 digits to decimal (takes the sum)
                             This is the number of times each sum was true
</code>```

Title: A penny saved is a penny

Body:
J, 27 bytes

1#.[=](+/ .*~]#:,@i.)1+<.@%

Usage

   f =: 1#.[=](+/ .*~]#:,@i.)1+<.@%
   12 f 1 5 10
4
   26 f 1 5 10 25
13
   19 f 2 7 12
2
   13 f 2 8 25
0

Explanation

1#.[=](+/ .*~]#:,@i.)1+<.@%  Input: target T (LHS), denominations D (RHS)
                          %  Divide T by each in D
                       <.@   Floor each
                             These are the maximum number of each denomination
                     1+      Add 1 to each, call these B
                ,@i.         Forms the range 0 the the product of B
             ]               Get B
              #:             Convert each in the range to mixed radix B
     ]                       Get D
       +/ .*~                Dot product between D and each mixed radix number
                             These are all combinations of denominations up to T
   [                         Get T
    =                        Test if each sum is equal to T
1#.                          Convert as base 1 digits to decimal (takes the sum)
                             This is the number of times each sum was true


问:
Reconstruct a missing RGB channel
Look at these photographs of natural scenes, with one of the RGB channels taken out of them:

Source (with red): https://en.wikipedia.org/wiki/File:Altja_j%C3%B5gi_Lahemaal.jpg

Source (with green): https://commons.wikimedia.org/wiki/File:2007_mather-lake_hg.jpg

Source (with blue): https://commons.wikimedia.org/wiki/File:Fox_01.jpg

Even without one of the channels, you can probably make out what colours certain things are supposed to be, or at least have a good idea if a reconstruction of the missing channel is accurate.

For example, here is the first picture with a red channel added back onto it which is just random noise:

This image clearly isn't an accurate reconstruction of the red channel. This is because nature photos generally don't use the entire RGB spectrum, but only a subset of "natural-looking colours". Also, the shades of red will follow certain gradients that correlate with the others.

Your task is to build a program that will take a photograph that's had one channel removed and attempt to approximate the original image as closely as possible by reconstructing what it believes is the missing channel.

Your program will be scored on how closely the missing channel matches with the channel of the original image, by counting the percentage of pixels whose values of that channel are within ±15 (inclusive) of the actual value in the original image (where the values range from 0 to 255 as in a standard 8-bit colour channel).

The test cases that your program will be scored on can be found here (9.04 MB zip file, 6 images). Currently it only contains the three example images above and their originals, but I'll add a few more later to make the full suite once I've done them.

Each image is scaled down and cropped to 1024 x 768, so they will have the same weight in your score. The program that can predict the most pixels within the given tolerance wins.

答:
Lua, Love2D

Just sets the missing channel to the smaller of the two remaining channels.

```<code>local inp = love.image.newImageData(arg[2])

local channels = {1, 2, 3}
local removed = nil
local removed_options = {true,true,true}

inp:mapPixel(function(x,y,r,g,b)
    local o = {r,g,b}
    for k,v in pairs(o) do
        if v > 0 then
            removed_options[k] = false
        end
    end
    return r,g,b
end)

for k,v in pairs(removed_options) do
    if v then
        removed = k
        break
    end
end
inp:mapPixel(function(x,y,r,g,b)
    local o = {r,g,b}
    o[removed] = math.min(o[removed%3+1], o[(removed+1)%3 + 1])
    return unpack(o)
end)

inp:encode('png', IMAGE:gsub("%.png", "2.png"))
</code>```

Takes a filename as an argument on the command line.

Bonus

I tried setting the missing channel to 255-(a+b), clamping the value. As to "fill in the gap". The results are useless but glorious.

And with 255-(a+b)/2

Title: Reconstruct a missing RGB channel

Body:
Lua, Love2D

Just sets the missing channel to the smaller of the two remaining channels.

local inp = love.image.newImageData(arg[2])

local channels = {1, 2, 3}
local removed = nil
local removed_options = {true,true,true}

inp:mapPixel(function(x,y,r,g,b)
    local o = {r,g,b}
    for k,v in pairs(o) do
        if v > 0 then
            removed_options[k] = false
        end
    end
    return r,g,b
end)

for k,v in pairs(removed_options) do
    if v then
        removed = k
        break
    end
end
inp:mapPixel(function(x,y,r,g,b)
    local o = {r,g,b}
    o[removed] = math.min(o[removed%3+1], o[(removed+1)%3 + 1])
    return unpack(o)
end)

inp:encode('png', IMAGE:gsub("%.png", "2.png"))

Takes a filename as an argument on the command line.

Bonus

I tried setting the missing channel to 255-(a+b), clamping the value. As to "fill in the gap". The results are useless but glorious.

And with 255-(a+b)/2


问:
Find the Centroid of a Polygon
From Wikipedia:

The centroid of a non-self-intersecting closed polygon
  defined by n vertices (x0,y0),
  (x1,y1), ...,
  (xn−1,yn−1) is the point (Cx,
  Cy), where

and where A is the polygon's signed area,

In these formulas, the vertices are assumed to be numbered in order of
  their occurrence along the polygon's perimeter. Furthermore, the
  vertex ( xn, yn ) is assumed to be the same as
  ( x0, y0 ), meaning i + 1 on the last case
  must loop around to i = 0. Note that if the points are numbered in
  clockwise order the area A, computed as above, will have a negative
  sign; but the centroid coordinates will be correct even in this case.

Given a list of vertices in order (either clockwise, or counter-clockwise), find the centroid of the non-self-intersecting closed polygon represented by the vertices.

If it helps, you may assume input to be only CW, or only CCW. Say so in your answer if you require this.

The coordinates are not required to be integers, and may contain negative numbers.

Input will always be valid and contain at least three vertices.

Inputs only need to be handled that fit in your language's native floating point data type.

You may assume that input numbers will always contain a decimal point.

You may assume that input integers end in . or .0.

You may use complex numbers for input.

Output should be accurate to the nearest thousandth.

Examples

```<code>[(0.,0.), (1.,0.), (1.,1.), (0.,1.)]        -> (0.5, 0.5)
[(-15.21,0.8), (10.1,-0.3), (-0.07,23.55)]  -> -1.727 8.017
[(-39.00,-55.94), (-56.08,-4.73), (-72.64,12.12), (-31.04,53.58), (-30.36,28.29), (17.96,59.17), (0.00,0.00), (10.00,0.00), (20.00,0.00), (148.63,114.32), (8.06,-41.04), (-41.25,34.43)]   -> 5.80104769975, 15.0673812762
</code>```

Too see each polygon on a coordinate plane, paste the coordinates without the square brackets in the "Edit" menu of this page.

I confirmed my results using this Polygon Centroid Point Calculator, which is awful. I couldn't find one that you can input all vertices at once, or that didn't try to erase your - sign when you type it first. I'll post my Python solution for your use after people have had a chance to answer.

答:
R + sp (46 bytes)

Assumes sp package is installed (https://cran.r-project.org/web/packages/sp/)

Takes a list of vertices, (for example list(c(0.,0.), c(1.,0.), c(1.,1.), c(0.,1.)))

Takes advantage of the fact that the "labpt" of a Polygon is the centroid.

```<code>function(l)sp::Polygon(do.call(rbind,l))@labpt
</code>```

Title: Find the Centroid of a Polygon

Body:
R + sp (46 bytes)

Assumes sp package is installed (https://cran.r-project.org/web/packages/sp/)

Takes a list of vertices, (for example list(c(0.,0.), c(1.,0.), c(1.,1.), c(0.,1.)))

Takes advantage of the fact that the "labpt" of a Polygon is the centroid.

function(l)sp::Polygon(do.call(rbind,l))@labpt


问:
Maximal number of regions obtained by joining n points around a circle by straight lines
Let's define f(n) as the maximal number of regions obtained by joining n points around a circle by straight lines. For example, two points would split the circle into two pieces, three into four, like this:

Make sure when you are drawing the lines, you don't have an intersection of more than two lines.

Your task

Given a number n, print f(n).

Test cases:

```<code> n | f(n)
---+-----
 1 |   1
 2 |   2
 3 |   4
 4 |   8
 5 |  16
 6 |  31
 7 |  57
 8 |  99
 9 | 163
</code>```

You can see more here.

Using built-in sequence generators is not allowed.

Remember, this is code-golf, so the code with the smallest number of bytes wins.

If you guys want the formula, here it is:

答:
Mathematica, 23 bytes

```<code>Tr@Binomial[#,{0,2,4}]&
</code>```

Uses the formula in the question.

Body:
Mathematica, 23 bytes

Tr@Binomial[#,{0,2,4}]&

Uses the formula in the question.


答:
Jelly, 6 bytes

```<code>c3ḶḤ¤S
</code>```

Try it online! or verify all test cases.

How it works

```<code>c3ḶḤ¤S  Main link. Argument: n

    ¤   Combine the three links to the left into a niladic chain.
 3        Yield 3.
  Ḷ       Unlength; yield [0, 1, 2].
   Ḥ      Unhalve; yield [0, 2, 4].
c       Combinations; compute [nC0, nC2, nC4].
     S  Sum; return nC0 + nc2 + nC4.
</code>```

Title: Maximal number of regions obtained by joining n points around a circle by straight lines

Body:
Let's define f(n) as the maximal number of regions obtained by joining n points around a circle by straight lines. For example, two points would split the circle into two pieces, three into four, like this:

Make sure when you are drawing the lines, you don't have an intersection of more than two lines.

Your task

Given a number n, print f(n).

Test cases:

```<code> n | f(n)
---+-----
 1 |   1
 2 |   2
 3 |   4
 4 |   8
 5 |  16
 6 |  31
 7 |  57
 8 |  99
 9 | 163
</code>```

You can see more here.

Using built-in sequence generators is not allowed.

Remember, this is code-golf, so the code with the smallest number of bytes wins.

If you guys want the formula, here it is:

Body:
Jelly, 6 bytes

c3ḶḤ¤S

Try it online! or verify all test cases.

How it works

c3ḶḤ¤S  Main link. Argument: n

    ¤   Combine the three links to the left into a niladic chain.
 3        Yield 3.
  Ḷ       Unlength; yield [0, 1, 2].
   Ḥ      Unhalve; yield [0, 2, 4].
c       Combinations; compute [nC0, nC2, nC4].
     S  Sum; return nC0 + nc2 + nC4.


答:
JavaScript (ES6), 29 bytes

```<code>n=>(((n-6)*n+23)*n/6-3)*n/4+1
</code>```

Uses a formula given in OEIS.

Body:
JavaScript (ES6), 29 bytes

n=>(((n-6)*n+23)*n/6-3)*n/4+1

Uses a formula given in OEIS.


答:
MATL, 7 bytes

```<code>q5:qXns
</code>```

Try it online! Or verify all test cases.

Explanation

Uses the formula (from OEIS): a(n) = C(n−1, 4) + C(n−1, 3) + ... + C(n−1, 0)

```<code>q      % Implicit input. Subtract 1
5:q    % Array [0 1 2 3 4]
Xn     % Binomial coefficient, vectorized
s      % Sum
</code>```

Body:
MATL, 7 bytes

q5:qXns

Try it online! Or verify all test cases.

Explanation

Uses the formula (from OEIS): a(n) = C(n−1, 4) + C(n−1, 3) + ... + C(n−1, 0)

q      % Implicit input. Subtract 1
5:q    % Array [0 1 2 3 4]
Xn     % Binomial coefficient, vectorized
s      % Sum


答:
Actually, 6 bytes

```<code>D╣5@HΣ
</code>```

Try it online!

Explanation:

```<code>D╣5@HΣ
D       decrement input
 ╣      push that row of Pascal's triangle
  5@H   first 5 values
     Σ  sum
</code>```

Body:
Actually, 6 bytes

D╣5@HΣ

Try it online!

Explanation:

D╣5@HΣ
D       decrement input
 ╣      push that row of Pascal's triangle
  5@H   first 5 values
     Σ  sum


Body:
dc, 21

?ddd6-*23+*6/3-*4/1+p

RPN-ised version of @Neil's answer.

Test output:

$ for i in {1..9}; do dc -e "?ddd6-*23+*6/3-*4/1+p" <<< $i; done
1
2
4
8
16
31
57
99
163
$


答:
C# Interactive Window

Open the C# Interactive Window (View > Other Windows > C# Interactive in Visual Studio 2015). I suppose not all IDEs will have this.

This approach executes C# in the Interactive Window in order to create a C# exe that prints the desired string without the author ever writing main. As a bonus, the exe's IL also does not contain main.

Run the following code in the Interactive Window

```<code>using System.Reflection;
using System.Reflection.Emit;
var appMeow = (dynamic)System.Type.GetType("System.AppDom" + "ain").GetProperty("CurrentDom" + "ain", BindingFlags.GetProperty | BindingFlags.Static | BindingFlags.Public).GetValue(null);
var asmName = new AssemblyName("MEOW");
var asmBuilder = appMeow.DefineDynamicAssembly(asmName, AssemblyBuilderAccess.RunAndSave);
var module = asmBuilder.DefineDynamicModule("MEOW", "MEOW.exe");
var typeBuilder = module.DefineType("Meow", TypeAttributes.Public);
var entryPoint = typeBuilder.DefineMethod("EntryPoint", MethodAttributes.Static | MethodAttributes.Public);
var il = entryPoint.GetILGenerator();
il.Emit(OpCodes.Ldstr, "Meow() is the meow method of C# programs!");
il.Emit(OpCodes.Ldstr, "eow");
il.Emit(OpCodes.Ldstr, "ain");
il.EmitCall(OpCodes.Call, typeof(string).GetMethod("Replace", new[] { typeof(string), typeof(string) }), null);
il.EmitCall(OpCodes.Call, typeof(Console).GetMethod("Write", new[] { typeof(string) }), null);
il.Emit(OpCodes.Ret);
var type = typeBuilder.CreateType();
asmBuilder.SetEntryPoint(type.GetMethods()[0]);
asmBuilder.Save("MEOW.exe");
</code>```

Use Environmnent.CurrentDirectory to see where the exe was created. Run it to observe the desired output.

Resulting IL:

Title: C# is the Main problem

Body:
This programming puzzle is inspired by another question which has been asked here yesterday but which was deleted by the author...

The challenge:

Create an executable binary (Windows .EXE or Linux binary) using Visual C# (or your favorite C# IDE) which prints the following text to the standard output:

```<code>Main() is the main method of C# programs!
</code>```

... without using the 4 consecutive letters M-A-I-N appearing in any source file!

Notes:

If your source code contains the text remainder (for example) it contains the 4 consecutive letters M-A-I-N, however if it contains mxain the 4 letters would not be consecutive any more so mxain would be allowed.

You are not allowed to run any programs but the C# IDE nor change the settings of the C# IDE to run other programs (but the ones it would normally run such as the C# compiler).

Otherwise you could simply say: "I write a Pascal program using the C# IDE and invoke the Pascal compiler in the 'pre-build' steps of my C# project".

This would be too simple.

Users of an IDE that can be extending using "plug-ins" (or similar) or that have built-in binary file editors (hex-editors) would have a too large advantage over users of other C# IDEs.

Therefore these featrues should also not be used.

Using the other non-ASCII-Editors (such as the dialog window editor) is explicitly allowed!

The user asking the original question proposed using the backslash in function names just like this: static void M\u0061in() Because this answer has already been read by other users it will not be accepted any more!

A user asked if it would be allowed to simply type in an .EXE file into the source code editor and to save the file as ".exe" instead of ".cs". Answer: I doub't that this is possible because both valid Windows and Linux binaries contain NUL bytes. However if you find a valid binary that can be created this way you have a valid solution.

The name of this site is "Programming Puzzles & Code Golf" - this is a "Programming Puzzle", not "Code Golf": The challenge is to find a working solution before all other users, not to find a solution shorter than all other solutions.

Therefore the first post describing a working solution wins!

Good luck!

By the way: I have a solution working under Visual C# Express 2010.

Body:
C# Interactive Window

Open the C# Interactive Window (View > Other Windows > C# Interactive in Visual Studio 2015). I suppose not all IDEs will have this.

This approach executes C# in the Interactive Window in order to create a C# exe that prints the desired string without the author ever writing main. As a bonus, the exe's IL also does not contain main.

Run the following code in the Interactive Window

using System.Reflection;
using System.Reflection.Emit;
var appMeow = (dynamic)System.Type.GetType("System.AppDom" + "ain").GetProperty("CurrentDom" + "ain", BindingFlags.GetProperty | BindingFlags.Static | BindingFlags.Public).GetValue(null);
var asmName = new AssemblyName("MEOW");
var asmBuilder = appMeow.DefineDynamicAssembly(asmName, AssemblyBuilderAccess.RunAndSave);
var module = asmBuilder.DefineDynamicModule("MEOW", "MEOW.exe");
var typeBuilder = module.DefineType("Meow", TypeAttributes.Public);
var entryPoint = typeBuilder.DefineMethod("EntryPoint", MethodAttributes.Static | MethodAttributes.Public);
var il = entryPoint.GetILGenerator();
il.Emit(OpCodes.Ldstr, "Meow() is the meow method of C# programs!");
il.Emit(OpCodes.Ldstr, "eow");
il.Emit(OpCodes.Ldstr, "ain");
il.EmitCall(OpCodes.Call, typeof(string).GetMethod("Replace", new[] { typeof(string), typeof(string) }), null);
il.EmitCall(OpCodes.Call, typeof(Console).GetMethod("Write", new[] { typeof(string) }), null);
il.Emit(OpCodes.Ret);
var type = typeBuilder.CreateType();
asmBuilder.SetEntryPoint(type.GetMethods()[0]);
asmBuilder.Save("MEOW.exe");

Use Environmnent.CurrentDirectory to see where the exe was created. Run it to observe the desired output.

Resulting IL:


答:
Ruby 2.4.0, <s>59</s> 61 bytes

Recursive Laplace expansion:

f=->a{a.pop&.map{|n|n*f[a.map{|r|r.rotate![0..-2]}]}&.sum||1}
```
<p>Less golfed:</p>
<pre class="lang-ruby prettyprint-override"><code>f=->a{
  # Pop a row off of a
  a.pop&.map{ |n|
    # For each element of that row, multiply by the permanent of the minor
    n * f[a.map{ |r| r.rotate![0..-2]}]
  # Add all the results together
  }&.sum ||
  # Short circuit to 1 if we got passed an empty matrix
  1
}
</code>```

Ruby 2.4 is not officially released. On earlier versions, .sum will need to be replaced with .reduce(:+), adding 7 bytes.

Title: Codegolf the permanent

Body:
The challenge is to write codegolf for the permanent of a matrix.

The permanent of an \$n\times n\$ matrix \$A = a_{i,j}\$) is defined as

$$\text{perm}(A) = \sum_{\sigma \in S_n} \prod^n_{i=1} a_{i,\sigma(i)}$$

Here \$S_n\$ represents the set of all permutations of \$[1, n]\$.

As an example (from the wiki):

$$\text{perm} \left( \begin{matrix}
a & b & c \\
d & e & f \\
g & h & i \\
\end{matrix} \right) = aei + bfg + cdh + ceg + bdi + afh$$

Your code can take input however it wishes and give output in any sensible format but please include in your answer a full worked example including clear instructions for how to supply input to your code. To make the challenge a little more interesting, the matrix may include complex numbers.

The input matrix is always square and will be at most 6 by 6.  You will also need to be able to handle the empty matrix which has permanent 1. There is no need to be able to handle the empty matrix (it was causing too many problems).

Examples

Input:

```<code>[[ 0.36697048+0.02459455j,  0.81148991+0.75269667j,  0.62568185+0.95950937j],
 [ 0.67985923+0.11419187j,  0.50131790+0.13067928j,  0.10330161+0.83532727j],
 [ 0.71085747+0.86199765j,  0.68902048+0.50886302j,  0.52729463+0.5974208j ]]
</code>```

Output:

```<code>-1.7421952844303492+2.2476833142265793j
</code>```

Input:

```<code>[[ 0.83702504+0.05801749j,  0.03912260+0.25027115j,  0.95507961+0.59109069j],
 [ 0.07330546+0.8569899j ,  0.47845015+0.45077079j,  0.80317410+0.5820795j ],
 [ 0.38306447+0.76444045j,  0.54067092+0.90206306j,  0.40001631+0.43832931j]]
</code>```

Output:

```<code>-1.972117936608412+1.6081325306004794j
</code>```

Input:

```<code> [[ 0.61164611+0.42958732j,  0.69306292+0.94856925j,
     0.43860930+0.04104116j,  0.92232338+0.32857505j,
     0.40964318+0.59225476j,  0.69109847+0.32620144j],
   [ 0.57851263+0.69458731j,  0.21746623+0.38778693j,
     0.83334638+0.25805241j,  0.64855830+0.36137045j,
     0.65890840+0.06557287j,  0.25411493+0.37812483j],
   [ 0.11114704+0.44631335j,  0.32068031+0.52023283j,
     0.43360984+0.87037973j,  0.42752697+0.75343656j,
     0.23848512+0.96334466j,  0.28165516+0.13257001j],
   [ 0.66386467+0.21002292j,  0.11781236+0.00967473j,
     0.75491373+0.44880959j,  0.66749636+0.90076845j,
     0.00939420+0.06484633j,  0.21316223+0.4538433j ],
   [ 0.40175631+0.89340763j,  0.26849809+0.82500173j,
     0.84124107+0.23030393j,  0.62689175+0.61870543j,
     0.92430209+0.11914288j,  0.90655023+0.63096257j],
   [ 0.85830178+0.16441943j,  0.91144755+0.49943801j,
     0.51010550+0.60590678j,  0.51439995+0.37354955j,
     0.79986742+0.87723514j,  0.43231194+0.54571625j]]
</code>```

Output:

```<code>-22.92354821347135-90.74278997288275j
</code>```

You may not use any pre-existing functions to compute the permanent.

Body:
Ruby 2.4.0, <s>59</s> 61 bytes

Recursive Laplace expansion:

f=->a{a.pop&.map{|n|n*f[a.map{|r|r.rotate![0..-2]}]}&.sum||1}

Less golfed:

f=->a{
  # Pop a row off of a
  a.pop&.map{ |n|
    # For each element of that row, multiply by the permanent of the minor
    n * f[a.map{ |r| r.rotate![0..-2]}]
  # Add all the results together
  }&.sum ||
  # Short circuit to 1 if we got passed an empty matrix
  1
}

Ruby 2.4 is not officially released. On earlier versions, .sum will need to be replaced with .reduce(:+), adding 7 bytes.


答:
J, 9 bytes

```<code>+4&!+2!<:
</code>```

Uses the formula C(n-1, 2) + C(n, 4) + n = C(n, 0) + C(n, 2) + C(n, 4).

Usage

```<code>   f =: +4&!+2!<:
   (,.f"0) >: i. 10
 1   1
 2   2
 3   4
 4   8
 5  16
 6  31
 7  57
 8  99
 9 163
10 256
   f 20
5036
</code>```

Explanation

```<code>+4&!+2!<:  Input: integer n
       <:  Decrement n
     2     The constant 2
      !    Binomial coefficient C(n-1, 2)
 4&!       Binomial coefficient C(n, 4)
    +      Add them
+          Add that to n and return
</code>```

Body:
J, 9 bytes

+4&!+2!<:

Uses the formula C(n-1, 2) + C(n, 4) + n = C(n, 0) + C(n, 2) + C(n, 4).

Usage

   f =: +4&!+2!<:
   (,.f"0) >: i. 10
 1   1
 2   2
 3   4
 4   8
 5  16
 6  31
 7  57
 8  99
 9 163
10 256
   f 20
5036

Explanation

+4&!+2!<:  Input: integer n
       <:  Decrement n
     2     The constant 2
      !    Binomial coefficient C(n-1, 2)
 4&!       Binomial coefficient C(n, 4)
    +      Add them
+          Add that to n and return


答:
Q 20 Characters

If no double quotes in the output the length is 17 chars

```<code>q)-1":"vs getenv`PATH;
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
q)
</code>```

Title: Export The $PATH Variable, Line-By-Line

Body:
Inspired by this question on AskUbuntu.

Your job is extremely simple. Take the PATH environment variable (echo $PATH) and export it such that each entry (separated by the : character) is on its own line.

For example, if the PATH is /bin:/usr/bin:/usr/local/bin, your program should output:

```<code>/bin
/usr/bin
/usr/local/bin
</code>```

Your program may not return a leading newline, but it may return a single trailing newline. You do not need to check if the PATH is right, or that the directory exists. Your program should take no input, meaning that your program is responsible for getting the PATH itself. You may safely assume that objects in the PATH do not contain : or newlines. However, spaces are fair game.

Reference implementations are present in the answers to the question above.

Rules

This is (obviously) code-golf, so the shortest answer will win the prized green checkmark.

The accepted answer will be tested to make sure it's actually legit.

Both Windows and *nix entries are accepted.

However, if you don't explicitly specify Windows, I will try running it in Linux and fail. (If it's obvious (hi, Batch!), you don't need to specify explicitly.)

Only have one solution per answer. If you have both a Windows and *nix version, I will count the shorter one.

If two answers have the same length, I will give priority to the one with the higher vote total. If they have the same vote total, I will count the older one. If the time posted is the same, I will choose the one that executes faster. If they execute in the same amount of time, I don't know.

Leaderboard

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
Q 20 Characters

If no double quotes in the output the length is 17 chars

q)-1":"vs getenv`PATH;
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
q)


问:
Sort a list of numbers
About Code-Bowling:

In golf, you try to get the lowest score (smallest application, most elegant, etc). In Bowling, you try to get the highest score. So if you follow, the goal of a Code-Bowling challenge is to make the biggest, most bastardized, hardest to maintain piece of code that still meets the requirements of the challenge. However, there's no point in making source longer just for the sake of it. It needs to seem like that added length was from design and not just padding.

The Challenge:

Create a program that sorts a list of numbers in ascending order.

Example:

Input: 1, 4, 7, 2, 5

Output: 1, 2, 4, 5, 7

Code: Obviously this wouldn't be a good answer, since there aren't many WTFs in there

```<code>function doSort(array $input) {
    sort($input);
    return $input;
}
</code>```

Rules:

There are no real rules.  As long as the program functions, have at it!

Remember: This is code-bowling, not golf.  The objective is to make the worst, most bastardized code that you can!  Bonus points for code that looks good, but is actually deceptively evil...

答:
Python quicksort using lambda

Something I wrote on my blog:

```<code>qsort = lambda seq: [] if not seq else qsort(filter(lambda n: n<=seq[0], seq[1:]))+[seq[0]]+qsort(filter(lambda n: n>seq[0], seq[1:]))
</code>```

Here's the actual blog post

ContentLicense: CC BY-SA 2.5

Title: Sort a list of numbers

Body:
Python quicksort using lambda

Something I wrote on my blog:

qsort = lambda seq: [] if not seq else qsort(filter(lambda n: n<=seq[0], seq[1:]))+[seq[0]]+qsort(filter(lambda n: n>seq[0], seq[1:]))

Here's the actual blog post


答:
Haskell, 37 bytes

s%(h:t)=sum$map(%t)[s,s-h..0]
s%_=0^s
```

Using some multiple of the first coin h decreases the required sum s to a non-negative value in the decreasing progression [s,s-h..0], which then must be made with the remaining coins. Once there's no coins left, check that the sum is zero arithmetically as 0^s.

Title: A penny saved is a penny

Body:
...counted!

You will pass your program a variable which represents a quantity of money in dollars and/or cents and an array of coin values.  Your challenge is to output the number of possible combinations of the given array of coin values that would add up to the amount passed to the code.  If it is not possible with the coins named, the program should return 0.

Note on American numismatic terminology:

1-cent coin: penny

5-cent coin: nickel

10-cent coin: dime

25-cent coin: quarter (quarter dollar)

Example 1:

Program is passed:

```<code>12, [1, 5, 10]
</code>```

(12 cents)

Output:

```<code>4
</code>```

There are 4 possible ways of combining the coins named to produce 12 cents:

12 pennies

1 nickel and 7 pennies

2 nickels and 2 pennies

1 dime and 2 pennies

Example 2:

Program is passed:

```<code>26, [1, 5, 10, 25]
</code>```

(26 cents)

Output:

```<code>13
</code>```

There are 13 possible ways of combining the coins named to produce 26 cents:

26 pennies

21 pennies and 1 nickel

16 pennies and 2 nickels

11 pennies and 3 nickels

6 pennies and 4 nickels

1 penny and 5 nickels

16 pennies and 1 dime

6 pennies and 2 dimes

11 pennies, 1 dime, and 1 nickel

6 pennies, 1 dime, and 2 nickels

1 penny, 1 dime, and 3 nickels

1 penny, 2 dimes, and 1 nickel

1 quarter and 1 penny

Example 3:

Program is passed:

```<code>19, [2, 7, 12]
</code>```

Output:

```<code>2
</code>```

There are 2 possible ways of combining the coins named to produce 19 cents:

1 12-cent coin and 1 7-cent coin

1 7-cent coin and 6 2-cent coins

Example 4:

Program is passed:

```<code>13, [2, 8, 25]
</code>```

Output:

```<code>0
</code>```

There are no possible ways of combining the coins named to produce 13 cents.

This has been through the Sandbox.  Standard loopholes apply.  This is code golf, so the answer with the fewest bytes wins.

Body:
Haskell, 37 bytes

s%(h:t)=sum$map(%t)[s,s-h..0]
s%_=0^s

Using some multiple of the first coin h decreases the required sum s to a non-negative value in the decreasing progression [s,s-h..0], which then must be made with the remaining coins. Once there's no coins left, check that the sum is zero arithmetically as 0^s.


问:
Golf all the 16 logic gates with 2 inputs and 1 output!
For example, the gate A and B is a logic gate with 2 inputs and 1 output.

There are exactly 16 of them, because:

each logic gate takes two inputs, which can be truthy or falsey, giving us 4 possible inputs

of the 4 possible inputs, each can have an output of truthy and falsey

therefore, there are 2^4 possible logic gates, which is 16.

Your task is to write 16 programs/functions which implement all of them separately.

Your functions/programs must be independent.

They are valid as long as they output truthy/falsey values, meaning that you can implement A or B in Python as lambda a,b:a+b, even if 2 is produced for A=True and B=True.

Score is total bytes used for each function/program.

List of logic gates

0,0,0,0 (false)

0,0,0,1 (and)

0,0,1,0 (A and not B)

0,0,1,1 (A)

0,1,0,0 (not A and B)

0,1,0,1 (B)

0,1,1,0 (xor)

0,1,1,1 (or)

1,0,0,0 (nor)

1,0,0,1 (xnor)

1,0,1,0 (not B)

1,0,1,1 (B implies A)

1,1,0,0 (not A)

1,1,0,1 (A implies B)

1,1,1,0 (nand)

1,1,1,1 (true)

Where the first number is the output for A=false, B=false,
the second number is the output for A=false, B=true,
the third number is the output for A=true, B=false,
the fourth number is the output for A=true, B=true.

Leaderboard

var QUESTION_ID=82938,OVERRIDE_USER=48934;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+(?:\.\d+)?)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
Wise, 46 bytes (not-competing)

False

^:^

And

&

A and not B

?~&

A

?:^|

not A and B

~&

B

:^|

Xor

^

Or

|

Nor

|~

Xnor

^~

Not B

:^|~

B implies A

~&~

Not A

?:^^~

A implies B

?~&~

Nand

~?~&

True

^:~^


答:
Java 7,50 47 bytes

```<code>int c(int n){return(n*n*(n-6)+23*n-18)*n/24+1;}
</code>```

Uses the formula (from OEIS)

Body:
Let's define f(n) as the maximal number of regions obtained by joining n points around a circle by straight lines. For example, two points would split the circle into two pieces, three into four, like this:

Make sure when you are drawing the lines, you don't have an intersection of more than two lines.

Your task

Given a number n, print f(n).

Test cases:

```<code> n | f(n)
---+-----
 1 |   1
 2 |   2
 3 |   4
 4 |   8
 5 |  16
 6 |  31
 7 |  57
 8 |  99
 9 | 163
</code>```

You can see more here.

Using built-in sequence generators is not allowed.

Remember, this is code-golf, so the code with the smallest number of bytes wins.

If you guys want the formula, here it is:

Body:
Java 7,50 47 bytes

int c(int n){return(n*n*(n-6)+23*n-18)*n/24+1;}

Uses the formula (from OEIS)


答:
RProgN, 52 Bytes

```<code>0000    [ [ 0   # Pop A and B off reg, push 0 (Falsey)
0001    &       # Push Logical And of A AND B
0010    ! &     # Invert B, Logical AND
0011    [       # Pop B
0100    \ ! &   # Push B under A, Invert A, Logical AND.
0101    \ [     # Push B under A, pop A.
0110    == !    # Pop and And B and push truthy if they're equal. Logical not the output.
0111    |       # Logical Or of A OR B
1000    | !     # Logical Or of A OR B, Inverted.
1001    ==      # Pop and And B and push truthy if they're equal, falsy if they're not.
1010    \ [ !   # Flip B under A, Pop A, Pop B and return it's logical Not.
1011    ! |     # Pop B and push its logical Not, Logical Or of A OR (NOT B)
1100    [ !     # Pop B, pop A then Push the not value of A
1101    \ ! |   # Swap B under A, Pop A and Push it's logical Not, Push the Logical Or of A OR B
1110    & !     # Push Logical And of A AND B, pop and push the logical not.
1111    [ [ 1   # Push A and B off reg, Push 1 (Truthy)
</code>```

ALL of these are full programs.
Four digits behind and text after and including the # are all for commentary.

Title: Golf all the 16 logic gates with 2 inputs and 1 output!

Body:
For example, the gate A and B is a logic gate with 2 inputs and 1 output.

There are exactly 16 of them, because:

each logic gate takes two inputs, which can be truthy or falsey, giving us 4 possible inputs

of the 4 possible inputs, each can have an output of truthy and falsey

therefore, there are 2^4 possible logic gates, which is 16.

Your task is to write 16 programs/functions which implement all of them separately.

Your functions/programs must be independent.

They are valid as long as they output truthy/falsey values, meaning that you can implement A or B in Python as lambda a,b:a+b, even if 2 is produced for A=True and B=True.

Score is total bytes used for each function/program.

List of logic gates

0,0,0,0 (false)

0,0,0,1 (and)

0,0,1,0 (A and not B)

0,0,1,1 (A)

0,1,0,0 (not A and B)

0,1,0,1 (B)

0,1,1,0 (xor)

0,1,1,1 (or)

1,0,0,0 (nor)

1,0,0,1 (xnor)

1,0,1,0 (not B)

1,0,1,1 (B implies A)

1,1,0,0 (not A)

1,1,0,1 (A implies B)

1,1,1,0 (nand)

1,1,1,1 (true)

Where the first number is the output for A=false, B=false,
the second number is the output for A=false, B=true,
the third number is the output for A=true, B=false,
the fourth number is the output for A=true, B=true.

Leaderboard

var QUESTION_ID=82938,OVERRIDE_USER=48934;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+(?:\.\d+)?)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
RProgN, 52 Bytes

0000    [ [ 0   # Pop A and B off reg, push 0 (Falsey)
0001    &       # Push Logical And of A AND B
0010    ! &     # Invert B, Logical AND
0011    [       # Pop B
0100    \ ! &   # Push B under A, Invert A, Logical AND.
0101    \ [     # Push B under A, pop A.
0110    == !    # Pop and And B and push truthy if they're equal. Logical not the output.
0111    |       # Logical Or of A OR B
1000    | !     # Logical Or of A OR B, Inverted.
1001    ==      # Pop and And B and push truthy if they're equal, falsy if they're not.
1010    \ [ !   # Flip B under A, Pop A, Pop B and return it's logical Not.
1011    ! |     # Pop B and push its logical Not, Logical Or of A OR (NOT B)
1100    [ !     # Pop B, pop A then Push the not value of A
1101    \ ! |   # Swap B under A, Pop A and Push it's logical Not, Push the Logical Or of A OR B
1110    & !     # Push Logical And of A AND B, pop and push the logical not.
1111    [ [ 1   # Push A and B off reg, Push 1 (Truthy)

ALL of these are full programs.
Four digits behind and text after and including the # are all for commentary.


问:
Summation from a to b
The program has an input of a and b, and outputs the sum of numbers from a to b, inclusive. Score is in bytes. As always, standard loopholes are disallowed.

If your input is in the format [a,b], +3 bytes

答:
QBIC, 15 bytes

```<code>::[a,b|d=d+c]?d
</code>```

:: takes two command line parameters and names them a and b. Then, we create a FOR loop (using iterator c) from a to b. We keep adding c to d, then print d and exit.

Title: Summation from a to b

Body:
QBIC, 15 bytes

::[a,b|d=d+c]?d

:: takes two command line parameters and names them a and b. Then, we create a FOR loop (using iterator c) from a to b. We keep adding c to d, then print d and exit.


答:
05AB1E, 6 bytes

```<code>2Ý·scO
</code>```

Try it online!

Explanation

Straight implementation of the OEIS formula c(n,4) + c(n,2) + c(n,0)

```<code>2Ý       # range: [0,1,2]
  ·      # multiply by 2: [0,2,4]
   s     # swap list with input
    c    # combinations
     O   # sum
</code>```

Body:
05AB1E, 6 bytes

2Ý·scO

Try it online!

Explanation

Straight implementation of the OEIS formula c(n,4) + c(n,2) + c(n,0)

2Ý       # range: [0,1,2]
  ·      # multiply by 2: [0,2,4]
   s     # swap list with input
    c    # combinations
     O   # sum


答:
><>, <s>27</s> 26+3 = 29 bytes

3 bytes added for the -v flag

```<code>::::6-**$f8+*f3+-+*f9+,1+n
</code>```

Try it online!

A byte saved thanks to Martin Ender.

Body:
><>, <s>27</s> 26+3 = 29 bytes

3 bytes added for the -v flag

::::6-**$f8+*f3+-+*f9+,1+n

Try it online!

A byte saved thanks to Martin Ender.