答:
Haskell, 350 bytes

Inspired by @Loovjo, I also use ASCII art. This works for numbers under 100000 (or something like that).

```<code>g k="\t"++(foldl (++) ""$map (\y->show y++"|") [0..k])
n k=length$g k
r z x=(show x)++":\t"++(replicate f ' ')++(replicate d s)++"\n" where y=mod (x*10) z;(a,b)=(min x y,max x y);s=(case compare y x of LT->'<';EQ->'.';GT->'>');f=n (a-1)-1;d=n b-f-2
w z=(g (z-1))++"\n"++(foldl1 (++) (map (r z) [0..(z-1)]))
main=do{n<-getLine;putStrLn (w$read n);}
</code>```

Basically you point from x to (x*10)%n.

You can try this here. But since codepad doesn't support input, change q to the value of n you want, and resubmit. (Note that forking doesn't work, so copy and resubmit from main page). The code submitted there is a bit different, because the above version takes input from console.

I hope the output is intuitive. Compression suggestions are welcome (particularly if that beats 294 ;)).

Title: Generate a modulo rosace

Body:
The cool stuff

The following rosace can help calculate numbers modulo 7.

In order to do that, you must start at 0 and turn clockwise a number of steps given by the first digit. Then, for each successive digit, follow the arrow and then turn clockwise the number of steps given by that digit.

Here is how you proceed for number 294:

You start at circle 0.

You turn clockwise the number of steps given by the first digit (which is a 2, you end up at 2).

You follow the arrow there (you end up at 6).

You turn clockwise the number of steps given by the second digit (which is a 9, you end up at 1).

You follow the arrow there (you end up at 3).

You turn clockwise the number of steps given by the third number (which is 4, you end up at 0).

294 mod 7 = 0 (meaning 294 is multiple of 7).

(Video explanation if you still didn't get it)

The goal

Figure out how that works (I know but I won't tell you).

Create a program that takes a number n in parameter and that generates a rosace for mod n.

The rosace can be displayed by any means you want (ASCII, generate PNG, generate SVG, ...) as long as it could be used by a 8 years old child (so no list of rules, I want a picture)!

You can use strait lines, even if it's a bit less clear than what I made for the example, but you must show clearly the numbers that point to themselves with some kind of tail-biting arrow.

Test cases

(I only give the links between the numbers, feel free to edit my question once your program sucessfully generates them)

mod 2:

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

mod 3:

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

mod 4:

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

mod 5:

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

mod 6:

```<code>0 -> 0
1 -> 4
2 -> 2
3 -> 0
4 -> 4
5 -> 2
</code>```

mod 7:

```<code>0 -> 0
1 -> 3
2 -> 6
3 -> 2
4 -> 5
5 -> 1
6 -> 4
</code>```

mod 8:

```<code>0 -> 0
1 -> 2
2 -> 4
3 -> 6
4 -> 0
5 -> 2
6 -> 4
7 -> 6
</code>```

mod 9:

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

mod 10:

```<code>0 -> 0
1 -> 0
2 -> 0
3 -> 0
4 -> 0
5 -> 0
6 -> 0
7 -> 0
8 -> 0
9 -> 0
</code>```

Rules

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

As usual, loopholes and cheats are forbidden.

Body:
Haskell, 350 bytes

Inspired by @Loovjo, I also use ASCII art. This works for numbers under 100000 (or something like that).

g k="\t"++(foldl (++) ""$map (\y->show y++"|") [0..k])
n k=length$g k
r z x=(show x)++":\t"++(replicate f ' ')++(replicate d s)++"\n" where y=mod (x*10) z;(a,b)=(min x y,max x y);s=(case compare y x of LT->'<';EQ->'.';GT->'>');f=n (a-1)-1;d=n b-f-2
w z=(g (z-1))++"\n"++(foldl1 (++) (map (r z) [0..(z-1)]))
main=do{n<-getLine;putStrLn (w$read n);}

Basically you point from x to (x*10)%n.

You can try this here. But since codepad doesn't support input, change q to the value of n you want, and resubmit. (Note that forking doesn't work, so copy and resubmit from main page). The code submitted there is a bit different, because the above version takes input from console.

I hope the output is intuitive. Compression suggestions are welcome (particularly if that beats 294 ;)).


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

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

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

Your program has to do the following:

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

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

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

A few explanations:

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

```<code>"trick"

"Treat"

"    TReAt"

"
     tRICk          "
</code>```

Invalid outputs:

```<code>"tri ck"

"tr
eat"

"trck"
</code>```

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

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

Leaderboards

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

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

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

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

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

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

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

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

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

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
/// / ><>, 29 bytes

```<code>/v//treat/
"l
t?
r!
i;
co
k
"
</code>```

Try /// online. This prints treat after it replaces all vs with null, then stops processing because of the single / which does not complete a /// block.

Try ><> online. Gives us trick. The first / wraps execution around to the " on line 8, it pushes trick onto the stack in reverse order, bounces off of the first / again, goes down at the v and uses a loop to print all the stacked characters LIFO.

ContentLicense: CC BY-SA 3.0

Title: Trick or Treat polyglot

Body:
/// / ><>, 29 bytes

/v//treat/
"l
t?
r!
i;
co
k
"

Try /// online. This prints treat after it replaces all vs with null, then stops processing because of the single / which does not complete a /// block.

Try ><> online. Gives us trick. The first / wraps execution around to the " on line 8, it pushes trick onto the stack in reverse order, bounces off of the first / again, goes down at the v and uses a loop to print all the stacked characters LIFO.


答:
Windows Batch, JScript, 35 bytes

trick="treat";WScript.
echo (trick)

The batch version displays the parentheses as delimiters.

Title: Trick or Treat polyglot

Body:
Since Halloween is coming up I thought I might start a fun little code golf challenge!

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

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

Your program has to do the following:

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

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

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

A few explanations:

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

```<code>"trick"

"Treat"

"    TReAt"

"
     tRICk          "
</code>```

Invalid outputs:

```<code>"tri ck"

"tr
eat"

"trck"
</code>```

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

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

Leaderboards

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

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

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

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

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

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

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

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

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

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```


答:
Windows Batch, VBScript, 34 bytes

```<code>trick="treat":WScript._
echo trick
</code>```

The Batch echo will display the immediate text.

The VBScript uses the "_" line-continuation to run the "echo" command, which displays the contents of the variable "trick", which contains the string "treat".

VBScript does not require parenthesis for functions which do not return a value.

Title: Trick or Treat polyglot

Body:
Windows Batch, VBScript, 34 bytes

trick="treat":WScript._
echo trick

The Batch echo will display the immediate text.

The VBScript uses the "_" line-continuation to run the "echo" command, which displays the contents of the variable "trick", which contains the string "treat".

VBScript does not require parenthesis for functions which do not return a value.


问:
Traveling Pumpkin Problem

Background:

Jack is a pumpkin that enjoys spooking the citizens of the villages near his pumpkin patch every Halloween.  However, every year after someone lights the candle inside of him, he has a limited amount of time to spook everyone before the candle burns out, thus being unable to spook any more villagers because nobody can see him.  In past years, he has only been able to spook a small amount of villages due to his poor decision making, but now that he has you to help him, he will be able to spook as many villages as possible!

Task:

Given a list of village locations and a candle lifespan, output the maximum number of villages Jack can visit.  You do not have to print the path itself.

Input:

The lifespan of the candle and a list of village locations in a Cartesian coordinate system.  The pumpkin patch Jack originates from will always be at 0,0.  You may format the input in anyway you wish.  To simplify Jack's movements, he can only move horizontally, vertically, or diagonally, meaning his candle will either lose 1 or 1.5 (he takes a bit longer diagonally) units of life every move.  The candle burns out when the lifespan is less than or equal to 0.

Output:

An integer equal to the maximum number of villages Jack can visit before the candle burns out.

Rules:

This is code-golf, so shortest code in bytes wins.  Standard loopholes are not allowed.

Test cases:

```<code>// Format [lifespan] [list of village coordinates] -> [maximum visit-able villages]

4 -1,0 1,0 2,0 3,0 4,0 5,0 -> 3
4 1,1 2,2 3,3 -> 2
5 1,1 2,1 3,1 4,1 5,0 5,1 -> 4
</code>```

答:
Racket

```<code>(define (dist x1 y1 x2 y2)     ; fn to find distance between 2 pts
  (sqrt(+ (expt(- x2 x1)2)
          (expt(- y2 y1)2))))

(define (fu x1 y1 x2 y2)       ; find fuel used to move from x1 y1 to x2 y2;
  (let loop ((x1 x1)
             (y1 y1)
             (fuelUsed 0))
    (let* ((d1 (dist (add1 x1) y1 x2 y2))        ; horizontal movement
           (d2 (dist x1 (add1 y1) x2 y2))        ; vertical movement
           (d3 (dist (add1 x1) (add1 y1) x2 y2)) ; diagonal movement
           (m (min d1 d2 d3))) ; find which of above leads to min remaining distance;
      (cond
        [(or (= d2 0)(= d1 0)) (add1 fuelUsed)]
        [(= d3 0) (+ 1.5 fuelUsed)]
        [(= m d1) (loop (add1 x1) y1 (add1 fuelUsed))]
        [(= m d2) (loop x1 (add1 y1) (add1 fuelUsed))]
        [(= m d3) (loop (add1 x1) (add1 y1) (+ 1.5 fuelUsed))]))))

(define (f a l)
  (define u (for/list ((i l))
    (fu 0 0 (list-ref i 0) (list-ref i 1))))  ; find fuel used for each point;
  (for/last ((i u)(n (in-naturals)) #:final (>= i a))
    n))
</code>```

Testing:

```<code>(f 4 '((1 1) (2 2) (3 3))) ;-> 2
(f 5 '((1 1) (2 1) (3 1) (4 1) (5 0) (5 1))) ;-> 4
</code>```

Output:

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

However, above code does not work for negative values of x and y.

Title: Traveling Pumpkin Problem

Body:
Racket

(define (dist x1 y1 x2 y2)     ; fn to find distance between 2 pts
  (sqrt(+ (expt(- x2 x1)2)
          (expt(- y2 y1)2))))

(define (fu x1 y1 x2 y2)       ; find fuel used to move from x1 y1 to x2 y2;
  (let loop ((x1 x1)
             (y1 y1)
             (fuelUsed 0))
    (let* ((d1 (dist (add1 x1) y1 x2 y2))        ; horizontal movement
           (d2 (dist x1 (add1 y1) x2 y2))        ; vertical movement
           (d3 (dist (add1 x1) (add1 y1) x2 y2)) ; diagonal movement
           (m (min d1 d2 d3))) ; find which of above leads to min remaining distance;
      (cond
        [(or (= d2 0)(= d1 0)) (add1 fuelUsed)]
        [(= d3 0) (+ 1.5 fuelUsed)]
        [(= m d1) (loop (add1 x1) y1 (add1 fuelUsed))]
        [(= m d2) (loop x1 (add1 y1) (add1 fuelUsed))]
        [(= m d3) (loop (add1 x1) (add1 y1) (+ 1.5 fuelUsed))]))))

(define (f a l)
  (define u (for/list ((i l))
    (fu 0 0 (list-ref i 0) (list-ref i 1))))  ; find fuel used for each point;
  (for/last ((i u)(n (in-naturals)) #:final (>= i a))
    n))

Testing:

(f 4 '((1 1) (2 2) (3 3))) ;-> 2
(f 5 '((1 1) (2 1) (3 1) (4 1) (5 0) (5 1))) ;-> 4

Output:

2
4

However, above code does not work for negative values of x and y.


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

Example output:

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

or

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

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

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

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

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

Example solution (C, ungolfed, 3768 bytes)

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

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

答:
Jelly, <s>6</s> 4 bytes

```<code>³Ȯ*¡
</code>```

This is a niladic link (function w/o arguments) that prints 10200 copies of the string 100, meaning that it prints 10100 copies of the string that consists of 10100 copies of the string 100.

Try it online!

Note that the online interpreter cuts the output at 100 KB for practical reasons. The code also works as a full program, but due to implicit output, that program prints one copy too many.

How it works

```<code>³Ȯ*¡  Niladic link. No arguments.

³     Set the left argument and initial return value to 100.
 Ȯ    Print the current return value.
  *   Compute 100 ** 100 = 1e200.
   ¡  Call Ȯ 1e200 times.
</code>```

ContentLicense: CC BY-SA 4.0

Title: Output a googol copies of a string

Body:
Jelly, <s>6</s> 4 bytes

³Ȯ*¡

This is a niladic link (function w/o arguments) that prints 10200 copies of the string 100, meaning that it prints 10100 copies of the string that consists of 10100 copies of the string 100.

Try it online!

Note that the online interpreter cuts the output at 100 KB for practical reasons. The code also works as a full program, but due to implicit output, that program prints one copy too many.

How it works

³Ȯ*¡  Niladic link. No arguments.

³     Set the left argument and initial return value to 100.
 Ȯ    Print the current return value.
  *   Compute 100 ** 100 = 1e200.
   ¡  Call Ȯ 1e200 times.


答:
05AB1E, 6 bytes

```<code>Tn°F1?
</code>```

Explanation

```<code>Tn°    # push 10^100
   F   # 10^100 times do
    1? # print 1
</code>```

Title: Output a googol copies of a string

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

Example output:

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

or

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

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

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

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

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

Example solution (C, ungolfed, 3768 bytes)

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

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

Body:
05AB1E, 6 bytes

Tn°F1?

Explanation

Tn°    # push 10^100
   F   # 10^100 times do
    1? # print 1


Title: Output a googol copies of a string

Body:
Haskell, <s>45</s> 43 bytes

r 0=[]
r i='1':r(i-1)
main=putStr.r$10^100


答:
Python,  28 bytes

-1 byte thanks to Jonathan Allan!

Python 2:

i=10**100
while i:print;i-=1
```
<p><strong>Python 3 (30 bytes):</strong></p>
<pre class="lang-py prettyprint-override"><code>i=10**100
while i:print();i-=1
</code>```

Title: Output a googol copies of a string

Body:
Python,  28 bytes

-1 byte thanks to Jonathan Allan!

Python 2:

i=10**100
while i:print;i-=1

Python 3 (30 bytes):

i=10**100
while i:print();i-=1


问:
Encode the alphabet cipher
Given a string that contains only lowercase letters, encode that string with the alphabet cipher.

To encode with the alphabet cipher (I will be using the example hello):

First, convert each letter in the string to a number depending on its position in the alphabet (a = 1, b = 2, etc.) Example: 8 5 12 12 15

Pad each number to two characters with 0s. Example: 08 05 12 12 15

Join. Example: 0805121215

Test cases

```<code>helloworld -> 08051212152315181204
codegolf -> 0315040507151206
alphabetcipher -> 0112160801020520030916080518
johncena -> 1015081403051401
</code>```

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

答:
Perl, 24 bytes

Includes +1 for -p

Give input on STDIN:

```<code>encode.pl <<< hello
</code>```

encode.pl

```<code>#!/usr/bin/perl -p
s/./substr 4+ord$&,1/eg
</code>```

Title: Encode the alphabet cipher

Body:
Perl, 24 bytes

Includes +1 for -p

Give input on STDIN:

encode.pl <<< hello

encode.pl

#!/usr/bin/perl -p
s/./substr 4+ord$&,1/eg


答:
Ruby, 20 bytes

```<code>(10**100).times{p 1}
</code>```

Prints 1 followed by a newline 1E100 times.

1E100 does not work as it evaluates to a float, not an arbitrary precision integer.

Title: Output a googol copies of a string

Body:
Ruby, 20 bytes

(10**100).times{p 1}

Prints 1 followed by a newline 1E100 times.

1E100 does not work as it evaluates to a float, not an arbitrary precision integer.


问:
Figure Out the Android Lock Pattern
Lets say you saw your friend enter his or her password into their Android phone.  You don't remember how they made the pattern but you remember what the pattern looks like.  Being the concerned friend that you are you want to know how secure their password is.  Your job is to calculate all the ways that a particular pattern can be made.

How Android patterns work

Patterns are drawn on a 3x3 grid of nodes.  In a pattern one visits a series of nodes without ever lifting their finger from the screen.  Each node they visit is connected to the previous node by a edge. There are two rules to keep in mind.

You may not visit any one node more than once

An edge may not pass through an unvisited node

Note that, while typically very hard to perform and thus not very common in real android lock combinations, it is possible to move like a Knight.  That is, it is possible to move from one side to a non-adjacent corner or the other way around.  Here are two examples of patterns employing such a move:

Here is a an animated Gif of it being performed.

Solving a pattern

A typical pattern might look something like this:

With a simple pattern like this one it there are two ways two draw the pattern.  You can start at either of the two loose ends and traveling through the highlighted nodes to the other.  While this is true for many patterns particularly ones that human beings typically employ this is not true for all patterns.

Consider the following pattern:

There are two immediately recognizable solutions.  One starting in the upper left:

And one starting in the bottom center:

However because a line is permitted to pass through a point once it has already been selected there is an additional pattern starting in the top middle:

This particular pattern has 3 solutions but patterns can have anywhere between 1 and 4 solutions[citation needed].

Here are some examples of each:

1.

2.

3.

4.

I/O

A node can be represented as the integers from zero to nine inclusive, their string equivalents or the characters from a to i (or A to I).  Each node must have a unique representation from one of these sets.

A solution will be represented by an ordered container containing node representations.  Nodes must be ordered in the same order they are passed through.

A pattern will be represented by an unordered container of pairs of nodes. Each pair represents an edge starting connecting the two points in the pair.  Pattern representations are not unique.

You will take a pattern representation as input via standard input methods and output all the possible solutions that create the same pattern via standard output methods.

You can assume each input will have at least one solution and will connect at least 4 nodes.

You may choose to use a ordered container in place of an unordered one, if you so desire or are forced to by language selection.

Test Cases

With the nodes arranged in the following pattern:

```<code>0 1 2
3 4 5
6 7 8
</code>```

Let {...} be an unordered container, [...] be a ordered container, and (...) be a pair.

The following inputs and outputs should match

```<code>{(1,4),(3,5),(5,8)} -> {[1,4,3,5,8]}
{(1,4),(3,4),(5,4),(8,5)} -> {[1,4,3,5,8]}
{(0,4),(4,5),(5,8),(7,8)} -> {[0,4,5,8,7],[7,8,5,4,0]}
{(0,2),(2,4),(4,7)} -> {[0,1,2,4,7],[1,0,2,4,7],[7,4,2,1,0]}
{(0,2),(2,6),(6,8)} -> {[0,1,2,4,6,7,8],[1,0,2,4,6,7,8],[8,7,6,4,2,1,0],[7,8,6,4,2,1,0]}
{(2,3),(3,7),(7,8)} -> {[2,3,7,8],[8,7,3,2]}
{(0,7),(1,2),(1,4),(2,7)} -> {[0,7,2,1,4],[4,1,2,7,0]}
{(0,4),(0,7),(1,3),(2,6),(2,8),(3,4),(5,7)} -> {[1,3,4,0,7,5,8,2,6]}
{(1,3),(5,8)} -> {}
</code>```

An imgur album of all the test cases as pictures can be found here.  Patterns are in blue solutions in red.

Scoring

This is code golf. Fewest bytes wins.

答:
Python 2.7, <s>493</s> 430 bytes

exec("L=['012','345','678','036','147','258','048','246'];L+=[i[::-1]IL];S=sorted;F=lambda t:''.join(str(i)It)\ndef N(x):\n s=' '.join(F(S(i))Ix)\nIL:s=s.replace(i[::2],i[:2]+' '+i[1:])\n return S(set(s.split()))\ndef P(s):\n e=0\nIL:e|=-1<s.find(i[::2])<s.find(i[1])\n return[zip(s[:-1],s[1:]),L][e]\nx=N(input());print[F(i)I__import__('itertools').permutations({iI`x`if i.isdigit()})if x==N(P(F(i)))]".replace('I',' for i in '))
```

<p>The single line version wraps the program with <code>exec("...".replace('I',' for i in '))</code> so that all for-loops and generators can be shorted with a single <code>I</code> and saves 15 bytes over this more readable version:</p>

<pre class="lang-python prettyprint-override"><code>L=['012','345','678','036','147','258','048','246'];L+=[i[::-1]for i in L]
S=sorted;F=lambda t:''.join(str(i)for i in t)
def N(x):
 s=' '.join(F(S(i))for i in x)
 for i in L:s=s.replace(i[::2],i[:2]+' '+i[1:])
 return S(set(s.split()))
def P(s):
 e=0
 for i in L:e|=-1<s.find(i[::2])<s.find(i[1])
 return[zip(s[:-1],s[1:]),L][e]
x=N(input())
print[F(i)for i in __import__('itertools').permutations({i for i in`x`if i.isdigit()})if x==N(P(F(i)))]
</code>```

The program takes the input in the manner shown (e.g. {(1,4),(3,4),(5,4),(8,5)}) or as a list of string (e.g. ['14','34','54','85']) (or in other python friendly formats) and returns the output as a list of strings. So we technically have an ordered container of ordered containers.

The function N normalizes a pattern so that two patterns can be easily compared. The normalization sorts the pairs denoting edges (so '02' instead of '20'), use string replacement to expand double edges (e.g. '02' becomes '01 12'), splits the edges into a set to remove duplicates, and sorts the result.

The function F flattens tuples of ints/strings to strings, so we can normalize paths produced in different ways.

The list L contains all lines on screen.

We then take each permutation of all digits in the normalized pattern and compute a valid path or L if invalid (which never normalizes to list of pairs like real paths would), or a list of pairs indicating the order nodes are visited if valid. If this normalizes to the same pattern then we have a valid solution and include it in the final list.

The main check needed to validate a permutation as a string s is -1<s.find(i[::2])<s.find(i[1]), which detects an error with a line i. For instance with the line '210' the code detects an error if '20' occurs (i.e. it's index is greater than -1) and '1' occurs after it. We don't have to worry about 1 not occurring because the 1 will show up in the normalized pattern when it wasn't in the input.

NOTE: I know replacing str(i)for i in t with map(str,t) and {i for i in`x`if i.isdigit()} with set('012345678')&set(`x`) would make the original code shorter, but this would still be slightly longer that substituting I.

Title: Figure Out the Android Lock Pattern

Body:
Python 2.7, <s>493</s> 430 bytes

exec("L=['012','345','678','036','147','258','048','246'];L+=[i[::-1]IL];S=sorted;F=lambda t:''.join(str(i)It)\ndef N(x):\n s=' '.join(F(S(i))Ix)\nIL:s=s.replace(i[::2],i[:2]+' '+i[1:])\n return S(set(s.split()))\ndef P(s):\n e=0\nIL:e|=-1<s.find(i[::2])<s.find(i[1])\n return[zip(s[:-1],s[1:]),L][e]\nx=N(input());print[F(i)I__import__('itertools').permutations({iI`x`if i.isdigit()})if x==N(P(F(i)))]".replace('I',' for i in '))

The single line version wraps the program with exec("...".replace('I',' for i in ')) so that all for-loops and generators can be shorted with a single I and saves 15 bytes over this more readable version:

L=['012','345','678','036','147','258','048','246'];L+=[i[::-1]for i in L]
S=sorted;F=lambda t:''.join(str(i)for i in t)
def N(x):
 s=' '.join(F(S(i))for i in x)
 for i in L:s=s.replace(i[::2],i[:2]+' '+i[1:])
 return S(set(s.split()))
def P(s):
 e=0
 for i in L:e|=-1<s.find(i[::2])<s.find(i[1])
 return[zip(s[:-1],s[1:]),L][e]
x=N(input())
print[F(i)for i in __import__('itertools').permutations({i for i in`x`if i.isdigit()})if x==N(P(F(i)))]

The program takes the input in the manner shown (e.g. {(1,4),(3,4),(5,4),(8,5)}) or as a list of string (e.g. ['14','34','54','85']) (or in other python friendly formats) and returns the output as a list of strings. So we technically have an ordered container of ordered containers.

The function N normalizes a pattern so that two patterns can be easily compared. The normalization sorts the pairs denoting edges (so '02' instead of '20'), use string replacement to expand double edges (e.g. '02' becomes '01 12'), splits the edges into a set to remove duplicates, and sorts the result.

The function F flattens tuples of ints/strings to strings, so we can normalize paths produced in different ways.

The list L contains all lines on screen.

We then take each permutation of all digits in the normalized pattern and compute a valid path or L if invalid (which never normalizes to list of pairs like real paths would), or a list of pairs indicating the order nodes are visited if valid. If this normalizes to the same pattern then we have a valid solution and include it in the final list.

The main check needed to validate a permutation as a string s is -1<s.find(i[::2])<s.find(i[1]), which detects an error with a line i. For instance with the line '210' the code detects an error if '20' occurs (i.e. it's index is greater than -1) and '1' occurs after it. We don't have to worry about 1 not occurring because the 1 will show up in the normalized pattern when it wasn't in the input.

NOTE: I know replacing str(i)for i in t with map(str,t) and {i for i in`x`if i.isdigit()} with set('012345678')&set(`x`) would make the original code shorter, but this would still be slightly longer that substituting I.


答:
Pyth, <s>8</s> 7 bytes

```<code>V^T100G
</code>```

Link

Solution is tested with small output, but it should print abcdefghijklmnopqrstuvwxyz 1e100 times.

For some reason, the p was unneeded, as 31343 (Maltysen) said.

Title: Output a googol copies of a string

Body:
Pyth, <s>8</s> 7 bytes

V^T100G

Link

Solution is tested with small output, but it should print abcdefghijklmnopqrstuvwxyz 1e100 times.

For some reason, the p was unneeded, as 31343 (Maltysen) said.


答:
/// / ><>, 22 bytes

```<code>\treat/
>"kcirt"ooooo;
</code>```

Try it online! Slashes | Fish

Explanation

(♥ is a newline)

///

```<code>\t                      Print "t"
  reat                  Print "reat"
      /♥>"kcirt"ooooo;  Incomplete replacement, ignored
</code>```

><>

```<code>\                       Mirror, makes IP go down
       ♥>               Go right
         "kcirt"ooooo   Print "trick"
                     ;  End program
</code>```

Title: Trick or Treat polyglot

Body:
/// / ><>, 22 bytes

\treat/
>"kcirt"ooooo;

Try it online! Slashes | Fish

Explanation

(♥ is a newline)

///

\t                      Print "t"
  reat                  Print "reat"
      /♥>"kcirt"ooooo;  Incomplete replacement, ignored

><>

\                       Mirror, makes IP go down
       ♥>               Go right
         "kcirt"ooooo   Print "trick"
                     ;  End program


答:
C, 51 bytes

Function g() calls recursive function f() to depth 99.

Excludes unnecessary newline added between f() and g() for clarity.

```<code>f(n,i){for(i=10;i--;)n?f(n-1):puts("");}
g(){f(99);}

//call like this
main(){g();}
</code>```

Prints 1E100 newlines.

Declaration of i as second parameter of f() not guaranteed to work in all versions of C. Tested on my own machine (GCC on CygWin) and on ideone.com (I believe they also run GCC), but not up to f(99) for obvious reasons!

Title: Output a googol copies of a string

Body:
C, 51 bytes

Function g() calls recursive function f() to depth 99.

Excludes unnecessary newline added between f() and g() for clarity.

f(n,i){for(i=10;i--;)n?f(n-1):puts("");}
g(){f(99);}

//call like this
main(){g();}

Prints 1E100 newlines.

Declaration of i as second parameter of f() not guaranteed to work in all versions of C. Tested on my own machine (GCC on CygWin) and on ideone.com (I believe they also run GCC), but not up to f(99) for obvious reasons!


答:
Pyth, 7 Bytes

New (Competing)

```<code>V^T*TTG
</code>```

Explanation

```<code>G=The alphabet
Repeat 10^(10*10) times
    print(G)
</code>```

Old (Non Competing) 7 Bytes

```<code>*G^T*TT
</code>```

Explanation

```<code>G=The alphabet
G*(10^(10*10))==G*10^100
</code>```

Title: Output a googol copies of a string

Body:
Pyth, 7 Bytes

New (Competing)

V^T*TTG

Explanation

G=The alphabet
Repeat 10^(10*10) times
    print(G)

Old (Non Competing) 7 Bytes

*G^T*TT

Explanation

G=The alphabet
G*(10^(10*10))==G*10^100


Title: Output a googol copies of a string

Body:
Fuzzy Octo Guacamole, <s>13</s> <s>12</s> <s>11</s> 10 bytes

9+ddpp![g]

Explanation:

9+ddpp![g]
9+           # push 9 and increment, giving 10
  dd         # duplicate, twice. now you have [10,10,10]
    pp       # raise a 10 to the 10th power, then raise that to the 10th again. That ends up being 10^100.
      ![ ]   # for loop, `!` sets the counter to the top of stack
        g    # prints an ASCII art goat.

Sample of the goat printed:

                  ___.
                 //  \\
                ((   ""
                 \\__,
                /6 (%)\,
               (__/:";,;\--____----_
                ;; :";,:";`;,";,;";`,`_
                  ;:,;;";";,;":,";";,-Y\
                   ;,;,;";";,;":;";"; Z/
                   / ;,";";,;";,;";;"
                  / / |";/~~~~~\";;"
                 ( K  | |      || |
                  \_\ | |      || |
                   \Z | |      || |
                      L_|      LL_|
                      LW/      LLW/


答:
C# - <s>127</s> <s>123</s> 98 bytes

```<code>using System;using b=Numerics.BigInteger;void f(){for(b n=b.Pow(10,100);n-->0;)Console.Write(0);}}
</code>```

1 byte from Kevin Cruijssen!

24 bytes from Phaeze!

Prints 10^100 copies of 0.

Title: Output a googol copies of a string

Body:
C# - <s>127</s> <s>123</s> 98 bytes

using System;using b=Numerics.BigInteger;void f(){for(b n=b.Pow(10,100);n-->0;)Console.Write(0);}}

1 byte from Kevin Cruijssen!

24 bytes from Phaeze!

Prints 10^100 copies of 0.


答:
Ruby / Crystal, 31 bytes

puts 'a'=="a"&&"trick"||"treat"

'a' is a string literal in Ruby and a character literal in Crystal. "a" is a string literal in both. This abuses that difference to detect the language the script is ran in.

Title: Trick or Treat polyglot

Body:
Since Halloween is coming up I thought I might start a fun little code golf challenge!

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

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

Your program has to do the following:

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

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

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

A few explanations:

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

```<code>"trick"

"Treat"

"    TReAt"

"
     tRICk          "
</code>```

Invalid outputs:

```<code>"tri ck"

"tr
eat"

"trck"
</code>```

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

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

Leaderboards

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

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

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

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

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

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

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

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

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

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```


问:
Reimplementing square root
Define a function, s, which takes a number and returns the square root.

No use of library functions, such as Java's Math.sqrt() or PHP's built in sqrt(), allowed.

答:
```<code>def sqrt_newton(x):
 f,g,w,d=lambda a:a*a-x,lambda a:2.0*a,x/2.0,1e-4
 while abs(f(w))>d:w-=(f(w)/2.0/w)
 return w
</code>```

reduced version of https://gist.github.com/713104

ContentLicense: CC BY-SA 2.5

Title: Reimplementing square root

Body:
def sqrt_newton(x):
 f,g,w,d=lambda a:a*a-x,lambda a:2.0*a,x/2.0,1e-4
 while abs(f(w))>d:w-=(f(w)/2.0/w)
 return w

reduced version of https://gist.github.com/713104


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

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

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

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

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

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

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

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

Title: Next Friday the 13th

Body:
BASH

#!/bin/bash
from=$1
if [ "$from" = "" ]; then
from=`date +%Y-%m-%d`
fi
i=1
while [ "$isFri" = "" ] || [ "$is13" = "" ]
do
isFri=`date -d "${from} ${i} days" | grep Fri`
is13=`date -d "${from} ${i} days" +%Y-%m-%d | grep "\-13"`
((i++))
done
((i--))
date -d "${from} ${i} days" +%Y-%m-%d

CONCEPT USED:

$ date -d "2011-02-16 2 days" +%Y-%m-%d
2011-02-18

SAMPLE I/O

:~/aman> ./fr13th.sh
2011-05-13
:~/aman> ./fr13th.sh 2013-05-09
2013-09-13
:~/aman> ./fr13th.sh 2007-06-29
2007-07-13
:~/aman> ./fr13th.sh 2007-07-13
2008-06-13


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

答:
C (Atari TOS 2.06 US), <s>129 124 117</s> 113 bytes

```<code>short*a=0xe013b0;main(j,l)char**l;{for(;*a++-224;puts(""))for(j=*l[1]*16-768;j--;printf(*a&1<<j%16?"##":"  "));}
</code>```

This uses the bomb bitmap from the TOS ROM, which is slightly different from the one in the question. For other versions of TOS, you'll have to adjust the address pointed to by *a. Note that some emulator roms don't include the bomb bitmap!

If you don't provide a command line argument, several high resolution bitmapped bombs may be displayed :-)

Title: Let's draw some Atari ST bombs!

Body:
C (Atari TOS 2.06 US), <s>129 124 117</s> 113 bytes

short*a=0xe013b0;main(j,l)char**l;{for(;*a++-224;puts(""))for(j=*l[1]*16-768;j--;printf(*a&1<<j%16?"##":"  "));}

This uses the bomb bitmap from the TOS ROM, which is slightly different from the one in the question. For other versions of TOS, you'll have to adjust the address pointed to by *a. Note that some emulator roms don't include the bomb bitmap!

If you don't provide a command line argument, several high resolution bitmapped bombs may be displayed :-)


答:
Pyke, <s>6</s> 5 bytes

```<code>TTX^V
</code>```

Try it here!

Untested as it crashes my browser. The first 4 chars generate 10^100 and V prints out that many newlines. Test with 100V.

Title: Output a googol copies of a string

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

Example output:

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

or

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

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

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

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

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

Example solution (C, ungolfed, 3768 bytes)

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

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

Body:
Pyke, <s>6</s> 5 bytes

TTX^V

Try it here!

Untested as it crashes my browser. The first 4 chars generate 10^100 and V prints out that many newlines. Test with 100V.


答:
Node, 89 bytes

```<code>for(i="0".repeat(100)+1;+i;i=i.replace(/0*./,x=>"9".repeat(x.length-1)+~-x))console.log()
</code>```

Outputs 10100 newlines. (Theoretically, that is; test by replacing 100 with 1 to output 101 newlines instead.)

This works by setting i to the string

```<code>00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
</code>```

(100 zeroes and a 1; a googol reversed), then repeatedly "subtracting 1" with a regex replace and outputting a newline until the string is all zeroes.

A port of the C++ answer would be 49 bytes:

```<code>(f=n=>{for(i=10;i--;)n?f(n-1):console.log()})(99)
</code>```

Title: Output a googol copies of a string

Body:
Node, 89 bytes

for(i="0".repeat(100)+1;+i;i=i.replace(/0*./,x=>"9".repeat(x.length-1)+~-x))console.log()

Outputs 10100 newlines. (Theoretically, that is; test by replacing 100 with 1 to output 101 newlines instead.)

This works by setting i to the string

00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001

(100 zeroes and a 1; a googol reversed), then repeatedly "subtracting 1" with a regex replace and outputting a newline until the string is all zeroes.

A port of the C++ answer would be 49 bytes:

(f=n=>{for(i=10;i--;)n?f(n-1):console.log()})(99)


问:
Pythagorean Triple Sequence

A Pythagorean triple consists of three positive integers a, b, and c, such that a2 + b2 = c2. Such a triple is commonly written (a, b, c), and a well-known example is (3, 4, 5). If (a, b, c) is a Pythagorean triple, then so is (ka, kb, kc) for any positive integer k. A primitive Pythagorean triple is one in which a, b and c are coprime.

Using this knowledge, we can create a sequence by chaining together the least lengths of triples, where the next element in the sequence is the hypotenuse (largest number) of the smallest primitive Pythagorean triple containing the previous element as the smallest one of its lengths.

Start with the smallest primitive Pythagorean triple (3, 4, 5). The sequence begins with 3, and the hypotenuse (next element in the sequence) is 5. Then find the smallest primitive Pythagorean triple with 5 as a leg, and you get (5, 12, 13). So the sequence continues with 13.

Either output the sequence forever, or take an integer input n and output the first n elements of the sequence, either zero or one indexed.

You need to support output at least through and including 28455997, but if the limit of the data type you are using was suddenly raised, it would need to work for that new limit. So you cannot hard code a list of numbers.

```<code>3
5
13
85
157
12325
90733
2449525
28455997
295742792965
171480834409967437
656310093705697045
1616599508725767821225590944157
4461691012090851100342993272805
115366949386695884000892071602798585632943213
12002377162350258332845595301471273220420939451301220405
</code>```

OEIS A239381

Similar sequences (don't output these!):

A018928

A077034 (the odd terms)

答:
Java 8, 133 Bytes

-25 bytes thanks to miles Using n*n instead of Math.pow(n, 2)

-24 bytes thanks to miles Using for loops instead of while, changing datatype, eliminating () due to order of operations

```<code>()->{long b=3,c,n;for(;;){for(n=1;;n++){c=b+2*n*n;double d=Math.sqrt(c*c-b*b);if(d==(int)d&b<d){System.out.println(b);break;}}b=c;}};
</code>```

Uses the fact that

for any pair of integers m > n > 0. Therefore, C is equal to A plus 2(N)2. The function above finds the least value of N that satisfies this relation, while making the second element of the Pythagorean triple an integer and greater than the first element. Then it sets the value of the first element to the third element and repeats with the updated first element.

Ungolfed:

```<code>void printPythagoreanTriples() {
    long firstElement = 3, thirdElement, n;
    while (true) {
        for (n = 1; ; n++) {
            thirdElement = firstElement + (2 * n * n);
            double secondElement = Math.sqrt(thirdElement * thirdElement - firstElement * firstElement);
            if (secondElement == (int) secondElement && firstElement < secondElement) {
                System.out.println("Found Pythagorean Triple [" +
                        firstElement + ", " +
                        secondElement + ", " +
                        thirdElement + "]");
                break;
            }
        }
        firstElement = thirdElement;
    }
}
</code>```

Ideone it!

*The ideone does not print the last required element due to time limits, however as you can see through the logic of the program and the ungolfed version (which prints the 28455997 as the third element of the previous Pythagorean triple rather than the first element of the next), the values are, with a higher time limit, printed.

Title: Pythagorean Triple Sequence

Body:
Java 8, 133 Bytes

-25 bytes thanks to miles Using n*n instead of Math.pow(n, 2)

-24 bytes thanks to miles Using for loops instead of while, changing datatype, eliminating () due to order of operations

()->{long b=3,c,n;for(;;){for(n=1;;n++){c=b+2*n*n;double d=Math.sqrt(c*c-b*b);if(d==(int)d&b<d){System.out.println(b);break;}}b=c;}};

Uses the fact that

for any pair of integers m > n > 0. Therefore, C is equal to A plus 2(N)2. The function above finds the least value of N that satisfies this relation, while making the second element of the Pythagorean triple an integer and greater than the first element. Then it sets the value of the first element to the third element and repeats with the updated first element.

Ungolfed:

void printPythagoreanTriples() {
    long firstElement = 3, thirdElement, n;
    while (true) {
        for (n = 1; ; n++) {
            thirdElement = firstElement + (2 * n * n);
            double secondElement = Math.sqrt(thirdElement * thirdElement - firstElement * firstElement);
            if (secondElement == (int) secondElement && firstElement < secondElement) {
                System.out.println("Found Pythagorean Triple [" +
                        firstElement + ", " +
                        secondElement + ", " +
                        thirdElement + "]");
                break;
            }
        }
        firstElement = thirdElement;
    }
}

Ideone it!

*The ideone does not print the last required element due to time limits, however as you can see through the logic of the program and the ungolfed version (which prints the 28455997 as the third element of the previous Pythagorean triple rather than the first element of the next), the values are, with a higher time limit, printed.


答:
ABCR, 56 bytes

```<code>++++++++++AAAAAAAAAA7a*A!(x4bBBBBBBBBBB7b+B@(xa(Ax5b(Box
</code>```

Turing tarpits are fun, especially when they don't have easy multiplication or exponents.  On the other hand, I only needed to use two of the three queues!

Explanation:

```<code>++++++++++                                             Set register to 10
          AAAAAAAAAA                                   Queue 10 to queue A 10 times
                    7a*A!(x                            Sum up all of queue A by:
                    7     x                             While the register is truthy:
                     a*                                 Dequeue two elements of A, sum them...
                       A                                ...and queue the result back to A.
                        !(                              If there's only one element left,
                                                        i.e. !(A.len - 1),
                                                        break from the loop.  A now has 100, our exponent.

                             4                        While A's front is truthy:
                              bBBBBBBBBBB              Clone the front of B 10 (our base) times.  (The first iteration fills it up with ten 1s)
                                         7b+B@(x       Sum up all of queue B like we did with A
                                                a(A    Decrement a (so that the loop actually ends. Runs 101 times like it should) x

                                                       B now contains 10^100 only.

                                                   5b(B x   10^100 times:
                                                       o     print the front of queue A (0)
</code>```

Title: Output a googol copies of a string

Body:
ABCR, 56 bytes

++++++++++AAAAAAAAAA7a*A!(x4bBBBBBBBBBB7b+B@(xa(Ax5b(Box

Turing tarpits are fun, especially when they don't have easy multiplication or exponents.  On the other hand, I only needed to use two of the three queues!

Explanation:

++++++++++                                             Set register to 10
          AAAAAAAAAA                                   Queue 10 to queue A 10 times
                    7a*A!(x                            Sum up all of queue A by:
                    7     x                             While the register is truthy:
                     a*                                 Dequeue two elements of A, sum them...
                       A                                ...and queue the result back to A.
                        !(                              If there's only one element left,
                                                        i.e. !(A.len - 1),
                                                        break from the loop.  A now has 100, our exponent.

                             4                        While A's front is truthy:
                              bBBBBBBBBBB              Clone the front of B 10 (our base) times.  (The first iteration fills it up with ten 1s)
                                         7b+B@(x       Sum up all of queue B like we did with A
                                                a(A    Decrement a (so that the loop actually ends. Runs 101 times like it should) x

                                                       B now contains 10^100 only.

                                                   5b(B x   10^100 times:
                                                       o     print the front of queue A (0)


Title: Output a googol copies of a string

Body:
Racket 36 bytes

(for((i(expt 10 100)))(display "1"))

Output:

1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...


问:
Find the Wavy Words!
(Note: this is an easier spin-off of my previous challenge Find the Infinity Words!, which is a spin-off of my other previous challenge Find the Swirling Words! :) )

Definition of a Wavy Word:

If you connect with curves all the characters of a Wavy Word on the alphabet (A-Z) you obtain the path of a wave continuously going toward right or toward left and never changing direction, like in the diagrams below.

A Wavy Word can be:

Raising if each consecutive character is at the right (on the alphabet) of the previous one.

Decreasing if each consecutive character is at the left (on the alphabet) of the previous one.

All the even connection must be down, all the odd connections must be up.

You can ignore upper/lowercase or consider/convert all to upper case or all to lower case.

The input words are only characters in the alphabet range of A-Z, no spaces, no punctuation, or symbols.

If a word has double characters, like "SPOON", you must collapse the doubles to one character: "SPOON" > "SPON" (because if you go from O to O is zero distance).

The Wavy Words will contain at least 3 distinct characters (even after doubles collapsing).

Here there are some examples:

Task:

Write a full program or function that will take a word from standard input and will output if it is a Wavy Word or not, and in positive case, output if it is raising or decreasing. The output can be True/False/Null, 2/1/0, 1/Null/0, -1/0/1, NO/WR/WD, etc, you decide how to represent it.

Test cases:

```<code>WAVY WORDS:
  ADEPT, BEGIN, BILL, BOSS, BOOST, CHIMP,
  KNOW, SPONGE, SPOON, TROLL, WOLF

ADEPT  > YES > RAISING
BEGIN  > YES > RAISING
BILL   > YES > RAISING
BOSS   > YES > RAISING
BOOST  > YES > RAISING
CHIMP  > YES > RAISING
KNOW   > YES > RAISING
SPONGE > YES > DECREASING
SPOON  > YES > DECREASING
TROLL  > YES > DECREASING
WOLF   > YES > DECREASING

NOT WAVY WORDS:
  WATCH, EARTH, NINON, FOO, BAR, WAVE, SELECTION,
  YES, NO, DEFINITION, WATER, WINE, CODE, AAAHHHH, I, MM, ABCA
</code>```

Rules:

Shortest code wins.

Optional Task:

Find, as a list, as many Wavy Words as you can in an English dictionary, and the longest as well. You can take for example as reference the complete list of English words here.

答:
Groovy - 56 bytes

```{d=it[0];c=[0]*3;it.each{a->c[(a<=>d)]=1;d=a};c[1..-1]}```

Outputs [1,0] for raising wavy, [0,1] for decreasing wavy, [0,0] for single character input or [1,1] for non-wavy.

NOTE: Assumes input is either a String or a char[] and all letters are of the same case.

Title: Find the Wavy Words!

Body:
Groovy - 56 bytes

{d=it[0];c=[0]*3;it.each{a->c[(a<=>d)]=1;d=a};c[1..-1]}

Outputs [1,0] for raising wavy, [0,1] for decreasing wavy, [0,0] for single character input or [1,1] for non-wavy.

NOTE: Assumes input is either a String or a char[] and all letters are of the same case.


答:
Batch, <s>574</s> 242 bytes

```<code>@echo off
set t=for /l %%a in (2,1,33554432)do call:
set f=for /l %%a in (2,1,9765625)do call:
%t%a
:a
%t%b
:b
%t%c
:c
%t%d
:d
%f%e
:e
%f%f
:f
%f%g
:g
%f%h
:h
%f%i
:i
%f%j
:j
%f%k
:k
%f%l
:l
%f%m
:m
%f%n
:n
echo
</code>```

Each loop falls through therefore executing an additional iteration. Loops are limited to ~2³² due to the 32-bit integer limit. The first four loops each count 2²⁵ for a total of 2¹⁰⁰ while the remaining ten loops each count 5¹⁰ for a total of 5¹⁰⁰.

Edit: Saved an unimaginable 58% thanks to @ConorO'Brien.

Title: Output a googol copies of a string

Body:
Batch, <s>574</s> 242 bytes

@echo off
set t=for /l %%a in (2,1,33554432)do call:
set f=for /l %%a in (2,1,9765625)do call:
%t%a
:a
%t%b
:b
%t%c
:c
%t%d
:d
%f%e
:e
%f%f
:f
%f%g
:g
%f%h
:h
%f%i
:i
%f%j
:j
%f%k
:k
%f%l
:l
%f%m
:m
%f%n
:n
echo

Each loop falls through therefore executing an additional iteration. Loops are limited to ~2³² due to the 32-bit integer limit. The first four loops each count 2²⁵ for a total of 2¹⁰⁰ while the remaining ten loops each count 5¹⁰ for a total of 5¹⁰⁰.

Edit: Saved an unimaginable 58% thanks to @ConorO'Brien.


Title: Pythagorean Triple Sequence

Body:
A Pythagorean triple consists of three positive integers a, b, and c, such that a2 + b2 = c2. Such a triple is commonly written (a, b, c), and a well-known example is (3, 4, 5). If (a, b, c) is a Pythagorean triple, then so is (ka, kb, kc) for any positive integer k. A primitive Pythagorean triple is one in which a, b and c are coprime.

Using this knowledge, we can create a sequence by chaining together the least lengths of triples, where the next element in the sequence is the hypotenuse (largest number) of the smallest primitive Pythagorean triple containing the previous element as the smallest one of its lengths.

Start with the smallest primitive Pythagorean triple (3, 4, 5). The sequence begins with 3, and the hypotenuse (next element in the sequence) is 5. Then find the smallest primitive Pythagorean triple with 5 as a leg, and you get (5, 12, 13). So the sequence continues with 13.

Either output the sequence forever, or take an integer input n and output the first n elements of the sequence, either zero or one indexed.

You need to support output at least through and including 28455997, but if the limit of the data type you are using was suddenly raised, it would need to work for that new limit. So you cannot hard code a list of numbers.

```<code>3
5
13
85
157
12325
90733
2449525
28455997
295742792965
171480834409967437
656310093705697045
1616599508725767821225590944157
4461691012090851100342993272805
115366949386695884000892071602798585632943213
12002377162350258332845595301471273220420939451301220405
</code>```

OEIS A239381

Similar sequences (don't output these!):

A018928

A077034 (the odd terms)

Body:
Racket 106 bytes

(let p((h 3))(println h)(let p2((i 1))(define g(sqrt(+(* h h)(* i i))))(if(integer? g)(p g)(p2(add1 i)))))

Ungolfed:

(define (f)
  (let loop ((h 3))
    (let loop2 ((i 1))
      (define g (sqrt (+(* h h) (* i i))))
      (if (not(integer? g))
          (loop2 (add1 i))
          (begin (printf "~a ~a ~a~n" h i g)
                 (loop g))))))

Testing:

(f)

Output of golfed version:

3
5
13
85
157
12325
12461
106285
276341
339709
10363909
17238541

Output of ungolfed version:

3 4 5
5 12 13
13 84 85
85 132 157
157 12324 12325
12325 1836 12461
12461 105552 106285
106285 255084 276341
276341 197580 339709
339709 10358340 10363909
10363909 13775220 17238541

(Error after this on my machine)


答:
ForceLang, 58 bytes

```<code>set k 10.pow 100
label a
set k k+-1
io.write 1
if k
goto a
</code>```

Title: Output a googol copies of a string

Body:
ForceLang, 58 bytes

set k 10.pow 100
label a
set k k+-1
io.write 1
if k
goto a


答:
Java, <s>198</s> <s>179</s> 155 bytes

```<code>import java.math.*;class a{void A(a[]x){for(BigInteger b=BigInteger.ZERO;!(b=b.add(BigInteger.ONE)).equals(BigInteger.TEN.pow(100));)System.out.print(x);}}
</code>```

Prints (x == null ? null : a string that starts with [La;@ or something like that) 10100 times in O(forever) time.

Title: Output a googol copies of a string

Body:
Java, <s>198</s> <s>179</s> 155 bytes

import java.math.*;class a{void A(a[]x){for(BigInteger b=BigInteger.ZERO;!(b=b.add(BigInteger.ONE)).equals(BigInteger.TEN.pow(100));)System.out.print(x);}}

Prints (x == null ? null : a string that starts with [La;@ or something like that) 10100 times in O(forever) time.


答:
JAISBaL, 4 bytes

```<code>˖Q
</code>```

Chrome can't read all the symbols, and I'm not sure about other browsers, so here's a picture:

Explanation:

```<code># \# enable verbose parsing #\
10^100       \# [0] push 10^100 onto the stack #\
for          \# [1] start for loop #\
    space    \# [2] print a space #\
</code>```

Pretty simple.... just prints a googol spaces. Three instructions, but the googol constant is two bytes.

(Written in version 3.0.5)

Title: Output a googol copies of a string

Body:
JAISBaL, 4 bytes

˖Q

Chrome can't read all the symbols, and I'm not sure about other browsers, so here's a picture:

Explanation:

# \# enable verbose parsing #\
10^100       \# [0] push 10^100 onto the stack #\
for          \# [1] start for loop #\
    space    \# [2] print a space #\

Pretty simple.... just prints a googol spaces. Three instructions, but the googol constant is two bytes.

(Written in version 3.0.5)


答:
Befunge 93, 33 bytes

```<code>1>01g0`#@!# _01v
d^.1 **52p10-1g<
</code>```

Unfortunately, Befunge does not have a power function, so almost all of that code is my implementation of a power function. I'm still working on this.

Explanation:

```<code>1 > 01g 0` #@!# _ 01g 1- 01p 25** 1. v
d ^                                  <
</code>```

1: Start off with 1 in the top left so that when we multiply, we don't get 0 every time.

01g: get the character at position (0, 1), which is d, whose ASCII code is 100.

0`: see if the value stored in (0, 1) is greater than 0; this value will change.

#@!# _: Logical not ! to the value we get from the last step (0 or 1), so that if it was 1, now we have 0, and we  Note that # means that you skip the next character in the code.

01g 1- 01p: Take the value stored in (0, 1) again, subtract 1 from it, and store this new value at (0, 1)

25**: multiply the top value of the stack by 10

1.: print 1 every time this loops

1 is printed (in theory) googol times, but that quickly runs off of the page that I tested this on.

You can run Befunge 93 code here. For some reason, the top value of the stack is 1.0000000000000006e+100 when it should be 1.0e+100. I don't know where that 6 came from, but I don't think it should be there and that it may be some rounding error or something like that.

Title: Output a googol copies of a string

Body:
Befunge 93, 33 bytes

1>01g0`#@!# _01v
d^.1 **52p10-1g<

Unfortunately, Befunge does not have a power function, so almost all of that code is my implementation of a power function. I'm still working on this.

Explanation:

1 > 01g 0` #@!# _ 01g 1- 01p 25** 1. v
d ^                                  <

1: Start off with 1 in the top left so that when we multiply, we don't get 0 every time.

01g: get the character at position (0, 1), which is d, whose ASCII code is 100.

0`: see if the value stored in (0, 1) is greater than 0; this value will change.

#@!# _: Logical not ! to the value we get from the last step (0 or 1), so that if it was 1, now we have 0, and we  Note that # means that you skip the next character in the code.

01g 1- 01p: Take the value stored in (0, 1) again, subtract 1 from it, and store this new value at (0, 1)

25**: multiply the top value of the stack by 10

1.: print 1 every time this loops

1 is printed (in theory) googol times, but that quickly runs off of the page that I tested this on.

You can run Befunge 93 code here. For some reason, the top value of the stack is 1.0000000000000006e+100 when it should be 1.0e+100. I don't know where that 6 came from, but I don't think it should be there and that it may be some rounding error or something like that.


问:
The Last Monday
Monday, October 31st, is Halloween. And it got me thinking -- I wonder what other months have the last day of the month also be a Monday?

Input

A positive integer in any convenient format representing a year, 10000 > y > 0.

The input can be padded with zeros (e.g., 0025 for year 25) if
required.

Output

A list of the months of that year where the last day of the month is a Monday.

This can be as month names (e.g., January, March, October), or shortnames (Jan, Mar, Oct), or numbers (1, 3, 10), as separate lines or a list or delimited, etc., just so long as it's unambiguous to the reader.

The output format must be consistent:

For all years input (meaning, you can't output month names for some inputs, and month numbers for other inputs)

As well as consistent per output (meaning, you can't output 1 for January in the same output as Jul for July)

Basically, pick one format and stick to it.

Rules

Assume the Gregorian calendar for input/output, even down to y = 1.

Leap years must be properly accounted for (as a reminder: every year divisible by 4, except not years divisible by 100, unless also divisible by 400 -- 1700, 1800, 1900 all weren't leap years, but 2000 was).

You may use any built-ins or other date calculation tools you like.

Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.

Standard loopholes are forbidden.

This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

Examples

```<code>   1 --> Apr, Dec
 297 --> May
1776 --> Sep
2000 --> Jan, Jul
2016 --> Feb, Oct
3385 --> Jan, Feb, Oct
</code>```

Leaderboard

var QUESTION_ID=97585,OVERRIDE_USER=42963;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

```

答:
C, 119 bytes

t=1248700335,m;main(y){for(scanf("%d",&y),t+=y&3||y%25<1&&y&15;m++,(6+y+y/4-y/100+y/400+t)%7||printf("%d,",m),t;t/=7);}
```

<p>This uses a table that contains the offset of the weekdays of the last day of every month for a leap year, encoded in a signed 32-bit word using base 7. If it is not a leap year we add 1 to the offset of January (as you can see <code>y&3||y%25<1&&y&15</code> is used to check for years without leap days). Then we simply loop through every month and check if its last day is a Monday. Quite simple actually, no ugly hacks or tricks. Here it is slightly ungolfed:</p>

<pre class="lang-c prettyprint-override"><code>t=1248700335,m;
main(y){
  for(
    scanf("%d",&y),t+=y&3||y%25<1&&y&15;
    m++,(6+y+y/4-y/100+y/400+t)%7||printf("%d,",m),t;
    t/=7
  );
}
</code>```

I might revisit this to rewrite it as a function to save a few characters. The printf also takes up a little too much space...

Title: The Last Monday

Body:
C, 119 bytes

t=1248700335,m;main(y){for(scanf("%d",&y),t+=y&3||y%25<1&&y&15;m++,(6+y+y/4-y/100+y/400+t)%7||printf("%d,",m),t;t/=7);}

This uses a table that contains the offset of the weekdays of the last day of every month for a leap year, encoded in a signed 32-bit word using base 7. If it is not a leap year we add 1 to the offset of January (as you can see y&3||y%25<1&&y&15 is used to check for years without leap days). Then we simply loop through every month and check if its last day is a Monday. Quite simple actually, no ugly hacks or tricks. Here it is slightly ungolfed:

t=1248700335,m;
main(y){
  for(
    scanf("%d",&y),t+=y&3||y%25<1&&y&15;
    m++,(6+y+y/4-y/100+y/400+t)%7||printf("%d,",m),t;
    t/=7
  );
}

I might revisit this to rewrite it as a function to save a few characters. The printf also takes up a little too much space...


答:
Haskell, 28 bytes

```<code>main=putStr$[1..10^100]>>"1"
</code>```

Concatenates 10^100 copies of the string "1" and prints it.

Title: Output a googol copies of a string

Body:
Haskell, 28 bytes

main=putStr$[1..10^100]>>"1"

Concatenates 10^100 copies of the string "1" and prints it.


答:
gcc C/Python 3, <s>76</s> 53 bytes

```<code>#define print(_)main(){puts("trick");}
print("treat")
</code>```

Saved 23 bytes thanks to Dennis!

The gcc C preprocessor replaces the print macro (discarding it's argument) with a C program that prints "trick". And Python 3 ignores the first line as a comment and simply prints "treat".

Title: Trick or Treat polyglot

Body:
Since Halloween is coming up I thought I might start a fun little code golf challenge!

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

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

Your program has to do the following:

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

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

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

A few explanations:

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

```<code>"trick"

"Treat"

"    TReAt"

"
     tRICk          "
</code>```

Invalid outputs:

```<code>"tri ck"

"tr
eat"

"trck"
</code>```

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

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

Leaderboards

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

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

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

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

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

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

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

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

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

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
gcc C/Python 3, <s>76</s> 53 bytes

#define print(_)main(){puts("trick");}
print("treat")

Saved 23 bytes thanks to Dennis!

The gcc C preprocessor replaces the print macro (discarding it's argument) with a C program that prints "trick". And Python 3 ignores the first line as a comment and simply prints "treat".


答:
TI-Basic, 20 bytes

Straightforward. Only eight lines are displayed at once, and previous lines do not stay in memory. Because ᴇ100 is unsupported, we must loop from -ᴇ99 to 9ᴇ99. Then, if I!=0, display the string (which, by the way, is 3). This way, we print it exactly ᴇ100 times.

```<code>For(I,-ᴇ99,9ᴇ99:If I:Disp 3:End
</code>```

Title: Output a googol copies of a string

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

Example output:

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

or

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

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

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

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

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

Example solution (C, ungolfed, 3768 bytes)

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

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

Body:
TI-Basic, 20 bytes

Straightforward. Only eight lines are displayed at once, and previous lines do not stay in memory. Because ᴇ100 is unsupported, we must loop from -ᴇ99 to 9ᴇ99. Then, if I!=0, display the string (which, by the way, is 3). This way, we print it exactly ᴇ100 times.

For(I,-ᴇ99,9ᴇ99:If I:Disp 3:End


Title: Output a googol copies of a string


答:
reticular + Turtlèd, 16 bytes

```<code>"trick"oll"eat";
</code>```

Try reticular online! Try Turtlèd online!

reticular explanation:

```<code>"trick"oll"eat";
"trick"           push the string "trick" to the stack
       o          output it
        l         push length of stack (0)
         l        push length of stack (1)
          "eat"   push the string "eat" to the stack
               ;  terminate
</code>```

Turtlèd explanation:

```<code>"trick"oll"eat";
"trick"           write "trick" to the grid, move turtle to the "k"
       o          idk, probably no-op
        ll        move turtle left two, to the "i"
          "eat"   write "eat" to the grid
               ;  something
</code>```

Title: Trick or Treat polyglot

Body:
reticular + Turtlèd, 16 bytes

"trick"oll"eat";

Try reticular online! Try Turtlèd online!

reticular explanation:

"trick"oll"eat";
"trick"           push the string "trick" to the stack
       o          output it
        l         push length of stack (0)
         l        push length of stack (1)
          "eat"   push the string "eat" to the stack
               ;  terminate

Turtlèd explanation:

"trick"oll"eat";
"trick"           write "trick" to the grid, move turtle to the "k"
       o          idk, probably no-op
        ll        move turtle left two, to the "i"
          "eat"   write "eat" to the grid
               ;  something


答:
Python 2, 35 bytes

Under more realistic programming circumstances, Python allows you to multiply strings by a number, as with 'x' * 100, which would produce a string that's a hundred characters long and composed of nothing but the letter x.

However, it appears that Python string objects don't appreciate having indices whose values exceed the maximum of int. Python is content to re-cast large int values to a special bignum sort of thing, but the longest string that Python can handle is on the order of several gigabytes, and assuming each character in Python is 1 byte, it would take much, much more memory to contain the string that would unfold from 'x'*10**100.

As such, Python's built-in arbitrary arithmetic and the humble while loop allow us to produce a more practical program, which spits out one x per line for a googol lines. Thankfully, this proves to be shorter than the admittedly more readable for x in xrange(10**100):, as range() and xrange() are both limited to the largest possible value for a C long type, which is Python's native non-bignum int.

```<code>i=0
while i<10**100:
    print'x';i+=1
</code>```

Title: Output a googol copies of a string

Body:
Python 2, 35 bytes

Under more realistic programming circumstances, Python allows you to multiply strings by a number, as with 'x' * 100, which would produce a string that's a hundred characters long and composed of nothing but the letter x.

However, it appears that Python string objects don't appreciate having indices whose values exceed the maximum of int. Python is content to re-cast large int values to a special bignum sort of thing, but the longest string that Python can handle is on the order of several gigabytes, and assuming each character in Python is 1 byte, it would take much, much more memory to contain the string that would unfold from 'x'*10**100.

As such, Python's built-in arbitrary arithmetic and the humble while loop allow us to produce a more practical program, which spits out one x per line for a googol lines. Thankfully, this proves to be shorter than the admittedly more readable for x in xrange(10**100):, as range() and xrange() are both limited to the largest possible value for a C long type, which is Python's native non-bignum int.

i=0
while i<10**100:
    print'x';i+=1