答:
Cubix, 17 bytes

```<code>..U;I0-!@;)wONow!
</code>```

Try it here

Cubix is a 2D language created by @ETHProductions where the commands are wrapped onto a cube.  This program wraps onto a cube with an edge length of 2 as follows.

```<code>    . .
    U ;
I 0 - ! @ ; ) w
O N o w ! . . .
    . .
    . .
</code>```

I gets the integer input

0 push 0 to the stack

- subtract top items of stack

! if truthy jump the next command @ terminate

; pop the subtraction result from the stack

) increment top of stack

w move ip to the right and carry on.  This causes it to drop to the next line

O output the top of stack as a number

N push linefeed (10) to the stack

o output a linefeed

w move ip to the right and carry on.  This causes it to drop to the next face

! because TOS truthy, jump the @ terminate

; pop the linefeed from the stack

U uturn to the left onto the - subtraction and resume from there

Title: Count up folks!

Body:
Introduction

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

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

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

Challenge

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

Rules

You can get n any way.

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

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

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

Standard loopholes are denied.

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

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

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

Bonuses

20%

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

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

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

Body:
Cubix, 17 bytes

..U;I0-!@;)wONow!

Try it here

Cubix is a 2D language created by @ETHProductions where the commands are wrapped onto a cube.  This program wraps onto a cube with an edge length of 2 as follows.

    . .
    U ;
I 0 - ! @ ; ) w
O N o w ! . . .
    . .
    . .

I gets the integer input

0 push 0 to the stack

- subtract top items of stack

! if truthy jump the next command @ terminate

; pop the subtraction result from the stack

) increment top of stack

w move ip to the right and carry on.  This causes it to drop to the next line

O output the top of stack as a number

N push linefeed (10) to the stack

o output a linefeed

w move ip to the right and carry on.  This causes it to drop to the next face

! because TOS truthy, jump the @ terminate

; pop the linefeed from the stack

U uturn to the left onto the - subtraction and resume from there


问:
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>```

答:
Julia, 37 bytes

```<code>x->sum(log2(endof(x)./sum(x.==x',1)))
</code>```

Takes a character array as input. Try it online!

ContentLicense: CC BY-SA 3.0

Body:
Julia, 37 bytes

x->sum(log2(endof(x)./sum(x.==x',1)))

Takes a character array as input. Try it online!


问:
Generate a parity bit
A parity bit, is one of the simplest forms of a checksum. First, you have to pick the parity, even or odd. Let's say we pick even. Now, we need a message to transmit. Let's say our message is "Foo". This is written in binary as:

```<code>01000110 01101111 01101111
</code>```

Now, we count the total number of 1's in there, which is 15. Since 15 is an odd number, we must add one extra bit to the end of our message, and we will now have an even number of 'on' bits. This last added bit is known as the "parity bit". If we had picked an odd parity for our checksum, we would have to add an extra '0' so that the number of on bits remains odd.

The challenge:

You must write a program or function that determines what the correct parity bit for a string is. Your program must take two inputs:

A string, s. This is the message that the checksum will be calculated on. This will be restricted to the 95 printable ASCII characters.

A character or single character string p, that will either be e for even parity, or o for odd parity.

and produce a truthy-falsey value representing the correct parity bit. Truthy if it's a 1, and falsey if it's a 0.

Builtins that count the number of "on" bits in a string or character are not allowed. For example, a function f that does this: f('a') == 3 or f('foo') == 16 is banned. Anything else, such as base conversion, is fair game.

Test IO:

```<code>(without the quotes)
s: "0"
p: 'e'
output: 0

s: "Foo"
p: 'e'
output: 1

s: "Hello World!"
p: 'o'
output: 0

s: "Alex is right"
p: 'e'
output: 1

s: "Programming Puzzles and Code-Golf"
p: 'e'
output: 0

s: "Programming Puzzles and Code-Golf"
p: 'o'
output: 1
</code>```

This is codegolf, so standard loopholes apply, and the shortest answer in bytes wins.

Leaderboard

var QUESTION_ID=78569,OVERRIDE_USER=31716;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

```

答:
Java, 97 bytes

Because, ya know, Java.

(s,c)->{boolean e=1>0;for(int i:s.getBytes())while(i>0){if(i%2==1)e=!e;i/=2;}return c=='o'?e:!e;}
```

This is a lambda for a BiFunction<String, Character, Boolean>.

e and o appear to be reversed in the return statement because apparently my logic was backwards.

Title: Generate a parity bit

Body:
Java, 97 bytes

Because, ya know, Java.

(s,c)->{boolean e=1>0;for(int i:s.getBytes())while(i>0){if(i%2==1)e=!e;i/=2;}return c=='o'?e:!e;}

This is a lambda for a BiFunction<String, Character, Boolean>.

e and o appear to be reversed in the return statement because apparently my logic was backwards.


问:
Code Golf : Parsing google results
When you search something on google, within the results page, the user can see green links, for the first page of results.

In the shortest form possible, in bytes, using any language, display those links to stdout in the form of a list. Here is an example, for the first results of the stack exchange query :

Input :

you choose : the URL (www.google.com/search?q=stackexchange&ie=utf-8&oe=utf-8) or just stackexchange

Output :

```<code>french.stackexchange.com/, stackoverflow.com/, fr.wikipedia.org/wiki/Stack_Exchange_Network, en.wikipedia.org/wiki/Stack_Exchange,...
</code>```

Rules :

You may use URL shorteners or other search tools/APIs as long as the results would be the same as searching https://www.google.com.

It's ok if your program has side effects like opening a web browser so the cryptic Google html/js pages can be read as they are rendered.

You may use browser plugins, userscripts...

If you can't use stdout, print it to the screen with, eg. a popup or javascript alert !

You don't need the ending / or the starting http(s)://

You should not show any other link

Shortest code wins !

Good luck !

EDIT :
This golf ends the 07/08/15.

答:
Factor, 31 bytes

There happens to be a library for this.

```<code>[ google-search [ url>> ] map ]
</code>```

ContentLicense: CC BY-SA 4.0

Title: Code Golf : Parsing google results

Body:
Factor, 31 bytes

There happens to be a library for this.

[ google-search [ url>> ] map ]


问:
Count up folks!

Introduction

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

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

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

Challenge

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

Rules

You can get n any way.

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

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

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

Standard loopholes are denied.

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

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

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

Bonuses

20%

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

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

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

答:
Hoon, 13 bytes

```<code>(cury gulf 1)
</code>```

++gulf returns a list containing the numbers from a to b. Returned a curried function with 1 for a.

Usage:

```<code>> %.  9
  (cury gulf 1)
~[1 2 3 4 5 6 7 8 9]
</code>```

Title: Count up folks!

Body:
Hoon, 13 bytes

(cury gulf 1)

++gulf returns a list containing the numbers from a to b. Returned a curried function with 1 for a.

Usage:

> %.  9
  (cury gulf 1)
~[1 2 3 4 5 6 7 8 9]


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

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

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

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

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

答:
Hoon, 32 bytes

```<code>|*
a/*
?<
=(a "google")
(lent a)
</code>```

Uses a wet gate to avoid having to specify a/tape instead of a/*, assert that a doesn't equal "google" or panic, return the length of the tape.

```<code>> %.  "abc"
  |*
  a/*
  ?<
  =(a "google")
  (lent a)
3
> %.  "google"
  |*
  a/*
  ?<
  =(a "google")
  (lent a)
ford: build failed ~[/g/~dirdet-lasmes-digwyc-ribrux--rispyx-bitrus-bidmut-winsud/use/dojo/~dirdet-lasmes-digwyc-ribrux--rispyx-bitrus-bidmut-winsud/inn/hand /g/~dirdet-lasmes-digwyc-ribrux--rispyx-bitrus-bidmut-winsud/use/hood/~dirdet-lasmes-digwyc-ribrux--rispyx-bitrus-bidmut-winsud/out/dojo/drum/phat/~dirdet-lasmes-digwyc-ribrux--rispyx-bitrus-bidmut-winsud/dojo /d //term/1]
</code>```

Title: Don't google "google"

Body:
Hoon, 32 bytes

|*
a/*
?<
=(a "google")
(lent a)

Uses a wet gate to avoid having to specify a/tape instead of a/*, assert that a doesn't equal "google" or panic, return the length of the tape.

> %.  "abc"
  |*
  a/*
  ?<
  =(a "google")
  (lent a)
3
> %.  "google"
  |*
  a/*
  ?<
  =(a "google")
  (lent a)
ford: build failed ~[/g/~dirdet-lasmes-digwyc-ribrux--rispyx-bitrus-bidmut-winsud/use/dojo/~dirdet-lasmes-digwyc-ribrux--rispyx-bitrus-bidmut-winsud/inn/hand /g/~dirdet-lasmes-digwyc-ribrux--rispyx-bitrus-bidmut-winsud/use/hood/~dirdet-lasmes-digwyc-ribrux--rispyx-bitrus-bidmut-winsud/out/dojo/drum/phat/~dirdet-lasmes-digwyc-ribrux--rispyx-bitrus-bidmut-winsud/dojo /d //term/1]


问:
Polynomialception
Given two polynomials f,g of arbitrary degree over the integers, your program/function should evaluate the first polynomial in the second polynomial. f(g(x)) (a.k.a. the composition (fog)(x) of the two polynomials)

Details

Builtins are allowed. You can assume any reasonable formatting as input/output, but the input and output format should match. E.g. formatting as a string

```<code>x^2+3x+5
</code>```

or as as list of coefficients:

```<code>[1,3,5] or alternatively [5,3,1]
</code>```

Furthermore the input polynomials can be assumed to be fully expanded, and the outputs are also expected to be fully expanded.

Examples

```<code>A(x) = x^2 + 3x + 5, B(y) = y+1
A(B(y)) = (y+1)^2 + 3(y+1) + 5 = y^2 + 5y + 9

A(x) = x^6 + x^2 + 1, B(y) = y^2 - y
A(B(y))= y^12 - 6y^11 + 15y^10 - 20y^9 + 15y^8 - 6y^7 + y^6 + y^4 - 2 y^3 + y^2 + 1

A(x) = 24x^3 - 144x^2 + 288x - 192, B(y) = y + 2
A(B(y)) = 24y^3

A(x) = 3x^4 - 36x^3 + 138x^2 - 180x + 27, B(y) = 2y + 3
A(B(y)) = 48y^4 - 96y^2
</code>```

答:
JavaScript (ES6), <s>150</s> 103 bytes

```<code>(f,g)=>f.map(n=>r=p.map((m,i)=>(g.map((n,j)=>p[j+=i]=m*n+(p[j]||0)),m*n+(r[i]||0)),p=[]),r=[],p=[1])&&r
</code>```

Accepts and returns polynomials as an array a = [a0, a1, a2, ...] that represents a0 + a1*x + a2*x2 ...

Edit: Saved 47 bytes by switching from recursive to iterative polynomial multiplication, which then allowed me to merge two map calls.

Explanation: r is the result, which starts at zero, represented by an empty array, and p is gh, which starts at one. p is multiplied by each fh in turn, and the result accumulated in r. p is also multiplied by g at the same time.

```<code>(f,g)=>f.map(n=>            Loop through each term of f (n = f[h])
 r=p.map((m,i)=>(           Loop through each term of p (m = p[i])
  g.map((n,j)=>             Loop though each term of g (n = g[j])
   p[j+=i]=m*n+(p[j]||0)),  Accumulate p*g in p
  m*n+(r[i]||0)),           Meanwhile add p[i]*f[h] to r[i]
  p=[]),                    Reset p to 0 each loop to calculate p*g
 r=[],                      Initialise r to 0
 p=[1]                      Initialise p to 1
)&&r                        Return the result
</code>```

Title: Polynomialception

Body:
JavaScript (ES6), <s>150</s> 103 bytes

(f,g)=>f.map(n=>r=p.map((m,i)=>(g.map((n,j)=>p[j+=i]=m*n+(p[j]||0)),m*n+(r[i]||0)),p=[]),r=[],p=[1])&&r

Accepts and returns polynomials as an array a = [a0, a1, a2, ...] that represents a0 + a1*x + a2*x2 ...

Edit: Saved 47 bytes by switching from recursive to iterative polynomial multiplication, which then allowed me to merge two map calls.

Explanation: r is the result, which starts at zero, represented by an empty array, and p is gh, which starts at one. p is multiplied by each fh in turn, and the result accumulated in r. p is also multiplied by g at the same time.

(f,g)=>f.map(n=>            Loop through each term of f (n = f[h])
 r=p.map((m,i)=>(           Loop through each term of p (m = p[i])
  g.map((n,j)=>             Loop though each term of g (n = g[j])
   p[j+=i]=m*n+(p[j]||0)),  Accumulate p*g in p
  m*n+(r[i]||0)),           Meanwhile add p[i]*f[h] to r[i]
  p=[]),                    Reset p to 0 each loop to calculate p*g
 r=[],                      Initialise r to 0
 p=[1]                      Initialise p to 1
)&&r                        Return the result


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

```<code>OBFSḂ⁼V}
</code>```

Try it online!

```<code>O         convert each character in argument 1 (left arg) to its codepoint (ord)
 B        convert to binary (list of 0s and 1s)
  F       flatten
   S      sum the entire list, giving the number of 1s in the entire string
    Ḃ     mod 2 (take the last bit)
       }  now, with the second (right) argument...
      V   eval with no arguments. This returns...
            1 for e because it expands to 0e0 (i.e., does 0 exist in [0])
            0 for o because it expands to 0o0 (0 OR 0, false OR false, false)
     ⁼    test equality between the two results
</code>```

Thanks to Dennis for a byte!

Title: Generate a parity bit

Body:
A parity bit, is one of the simplest forms of a checksum. First, you have to pick the parity, even or odd. Let's say we pick even. Now, we need a message to transmit. Let's say our message is "Foo". This is written in binary as:

```<code>01000110 01101111 01101111
</code>```

Now, we count the total number of 1's in there, which is 15. Since 15 is an odd number, we must add one extra bit to the end of our message, and we will now have an even number of 'on' bits. This last added bit is known as the "parity bit". If we had picked an odd parity for our checksum, we would have to add an extra '0' so that the number of on bits remains odd.

The challenge:

You must write a program or function that determines what the correct parity bit for a string is. Your program must take two inputs:

A string, s. This is the message that the checksum will be calculated on. This will be restricted to the 95 printable ASCII characters.

A character or single character string p, that will either be e for even parity, or o for odd parity.

and produce a truthy-falsey value representing the correct parity bit. Truthy if it's a 1, and falsey if it's a 0.

Builtins that count the number of "on" bits in a string or character are not allowed. For example, a function f that does this: f('a') == 3 or f('foo') == 16 is banned. Anything else, such as base conversion, is fair game.

Test IO:

```<code>(without the quotes)
s: "0"
p: 'e'
output: 0

s: "Foo"
p: 'e'
output: 1

s: "Hello World!"
p: 'o'
output: 0

s: "Alex is right"
p: 'e'
output: 1

s: "Programming Puzzles and Code-Golf"
p: 'e'
output: 0

s: "Programming Puzzles and Code-Golf"
p: 'o'
output: 1
</code>```

This is codegolf, so standard loopholes apply, and the shortest answer in bytes wins.

Leaderboard

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

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

OBFSḂ⁼V}

Try it online!

O         convert each character in argument 1 (left arg) to its codepoint (ord)
 B        convert to binary (list of 0s and 1s)
  F       flatten
   S      sum the entire list, giving the number of 1s in the entire string
    Ḃ     mod 2 (take the last bit)
       }  now, with the second (right) argument...
      V   eval with no arguments. This returns...
            1 for e because it expands to 0e0 (i.e., does 0 exist in [0])
            0 for o because it expands to 0o0 (0 OR 0, false OR false, false)
     ⁼    test equality between the two results

Thanks to Dennis for a byte!


Title: Generate a parity bit

Body:
JavaScript (ES6), 69 bytes

(s,p)=>[...s].map(c=>{for(n=c.charCodeAt();n;n>>=1)r^=n&1},r=p>"e")|r


答:
PGP, 28 Bytes

PHP Golf Processor (https://github.com/barkermn01/PGP-php-CodeGolf/)
to run it php pgp.php file.pgp or php pgp.php '{code here}'

```<code>f(;$i!=$argv[1];)e ++$i." ";
</code>```

Title: Count up folks!

Body:
PGP, 28 Bytes

PHP Golf Processor (https://github.com/barkermn01/PGP-php-CodeGolf/)
to run it php pgp.php file.pgp or php pgp.php '{code here}'

f(;$i!=$argv[1];)e ++$i." ";


问:
Reverse positive runs

Input

Your input is a list of single-digit numbers in any reasonable format, including a string of digits.
The input will not be empty.

Output

Your output shall be the input list, but with each maximal run of nonzero digits being reversed.

Example

Consider the input

```<code>95883007414830
<--->  <---->
</code>```

where the nonzero runs have been marked with arrows.
Reversing each of these runs, we obtain the output

```<code>38859003841470
</code>```

Rules and scoring

You can write a full program or a function.
The lowest byte count wins, and standard loopholes are disallowed.

This challenge is related, but much more complex, since it includes additional string processing.

Test cases

```<code>4 -> 4
00 -> 00
123 -> 321
0010 -> 0010
12000345 -> 21000543
18161604 -> 61618104
95883007414830 -> 38859003841470
010230456078912 -> 010320654021987
357509902003550 -> 575309902005530
2492882377675046 -> 5767732882942064
03026302053000357099 -> 03036202035000753099
</code>```

Leaderboard

Here's a Stack Snippet to generate a leaderboard and list of winners by language.
To make sure your answer shows up, start it with a header of the form

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

You can keep old scores in the header by using the strikethrough tags: <s>57</s> will appear as <s>57</s>.

/* Configuration */

var QUESTION_ID = 78510; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 32014; // This should be the user ID of the challenge author.

/* App */

var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;

function answersUrl(index) {
  return "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

function commentUrl(index, answers) {
  return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}

function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}

function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });
}

getAnswers();

var SCORE_REG = /<h\d>\s*([^\n,]*[^\s,]),.*?(-?\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

var OVERRIDE_REG = /^Override\s*header:\s*/i;

function getAuthorName(a) {
  return a.owner.display_name;
}

function process() {
  var valid = [];

  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '
' + c.body.replace(OVERRIDE_REG, '') + '
';
    });

    var match = body.match(SCORE_REG);
    if (match)
      valid.push({
        user: getAuthorName(a),
        size: +match[2],
        language: match[1],
        link: a.share_link,
      });

  });

  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });

  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;

    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);

    var lang = a.language;
    if (! /<a/.test(lang)) lang = '' + lang + '';
    lang = jQuery(lang).text().toLowerCase();

    languages[lang] = languages[lang] || {lang: a.language, user: a.user, size: a.size, link: a.link, uniq: lang};
  });

  var langs = [];
  for (var lang in languages)
    if (languages.hasOwnProperty(lang))
      langs.push(languages[lang]);

  langs.sort(function (a, b) {
    if (a.uniq > b.uniq) return 1;
    if (a.uniq < b.uniq) return -1;
    return 0;
  });

  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.size)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }

}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body { text-align: left !important}

#answer-list {
  padding: 10px;
  width: 290px;
  float: left;
}

#language-list {
  padding: 10px;
  width: 290px;
  float: left;
}

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}</code>```

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
Julia, 30 bytes

```<code>s->replace(s,r"[^0]+",reverse)
</code>```

This is an anonymous function that accepts a string and returns a string. To call it, assign it to a variable.

The replace function provides the ability to replace matches of a regular expression with the result of a function applied to each match. In this case we can get nonzeros using [^0]+ and replace those runs with the result of the reverse function applied to the matched text.

Verify all test cases online!

Title: Reverse positive runs

Body:
Julia, 30 bytes

s->replace(s,r"[^0]+",reverse)

This is an anonymous function that accepts a string and returns a string. To call it, assign it to a variable.

The replace function provides the ability to replace matches of a regular expression with the result of a function applied to each match. In this case we can get nonzeros using [^0]+ and replace those runs with the result of the reverse function applied to the matched text.

<a href="http://julia.tryitonline.net/#code=Zj1zLT5yZXBsYWNlKHMsciJbXjBdKyIscmV2ZXJzZSkKCmZvciBjYXNlIGluIFsoIjQiLCAiNCIpLAogICAgICAgICAgICAgKCIwMCIsICIwMCIpLAogICAgICAgICAgICAgKCIxMjMiLCAiMzIxIiksCiAgICAgICAgICAgICAoIjAwMTAiLCAiMDAxMCIpLAogICAgICAgICAgICAgKCIxMjAwMDM0NSIsICIyMTAwMDU0MyIpLAogICAgICAgICAgICAgKCIxODE2MTYwNCIsICI2MTYxODEwNCIpLAogICAgICAgICAgICAgKCI5NTg4MzAwNzQxNDgzMCIsICIzODg1OTAwMzg0MTQ3MCIpLAogICAgICAgICAgICAgKCIwMTAyMzA0NTYwNzg5MTIiLCAiMDEwMzIwNjU0MDIxOTg3IiksCiAgICAgICAgICAgICAoIjM1NzUwOTkwMjAwMzU1MCIsICI1NzUzMDk5MDIwMDU1MzAiKSwKICAgICAgICAgICAgICgiMjQ5Mjg4MjM3NzY3NTA0NiIsICI1NzY3NzMyODgyOTQyMDY0IiksCiAgICAgICAgICAgICAoIjAzMDI2MzAyMDUzMDAwMzU3MDk5IiwgIjAzMDM2MjAyMDM1MDAwNzUzMDk5IildCiAgICBwcmludGxuKGYoY2FzZVsxXSkgPT0gY2FzZVsyXSkKZW5k&input=" rel="nofollow">Verify all test cases online!


答:
F#, 103 bytes

```<code>let f x=x="";x.Split '0'|>Array.map(fun s->System.String(s|>Seq.toArray|>Array.rev))|>String.concat "0"
</code>```

Title: Reverse positive runs

Body:
Input

Your input is a list of single-digit numbers in any reasonable format, including a string of digits.
The input will not be empty.

Output

Your output shall be the input list, but with each maximal run of nonzero digits being reversed.

Example

Consider the input

```<code>95883007414830
<--->  <---->
</code>```

where the nonzero runs have been marked with arrows.
Reversing each of these runs, we obtain the output

```<code>38859003841470
</code>```

Rules and scoring

You can write a full program or a function.
The lowest byte count wins, and standard loopholes are disallowed.

This challenge is related, but much more complex, since it includes additional string processing.

Test cases

```<code>4 -> 4
00 -> 00
123 -> 321
0010 -> 0010
12000345 -> 21000543
18161604 -> 61618104
95883007414830 -> 38859003841470
010230456078912 -> 010320654021987
357509902003550 -> 575309902005530
2492882377675046 -> 5767732882942064
03026302053000357099 -> 03036202035000753099
</code>```

Leaderboard

Here's a Stack Snippet to generate a leaderboard and list of winners by language.
To make sure your answer shows up, start it with a header of the form

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

You can keep old scores in the header by using the strikethrough tags: <s>57</s> will appear as <s>57</s>.

/* Configuration */

var QUESTION_ID = 78510; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 32014; // This should be the user ID of the challenge author.

/* App */

var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;

function answersUrl(index) {
  return "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

function commentUrl(index, answers) {
  return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}

function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}

function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });
}

getAnswers();

var SCORE_REG = /<h\d>\s*([^\n,]*[^\s,]),.*?(-?\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

var OVERRIDE_REG = /^Override\s*header:\s*/i;

function getAuthorName(a) {
  return a.owner.display_name;
}

function process() {
  var valid = [];

  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '
' + c.body.replace(OVERRIDE_REG, '') + '
';
    });

    var match = body.match(SCORE_REG);
    if (match)
      valid.push({
        user: getAuthorName(a),
        size: +match[2],
        language: match[1],
        link: a.share_link,
      });

  });

  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });

  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;

    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);

    var lang = a.language;
    if (! /<a/.test(lang)) lang = '' + lang + '';
    lang = jQuery(lang).text().toLowerCase();

    languages[lang] = languages[lang] || {lang: a.language, user: a.user, size: a.size, link: a.link, uniq: lang};
  });

  var langs = [];
  for (var lang in languages)
    if (languages.hasOwnProperty(lang))
      langs.push(languages[lang]);

  langs.sort(function (a, b) {
    if (a.uniq > b.uniq) return 1;
    if (a.uniq < b.uniq) return -1;
    return 0;
  });

  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.size)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }

}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body { text-align: left !important}

#answer-list {
  padding: 10px;
  width: 290px;
  float: left;
}

#language-list {
  padding: 10px;
  width: 290px;
  float: left;
}

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}</code>```

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
F#, 103 bytes

let f x=x="";x.Split '0'|>Array.map(fun s->System.String(s|>Seq.toArray|>Array.rev))|>String.concat "0"


答:
C, 62 bytes

12 bytes saved thanks to @LevelRiverSt and @TonHospel.

XOR has the nice property that it can be used to reduce strings down to one char, while preserving parity.

f(s,p)char*s;{for(p/=8;*s;)p^=*s>>4^*s++;p^=p/4;return p%4%3;}
```

Ideone.

Title: Generate a parity bit

Body:
C, 62 bytes

12 bytes saved thanks to @LevelRiverSt and @TonHospel.

XOR has the nice property that it can be used to reduce strings down to one char, while preserving parity.

f(s,p)char*s;{for(p/=8;*s;)p^=*s>>4^*s++;p^=p/4;return p%4%3;}

Ideone.


答:
Ruby, 57 bytes

If 0 was falsey in Ruby, the == could probably be switched to just -, or there could be other optimizations, but it isn't.

```<code>->s,b{s.gsub(/./){$&.ord.to_s 2}.count(?1)%2==(b>?i?0:1)}
</code>```

Title: Generate a parity bit

Body:
Ruby, 57 bytes

If 0 was falsey in Ruby, the == could probably be switched to just -, or there could be other optimizations, but it isn't.

->s,b{s.gsub(/./){$&.ord.to_s 2}.count(?1)%2==(b>?i?0:1)}


答:
APL, <s>18</s> 14 bytes

```<code>+/2⍟≢÷(+/∘.=⍨)
</code>```

This is an unnamed, monadic function train that accepts a string on the right and returns a real.

Like all good things in life, this uses xnor's formula. We get a matrix of booleans corresponding to the occurrences of each character in the string using ∘.=⍨, sum this along the first axis (+/) to get the number of occurrences of each character, divide the length of the string by each, then take log base 2 (2⍟) and sum.

Try it here

Saved 4 bytes thanks to Dennis!

Title: Compute the histogram entropy estimation of a string

Body:
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>```

Body:
APL, <s>18</s> 14 bytes

+/2⍟≢÷(+/∘.=⍨)

This is an unnamed, monadic function train that accepts a string on the right and returns a real.

Like all good things in life, this uses xnor's formula. We get a matrix of booleans corresponding to the occurrences of each character in the string using ∘.=⍨, sum this along the first axis (+/) to get the number of occurrences of each character, divide the length of the string by each, then take log base 2 (2⍟) and sum.

Try it here

Saved 4 bytes thanks to Dennis!


答:
Julia, <s>58</s> <s>47</s> <s>45</s> 40 bytes

f(s,p)=(p>'e')$endof(prod(bin,s)∩49)&1
```

This is a function that accepts a string and a character and returns an integer.

To get the number of ones in the binary representation, we first apply the bin function to each character in the string, which gives us an array of binary strings. Then reduce them into one using prod (since * is string concatenation in Julia) and take the set intersection of that string and the character code for 1, which gives us a string of ones. The last index of that string is the number of ones. We XOR this with 1 if the provided character is o and 0 otherwise, then get the parity using bitwise AND 1.

Try it online! (includes all test cases)

Saved 18 bytes thanks to Dennis!

Title: Generate a parity bit

Body:
Julia, <s>58</s> <s>47</s> <s>45</s> 40 bytes

f(s,p)=(p>'e')$endof(prod(bin,s)∩49)&1

This is a function that accepts a string and a character and returns an integer.

To get the number of ones in the binary representation, we first apply the bin function to each character in the string, which gives us an array of binary strings. Then reduce them into one using prod (since * is string concatenation in Julia) and take the set intersection of that string and the character code for 1, which gives us a string of ones. The last index of that string is the number of ones. We XOR this with 1 if the provided character is o and 0 otherwise, then get the parity using bitwise AND 1.

Try it online! (includes all test cases)

Saved 18 bytes thanks to Dennis!


问:
Coding Around The Clock
Write a single line program two or more characters long that contains no line terminators and takes no input. For example, your program might be:

```<code>MyProgram
</code>```

When your program is arranged into the shapes a clock's hands make at 12, 3, 6, and 9 o'clock, it needs to output the corresponding hour number. No other times need be supported.

Specifically:

When your program is arranged like clock hands at 12 o'clock ()

```<code>m
a
r
g
o
r
P
y
M
</code>```

running it should output 12.

When your program is arranged like clock hands at 3 o'clock ()

```<code>m
a
r
g
o
r
P
y
MyProgram
</code>```

running it should output 3.

When your program is arranged like clock hands at 6 o'clock ()

```<code>m
a
r
g
o
r
P
y
M
y
P
r
o
g
r
a
m
</code>```

running it should output 6.

When your program is arranged like clock hands at 9 o'clock ()

```<code>........m
........a
........r
........g
........o
........r
........P
........y
margorPyM
</code>```

running it should output 9.

Notes

The first character in your program is always placed at the center of the clock. (Note how there is only one M in the 6 o'clock example.)

Any one non-newline character may be used to indent the program for the 9 o'clock arrangement. In the examples . is used, but space or / or # would be just as valid.

For the 3 o'clock arrangement, no characters should be in the empty upper right region. (i.e. keep it empty, don't fill it with spaces.)

The initial program arrangement (MyProgram as is) does not need to do anything. Only the 12, 3, 6, and 9 o'clock arrangements need to have correct, well-defined output.

Code that only works as a function or REPL command is not allowed. Each of the four arrangements should be ready to run as full programs as is.

The shortest program in bytes wins. e.g. MyProgram has a length of 9 bytes.

答:
GolfScript, <s>11</s> 10 bytes

```<code>21;;3#9];6
</code>```

Uses # as padding character.

12 o'clock

```<code>6
;
]
9
#
3
;
;
1
2
</code>```

Try it online!

How it works.

6 is pushed on the stack, ; discards it.

] wraps the stack in an array (does not affect output).

9 and 3 are pushed on the stack, ; and ; discard them.

Finally, 1 and 2 are pushed on the stack, and implicitly printed without separation.

3 o'clock

```<code>6
;
]
9
#
3
;
;
1
21;;3#9];6
</code>```

Try it online!

How it works

6 is pushed on the stack, ; discards it.

] wraps the stack in an array (does not affect output).

9 and 3 are pushed on the stack, ; and ; discard them.

1 and 21 are pushed on the stack, ;; discards them.

3 is pushed on the stack.

# begins a comment until the end of the line.

6 o'clock

```<code>6
;
]
9
#
3
;
;
1
2
1
;
;
3
#
9
]
;
6
</code>```

Try it online!

How it works

6 is pushed on the stack, ; discards it.

] wraps the stack in an array (does not affect output).

9 and 3 are pushed on the stack, ; and ; discard them.

1, 2 and 1 are pushed on the stack.

; and ; discard the last 1 and 2.

3 and 9 are pushed on the stack.

] and ; wrap the stack in an array and discard it, clearing the stack.

6 is pushed on the stack.

9 o'clock

```<code>#########6
#########;
#########]
#########9
##########
#########3
#########;
#########;
#########1
6;]9#3;;12
</code>```

Try it online!

How it works

All lines but the last are comments.

6 is pushed on the stack, ; discards it.

] wraps the stack in an array (does not affect output).

9 is pushed on the stack.

# begins a comment until the end of the line.

Title: Coding Around The Clock

Body:
GolfScript, <s>11</s> 10 bytes

21;;3#9];6

Uses # as padding character.

12 o'clock

6
;
]
9
#
3
;
;
1
2

Try it online!

How it works.

6 is pushed on the stack, ; discards it.

] wraps the stack in an array (does not affect output).

9 and 3 are pushed on the stack, ; and ; discard them.

Finally, 1 and 2 are pushed on the stack, and implicitly printed without separation.

3 o'clock

6
;
]
9
#
3
;
;
1
21;;3#9];6

Try it online!

How it works

6 is pushed on the stack, ; discards it.

] wraps the stack in an array (does not affect output).

9 and 3 are pushed on the stack, ; and ; discard them.

1 and 21 are pushed on the stack, ;; discards them.

3 is pushed on the stack.

# begins a comment until the end of the line.

6 o'clock

6
;
]
9
#
3
;
;
1
2
1
;
;
3
#
9
]
;
6

Try it online!

How it works

6 is pushed on the stack, ; discards it.

] wraps the stack in an array (does not affect output).

9 and 3 are pushed on the stack, ; and ; discard them.

1, 2 and 1 are pushed on the stack.

; and ; discard the last 1 and 2.

3 and 9 are pushed on the stack.

] and ; wrap the stack in an array and discard it, clearing the stack.

6 is pushed on the stack.

9 o'clock

#########6
#########;
#########]
#########9
##########
#########3
#########;
#########;
#########1
6;]9#3;;12

Try it online!

How it works

All lines but the last are comments.

6 is pushed on the stack, ; discards it.

] wraps the stack in an array (does not affect output).

9 is pushed on the stack.

# begins a comment until the end of the line.


答:
><>, 20 bytes

```<code>X   n-+g+aa0g+9a2c!v
</code>```

There's unprintables in there, namely:

After the X is \x06\t

After the c is \x03

The same part of source code is run each time, using g on two parts of the source code to determine what to subtract from 12.

```<code>v                         Make IP move downwards
 !\x03                    Jump over the \x03
      c                   Push 12
       2a9+g              Get the char at position (2, 19), i.e. the \t for
                          3 o'clock, the \x03 for 9 o'clock, 0 otherwise
            0aa+g         Get the char at position (0, 20), i.e. first char on
                          the line after the X, \x06 for 6 o'clock
                 +        Add
                  -       Subtract from the 12
                   n      Output as number
                    \t    Unrecognised instruction - errors out
</code>```

12 o'clock | 3 o'clock | 6 o'clock |  9 o'clock (looks misaligned due to the tab)

Title: Coding Around The Clock

Body:
Write a single line program two or more characters long that contains no line terminators and takes no input. For example, your program might be:

```<code>MyProgram
</code>```

When your program is arranged into the shapes a clock's hands make at 12, 3, 6, and 9 o'clock, it needs to output the corresponding hour number. No other times need be supported.

Specifically:

When your program is arranged like clock hands at 12 o'clock ()

```<code>m
a
r
g
o
r
P
y
M
</code>```

running it should output 12.

When your program is arranged like clock hands at 3 o'clock ()

```<code>m
a
r
g
o
r
P
y
MyProgram
</code>```

running it should output 3.

When your program is arranged like clock hands at 6 o'clock ()

```<code>m
a
r
g
o
r
P
y
M
y
P
r
o
g
r
a
m
</code>```

running it should output 6.

When your program is arranged like clock hands at 9 o'clock ()

```<code>........m
........a
........r
........g
........o
........r
........P
........y
margorPyM
</code>```

running it should output 9.

Notes

The first character in your program is always placed at the center of the clock. (Note how there is only one M in the 6 o'clock example.)

Any one non-newline character may be used to indent the program for the 9 o'clock arrangement. In the examples . is used, but space or / or # would be just as valid.

For the 3 o'clock arrangement, no characters should be in the empty upper right region. (i.e. keep it empty, don't fill it with spaces.)

The initial program arrangement (MyProgram as is) does not need to do anything. Only the 12, 3, 6, and 9 o'clock arrangements need to have correct, well-defined output.

Code that only works as a function or REPL command is not allowed. Each of the four arrangements should be ready to run as full programs as is.

The shortest program in bytes wins. e.g. MyProgram has a length of 9 bytes.

Body:
><>, 20 bytes

X   n-+g+aa0g+9a2c!v

There's unprintables in there, namely:

After the X is \x06\t

After the c is \x03

The same part of source code is run each time, using g on two parts of the source code to determine what to subtract from 12.

v                         Make IP move downwards
 !\x03                    Jump over the \x03
      c                   Push 12
       2a9+g              Get the char at position (2, 19), i.e. the \t for
                          3 o'clock, the \x03 for 9 o'clock, 0 otherwise
            0aa+g         Get the char at position (0, 20), i.e. first char on
                          the line after the X, \x06 for 6 o'clock
                 +        Add
                  -       Subtract from the 12
                   n      Output as number
                    \t    Unrecognised instruction - errors out

12 o'clock | 3 o'clock | 6 o'clock |  <a href="http://fish.tryitonline.net/#code=ICAgICAgICAgICAgICAgICAgIHYKICAgICAgICAgICAgICAgICAgICEKICAgICAgICAgICAgICAgICAgIAMKICAgICAgICAgICAgICAgICAgIGMKICAgICAgICAgICAgICAgICAgIDIKICAgICAgICAgICAgICAgICAgIGEKICAgICAgICAgICAgICAgICAgIDkKICAgICAgICAgICAgICAgICAgICsKICAgICAgICAgICAgICAgICAgIGcKICAgICAgICAgICAgICAgICAgIDAKICAgICAgICAgICAgICAgICAgIGEKICAgICAgICAgICAgICAgICAgIGEKICAgICAgICAgICAgICAgICAgICsKICAgICAgICAgICAgICAgICAgIGcKICAgICAgICAgICAgICAgICAgICsKICAgICAgICAgICAgICAgICAgIC0KICAgICAgICAgICAgICAgICAgIG4KICAgICAgICAgICAgICAgICAgIAkKICAgICAgICAgICAgICAgICAgIAYKdiEDYzJhOStnMGFhK2crLW4JBlg&input=">9 o'clock (looks misaligned due to the tab)


答:
Java, 179 bytes(with import)

```<code>import java.util.*;static void r(String s){StringJoiner x= new StringJoiner("0");for(String a:s.split("0",s.length())){x.add(new StringBuilder(a).reverse());}System.out.print(x);}
</code>```

Takes in a string input and splits the characters by zero then adds them back by calling the add method on the StringJoiner class.

Title: Reverse positive runs

Body:
Java, 179 bytes(with import)

import java.util.*;static void r(String s){StringJoiner x= new StringJoiner("0");for(String a:s.split("0",s.length())){x.add(new StringBuilder(a).reverse());}System.out.print(x);}

Takes in a string input and splits the characters by zero then adds them back by calling the add method on the StringJoiner class.


答:
Actually, 22 bytes

```<code>k"a%sa"%'0@s♂R'0j#pXdX
</code>```

This actually made me notice that there's a bug in the split command - it doesn't preserve empty splits. As a workaround, I surround the input string with as before doing the split, reverse, and join, then remove the as at the end. Input is taken as a string, output is a list of single-character strings.

Try it online

Explanation:

```<code>k"a%sa"%'0@s♂R'0j#pXdX
k"a%sa"%                surround input with "a" characters
        '0@s            split on 0
            ♂R          reverse each piece
              '0j       join on 0
                 #pXdX  listify, remove first and last element (the "a"s)
</code>```

Title: Reverse positive runs

Body:
Actually, 22 bytes

k"a%sa"%'0@s♂R'0j#pXdX

This actually made me notice that there's a bug in the split command - it doesn't preserve empty splits. As a workaround, I surround the input string with as before doing the split, reverse, and join, then remove the as at the end. Input is taken as a string, output is a list of single-character strings.

Try it online

Explanation:

k"a%sa"%'0@s♂R'0j#pXdX
k"a%sa"%                surround input with "a" characters
        '0@s            split on 0
            ♂R          reverse each piece
              '0j       join on 0
                 #pXdX  listify, remove first and last element (the "a"s)


答:
Actually, 1 byte

```<code>R
</code>```

Boring builtin is boring. Requires a 64-bit version of Python 3 to get all the way up to 2**64.

Try it online! (due to memory and output length restrictions, the online interpreter can't go very high).

Here's a 5-byte version that doesn't require 64-bit Python 3 and is a little nicer on memory usage:

```<code>W;DWX
</code>```

Try it online! (see above caveats)

Title: Count up folks!

Body:
Introduction

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

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

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

Challenge

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

Rules

You can get n any way.

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

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

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

Standard loopholes are denied.

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

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

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

Bonuses

20%

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

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

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

Body:
Actually, 1 byte

R

Boring builtin is boring. Requires a 64-bit version of Python 3 to get all the way up to 2**64.

Try it online! (due to memory and output length restrictions, the online interpreter can't go very high).

Here's a 5-byte version that doesn't require 64-bit Python 3 and is a little nicer on memory usage:

W;DWX

Try it online! (see above caveats)


问:
Watson-Crick palindromes

Problem

Create a function that can determine whether or not an arbitrary DNA string is a Watson-Crick palindrome. The function will take a DNA string and output a true  value if the string is a Watson-Crick palindrome and a false value if it is not. (True and False can also be represented as 1 and 0, respectively.)

The DNA string may either be in all uppercase or all lowercase depending on your preference.

Also, the DNA string will not be empty.

Explanation

A DNA string is a Watson-Crick palindrome when the complement of its reverse is equal to itself.

Given a DNA string, first reverse it, and then complement each character according to the DNA bases (A ↔ T and C ↔ G). If the original string is equal to the complemented-reverse string, it is a Watson-Crick palindrome.

For more, see this question. It is a different challenge where you must find the longest substring of a DNA string where that substring is a Watson-Crick palindrome.

Goal

This is code-golf and the shortest code wins.

Test Cases

The format is <input> = <output>.

```<code>ATCGCGAT = true
AGT = false
GTGACGTCAC = true
GCAGTGA = false
GCGC = true
AACTGCGTTTAC = false
ACTG = false
</code>```

答:
Labyrinth, 42 bytes

```<code>_8
,%
;
"}{{+_5
"=    %_!
 = """{
 ;"{" )!
</code>```

Terminates with a division-by-zero error (error message on STDERR).

Try it online!

The layout feels really inefficient but I'm just not seeing a way to golf it right now.

Explanation

This solution is based on Dennis's arithmetic trick: take all character codes modulo 8, add a pair from both ends and make sure it's divisible by 5.

Labyrinth primer:

Labyrinth has two stacks of arbitrary-precision integers, main and aux(iliary), which are initially filled with an (implicit) infinite amount of zeros.

The source code resembles a maze, where the instruction pointer (IP) follows corridors when it can (even around corners). The code starts at the first valid character in reading order, i.e. in the top left corner in this case. When the IP comes to any form of junction (i.e. several adjacent cells in addition to the one it came from), it will pick a direction based on the top of the main stack. The basic rules are: turn left when negative, keep going ahead when zero, turn right when positive. And when one of these is not possible because there's a wall, then the IP will take the opposite direction. The IP also turns around when hitting dead ends.

Digits are processed by multiplying the top of the main stack by 10 and then adding the digit.

The code starts with a small 2x2, clockwise loop, which reads all input modulo 8:

```<code>_   Push a 0.
8   Turn into 8.
%   Modulo. The last three commands do nothing on the first iteration
    and will take the last character code modulo 8 on further iterations.
,   Read a character from STDIN or -1 at EOF. At EOF we will leave loop.
</code>```

Now ; discards the -1. We enter another clockwise loop which moves the top of the main stack (i.e. the last character) down to the bottom:

```<code>"   No-op, does nothing.
}   Move top of the stack over to aux. If it was at the bottom of the stack
    this will expose a zero underneath and we leave the loop.
=   Swap top of main with top of aux. The effect of the last two commands
    together is to move the second-to-top stack element from main to aux.
"   No-op.
</code>```

Now there's a short linear bit:

```<code>{{  Pull two characters from aux to main, i.e. the first and last (remaining)
    characters of the input (mod 8).
+   Add them.
_5  Push 5.
%   Modulo.
</code>```

The IP is now at a junction which acts as a branch to test divisibility by 5. If the result of the modulo is non-zero, we know that the input is not a Watson-Crick palindrome and we turn east:

```<code>_   Push 0.
!   Print it. The IP hits a dead end and turns around.
_   Push 0.
%   Try to take modulo, but division by zero fails and the program terminates.
</code>```

Otherwise, we need to keep checking the rest of the input, so the IP keeps going south. The { pulls over the bottom of the remaining input. If we've exhausted the input, then this will be a 0 (from the bottom of aux), and the IP continues moving south:

```<code>)   Increment 0 to 1.
!   Print it. The IP hits a dead end and turns around.
)   Increment 0 to 1.
{   Pull a zero over from aux, IP keeps moving north.
%   Try to take modulo, but division by zero fails and the program terminates.
</code>```

Otherwise, there are more characters in the string to be checked. The IP turns west and moves into the next (clockwise) 2x2 loop which consists largely of no-ops:

```<code>"   No-op.
"   No-op.
{   Pull one value over from aux. If it's the bottom of aux, this will be
    zero and the IP will leave the loop eastward.
"   No-op.
</code>```

After this loop, we've got the input on the main stack again, except for its first and last character and with a zero on top. The ; discards the 0 and then = swaps the tops of the stacks, but this is just to cancel the first = in the loop, because we're now entering the loop in a different location. Rinse and repeat.

Title: Watson-Crick palindromes

Body:
Labyrinth, 42 bytes

_8
,%
;
"}{{+_5
"=    %_!
 = """{
 ;"{" )!

Terminates with a division-by-zero error (error message on STDERR).

Try it online!

The layout feels really inefficient but I'm just not seeing a way to golf it right now.

Explanation

This solution is based on Dennis's arithmetic trick: take all character codes modulo 8, add a pair from both ends and make sure it's divisible by 5.

Labyrinth primer:

Labyrinth has two stacks of arbitrary-precision integers, main and aux(iliary), which are initially filled with an (implicit) infinite amount of zeros.

The source code resembles a maze, where the instruction pointer (IP) follows corridors when it can (even around corners). The code starts at the first valid character in reading order, i.e. in the top left corner in this case. When the IP comes to any form of junction (i.e. several adjacent cells in addition to the one it came from), it will pick a direction based on the top of the main stack. The basic rules are: turn left when negative, keep going ahead when zero, turn right when positive. And when one of these is not possible because there's a wall, then the IP will take the opposite direction. The IP also turns around when hitting dead ends.

Digits are processed by multiplying the top of the main stack by 10 and then adding the digit.

The code starts with a small 2x2, clockwise loop, which reads all input modulo 8:

_   Push a 0.
8   Turn into 8.
%   Modulo. The last three commands do nothing on the first iteration
    and will take the last character code modulo 8 on further iterations.
,   Read a character from STDIN or -1 at EOF. At EOF we will leave loop.

Now ; discards the -1. We enter another clockwise loop which moves the top of the main stack (i.e. the last character) down to the bottom:

"   No-op, does nothing.
}   Move top of the stack over to aux. If it was at the bottom of the stack
    this will expose a zero underneath and we leave the loop.
=   Swap top of main with top of aux. The effect of the last two commands
    together is to move the second-to-top stack element from main to aux.
"   No-op.

Now there's a short linear bit:

{{  Pull two characters from aux to main, i.e. the first and last (remaining)
    characters of the input (mod 8).
+   Add them.
_5  Push 5.
%   Modulo.

The IP is now at a junction which acts as a branch to test divisibility by 5. If the result of the modulo is non-zero, we know that the input is not a Watson-Crick palindrome and we turn east:

_   Push 0.
!   Print it. The IP hits a dead end and turns around.
_   Push 0.
%   Try to take modulo, but division by zero fails and the program terminates.

Otherwise, we need to keep checking the rest of the input, so the IP keeps going south. The { pulls over the bottom of the remaining input. If we've exhausted the input, then this will be a 0 (from the bottom of aux), and the IP continues moving south:

)   Increment 0 to 1.
!   Print it. The IP hits a dead end and turns around.
)   Increment 0 to 1.
{   Pull a zero over from aux, IP keeps moving north.
%   Try to take modulo, but division by zero fails and the program terminates.

Otherwise, there are more characters in the string to be checked. The IP turns west and moves into the next (clockwise) 2x2 loop which consists largely of no-ops:

"   No-op.
"   No-op.
{   Pull one value over from aux. If it's the bottom of aux, this will be
    zero and the IP will leave the loop eastward.
"   No-op.

After this loop, we've got the input on the main stack again, except for its first and last character and with a zero on top. The ; discards the 0 and then = swaps the tops of the stacks, but this is just to cancel the first = in the loop, because we're now entering the loop in a different location. Rinse and repeat.


问:
Perfect powers in more than one way?

Challenge

Your task is to write a program or function which, given a positive integer \$N\$, finds all positive integers less than or equal to \$N\$ that can be expressed as a perfect power in more than one way.

Definition

A perfect power is defined as a number \$i\$ found by \$m^k\$, where:

\$m\$ and \$i\$ are positive integers

\$m \ne k\$

Test Cases

```
input -> output
1000 ->  16, 64, 81, 256, 512, 625, 729
56 -> 16
999 -> 16, 64, 81, 256, 512, 625, 729
81 -> 16, 64, 81
1500 -> 16, 64, 81, 256, 512, 625, 729, 1024, 1296
```

Please provided a readable, commented version as well.

答:
Perl: 68 chars

Gets the maximum (1000) in $N and returns the answer in @a.

```<code>for $x ( 2..$N ) {
    $c{$x**$_}++ for 2..log($N)/log$x
}
@a = grep { $c{$_} > 1 } keys %c
</code>```

For a whole program, I need another 18 chars:

```<code>$m = shift;
for $x ( 2..$m ) {
    $c{$x**$_}++ for 2..log($m)/log$x
}
print join ' ', grep { $c{$_} > 1 } keys %c
</code>```

Title: Perfect powers in more than one way?

Body:
Perl: 68 chars

Gets the maximum (1000) in $N and returns the answer in @a.

for $x ( 2..$N ) {
    $c{$x**$_}++ for 2..log($N)/log$x
}
@a = grep { $c{$_} > 1 } keys %c

For a whole program, I need another 18 chars:

$m = shift;
for $x ( 2..$m ) {
    $c{$x**$_}++ for 2..log($m)/log$x
}
print join ' ', grep { $c{$_} > 1 } keys %c

ContentLicense: CC BY-SA 2.5


答:
R, 70 bytes

```<code>f=function(x)all(chartr("GCTA","CGAT",y<-strsplit(x,"")[[1]])==rev(y))
</code>```

Usage:

```<code>> f=function(x)all(chartr("GCTA","CGAT",y<-strsplit(x,"")[[1]])==rev(y))
> f("GTGACGTCAC")
[1] TRUE
> f("AACTGCGTTTAC")
[1] FALSE
> f("AGT")
[1] FALSE
> f("ATCGCGAT")
[1] TRUE
</code>```

Title: Watson-Crick palindromes

Body:
Problem

Create a function that can determine whether or not an arbitrary DNA string is a Watson-Crick palindrome. The function will take a DNA string and output a true  value if the string is a Watson-Crick palindrome and a false value if it is not. (True and False can also be represented as 1 and 0, respectively.)

The DNA string may either be in all uppercase or all lowercase depending on your preference.

Also, the DNA string will not be empty.

Explanation

A DNA string is a Watson-Crick palindrome when the complement of its reverse is equal to itself.

Given a DNA string, first reverse it, and then complement each character according to the DNA bases (A ↔ T and C ↔ G). If the original string is equal to the complemented-reverse string, it is a Watson-Crick palindrome.

For more, see this question. It is a different challenge where you must find the longest substring of a DNA string where that substring is a Watson-Crick palindrome.

Goal

This is code-golf and the shortest code wins.

Test Cases

The format is <input> = <output>.

```<code>ATCGCGAT = true
AGT = false
GTGACGTCAC = true
GCAGTGA = false
GCGC = true
AACTGCGTTTAC = false
ACTG = false
</code>```

Body:
R, 70 bytes

f=function(x)all(chartr("GCTA","CGAT",y<-strsplit(x,"")[[1]])==rev(y))

Usage:

> f=function(x)all(chartr("GCTA","CGAT",y<-strsplit(x,"")[[1]])==rev(y))
> f("GTGACGTCAC")
[1] TRUE
> f("AACTGCGTTTAC")
[1] FALSE
> f("AGT")
[1] FALSE
> f("ATCGCGAT")
[1] TRUE


问:
Permutations with Indistinguishable Items
Given a list of integers, output the number of permutations of the integers, with indistinguishable permutations counted once. If there are n integers, and each group of indistinguishable numbers has length n_i, this is n! / (n_1! * n_2! * ...)

Rules

Input will be some form of list as arguments to a function or the program with 1 to 12 non-negative integers.

Output will be printing or returning the number of permutations as described above.

No standard loopholes or built-in functions (generating permutations, combinations, etc.). Factorials are allowed.

Test Cases

Inputs:

```<code>1, 3000, 2, 2, 8
1, 1, 1
2, 4, 3, 2, 3, 4, 4, 4, 4, 4, 1, 1
</code>```

Outputs:

```<code>60
1
83160
</code>```

答:
Pyth, 11 bytes

```<code>/.!lQ*F/V._
</code>```

Test suite

Uses the standard formula, n! / (count1! * count2! * ...), except that the factorials of the counts are found by counting how many times each element occurs in the prefix leading up to that, then multiplying all such numbers together.

Explanation:

```<code>/.!lQ*F/V._
/.!lQ*F/V._QQ    Implicit variable introduction.
                 Q = eval(input())
         ._Q     Form all prefixes of the input.
       /V   Q    Count how many times each element occurs in the prefix
                 ending with that element.
     *F          Fold on multiplication - take the product.
 .!lQ            Take the factorial of the input length
/                Divide.
</code>```

Body:
Pyth, 11 bytes

/.!lQ*F/V._

Test suite

Uses the standard formula, n! / (count1! * count2! * ...), except that the factorials of the counts are found by counting how many times each element occurs in the prefix leading up to that, then multiplying all such numbers together.

Explanation:

/.!lQ*F/V._
/.!lQ*F/V._QQ    Implicit variable introduction.
                 Q = eval(input())
         ._Q     Form all prefixes of the input.
       /V   Q    Count how many times each element occurs in the prefix
                 ending with that element.
     *F          Fold on multiplication - take the product.
 .!lQ            Take the factorial of the input length
/                Divide.


答:
Perl, 29 bytes

Includes +2 for -p

Run with the input on STDIN as parity character space string, e.g.

```<code>parity.pl <<< "p Programming Puzzles and Code-Golf"
</code>```

parity.pl

```<code>#!/usr/bin/perl -p
$_=unpack"B*",$_|b;$_=1&y;1;
</code>```

Title: Generate a parity bit

Body:
A parity bit, is one of the simplest forms of a checksum. First, you have to pick the parity, even or odd. Let's say we pick even. Now, we need a message to transmit. Let's say our message is "Foo". This is written in binary as:

```<code>01000110 01101111 01101111
</code>```

Now, we count the total number of 1's in there, which is 15. Since 15 is an odd number, we must add one extra bit to the end of our message, and we will now have an even number of 'on' bits. This last added bit is known as the "parity bit". If we had picked an odd parity for our checksum, we would have to add an extra '0' so that the number of on bits remains odd.

The challenge:

You must write a program or function that determines what the correct parity bit for a string is. Your program must take two inputs:

A string, s. This is the message that the checksum will be calculated on. This will be restricted to the 95 printable ASCII characters.

A character or single character string p, that will either be e for even parity, or o for odd parity.

and produce a truthy-falsey value representing the correct parity bit. Truthy if it's a 1, and falsey if it's a 0.

Builtins that count the number of "on" bits in a string or character are not allowed. For example, a function f that does this: f('a') == 3 or f('foo') == 16 is banned. Anything else, such as base conversion, is fair game.

Test IO:

```<code>(without the quotes)
s: "0"
p: 'e'
output: 0

s: "Foo"
p: 'e'
output: 1

s: "Hello World!"
p: 'o'
output: 0

s: "Alex is right"
p: 'e'
output: 1

s: "Programming Puzzles and Code-Golf"
p: 'e'
output: 0

s: "Programming Puzzles and Code-Golf"
p: 'o'
output: 1
</code>```

This is codegolf, so standard loopholes apply, and the shortest answer in bytes wins.

Leaderboard

var QUESTION_ID=78569,OVERRIDE_USER=31716;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:
Perl, 29 bytes

Includes +2 for -p

Run with the input on STDIN as parity character space string, e.g.

parity.pl <<< "p Programming Puzzles and Code-Golf"

parity.pl

#!/usr/bin/perl -p
$_=unpack"B*",$_|b;$_=1&y;1;


答:
JavaScript (ES6), 99 <s>103</s>

String increment using regexp, not limit except the string length

Edit 1 byte saved thx @user81655

x=>{for(a='';a!=x;console.log(a=(' '+a).replace(/.9*$/,x=>++x[0]+'0'.repeat(x.length-1)).trim()));}
```

<p><strong>Test</strong></p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>f=x=>{for(a='';a!=x;console.log(a=(' '+a).replace(/.9*$/,x=>++x[0]+'0'.repeat(x.length-1)).trim()));}

console.log=x=>o.push(x)

function test() {
  var v = I.value
  o=[]
  if (/^\d+$/.test(v)) f(v)
  else console.log('Invalid number' + v)
  if(o.length > 30) o.splice(15,o.length-30,'','...','');
  O.textContent=o.join`\n`
}

test()</code>```

<input id=I value=10000><button onclick='test()'>go</button>
(this test snippet will show just the first and last 15 lines of the output)

```</code>```

Title: Count up folks!

Body:
JavaScript (ES6), 99 <s>103</s>

String increment using regexp, not limit except the string length

Edit 1 byte saved thx @user81655

x=>{for(a='';a!=x;console.log(a=(' '+a).replace(/.9*$/,x=>++x[0]+'0'.repeat(x.length-1)).trim()));}

Test

f=x=>{for(a='';a!=x;console.log(a=(' '+a).replace(/.9*$/,x=>++x[0]+'0'.repeat(x.length-1)).trim()));}

console.log=x=>o.push(x)

function test() {
  var v = I.value
  o=[]
  if (/^\d+$/.test(v)) f(v)
  else console.log('Invalid number' + v)
  if(o.length > 30) o.splice(15,o.length-30,'','...','');
  O.textContent=o.join`\n`
}

test()

<input id=I value=10000><button onclick='test()'>go</button>
(this test snippet will show just the first and last 15 lines of the output)
<pre id=O></pre>


答:
PHP, <s>26</s> <s>23</s> 31 bytes

```<code><?=join(' ',range(1,$argv[1])); // 31 if using N isnt allowed
<?=join(' ',range(1,$n)); // 25 if using $n is allowed
<?=join(' ',range(1,N)); // 24 bytes, join() is an alias of implode()
<?=implode(' ',range(1,N)); // 27 bytes
</code>```

"You can get n any way" -> In this case, N is a constant.

Edit: Apperantly "any way" isn't "any way", it now takes commandline arguments

Title: Count up folks!

Body:
PHP, <s>26</s> <s>23</s> 31 bytes

<?=join(' ',range(1,$argv[1])); // 31 if using N isnt allowed
<?=join(' ',range(1,$n)); // 25 if using $n is allowed
<?=join(' ',range(1,N)); // 24 bytes, join() is an alias of implode()
<?=implode(' ',range(1,N)); // 27 bytes

"You can get n any way" -> In this case, N is a constant.

Edit: Apperantly "any way" isn't "any way", it now takes commandline arguments


答:
C++14, 142 bytes

#include<numeric>
#include<list>
using namespace std;[](auto n)->list<decltype(n)>{list<decltype(n)>t(n);iota(t.begin(),t.end(),1);return t;};
```

This declares an anonymous lambda function which can be captured and subsequently called. The function returns a std::list containing values of the same type as n. The unsigned long long data type can be used on 64-bit machines to support the full 64-bit unsigned integer range (calling it like f(18446744073709551615ULL)).

Try it online

Title: Count up folks!

Body:
C++14, 142 bytes

#include<numeric>
#include<list>
using namespace std;[](auto n)->list<decltype(n)>{list<decltype(n)>t(n);iota(t.begin(),t.end(),1);return t;};

This declares an anonymous lambda function which can be captured and subsequently called. The function returns a std::list containing values of the same type as n. The unsigned long long data type can be used on 64-bit machines to support the full 64-bit unsigned integer range (calling it like f(18446744073709551615ULL)).

Try it online


答:
C, 71 bytes

Requires ASCII codes for the relevant characters, but accepts uppercase, lowercase or mixed-case input.

```<code>f(char*s){char*p=s+strlen(s),b=0;for(;*s;b&=6)b|=*--p^*s++^4;return!b;}
</code>```

This code maintains two pointers, s and p, traversing the string in opposite directions.  At each step, we compare the corresponding characters, setting b true if they don't match.  The matching is based on XOR of the character values:

```<code>'A' ^ 'T' = 10101
'C' ^ 'G' = 00100

'C' ^ 'T' = 10111
'G' ^ 'A' = 00110
'A' ^ 'C' = 00010
'T' ^ 'G' = 10011
 x  ^  x  = 00000
</code>```

We can see in the above table that we want to record success for xx10x and failure for anything else, so we XOR with 00100 (four) and mask with 00110 (six) to get zero for AT or CG and non-zero otherwise.  Finally, we return true if all the pairs accumulated a zero result in b, false otherwise.

Test program:

#include <stdio.h>
int main(int argc, char **argv)
{
    while (*++argv)
        printf("%s = %s\n", *argv, f(*argv)?"true":"false");
}
```

Title: Watson-Crick palindromes

Body:
C, 71 bytes

Requires ASCII codes for the relevant characters, but accepts uppercase, lowercase or mixed-case input.

f(char*s){char*p=s+strlen(s),b=0;for(;*s;b&=6)b|=*--p^*s++^4;return!b;}

This code maintains two pointers, s and p, traversing the string in opposite directions.  At each step, we compare the corresponding characters, setting b true if they don't match.  The matching is based on XOR of the character values:

'A' ^ 'T' = 10101
'C' ^ 'G' = 00100

'C' ^ 'T' = 10111
'G' ^ 'A' = 00110
'A' ^ 'C' = 00010
'T' ^ 'G' = 10011
 x  ^  x  = 00000

We can see in the above table that we want to record success for xx10x and failure for anything else, so we XOR with 00100 (four) and mask with 00110 (six) to get zero for AT or CG and non-zero otherwise.  Finally, we return true if all the pairs accumulated a zero result in b, false otherwise.

Test program:

#include <stdio.h>
int main(int argc, char **argv)
{
    while (*++argv)
        printf("%s = %s\n", *argv, f(*argv)?"true":"false");
}


答:
Molecule, 10 bytes

```<code>0{1+~}InL.
</code>```

Explanation:

```<code>0{1+~}InL.
0          Push 0
 {1+~}     Create a code block
      In   Ask the amount of times to repeat
        L. Loop the code block n times and clean the stack.
</code>```

Title: Count up folks!

Body:
Molecule, 10 bytes

0{1+~}InL.

Explanation:

0{1+~}InL.
0          Push 0
 {1+~}     Create a code block
      In   Ask the amount of times to repeat
        L. Loop the code block n times and clean the stack.


答:
Perl 6, 5 bytes

```<code>1..+*
</code>```

Sadly, 1..* is an infinite range, so I've got to cheat to make Perl 6 understand it's actually an anonymous function (and * is the placeholder).

Title: Count up folks!

Body:
Perl 6, 5 bytes

1..+*

Sadly, 1..* is an infinite range, so I've got to cheat to make Perl 6 understand it's actually an anonymous function (and * is the placeholder).


问:
Have you mooed today?
The Debian Linux distribution (and Debian-based distros, like Ubuntu, Kali and others) uses a package-manager called APT. To install program foo you would type into a terminal

```<code>sudo apt-get install foo
</code>```

One little Easter Egg of APT is the following

```<code>apt-get moo
</code>```

Which after typing will produce the following output

```<code>                 (__)
                 (oo)
           /------\/
          / |    ||
         *  /\---/\
            ~~   ~~
..."Have you mooed today?"...
</code>```

You must write a program that produces this EXACT output in as few bytes as possible. (including trailing spaces and a new line)

Here is the same output with \n added to represent newline characters, and a * to represent trailing spaces

```<code>                 (__)*\n
                 (oo)*\n
           /------\/*\n
          / |    ||***\n
         *  /\---/\*\n
            ~~   ~~***\n
..."Have you mooed today?"...\n
</code>```

As requested in the comments, here is the md5sum of the mooing.

```<code>35aa920972944a9cc26899ba50024115  -
</code>```

Title: Have you mooed today?

Body:
Molecule, 145 bytes

"   "_____:a"  (__)
";a____"  (oo)
";a__"  /------\\/
";a__" / |    ||
";a__"*  /\\---/\\
";a____"~~"b"~~
...\"Have you mooed today?\"..."

My first time trying to compress ASCII art :P


答:
J, 27 bytes

```<code>'oe'&i.@[=[:~:/^:2@#:3&u:@]
</code>```

Usage

```<code>   f =: 'oe'&i.@[=[:~:/^:2@#:3&u:@]
   'e' f '0'
0
   'e' f 'Foo'
1
   'o' f 'Hello World!'
0
   'e' f 'Alex is right'
1
   'e' f 'Programming Puzzles and Code-Golf'
0
   'o' f 'Programming Puzzles and Code-Golf'
1
</code>```

Title: Generate a parity bit

Body:
J, 27 bytes

'oe'&i.@[=[:~:/^:2@#:3&u:@]

Usage

   f =: 'oe'&i.@[=[:~:/^:2@#:3&u:@]
   'e' f '0'
0
   'e' f 'Foo'
1
   'o' f 'Hello World!'
0
   'e' f 'Alex is right'
1
   'e' f 'Programming Puzzles and Code-Golf'
0
   'o' f 'Programming Puzzles and Code-Golf'
1


答:
Jolf, 29 + 1 = 30 bytes

This in fact is valid! It uses the same technique as the JavaScript answer, keeping an array of digits. It should thus theoretically work, but may not work due to time limitations (browser crashing, etc.) Make sure to have "Pretty Output" enabled if it isn't already. (Apparently, making sure is an extra byte, like a flag, so there's that.) Try it here!

```<code>Ζ²1W<ni)aRζEΖZWζγwlζh.ζγonhn}
</code>```

Ungolfed:

```<code>Z ~: 1
W < n i )
  a R ζ E
  Ζ ZW
    ζ
    w lζ
    h .ζ w lζ
  on h n
}
</code>```

That's real clean-looking for a golfing language! :D

Title: Count up folks!

Body:
Introduction

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

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

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

Challenge

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

Rules

You can get n any way.

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

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

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

Standard loopholes are denied.

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

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

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

Bonuses

20%

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

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

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

Body:
Jolf, 29 + 1 = 30 bytes

This in fact is valid! It uses the same technique as the JavaScript answer, keeping an array of digits. It should thus theoretically work, but may not work due to time limitations (browser crashing, etc.) Make sure to have "Pretty Output" enabled if it isn't already. (Apparently, making sure is an extra byte, like a flag, so there's that.) Try it here!

Ζ²1W<ni)aRζEΖZWζγwlζh.ζγonhn}

Ungolfed:

Z ~: 1
W < n i )
  a R ζ E
  Ζ ZW
    ζ
    w lζ
    h .ζ w lζ
  on h n
}

That's real clean-looking for a golfing language! :D