title: Make text triangle waves

text:
# Question
Title: Make text triangle waves
I was messing around on my 'ol TI-84 CE and made a program that produced this output (it was actually bigger but that is not the point):

```
 *
 *  *
 *  *  *
 *  *
 *
 *  *
 *  *  *
 *  *
 *
...

```

I evolved it to take input text and make the triangle waves out of that. The final step was to also take a number to specify the size (n\>0). But I am super lazy so you must do it for me!

# Challenge

Given a string and number (`n > 0`), output a triangle wave. This should be in the following format (with `*` as the string input)

```
 *
 *  *
 *  *  *
 *  *  * *
 *  *  * * (...)
 *  *  * *
 *  *  *
 *  *
 *
 *
 *  *
 *  *  *
 *  *  * *
 *  *  * * (...)
 *  *  * *
 *  *  *
 *  *
 *
 (...)

```
* Each line starts with 1 space on the left edge.
* The first line should have `*` on the right edge, for a full line of `*`.
* Every line after that, for the next `n - 1` lines, you add `*`, `<linenumber>` times. So for `n=3`:

```
 *
 *  *
 *  *  *
 *  *
 *

```
* Then, output this full triangle infinitely:

```
 *
 *  *
 *  *  *
 *  *
 *
 *  *
 *  *  *
 *  *
 *

```

Note that you can't have something like this, for `n=2`:

```
 *
 *  *
 *
 *
 *  *
 *

```

You must trim the repeated single `*`.

Another example, with a multichar string input:

```
'hi', 4 ->

 hi
 hi  hi
 hi  hi  hi
 hi  hi  hi  hi
 hi  hi  hi
 hi  hi
 hi
 hi  hi
 hi  hi  hi
...

```

### Assorted other rules:

* Output must be immediately visible (i.e. it will wait to display until the program ends)
* You may take the input in any reasonable way, so `["hi",3]` is allowed but `["h",1,"i"]` is not. However, you may *not* use `Ans` to take input in TI-Basic programs.
* You must continue the pattern forever, or until the program ends due to memory limits.
* You do not need to have trailing spaces but leading spaces are required.
* You must print up to one line at a time. (i.e. each line must be printed all at once, you can't print each triangle iteration by itself)
* The one space padding is before and after each instance of the text

Here is an answer you can use to check your output. (with video)

Leading or trailing newlines are fine.

## Leaderboard

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

```
/* Configuration */

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

/* App */

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

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

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

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

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

getAnswers();

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

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

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

function process() {
  var valid = [];

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

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

  });

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

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

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

    var lang = a.language;
    if (/<a/.test(lang)) lang = jQuery(lang).text();

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

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

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

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

}
```

```
body { text-align: left !important}

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

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

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}
```

```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">
<div id="answer-list">
  <h2>Leaderboard</h2>
  <table class="answer-list">
    <thead>
      <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr>
    </thead>
    <tbody id="answers">

    </tbody>
  </table>
</div>
<div id="language-list">
  <h2>Winners by Language</h2>
  <table class="language-list">
    <thead>
      <tr><td>Language</td><td>User</td><td>Score</td></tr>
    </thead>
    <tbody id="languages">

    </tbody>
  </table>
</div>
<table style="display: none">
  <tbody id="answer-template">
    <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr>
  </tbody>
</table>
<table style="display: none">
  <tbody id="language-template">
    <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr>
  </tbody>
</table>
```

# Answer
# 05AB1E, ~~13~~ 12 bytes

1 byte saved thanks to *Erik the Outgolfer*

```
[¹ð.ø²Lû¨×€,

```

Try it online!

Run locally if you want the lines displayed 1 at a time.

**Explanation**

```
[              # start infinite loop
 ¹ð.ø          # surround the first input by a space on each side
     ²Lû¨      # construct the range [1 ... n ... 2]
         ×     # replace each number in the range by that many instances of the string
          €    # for each string in the list
           ,   # print it on a separate line

```
> 8 votes

# Answer
# Haskell, ~~68~~ 62 bytes

```
t#n=mapM putStrLn[[1..n-abs m]>>' ':t++" "|m<-[1-n..n-2]]>>t#n

```

Try it online! Example usage: `"somestring" # 5`.

**Edit:** Saved 6 bytes thanks to @Ørjan Johansen!

Given for example `n=4`, `[1-n..n-2]` constructs the list `[-3,-2,-1,0,1,2]`. For each element `m` in this list, `[1..n-abs m]` is a list of length `n` minus the absolute value of `m`, thus we get lists of length `4-3, 4-2, 4-1, 4-0, 4-1` and `4-2`, that is `1, 2, 3, 4, 3` and `2`. For each of this numbers `>>' ':t++" "` concatenates as many times the given string `t` with a space added to back and front.

This yields a list of strings with the first triangle. `mapM putStrLn` prints each of the strings in the list on a new line, then the function `#` calls itself again with the same arguments and starts over.
> 5 votes

# Answer
# Java 7, ~~128~~ ~~129~~ ~~128~~ 125 bytes

+1 byte: Missed the padding after each character

-1 byte: Changed k==1 to k\<2

-3 byes thanks to Kevin Cruijssen

```
void a(String s,int i){s=" "+s;for(int j=-1,k=1,l;;k+=j){for(l=0;l<k;)System.out.print(s+(++l<k?" ":"\n"));j=k==i|k<2?-j:j;}}

```

First post here so let me know if I'm doing something wrong. Any golfing help is much appreciated.

Try it online! Note: this times out after 60 seconds and then prints the results, the actual code continually prints infinitely

Ungolfed

```
void a(String s,int i){
    s= " " + s;

    for(int j=-1, k=1, l;; k+=j){
        for(l=0; l<k;)
            System.out.print(s+ (++l < k ? " " : "\n"));

        j = (k == i | k < 2) ? -j : j;
    }
}

```

Prepends a space to the input string then starts an infinite loop. For each iteration it prints the string k times and then prints a new line. k is then incremented / decremented based on the sign of j
> 4 votes

# Answer
# Scala, 79 Bytes

```
(s:String,n:Int)=>while(1>0)(1 to n)++(n-1 to 2 by-1)map(y=>println(s" $s "*y))

```

Try it online!

My first attempt at one of these. The basic idea is to generate a sequence of numbers, from 1 to n, then concatenated with the reverse (minus the ends to avoid doubling up). Then just loop over those numbers and print the input plus spaces that many times for each number in our generated sequence.

Ungolfed:

```
(text: String, n: Int) =>
  while(1 > 0) {                          //loop forever

    ((1 to n) ++ (n-1 to 2 by-1))       //Generate a sequence of numbers, from 1 to n
                                        //and then concatenate it with the sequence n-1 to 2

      .map(y=>println(s" $text " * y))  //for each number y in the sequence we generated,
                                        // print the input text, surrounded by spaces, y times
    }

```
> 4 votes

# Answer
# C (gcc), ~~127~~ ~~108~~ ~~107~~ 102 bytes

The loop in MACRO P prints each line, the for(j) loops print up and down the wave.

-5 byte thanks to ceilingcat.

```
#define P for(i=j;i--;printf(" %s%c",s,i?32:10))
i,j;f(s,n){for(;j++<n;)P;for(--j;j^1&&j--;)P;f(s,n);}

```

Try it online!
> 3 votes

# Answer
# Röda, 49 bytes

```
f n,s{{{seq 1,n;seq n-1,2}while[]}|print` $s `*_}

```

Try it online!
> 2 votes

# Answer
# Jelly, ~~13~~ 15 bytes

+2 bytes to fix up to print each line separately.

```
⁶;WṁÐ€ŒḄṖK€Ṅ€ȧß

```

**Try it online!** (note that TIO produces the would-be constant output only after it times out, errors, or, as in this case most likely, exceeds the text limit; offline it prints line by line.)

### How?

```
⁶;WṁÐ€ŒḄṖK€Ṅ€ȧß - Main link: string s, integer n
⁶               - literal ' '
 ;              - concatenated with s
  W             - wrap in a list
   ṁÐ€          - mould like mapped over n (mould like [[1],[1,2],[1,2,3],...,[1,2,3,...,n]] - half of a sawtooth)
      ŒḄ        - bounce (reflect but only with one central element to make a triangle)
        Ṗ       - pop (remove the last element since the sawtooth triangles only have one shortest element between them, not two)
         K€     - join with spaces for €ach
           Ṅ€   - print and yield for €ach
             ȧ  - and
              ß - call this link with the same arity

```
> 2 votes

# Answer
## C, 85 bytes

```
i,c,d;f(s,n)char*s;{for(;;)for(i=c+=d=c^n?c<2?1:d:-1;i;printf(" %s%c",s,--i?32:10));}

```
> 2 votes

# Answer
# Python 3, ~~124~~ ~~108~~ ~~94~~ ~~90~~ 89 bytes

```
r=range
x=lambda c,n:print('\n'.join(f' {c} '*i for i in[*r(1,n+1),*r(n-1,1,-1)]))+x(c,n)

```

Recursive lambda that would obviously error out if it ever got to evaluating itself (Adding an infinite sequence of `None`s?). Thankfully, it doesn't!

It will still crash relatively soon, because of the default recursion limit, which can be overwritten using `sys.setrecursionlimit(large_number)`

Ungolfed:

```
def triangles(char, N):
    print(
        '\n'.join(
            # f' {char} ' is like ' {char} '.format(char=char)
            f' {char} ' * i
            for i in
            [*range(1, N+1), *range(N-1, 1, -1)]  # N=3 -> [1, 2, 3, 2, 1]
        )
    ) + triangles(char, N)

```
> 2 votes

# Answer
# Python 3, 92 Bytes

```
from itertools import*
lambda b,a:[print(f" {b} "*(abs(i%(a*2-2)-(a-1))+1))for i in count()]

```

This code does require itertools, which is a native library in Python. I imported cycle as c.
> 2 votes

# Answer
# \>\<\>, ~~183~~ ~~152~~ 138 bytes

```
1+&01-1001.1+bc+-*4b{~p@-$*8b}:g1$1: <
>{:0)?v~{{1+$:@@:@)?v~>1+:&:&(?v>:c2*^
^   o:<v@-10oa0           v?(1:<
^      <    o" "@-10<.1*3b<

```

Try it online!

Takes a string and a number on the stack.

## Explanation

```
# Initialization
1+&01-1001.
1+          Add 1 to value on top of stack (number from input)
  &         Store in register
   01-      Push 0 - 1 (-1) to stack
      10    Push 1 and 0 to stack
            (repetitions on this line, repetitions done for this line)
        01. Jump to row 1 column 0 and move
            (IP now on {)

# Output loop
>{:0)?v
^   o:<

{        Roll stack left
 :       Duplicate top of stack
  0      Push 0
   )     Greater than
    ?    If top of stack is nonzero (value > 0)
     v   Continue loop
      :  Duplicate top of stack
       o Output top of stack

# Line loop
>output~{{1+$:@@:@)?v

^           o" "@-10<

output                       Output word
      ~                      Delete -1 (end-of-word marker)
       {{                    Roll stack left twice
                             so the two repetition variables are on top
         1+                  Add one to repetitions done for this line
           $:@@:@            Duplicate both variables, preserving order
                 )           Greater than
                  ?          If nonzero (repetitions needed > repetitions done)
                   v         Continue loop
                    01-      Push -1
                       @     Roll top three items right so end-of-word marker is in correct place
                        " "  Push char code for space
                           o Output space

# Add newline
0ao01-@
0       Push 0 (repetitions done)
 a      Push charcode of newline (10)
  o     Output newline
   01-  Push -1
      @ Roll top 3 items right so end-of-word marker is in correct place

# Check if repetitions < 1
:1(?v
:     Duplicate (repetitions needed)
 1    Push 1
  (   Less than
   ?  If nonzero (repetitions needed < 1)
    v Continue loop (else add newline)

b3*1.
b3*            Push 11 * 3 (33)
   1           Push 1
    .          Jump to row 1 column 33 and move (IP was pointing left, so it is now on the second > in rebound loop)

# Rebound loop
          .1+bc+-*4b{~p@-$*8b}:g1$1: <
                     ~>1+:&:&(?v>:c2*^

~                                          Remove repetitions done for this line
 >                                         Make IP travel right (needed later)
  1+                                       Add 1 to top of stack (repetitions needed)
    :                                      Duplicate
     &:&                                   Get register value and store a copy back in register
        (                                  Less than
         ?                                 If nonzero
                                           (repetitions needed < input value + 1)
          v                                Check if repetitions < 1 (see above)
           >                               Make IP travel right (also needed later)
            :                              Duplicate top of stack (???)
             c2*                           Push 12 * 2 (24)
                :                          Duplicate
                 1                         Push 1
                  $                        Swap top two values
                   1                       Push 1
                    g                      Get value at row 1 column 24
                                           (initially the + near the start of this loop)
                     :                     Duplicate
                      }                    Roll right to put duplicate at bottom of stack
                       b8*                 Push 88
                          $                Swap
                           -               Subtract (turns '+' into '-' and vice versa)
                            @              Roll top 3 items to put at correct position
                             p             Put new character at row 1 column 24
                              ~            Delete ???
                               {           Roll stack left so original value of row 1 column 24 is back on top
                                b4*        Push 11 * 4 (44)
                                   -       Subtract
                                    +      Add to repetitions needed
                                     cb+   Push 12 + 11 (23)
                                        1  Push 1
                                         . Jump to row 1 column 23 and move (IP was pointing left, so it is now on the first >)

```
> 2 votes

# Answer
# PowerShell, 72 bytes

```
param($a,$b)$a=" $a ";if($b-1){for(){1..$b+($b-1)..2|%{$a*$_}}}for(){$a}

```

Try it online!
*(TIO has a 60 second timeout, but please be nice to Dennis' server ... also note that TIO doesn't output (refresh the page) until the program completes, so you won't get on-the-fly output. Running this locally produces correct output.)*

Straightforward. Takes input `$a` as the string and `$b` as the integer. We then pad `$a` with spaces and save it back. We then have an `if` check to handle the special case of `$b=1`. If `$b>1` then this test is `$TRUE` and we enter the `if`.

Inside the `if`, we're entering an infinite `for()` loop. Inside the loop, we're constructing a range from `1` to `$b` and then `$b-1` to `2`. There are two possibilities here. If `$b=2`, this range is `1,2,1,2` and so we're actually constructing *two* triangles every `for` loop. If `$b>2`, then the range is something like `1,2,3,4,3,2` to construct one triangle every `for` loop. Inside the range loop, `|%{}`, we just string-multiply `$a` by the appropriate number.

If `$b=1` then we don't enter the `if`, and so just enter a separate infinite `for()` loop that prints `$a` a bunch of times.

By default, PowerShell will "flush" the pipeline (for lack of a better term) on each `for` iteration, so that's where the implicit `Write-Output` happens.
> 1 votes

# Answer
# JavaScript ES6, 98 bytes

```
s=>n=>{while(1){for(i=0;i++<n;)eval(p="console.log(` ${s} `.repeat(i))");i--;for(;--i>1;)eval(p)}}

```

Try it online!
> 1 votes

# Answer
# CJam, 30 bytes

```
l~,:)_W%1>W<+S2*@*f*{_Nf+:o!}g

```

Try it online! *(same as with other answers: TIO dumps all output after 60 seconds, you have to run it locally to see the proper behaviour)*

**Explanation**

Example input: `"hi" 4`

```
l~     e# Read an eval a line of input
       e# STACK: ["hi" 4]
,:)    e# Generate the range 1 ... N
       e# STACK: ["hi" [1 2 3 4]]
_W%    e# Duplicate and reverse it
       e# STACK: ["hi" [1 2 3 4] [4 3 2 1]]
1>W<   e# Slice to remove the first and last elements of the copy
       e# STACK: ["hi" [1 2 3 4] [3 2]]
+      e# Concatenate
       e# STACK: ["hi" [1 2 3 4 3 2]]
S2*    e# Push "  "
       e# STACK: ["hi" [1 2 3 4 3 2] "  "]
@*     e# Bring the text to the top and join the space string with it
       e# STACK: [[1 2 3 4 3 2] " hi "]
f*     e# Repeat the resulting string by each number in the range
       e# STACK: [[" hi " " hi  hi " " hi  hi  hi " .....]]
{      e# Do:
 _     e#  Duplicate the top
       e#  STACK: [[" hi " " hi  hi "...] [" hi " " hi  hi "...]]
 Nf+   e#  Append a newline to each string in the top array
       e#  STACK: [[" hi " " hi  hi "...] [" hi \n" " hi  hi \n"...]]
 :o    e#  Pop and print each string in the top array (one by one)
       e#  STACK: [[" hi " " hi  hi "...] []]
 !     e#  Boolean negation
       e#  STACK: [[" hi " " hi  hi "...] 1]
}g     e# While the top of stack (popped) is truthy
       e# STACK: [[" hi " " hi  hi " " hi  hi  hi " .....]]

```
> 1 votes

# Answer
# TI Basic 210 Bytes

```
Prompt Str4
Prompt N
0->V
Lbl A
0->S
If (S=0
Then
0->B
1->S
Else
1->B
End
" "->Str1
Str1->Str2
Str1+Str4+Str1->Str5
0->P
Lbl B
If (S=1 and B<N)
Then
B+1->B
Str1+Str5->Str1
Disp Str1
0->P
End
Goto B
Else
For(H,N-1,2,-1)
0->R
" "->Str1
While (R<H)
Str1+Str5->Str1
End
Disp Str1
End
Goto A

```

Running it (video)
> 1 votes

# Answer
## Batch, 108 bytes

```
@set f=@for /l %%i in (2,1,%1)do @call echo %%s:.= %2 %%^&call set s=%%s
@set s=.
%f%%%.
%f%:~1%%
@%0 %*

```

Conveniently I both need to use the current value of a string in a for loop and substitute into it with another variable. Ungolfed:

```
@echo off
setlocal enabledelayedexpansion
set s=.
:l
for /l %%i in (2, 1, %1) do echo !s:.= %2 !&set s=!s!.
for /l %%i in (2, 1, %1) do echo !s:.= %2 !&set s=!s:~1!
goto l

```
> 1 votes

# Answer
# Groovy, ~~82~~ 80 bytes

```
{s,n->s+=" ";a=0;x={println s*a};for(;;){for(;a<n;a++){x()};for(;a>1;a--){x()}}}

```

**Previous answer**

```
{s,n->s+=" ";a=0;x={println s*a};for(;;){while(a<n){x();a++};while(a>1){x();a--}}}

```

**Ungolfed (previous answer)**

```
h={s,n->  //A closure with two arguments, the input text and the size of the wave peak
    s+=" " //add a space after the input text
    a=0    // a counter we will use later
    x={println s*a}  //another closure that prints the input text repeated "a" times
    for(;;){  //infinite loop
        while(a<n){  //two while loop that make "a" oscillate between 1 and "n", printing at each iteration
            x()
            a++
        }
        while(a>1){
            x()
            a--
        }
    }
}

```
> 1 votes

# Answer
# Excel VBA, <sub>~~97~~</sub> 79 Bytes

Anonymous VBE immediate Window Function that takes input of String from cell `[A1]` and variant/String of assumed type integer from cell `[B1]` and outputs a triangle wave using those values to the VBE immediate window.

```
n=[B1]:Do:DoEvents:For i=1To n*2-2:[C1]=n-Abs(i-n):?[Rept(A1&" ",C1)]:Next:Loop

```
> 1 votes

# Answer
# Jelly, 13 bytes

```
⁾  jẋŒḄ}ṖṄ€1¿

```

Try it online!

### How it works

```
⁾  jẋŒḄ}ṖṄ€¹¿  Main link. Left argument: s (string). Right argument: n (integer)

⁾  j           Join "  " with separator s, prepending and appending a space to s.
     ŒḄ}       Bounce right; yield [1, ..., n, ..., 1].
    ẋ          Repeat (" "+s+" ") 1, ..., n, ..., 1 times, yielding a string array.
        Ṗ      Pop; remove the last string.
           1¿  While 1 is truthy:
         Ṅ€      Print each string, followed by a linefeed.

```
> 1 votes

# Answer
# Lua, 104 bytes

```
p=print;function f(s,n)c=" "..s;while(0)do p(c)for i=2,n+n-2 do p(c:rep(i<=n and i or n+n-i))end end end

```
> 1 votes

---
Tags: code-golf, ascii-art
---


title: Anaglot Polygrams

text:
# Question
Title: Anaglot Polygrams
# Task

Write some code that can be rearranged into n different programs in n different languages each outputting a distinct number from 1 to n.

No two languages should be the same however different versions of "the same language" will be considered distinct languages, as long as they have different major version numbers. For this challenge REPL environments are not distinct from their parent languages but are still a language. Each language should run on a distinct permutation of the source code and output a distinct number in the range.

Permutations will be counted in bytes *not in characters*.

You should include each permutation that is run with the language that it is run in for testing purposes.

# Scoring

Your score will be the

Where N is the number of languages and L is the number of unique orderings of the programs bytes.

***L is not equal to the length of the program***

(unless the program is 1 or 0 bytes)

Here is a python script to calculate L courtesy of Conor O'Brien.

L is equal to the length of the program factorial if and only if there are no repeated bytes in the program.

The goal is to maximize your score.

# Answer
> 31 votes
# 34 Languages, 19 bytes, Score: 38,832,018,459,912,437,760,000

Here is a quick answer I threw together to show that it is possible to get an answer scoring better than 1.

```
 12233echo*+--@#..;

```

## 1. NTFJ

```
#*22331+..@o;-- ech

```

This outputs via character code, which is allowed by meta consensus.

Try it here

## 2. Tcsh

```
echo 2;#..1@2+33*--

```

## 3. 05AB1E

```
2231*+..@echo ;--#3

```

Try it online!

## 4. Actually

```
@..o; eho1#c3223-*+-

```

Try it online!

## 5. Befunge 98

```
23+.@.21*#3o;-- ech

```

Try it online!

## 6. Cubix

```
123+23*o@#;-- ech..

```

*Outputs by character code*

Try it here

Unfolded code:

```
    1 2
    3 +
2 3 * o @ # ; -
- e c h . . . .
    . .
    . .

```

## 7. Haskell 8 REPL

```
3+2*2 --31#;@..echo

```

## 8. Seriously

```
@..o; eho1#c3223-+*-

```

Try it online!

## 9. \>\<\>

```
33*o;2+..@#12-- ech

```

*Outputs by character code*

Try it online!

## 10. Befunge

```
33*1+.@.#22o;-- ech

```

Try it online!

## 11. brainbool

```
323*+..@echo ;--#12

```

Try it online!

## 12. 2sable

```
233*+..@echo ;--#12

```

Try it online!

## 13. Hexagony

```
13;2#2+@*3o-- ech..

```

*Outputs by character code*

Try it online!

Unfolded code:

```
  1 3 ;
 2 # 2 +
@ * 3 o -
 - e c h
  . . .

```

## 14. R

```
12+2#*33..@o; ech

```

Try it online!

## 15. bc

```
12+3#*23..@o;-- ech

```

## 16. Python 3 REPL

```
13+3#*22..@o;-- ech

```

## 17. irb (Ruby 2.4 REPL)

```
13+2*2#3..@o;-- ech

```

## 18. PowerShell

```
12+2*3#3..@o;-- ech

```

## 19. Python 2 REPL

```
13+2*3#2..@o;-- ech

```

## 20. Python 1.6.1 REPL

```
23-3#-+*21..@o; ech

```

## 21. Ksh

```
echo 21;#..2@3+3*--

```

## 22. Bash

```
echo 22;#..1@3+3*--

```

## 23. Zsh

```
echo 23;#..1@2+3*--

```

## 24. Applescript

```
23+1 --#2*3..@o;ech

```

## 25. Lua REPL

```
23+2 --#1*3..@o;ech

```

## 26. Julia REPL

```
23+3 #2*1..@o;--ech

```

## 27. irb (Ruby 1.9.3 REPL)

```
13*2+3-2 #..@o;-ech

```

## 28. Haskell 7 REPL

```
13*2+2--3#;@.. echo

```

## 29. J

```
echo --1#.23;@+2*.3

```

Try it online!

## 30. Nim

```
echo 33-2-1;#..@2+2*

```

## 31. fish

```
echo 31;#3-2-..@2+2*

```

## 32. PHP

```
echo 32;#+123*@..--

```

`<?php` is not needed due to this meta

Try it online!

## 33. Golfscript

```
3.#.1223*@+o;-- ech

```

Try it online!

## 34. Octave

```
33+1 #22echo*--@..;

```

Try it online!

# Answer
> 12 votes
# 1 language, 0 bytes, score 1

I don't know how high scores will get in this challenge, so let's take this spot.

```

```

Try it online!

In Retina, the empty program with no input prints `1`.

Score = 1!/0! = 1/1 = 1

# Answer
> 6 votes
## 2 languages, 2 bytes, score 1

Doesn't beat Leo's answer, but I thought I'd present a 2-language solution (well, and Wheat Wizard ninja'd a score-2 answer in between anyway).

### Retina, prints `1`

```
2`

```

Try it online!

This is essentially the same as Leo's empty program.

### Pyth, prints `2`

```
`2

```

Try it online!

This is `repr(2)` so it computes `"2"` which gets printed as `2`.

# Answer
> 5 votes
# 26 languages, 46 bytes, Score : 1.68861953e-28 (0.000000000000000000000000000168861953)

All the languages are mainstream ones (i.e. they are actually used by people in development) and there's no REPL solution in any language. This answer is never going to win, but that's not a reason for not posting it...

```
//#**print()ale123456789+chous :f{}:""enttd *;

```

---

## 1. Python 2

```
print 1#//**()alechous:f{}:23456789+ ""enttd*;

```

Try it online!

## 2. Python 3

```
print(2)#//**alechous13456789+: f{}: ""enttd*;

```

Try it online!

## 3. Ruby

```
puts 3#//**()alecho:f12456789+{}rin: ""enttd*;

```

Try it online!

## 4. CoffeeScript

```
alert 4#//**()pinchous:12356789+f{}: ""enttd*;

```

Try it online!

## 5. PHP

```
echo 5/*alrt#()pinus:f{:12346789+} ""enttd;**/

```

Try it online!

## 6. Perl 5

```
print 6#/*ale()chous:12345789+f{:} */""enttd*;

```

Try it online!

## 7. Perl 6

```
print 7#/*ale)(chous:f12345689+{:} */""enttd*;

```

Try it online!

## 8. JavaScript (ES5)

```
alert(8)//pin 12345679+#*chous:f{:} *""enttd*;

```

Try it online!

## 9. JavaScript (ES6)

```
alert(9)//inp 12345678+#*chous: f{:}*""enttd*;

```

Try it online!

## 10. JavaScript (ES7)

```
alert(9+1)//pni #*chous2345678: f{:}*""enttd*;

```

Try it online!

## 11. Batch

```
echo 9+2 ::alrt()//pni#*usf{1345678}*""enttd*;

```

*Couldn't find an online interpreter for this one. Try running this code in the Command Prompt, if you are on Windows.*

## 12. Bash

```
echo 12 #::alrt(3456789+)//pni*usf{}*""enttd*;

```

Try it online!

## 13. CSS

```
*:after{content:"13" /*h# l(2456789+)pisud;*/}

```

Try it online!

## 14. Less

```
*:after{content:"14" /*#h l(2356789+)pisud;*/}

```

Try it online!

## 15. Stylus

```
*:after{content:"15" /*#hl (2346789+)pisud;*/}

```

Try it online!

## 16. TypeScript

```
alert(16)//inp #*chous2345789+: :{f}*""entt*d;

```

Try it online!

## 17. Octave

```
disp(17)#//n *chou2345689+: :{f}*""entt*alert;

```

Try it online!

## 18. Swift

```
print(18)//ds# *chou2345679+: :{f}""ent*ale*t;

```

Try it online!

## 19. Julia

```
print(19)#ds// *chou2345678+: :{f}""ent*ale*t;

```

Try it online!

## 20. Maxima

```
print(18+2);/*#ds ouch 345679::{f}""entale*t*/

```

Try it online!

## 21. Clojure

```
(print "21");/*#ds ouch3456789+::{f}entale*t*/

```

Try it online!

## 22. Groovy

```
print 19+3//();*#ds oh245678::{fuc*}entalet*""

```

Try it online!

## 23. CommonLisp

```
(print 23);//*#ds oh1456789+::{fuc*}entalet*""

```

Try it online!

## 24. EmacsLisp

```
(print 24);//*#ds oh1356789+::{fuc*}entalet*""

```

Try it online!

## 25. PicoLisp

```
(print 25);//*#ds oh1346789+::{fuc*}entalet*""

```

Try it online!

## 26. Logo

```
print 21+5 ;//*#dsoh346789::{fuc*}entalet*""()

```

Try it online!

# Answer
> 3 votes
## 12 Languages, 16 Bytes - Score: 0.003

```
print(0b11000)#1

```

Prints `1` in **2sable**

```
print(0b1100)#10

```

Print `10` in **05AB1E**

```
print(0b11)#1000

```

Re-arranging the binary numbers prints 2-9, 11-12 in:

* Crystal
* Julia 0.5
* J-uby
* Lily
* Perl 5
* Perl 6
* Python 3
* Python 2
* Python
* Ruby

L=145297152000 12! = 479001600

I just used TiO for a list of valid languages for this (If these are all considered unique?). Removed some duplicate languages thanks to input from Wheat Wizard. This answer is looking pretty low, though I feel it has potential.

# Answer
> 1 votes
# JavaScript (ES6), Python 2, Python 3, Japt, 4.735e-15

```
# ()//1234=>inprt

```

## ES6 (1)

```
p=>1//rint 234()#

```

## Python 2 (2)

```
print 2#134=>//()

```

## Python 3 (3)

```
print(3)# 124=>//

```

## Japt (4)

```
#rint>=3/2)p (4/1

```

---
Tags: code-challenge, combinatorics, polyglot, permutations
---


title: Zooming in on a map

text:
# Question
Title: Zooming in on a map
Your task is to, given a map as input, zoom it out or in, depending on the scale. Note that the scale given is the scale by which to zoom *out*, so a scale between 0 and 1 will actually zoom in.

For example, given the following (badly made) map:

```
..____....
../OOO\...
..\OO/\...
..........

```

And a scale factor of 2, you should first separate it into 2x2 sections:

```
.. | __ | __ | .. | ..
.. | /O | OO | \. | ..
----------------------
.. | \O | O/ | \. | ..
.. | .. | .. | .. | ..

```

And in each section find the most common character:

```
.__..
.....

```

Note that there was an ambiguous section:

```
__
OO

```

I chose to use `_` for this section, but using `O` would have been perfectly acceptable too.

If, for example, you were given the scale factor of 4, you would split it into 4x4 sections, like so:

```
..__ | __.. | ..
../O | OO\. | ..
..\O | O/\. | ..
.... | .... | ..

```

As you can tell, the map doesn't perfectly fit into 4x4 sections, but that's fine, as we can just lower the size of the section at the side.

Also, whenever we need to cut off our maps, we cut off at the bottom or on the right side.

The resulting map would look like so:

```
...

```

What an interesting map!

For scale factors below 1, such as 0.5, the process is simpler as we zoom in instead. Take this map:

```
./O\.
.\O/.

```

Zooming with a scale of 0.5:

```
..//OO\\..
..//OO\\..
..\\OO//..
..\\OO//..

```

Note that whenever your zoom factor is less than `1`, the following will always be true: `1/(zoom factor) % 2 == 0`. When it is above `1`, the only guarantee you have is that it will be a whole number. When it is `1`, the map should stay the same.

## Examples:

```
4
/OO\
|OO|
|OO|
\OO/

O

0.25
ABCD

AAAABBBBCCCCDDDD
AAAABBBBCCCCDDDD
AAAABBBBCCCCDDDD
AAAABBBBCCCCDDDD

1
My zoom
should
not change

My zoom
should
not change

```

You may also take the map as a newline-separated array.

# Answer
# Mathematica, 105 bytes

```
If[#<1,ArrayFlatten[#2/.n_String:>Table[n,1/#,1/#]],Map[First@*Commonest,#2~Partition~UpTo@{#,#},{2,3}]]&

```

The input is (scale, array of characters). The scale must be an integer or an exact fraction.

### Explanation

```
If[#<1, ..., ... ]

```

If the first input is less than 1...

```
#2/.n_String:>Table[n,1/#,1/#]

```

Replace all Strings in the second input into a square array, with length 1/(first input)

```
ArrayFlatten[ ... ]

```

Flatten the result into a 2D array.

```
If[#<1, ..., ... ]

```

If the first input is not less than 1...

```
#2~Partition~UpTo@{#,#}

```

Partition the (second input) into partitions whose width/length are at most (first input).

```
Map[ ..., ... ,{2,3}]

```

Map onto level 2 and level 3...

```
First@*Commonest

```

The composition of the Commonest function (finds the commonest element in a list) and First (take the first element; in case there are multiple commonest elements).
> 7 votes

# Answer
# Python, ~~191~~ ~~182~~ 180 bytes

```
lambda m,s,j=''.join,i=int:[j((lambda p:max(p,key=p.count))(j(g[i(x*s):-i(~x*s//1)]for g in m[i(y*s):-i(~y*s//1)]))for x in range(-i(-len(m[0])//s)))for y in range(-i(-len(m)//s))]

```

Call `_(map, scale_factor)`, where map is an array of lines, and it returns an array of lines.

Though this answer has already been beaten, I want to explain it, as it doesn't special case where the scale factor is less than one.

It makes a `h` by `w` matrix, where `h = ceiling(map height / scale factor)`, and `w = ceiling(map width / scale factor)`.

For every index (x, y) in the matrix, do:

* Take a submatrix from the coordinates `int(x * scale factor), int(y * scale factor)` to `ceil((x + 1) * scale factor), ceil((y + 1) * scale factor)`.
* Put the most common character in that submatrix at (x, y).

Try it online!

Try test cases
> 2 votes

---
Tags: code-golf, string
---


title: Am I outgolfed by Dennis?

text:
# Question
Title: Am I outgolfed by Dennis?
According to legend, almost everyone is outgolfed by Dennis. If not, they will be.

Now I'm curious if I'm one of those 'almost everyone'.

You will be given a link to an answer in the format of `https://codegolf.stackexchange.com/questions/[QUESTION ID]/[QUESTION NAME]/#[ANSWER ID]`.

Find the length of the code, which we will assume as the *last* number on the first line (markdown wise) of the answer in the link.

Then, search for Dennis' answers, and do the same.

Now compare the input's and Dennis' answers code length, and if it is out-golfed (meaning one or more answer of Dennis' is shorter than that of the input answer), output a truthy value, and if not, a falsy value.

If there is no answer belonging to Dennis on the same question as the answer, output a falsy value.

# Examples

* Link : `true`
* Link : `false` (At least for now, tell me when it changes)

# Rules

* You may use any form of truthy/falsy value.
* The question of the answer you're given will always be .
* The question may not have an answer of Dennis', but the inputted answer will never belong to Dennis.
* You may assume there is always a number on the first line of the answer.

# Answer
## Python 3.6 + requests \+ bs4 \- ~~363~~ 358 bytes

```
import bs4,re,requests
u,n=input().split("/#");i=1;d=y=float("inf")
while i:
 A=bs4.BeautifulSoup(requests.get(u+f"?page={i}").text,"html.parser")(class_="answer")
 for a in A:
  c=int(re.findall("\d+",(a("h1")+a("h2")+a("p"))[0].text)[-1])
  if "Dennis"in a(class_="user-details")[-1].text:d=min(c,d)
  if a["data-answerid"]==n:y=c
 i=A and i+1;
print(d<y)

```

Prints `True` or `False`.

*Note: does not currently work on the second link because of invalid HTML produced by this answer (the `em` and `strong` tags are terminated in the wrong order at the end of the second line, and causes the parser to miss the username block). Try it on this link instead.*

## Using the API - ~~401~~ 380 bytes

```
import requests,re
q,A=re.findall("\d+",input());i=1;d=y=float("inf")
while i:
 r=requests.get(f"https://api.stackexchange.com/2.2/questions/{q}/answers?site=codegolf&filter=withbody&page={i}").json();i=r["has_more"]and i+1
 for a in r["items"]:
  c=int(re.search("(\d+)\D+$",a["body"]).group(1))
  if a["owner"]["user_id"]==12012:d=min(d,c)
  if a["answer_id"]==A:y=c
print(d<y)

```

*Note that this also fails on the second link, but because one answer started with `This may be foul play.` instead of the header...*
> 1 votes

# Answer
# Ruby, ~~314~~ ~~315~~ 308+20 = ~~334~~ ~~335~~ 328 bytes

Uses the flags `-n -rjson -ropen-uri`. +1 byte from fixing a minor bug.

-7 bytes by discovering the `open-uri` Ruby default library.

```
~/(\d+)\D+(\d+)/
u="http://api.stackexchange.com/2.2/questions/#$1/answers?site=codegolf&filter=withbody&page=%s"
n=eval$2
a="answer_id"
j=1
o=[]
(o+=r=JSON.parse(open(u%j).read)["items"]
j=r!=[]&&j+1)while j
p o.select{|e|e["owner"]["user_id"]==12012||e[a]==n}.min_by{|e|e["body"][/\d+\s*bytes/].to_i}[a]!=n

```
> 1 votes

---
Tags: code-golf, decision-problem, internet, stack-exchange-api
---


title: (The other day) I met a bear

text:
# Question
Title: (The other day) I met a bear
> Meta discussion: Is "(The other day) I met a bear" a duplicate?

Your challenge is to output this text:

```
The other day,
The other day,
I met a bear,
I met a bear,
A great big bear,
A great big bear,
Oh way out there.
Oh way out there.

The other day,
I met a bear,
A great big bear,
Oh way out there.

He looked at me,
He looked at me,
I looked at him,
I looked at him,
He sized up me,
He sized up me,
I sized up him.
I sized up him.

He looked at me,
I looked at him,
He sized up me,
I sized up him.

He said to me,
He said to me,
"Why don't you run?
"Why don't you run?
I see you ain't,
I see you ain't,
Got any gun."
Got any gun."

He said to me,
"Why don't you run?
I see you ain't,
Got any gun."

I says to him,
I says to him,
"That's a good idea."
"That's a good idea."
"Now legs get going,
"Now legs get going,
get me out of here!"
get me out of here!"

I says to him,
"That's a good idea."
"Now legs get going,
get me out of here!"

And so I ran,
And so I ran,
Away from there,
Away from there,
But right behind me,
But right behind me,
Was that bear.
Was that bear.

And so I ran,
Away from there,
But right behind me,
Was that bear.

In front of me,
In front of me,
There was a tree,
There was a tree,
A great big tree,
A great big tree,
Oh glory be!
Oh glory be!

In front of me,
There was a tree,
A great big tree,
Oh glory be!

The lowest branch,
The lowest branch,
Was ten feet up,
Was ten feet up,
So I thought I'd jump,
So I thought I'd jump,
And trust my luck.
And trust my luck.

The lowest branch,
Was ten feet up,
So I thought I'd jump,
And trust my luck.

And so I jumped,
And so I jumped,
Into the air,
Into the air,
But I missed that branch,
But I missed that branch,
A way up there.
A way up there.

And so I jumped,
Into the air,
But I missed that branch,
A way up there.

Now don't you fret,
Now don't you fret,
And don't you frown,
And don't you frown,
I Caught that branch,
I Caught that branch,
On the way back down!
On the way back down!

Now don't you fret,
And don't you frown,
I Caught that branch,
On the way back down!

This is the end,
This is the end,
There aint no more,
There aint no more,
Unless I see,
Unless I see,
That bear once more.
That bear once more.

This is the end,
There aint no more,
Unless I see,
That bear once more.

```

## Pattern:

First, each line is repeated once, linebreak-separated, and then 2 newlines, and then the above stanza is printed without the repetition. Then the next stanza.

## Rules

* Trailing whitespace is allowed at the end of the output, but the rest must be printed as-is.

# Answer
> 19 votes
## JavaScript (ES6), 690 bytes

```
f=(n=0)=>n<139?[...'DEFJKLMPQRVXYZ~0123456789'].map(c=>s=(e=s.split(c)).join(e.pop()),s=`P2other day9Xme8a 03 09Oh ~F8t6.|H2Yme9XYM9H2VZXV M.|H2said4oZ"Why7run?|Xse2yFEin't9Go8anyDun."|Xsays4o M9"That'sEDood idea."|"Now legsDe8going9ge8m2F8of 6!"1ran9A~Lm469Bu8riKbehindZWasQa80.|In Ln8ofZT6 wasE4Re34Re9OhDlory be!P2lowes5Was4en fee8up9So IQFKI'd jump9J4rus8my luck.1jumped9IntoQ2air9Bu8XmissedQa5A ~up46.|Now7fRt9J7Lwn9XCauKtha5OnQ2~back down!Pis isQ2end9T6Ein8no moR9Unless Xsee9Tha80 onc2moR.9,|8t 7 don'8yF 6heR58branch94 t39ADRa8big2e 1|J so X0bear~way Z me9YlookedE8XI Vsized upRreQ4hP|ThMhimLfroKgh8JAndFouE aD g`)&&s.split`|`[(i=+'11223344012340'[n%14])&&i+(n/14<<2)]+`
`+f(n+1):''

console.log(f())
```

### How?

The 41 unique lyric lines (including the empty one) are stored in a pipe-separated string ***s***.

```
"|The other day,|I met a bear,|A great big bear,|...|Unless I see,|That bear once more."

```

This string is compressed by replacing the most frequent sub-strings with characters that are not used anywhere else. The character set is `"DEFJKLMPQRVXYZ~0123456789"` and the substitutions are processed as follows (note that this is the decompression order):

```
 1. "D" -> " g"         | 10. "R" -> "re"         | 19. "3" -> "9A grea8big"
 2. "E" -> " a"         | 11. "V" -> "sized up"   | 20. "4" -> " t"
 3. "F" -> "ou"         | 12. "X" -> "I "         | 21. "5" -> "8branch9"
 4. "J" -> "And"        | 13. "Y" -> "looked a8"  | 22. "6" -> "here"
 5. "K" -> "gh8"        | 14. "Z" -> " me9"       | 23. "7" -> " don'8you "
 6. "L" -> "fro"        | 15. "~" -> "way "       | 24. "8" -> "t "
 7. "M" -> "him"        | 16. "0" -> "bear"       | 25. "9" -> ",|"
 8. "P" -> "|Th"        | 17. "1" -> "|And so I " |
 9. "Q" -> "4h"         | 18. "2" -> "e "         |

```

The compressed format is the one used in several popular JS packers such as RegPack: the substituted string is stored just after a last occurrence of the substitution character. Below is an example for `"TwoBearsThreeBearsFourBearsFiveBears!"`, where `"Bears"` is packed as `"~"`:

Hence the decompression formula:

```
c => s = (e = s.split(c)).join(e.pop())

```

Once ***s*** has been decompressed, we rebuild the original verses by applying the pattern:

```
00 - Line A
01 - Line A
02 - Line B
03 - Line B
04 - Line C
05 - Line C
06 - Line D
07 - Line D
08 - (empty)
09 - Line A
10 - Line B
11 - Line C
12 - Line D
13 - (empty)

```

# Answer
> 9 votes
# 05AB1E, ~~508~~ ~~491~~ ~~434~~ ~~432~~ 443 bytes

```
“€€€¶‚Ž, I™¬€…Ÿâ, Aƒ‰„¥Ÿâ,Šçƒƒ€Ä€Ç.€½Ÿà€›€á, IŸà€›„š,€½¼¸€¾€á, I¼¸€¾„š.€½‚Þ€„€á, "Why¥Ú't€î‡Ð? I€È€î ain't,†«€Æ©ª." IˆÍ€„„š, "That's€…‚¿Ž©." "Now©Ý€Õ…ì, xget€á€Ä€‚€Î!"€ƒ€Ê I³Þ,‡ë€š€Ç,€³ƒ©•¦€á,€¥€ŠŸâ.€†ˆæ€‚€á,€Ç€¥€…íÍ, Aƒ‰„¥íÍ,Šç»¦€ï!€€™…›ì,€¥—¿î°€¾,€Ê IŠã I'dïÅ,€ƒîç€¯³†.€ƒ€Ê IïÅed,‚í€€…Ö,€³ I°‡€Š›ì, Aƒƒ€¾€Ç.€Ó¥Ú't€î fret,€ƒ¥Ú't€î frown, I Caught€Š›ì,€‰€€ƒƒ‚ƒ„‹!€Œ€ˆ€€„–,€Ç ain't€¸€£,•Õ I€È,€ŠŸâˆ…€£.“#•:}nιÉ.sšžD•4вÌ£4ôvyvyðýª'XK})©€Dõ®õ)˜»,

```

Try it online!

This was painful.

# Answer
> 8 votes
# Python, ~~897~~ ~~891~~ 875 bytes

*6 bytes saved thanks to @Emigna*

```
for x in[['The other day,','I met a bear,','A great big bear,','Oh way out there.'],['He looked at me,','I looked at him,','He sized up me,','I sized up him.'],['He said to me,','"Why don\'t you run?',"I see you ain't,",'Got any gun."'],['I says to him,','"That\'s a good idea."','"Now legs get going,','get me out of here!"'],['And so I ran,','Away from there,','But right behind me,','Was that bear.'],['In front of me,','There was a tree,','A great big tree,','Oh glory be!'],['The lowest branch,','Was ten feet up,',"So I thought I'd jump,",'And trust my luck.'],['And so I jumped,','Into the air,','But I missed that branch,','A way up there.'],["Now don't you fret,","And don't you frown,",'I Caught that branch,','On the way back down!'],['This is the end,','There aint no more,','Unless I see,','That bear once more.']]:print(*(y+'\n'+y for y in x),'',*x,'',sep='\n')

```

# Answer
> 7 votes
# brainfuck, 23913 bytes

```
-[--->+<]>-.[---->+++++<]>-.---.--[--->+<]>-.+++++[->+++<]>.+++++.------------.---.+++++++++++++.[-->+++++<]>+++.+[->+++<]>+.---.+[--->+<]>+++.-[-->+++++<]>.>++++++++++.>-[--->+<]>-.[---->+++++<]>-.---.--[--->+<]>-.+++++[->+++<]>.+++++.------------.---.+++++++++++++.[-->+++++<]>+++.+[->+++<]>+.---.+[--->+<]>+++.-[-->+++++<]>.>++++++++++.++[++++>---<]>.-[->++++<]>.+[----->+<]>.--------.[--->+<]>---.[---->+<]>+++.[->+++<]>+.-[->+++<]>.[->+++<]>++.+++.----.--[--->+<]>---.[++>---<]>+.>++++++++++.++[++++>---<]>.-[->++++<]>.+[----->+<]>.--------.[--->+<]>---.[---->+<]>+++.[->+++<]>+.-[->+++<]>.[->+++<]>++.+++.----.--[--->+<]>---.[++>---<]>+.>++++++++++.+++[->+++++<]>.-[-->+<]>.++[->+++<]>+.+++++++++++.-------------.----.--[--->+<]>-.[---->+<]>+++.[->+++<]>++.+++++++.--.-[--->+<]>--.[->+++<]>++.+++.----.--[--->+<]>---.[++>---<]>+.>++++++++++.+++[->+++++<]>.-[-->+<]>.++[->+++<]>+.+++++++++++.-------------.----.--[--->+<]>-.[---->+<]>+++.[->+++<]>++.+++++++.--.-[--->+<]>--.[->+++<]>++.+++.----.--[--->+<]>---.[++>---<]>+.>++++++++++.[->++++++++<]>-.-[--->++++<]>.--[--->+<]>--.--[->++++<]>-.-[->+++<]>-.+[--->+<]>+++.-[---->+<]>++.+++++[->+++<]>.++++++.-.[---->+<]>+++.---[->++++<]>.------------.---.+++++++++++++.-------------.[->+++<]>-.>++++++++++.[->++++++++<]>-.-[--->++++<]>.--[--->+<]>--.--[->++++<]>-.-[->+++<]>-.+[--->+<]>+++.-[---->+<]>++.+++++[->+++<]>.++++++.-.[---->+<]>+++.---[->++++<]>.------------.---.+++++++++++++.-------------.[->+++<]>-.>++++++++++..>-[--->+<]>-.[---->+++++<]>-.---.--[--->+<]>-.+++++[->+++<]>.+++++.------------.---.+++++++++++++.[-->+++++<]>+++.+[->+++<]>+.---.+[--->+<]>+++.-[-->+++++<]>.>++++++++++.++[++++>---<]>.-[->++++<]>.+[----->+<]>.--------.[--->+<]>---.[---->+<]>+++.[->+++<]>+.-[->+++<]>.[->+++<]>++.+++.----.--[--->+<]>---.[++>---<]>+.>++++++++++.+++[->+++++<]>.-[-->+<]>.++[->+++<]>+.+++++++++++.-------------.----.--[--->+<]>-.[---->+<]>+++.[->+++<]>++.+++++++.--.-[--->+<]>--.[->+++<]>++.+++.----.--[--->+<]>---.[++>---<]>+.>++++++++++.[->++++++++<]>-.-[--->++++<]>.--[--->+<]>--.--[->++++<]>-.-[->+++<]>-.+[--->+<]>+++.-[---->+<]>++.+++++[->+++<]>.++++++.-.[---->+<]>+++.---[->++++<]>.------------.---.+++++++++++++.-------------.[->+++<]>-.>++++++++++..++[->++++++<]>.-[->+++++<]>++.--[--->+<]>-.++[--->++<]>.+++..----.------.-.-[--->+<]>-.[->+++<]>+.--[--->+<]>-.[---->+<]>+++.+[----->+<]>.--------.-[->+++<]>.>++++++++++.++[->++++++<]>.-[->+++++<]>++.--[--->+<]>-.++[--->++<]>.+++..----.------.-.-[--->+<]>-.[->+++<]>+.--[--->+<]>-.[---->+<]>+++.+[----->+<]>.--------.-[->+++<]>.>++++++++++.++[++++>---<]>.-[->++++<]>.++[--->++<]>.+++..----.------.-.-[--->+<]>-.[->+++<]>+.--[--->+<]>-.[---->+<]>+++.-[--->++<]>--.+.++++.+[----->++<]>.>++++++++++.++[++++>---<]>.-[->++++<]>.++[--->++<]>.+++..----.------.-.-[--->+<]>-.[->+++<]>+.--[--->+<]>-.[---->+<]>+++.-[--->++<]>--.+.++++.+[----->++<]>.>++++++++++.++[->++++++<]>.-[->+++++<]>++.--[--->+<]>-.---[->++++<]>-.----------.-[--->+<]>++.---[->+++<]>.-.-[--->+<]>-.---[->++++<]>+.-----.[------->++<]>.+[----->+<]>.--------.-[->+++<]>.>++++++++++.++[->++++++<]>.-[->+++++<]>++.--[--->+<]>-.---[->++++<]>-.----------.-[--->+<]>++.---[->+++<]>.-.-[--->+<]>-.---[->++++<]>+.-----.[------->++<]>.+[----->+<]>.--------.-[->+++<]>.>++++++++++.++[++++>---<]>.-[->++++<]>.---[->++++<]>-.----------.-[--->+<]>++.---[->+++<]>.-.-[--->+<]>-.---[->++++<]>+.-----.[------->++<]>.-[--->++<]>--.+.++++.+[----->++<]>++.>++++++++++.++[++++>---<]>.-[->++++<]>.---[->++++<]>-.----------.-[--->+<]>++.---[->+++<]>.-.-[--->+<]>-.---[->++++<]>+.-----.[------->++<]>.-[--->++<]>--.+.++++.+[----->++<]>++.>++++++++++..++[->++++++<]>.-[->+++++<]>++.--[--->+<]>-.++[--->++<]>.+++..----.------.-.-[--->+<]>-.[->+++<]>+.--[--->+<]>-.[---->+<]>+++.+[----->+<]>.--------.-[->+++<]>.>++++++++++.++[++++>---<]>.-[->++++<]>.++[--->++<]>.+++..----.------.-.-[--->+<]>-.[->+++<]>+.--[--->+<]>-.[---->+<]>+++.-[--->++<]>--.+.++++.+[----->++<]>.>++++++++++.++[->++++++<]>.-[->+++++<]>++.--[--->+<]>-.---[->++++<]>-.----------.-[--->+<]>++.---[->+++<]>.-.-[--->+<]>-.---[->++++<]>+.-----.[------->++<]>.+[----->+<]>.--------.-[->+++<]>.>++++++++++.++[++++>---<]>.-[->++++<]>.---[->++++<]>-.----------.-[--->+<]>++.---[->+++<]>.-.-[--->+<]>-.---[->++++<]>+.-----.[------->++<]>.-[--->++<]>--.+.++++.+[----->++<]>++.>++++++++++..++[->++++++<]>.-[->+++++<]>++.--[--->+<]>-.---[->++++<]>-.++[->+++<]>++.++++++++.-----.-[--->+<]>-.---[->++++<]>.-----.[--->+<]>-----.+[----->+<]>.--------.-[->+++<]>.>++++++++++.++[->++++++<]>.-[->+++++<]>++.--[--->+<]>-.---[->++++<]>-.++[->+++<]>++.++++++++.-----.-[--->+<]>-.---[->++++<]>.-----.[--->+<]>-----.+[----->+<]>.--------.-[->+++<]>.>++++++++++.+[->+++<]>+.>+[--->++<]>+.+++[->++++<]>.[--->+<]>+.-[---->+<]>++.+[->+++<]>+.+++++++++++.-.[++>---<]>++.[->+++<]>-.[---->+<]>+++.--[->++++<]>+.----------.++++++.-[---->+<]>+++.---[----->++<]>.+++.-------.[------>+<]>++.>++++++++++.+[->+++<]>+.>+[--->++<]>+.+++[->++++<]>.[--->+<]>+.-[---->+<]>++.+[->+++<]>+.+++++++++++.-.[++>---<]>++.[->+++<]>-.[---->+<]>+++.--[->++++<]>+.----------.++++++.-[---->+<]>+++.---[----->++<]>.+++.-------.[------>+<]>++.>++++++++++.++[++++>---<]>.-[->++++<]>.---[->++++<]>-.++++[->+++<]>..--[--->+<]>-.--[->++++<]>+.----------.++++++.-[---->+<]>+++.[->+++<]>+.++++++++.+++++.[++>---<]>++.[->+++<]>-.[++>---<]>--.>++++++++++.++[++++>---<]>.-[->++++<]>.---[->++++<]>-.++++[->+++<]>..--[--->+<]>-.--[->++++<]>+.----------.++++++.-[---->+<]>+++.[->+++<]>+.++++++++.+++++.[++>---<]>++.[->+++<]>-.[++>---<]>--.>++++++++++.[->+++++++<]>+.[--->+<]>++.+++++.[---->+<]>+++.[->+++<]>+.+++++++++++++.[--->+<]>-.-[---->+<]>++.++[->+++<]>+.--[--->+<]>--.-------.[----->++<]>++.------------.>++++++++++.[->+++++++<]>+.[--->+<]>++.+++++.[---->+<]>+++.[->+++<]>+.+++++++++++++.[--->+<]>-.-[---->+<]>++.++[->+++<]>+.--[--->+<]>--.-------.[----->++<]>++.------------.>++++++++++..++[->++++++<]>.-[->+++++<]>++.--[--->+<]>-.---[->++++<]>-.++[->+++<]>++.++++++++.-----.-[--->+<]>-.---[->++++<]>.-----.[--->+<]>-----.+[----->+<]>.--------.-[->+++<]>.>++++++++++.+[->+++<]>+.>+[--->++<]>+.+++[->++++<]>.[--->+<]>+.-[---->+<]>++.+[->+++<]>+.+++++++++++.-.[++>---<]>++.[->+++<]>-.[---->+<]>+++.--[->++++<]>+.----------.++++++.-[---->+<]>+++.---[----->++<]>.+++.-------.[------>+<]>++.>++++++++++.++[++++>---<]>.-[->++++<]>.---[->++++<]>-.++++[->+++<]>..--[--->+<]>-.--[->++++<]>+.----------.++++++.-[---->+<]>+++.[->+++<]>+.++++++++.+++++.[++>---<]>++.[->+++<]>-.[++>---<]>--.>++++++++++.[->+++++++<]>+.[--->+<]>++.+++++.[---->+<]>+++.[->+++<]>+.+++++++++++++.[--->+<]>-.-[---->+<]>++.++[->+++<]>+.--[--->+<]>--.-------.[----->++<]>++.------------.>++++++++++..++[++++>---<]>.-[->++++<]>.---[->++++<]>-.++[->+++<]>++.+[--->+<]>+++.------.+[---->+<]>+++.---[->++++<]>.-----.[--->+<]>-----.-[--->++<]>--.+.++++.+[----->++<]>.>++++++++++.++[++++>---<]>.-[->++++<]>.---[->++++<]>-.++[->+++<]>++.+[--->+<]>+++.------.+[---->+<]>+++.---[->++++<]>.-----.[--->+<]>-----.-[--->++<]>--.+.++++.+[----->++<]>.>++++++++++.+[->+++<]>+.>-[--->+<]>-.[---->+++++<]>-.-------.--[--->+<]>-.+[--->+<]>.-[->+++<]>+.+[---->+<]>+++.[->+++<]>+.-[->+++<]>.++[->+++<]>+.++++++++..-----------.-[--->+<]>-.-[--->++<]>-.-----.+.----.-[-->+<]>--.------------.>++++++++++.+[->+++<]>+.>-[--->+<]>-.[---->+++++<]>-.-------.--[--->+<]>-.+[--->+<]>.-[->+++<]>+.+[---->+<]>+++.[->+++<]>+.-[->+++<]>.++[->+++<]>+.++++++++..-----------.-[--->+<]>-.-[--->++<]>-.-----.+.----.-[-->+<]>--.------------.>++++++++++.+[->+++<]>+.[------->+<]>.-[--->+<]>.++++++++.+[---->+<]>++.++[--->++<]>.-------.++.++++++++++++.+[---->+<]>+++.++[->+++<]>+.--.[--->+<]>---.[---->+<]>+++.++[->+++<]>+.++++++++.------.+++++.-------.---[->+++<]>.>++++++++++.+[->+++<]>+.[------->+<]>.-[--->+<]>.++++++++.+[---->+<]>++.++[--->++<]>.-------.++.++++++++++++.+[---->+<]>+++.++[->+++<]>+.--.[--->+<]>---.[---->+<]>+++.++[->+++<]>+.++++++++.------.+++++.-------.---[->+++<]>.>++++++++++.--[----->+<]>-.--.[--->+<]>---.[---->+<]>+++.+[----->+<]>.--------.--[--->+<]>-.+++++[->+++<]>.++++++.-.[---->+<]>+++.+++++[->+++<]>.---------.[--->+<]>--.-[--->++<]>--.---.+++++++++++++.-------------.--[--->+<]>.+.>++++++++++.--[----->+<]>-.--.[--->+<]>---.[---->+<]>+++.+[----->+<]>.--------.--[--->+<]>-.+++++[->+++<]>.++++++.-.[---->+<]>+++.+++++[->+++<]>.---------.[--->+<]>--.-[--->++<]>--.---.+++++++++++++.-------------.--[--->+<]>.+.>++++++++++..++[++++>---<]>.-[->++++<]>.---[->++++<]>-.++[->+++<]>++.+[--->+<]>+++.------.+[---->+<]>+++.---[->++++<]>.-----.[--->+<]>-----.-[--->++<]>--.+.++++.+[----->++<]>.>++++++++++.+[->+++<]>+.>-[--->+<]>-.[---->+++++<]>-.-------.--[--->+<]>-.+[--->+<]>.-[->+++<]>+.+[---->+<]>+++.[->+++<]>+.-[->+++<]>.++[->+++<]>+.++++++++..-----------.-[--->+<]>-.-[--->++<]>-.-----.+.----.-[-->+<]>--.------------.>++++++++++.+[->+++<]>+.[------->+<]>.-[--->+<]>.++++++++.+[---->+<]>++.++[--->++<]>.-------.++.++++++++++++.+[---->+<]>+++.++[->+++<]>+.--.[--->+<]>---.[---->+<]>+++.++[->+++<]>+.++++++++.------.+++++.-------.---[->+++<]>.>++++++++++.--[----->+<]>-.--.[--->+<]>---.[---->+<]>+++.+[----->+<]>.--------.--[--->+<]>-.+++++[->+++<]>.++++++.-.[---->+<]>+++.+++++[->+++<]>.---------.[--->+<]>--.-[--->++<]>--.---.+++++++++++++.-------------.--[--->+<]>.+.>++++++++++..+++[->+++++<]>.[--->+<]>+++.----------.-[--->+<]>-.---[->++++<]>-.----.[--->+<]>-----.++++[->++<]>+.-[->++++<]>.---[----->++<]>.+++[->+++<]>++.+++++++++++++.[----->++<]>.>++++++++++.+++[->+++++<]>.[--->+<]>+++.----------.-[--->+<]>-.---[->++++<]>-.----.[--->+<]>-----.++++[->++<]>+.-[->++++<]>.---[----->++<]>.+++[->+++<]>++.+++++++++++++.[----->++<]>.>++++++++++.+++[->+++++<]>.[------->+<]>.-[->+++<]>-.+[--->+<]>+++.-[---->+<]>++.++[->+++<]>.++++++++++++.---.--.[->+++++<]>-.---[->++++<]>.------------.---.+++++++++++++.-------------.-[->+++<]>.>++++++++++.+++[->+++++<]>.[------->+<]>.-[->+++<]>-.+[--->+<]>+++.-[---->+<]>++.++[->+++<]>.++++++++++++.---.--.[->+++++<]>-.---[->++++<]>.------------.---.+++++++++++++.-------------.-[->+++<]>.>++++++++++.+[->++++++<]>.++[----->+<]>+.-.[---->+<]>+++.---[----->++<]>.---------.--.+.++++++++++++.[---->+<]>+++.[->+++<]>++.+++.+++.+.+++++.----------.-[--->+<]>-.+[----->+<]>.--------.-[->+++<]>.>++++++++++.+[->++++++<]>.++[----->+<]>+.-.[---->+<]>+++.---[----->++<]>.---------.--.+.++++++++++++.[---->+<]>+++.[->+++<]>++.+++.+++.+.+++++.----------.-[--->+<]>-.+[----->+<]>.--------.-[->+++<]>.>++++++++++.[------>+<]>.++++++++++.--[--->+<]>--.+[---->+<]>+++.---[->++++<]>.------------.-------.--[--->+<]>-.[---->+<]>+++.[->+++<]>++.+++.----.--[--->+<]>---.++[++>---<]>.>++++++++++.[------>+<]>.++++++++++.--[--->+<]>--.+[---->+<]>+++.---[->++++<]>.------------.-------.--[--->+<]>-.[---->+<]>+++.[->+++<]>++.+++.----.--[--->+<]>---.++[++>---<]>.>++++++++++..+++[->+++++<]>.[--->+<]>+++.----------.-[--->+<]>-.---[->++++<]>-.----.[--->+<]>-----.++++[->++<]>+.-[->++++<]>.---[----->++<]>.+++[->+++<]>++.+++++++++++++.[----->++<]>.>++++++++++.+++[->+++++<]>.[------->+<]>.-[->+++<]>-.+[--->+<]>+++.-[---->+<]>++.++[->+++<]>.++++++++++++.---.--.[->+++++<]>-.---[->++++<]>.------------.---.+++++++++++++.-------------.-[->+++<]>.>++++++++++.+[->++++++<]>.++[----->+<]>+.-.[---->+<]>+++.---[----->++<]>.---------.--.+.++++++++++++.[---->+<]>+++.[->+++<]>++.+++.+++.+.+++++.----------.-[--->+<]>-.+[----->+<]>.--------.-[->+++<]>.>++++++++++.[------>+<]>.++++++++++.--[--->+<]>--.+[---->+<]>+++.---[->++++<]>.------------.-------.--[--->+<]>-.[---->+<]>+++.[->+++<]>++.+++.----.--[--->+<]>---.++[++>---<]>.>++++++++++..++[++++>---<]>.+[--->+<]>.-[->+++++<]>-.++[->+++<]>.++++++++++++.---.-.++++++.[---->+<]>+++.+++++[->+++<]>.---------.[--->+<]>--.+[----->+<]>.--------.-[->+++<]>.>++++++++++.++[++++>---<]>.+[--->+<]>.-[->+++++<]>-.++[->+++<]>.++++++++++++.---.-.++++++.[---->+<]>+++.+++++[->+++<]>.---------.[--->+<]>--.+[----->+<]>.--------.-[->+++<]>.>++++++++++.>-[--->+<]>-.[---->+++++<]>-.---.+++++++++++++.-------------.--[--->+<]>-.--[->++++<]>-.-[->+++<]>-.--[--->+<]>--.+[---->+<]>+++.[->+++<]>+.-[->+++<]>.---[->++++<]>.--.-------------..-[->+++<]>.>++++++++++.>-[--->+<]>-.[---->+++++<]>-.---.+++++++++++++.-------------.--[--->+<]>-.--[->++++<]>-.-[->+++<]>-.--[--->+<]>--.+[---->+<]>+++.[->+++<]>+.-[->+++<]>.---[->++++<]>.--.-------------..-[->+++<]>.>++++++++++.+++[->+++++<]>.-[-->+<]>.++[->+++<]>+.+++++++++++.-------------.----.--[--->+<]>-.[---->+<]>+++.[->+++<]>++.+++++++.--.-[--->+<]>--.---[->++++<]>.--.-------------..-[->+++<]>.>++++++++++.+++[->+++++<]>.-[-->+<]>.++[->+++<]>+.+++++++++++.-------------.----.--[--->+<]>-.[---->+<]>+++.[->+++<]>++.+++++++.--.-[--->+<]>--.---[->++++<]>.--.-------------..-[->+++<]>.>++++++++++.[->++++++++<]>-.-[--->++++<]>.--[--->+<]>--.++[->+++<]>+.+++++.+++.+++.+++++++.-[---->+<]>++.[->+++<]>++.+++.--[--->+<]>.[--->+<]>-.[->++++++++<]>-.-[--->++++<]>.--[--->+<]>--.++[->+++<]>+.+++++.+++.+++.+++++++.-[---->+<]>++.[->+++<]>++.+++.--[--->+<]>.[--->+<]>-..++[++++>---<]>.+[--->+<]>.-[->+++++<]>-.++[->+++<]>.++++++++++++.---.-.++++++.[---->+<]>+++.+++++[->+++<]>.---------.[--->+<]>--.+[----->+<]>.--------.-[->+++<]>.>++++++++++.>-[--->+<]>-.[---->+++++<]>-.---.+++++++++++++.-------------.--[--->+<]>-.--[->++++<]>-.-[->+++<]>-.--[--->+<]>--.+[---->+<]>+++.[->+++<]>+.-[->+++<]>.---[->++++<]>.--.-------------..-[->+++<]>.>++++++++++.+++[->+++++<]>.-[-->+<]>.++[->+++<]>+.+++++++++++.-------------.----.--[--->+<]>-.[---->+<]>+++.[->+++<]>++.+++++++.--.-[--->+<]>--.---[->++++<]>.--.-------------..-[->+++<]>.>++++++++++.[->++++++++<]>-.-[--->++++<]>.--[--->+<]>--.++[->+++<]>+.+++++.+++.+++.+++++++.-[---->+<]>++.[->+++<]>++.+++.--[--->+<]>.[--->+<]>-..>-[--->+<]>-.[---->+++++<]>-.---.--[--->+<]>-.++[--->++<]>.+++.++++++++.[->+++<]>.[--->+<]>----.+.[---->+<]>+++.[->+++<]>++.[--->+<]>----.+++[->+++<]>++.+++++++++++++.-----------.+++++.----[->+++<]>.>++++++++++.>-[--->+<]>-.[---->+++++<]>-.---.--[--->+<]>-.++[--->++<]>.+++.++++++++.[->+++<]>.[--->+<]>----.+.[---->+<]>+++.[->+++<]>++.[--->+<]>----.+++[->+++<]>++.+++++++++++++.-----------.+++++.----[->+++<]>.>++++++++++.[------>+<]>.++++++++++.--[--->+<]>--.+[---->+<]>+++.---[->++++<]>.+++[->+++<]>.+++++++++.-[->+++++<]>-.++[->+++<]>.-..[--->+<]>---.[---->+<]>+++.---[->++++<]>+.-----.-[->+++++<]>+.>++++++++++.[------>+<]>.++++++++++.--[--->+<]>--.+[---->+<]>+++.---[->++++<]>.+++[->+++<]>.+++++++++.-[->+++++<]>-.++[->+++<]>.-..[--->+<]>---.[---->+<]>+++.---[->++++<]>+.-----.-[->+++++<]>+.>++++++++++.>-[--->+<]>--.[--->+<]>--.[--->+<]>-----.++++[->++<]>+.-[->++++<]>.---[->++++<]>.------------.+++++++.++++++.++[->+++<]>++.+.++++++++++++.[---->+<]>+++.++++[->++<]>+.+[-->+<]>++.-[--->+<]>++.-[--->+<]>-.-[--->++<]>.+++++++++++.--------.+++.-[->+++++<]>+.>++++++++++.>-[--->+<]>--.[--->+<]>--.[--->+<]>-----.++++[->++<]>+.-[->++++<]>.---[->++++<]>.------------.+++++++.++++++.++[->+++<]>++.+.++++++++++++.[---->+<]>+++.++++[->++<]>+.+[-->+<]>++.-[--->+<]>++.-[--->+<]>-.-[--->++<]>.+++++++++++.--------.+++.-[->+++++<]>+.>++++++++++.+++[->+++++<]>.[--->+<]>+++.----------.-[--->+<]>-.---[->++++<]>.--.+++.--.+.[---->+<]>+++.+[----->+<]>.--[--->+<]>.-[---->+<]>++.++[--->++<]>.+++++++++.+[->+++<]>+.++++++++.[->++++++++++<]>.>++++++++++.+++[->+++++<]>.[--->+<]>+++.----------.-[--->+<]>-.---[->++++<]>.--.+++.--.+.[---->+<]>+++.+[----->+<]>.--[--->+<]>.-[---->+<]>++.++[--->++<]>.+++++++++.+[->+++<]>+.++++++++.[->++++++++++<]>.>++++++++++..>-[--->+<]>-.[---->+++++<]>-.---.--[--->+<]>-.++[--->++<]>.+++.++++++++.[->+++<]>.[--->+<]>----.+.[---->+<]>+++.[->+++<]>++.[--->+<]>----.+++[->+++<]>++.+++++++++++++.-----------.+++++.----[->+++<]>.>++++++++++.[------>+<]>.++++++++++.--[--->+<]>--.+[---->+<]>+++.---[->++++<]>.+++[->+++<]>.+++++++++.-[->+++++<]>-.++[->+++<]>.-..[--->+<]>---.[---->+<]>+++.---[->++++<]>+.-----.-[->+++++<]>+.>++++++++++.>-[--->+<]>--.[--->+<]>--.[--->+<]>-----.++++[->++<]>+.-[->++++<]>.---[->++++<]>.------------.+++++++.++++++.++[->+++<]>++.+.++++++++++++.[---->+<]>+++.++++[->++<]>+.+[-->+<]>++.-[--->+<]>++.-[--->+<]>-.-[--->++<]>.+++++++++++.--------.+++.-[->+++++<]>+.>++++++++++.+++[->+++++<]>.[--->+<]>+++.----------.-[--->+<]>-.---[->++++<]>.--.+++.--.+.[---->+<]>+++.+[----->+<]>.--[--->+<]>.-[---->+<]>++.++[--->++<]>.+++++++++.+[->+++<]>+.++++++++.[->++++++++++<]>.>++++++++++..+++[->+++++<]>.[--->+<]>+++.----------.-[--->+<]>-.---[->++++<]>-.----.[--->+<]>-----.++++[->++<]>+.-[->++++<]>.-[--->++<]>.+++++++++++.--------.+++.-----------.-.[->+++<]>.>++++++++++.+++[->+++++<]>.[--->+<]>+++.----------.-[--->+<]>-.---[->++++<]>-.----.[--->+<]>-----.++++[->++<]>+.-[->++++<]>.-[--->++<]>.+++++++++++.--------.+++.-----------.-.[->+++<]>.>++++++++++.++[++++>---<]>.+[--->+<]>.++++++.-----.[--->+<]>-----.---[->++++<]>.------------.---.--[--->+<]>-.[->+++<]>+.++++++++.+++++++++.[++>---<]>+.>++++++++++.++[++++>---<]>.+[--->+<]>.++++++.-----.[--->+<]>-----.---[->++++<]>.------------.---.--[--->+<]>-.[->+++<]>+.++++++++.+++++++++.[++>---<]>+.>++++++++++.+[->++++++<]>.++[----->+<]>+.-.[---->+<]>+++.++++[->++<]>+.-[->++++<]>.+[----->+<]>.----.++++++++++..++++[->+++<]>.-.-[--->+<]>-.---[->++++<]>.------------.-------.--[--->+<]>-.[---->+<]>+++.[->+++<]>++.[--->+<]>----.+++[->+++<]>++.+++++++++++++.-----------.+++++.----[->+++<]>.>++++++++++.+[->++++++<]>.++[----->+<]>+.-.[---->+<]>+++.++++[->++<]>+.-[->++++<]>.+[----->+<]>.----.++++++++++..++++[->+++<]>.-.-[--->+<]>-.---[->++++<]>.------------.-------.--[--->+<]>-.[---->+<]>+++.[->+++<]>++.[--->+<]>----.+++[->+++<]>++.+++++++++++++.-----------.+++++.----[->+++<]>.>++++++++++.+++[->+++++<]>.-[-->+<]>.--[->++++<]>-.-[->+++<]>-.+[--->+<]>+++.-[---->+<]>++.---[->++++<]>+.-----.[------->++<]>.---[->++++<]>.------------.---.+++++++++++++.-------------.[->+++<]>-.>++++++++++.+++[->+++++<]>.-[-->+<]>.--[->++++<]>-.-[->+++<]>-.+[--->+<]>+++.-[---->+<]>++.---[->++++<]>+.-----.[------->++<]>.---[->++++<]>.------------.---.+++++++++++++.-------------.[->+++<]>-.>++++++++++..+++[->+++++<]>.[--->+<]>+++.----------.-[--->+<]>-.---[->++++<]>-.----.[--->+<]>-----.++++[->++<]>+.-[->++++<]>.-[--->++<]>.+++++++++++.--------.+++.-----------.-.[->+++<]>.>++++++++++.++[++++>---<]>.+[--->+<]>.++++++.-----.[--->+<]>-----.---[->++++<]>.------------.---.--[--->+<]>-.[->+++<]>+.++++++++.+++++++++.[++>---<]>+.>++++++++++.+[->++++++<]>.++[----->+<]>+.-.[---->+<]>+++.++++[->++<]>+.-[->++++<]>.+[----->+<]>.----.++++++++++..++++[->+++<]>.-.-[--->+<]>-.---[->++++<]>.------------.-------.--[--->+<]>-.[---->+<]>+++.[->+++<]>++.[--->+<]>----.+++[->+++<]>++.+++++++++++++.-----------.+++++.----[->+++<]>.>++++++++++.+++[->+++++<]>.-[-->+<]>.--[->++++<]>-.-[->+++<]>-.+[--->+<]>+++.-[---->+<]>++.---[->++++<]>+.-----.[------->++<]>.---[->++++<]>.------------.---.+++++++++++++.-------------.[->+++<]>-.>++++++++++..+++[->++++++<]>.-[--->+<]>.++++++++.+[---->+<]>++.+[->+++<]>+.+++++++++++.-.[++>---<]>++.[->+++<]>-.[---->+<]>+++.--[->++++<]>+.----------.++++++.-[---->+<]>+++.++[->+++<]>.++++++++++++.-------------.[--->+<]>---.[++>---<]>--.>++++++++++.+++[->++++++<]>.-[--->+<]>.++++++++.+[---->+<]>++.+[->+++<]>+.+++++++++++.-.[++>---<]>++.[->+++<]>-.[---->+<]>+++.--[->++++<]>+.----------.++++++.-[---->+<]>+++.++[->+++<]>.++++++++++++.-------------.[--->+<]>---.[++>---<]>--.>++++++++++.+++[->+++++<]>.[--->+<]>+++.----------.-[--->+<]>-.+[->+++<]>+.+++++++++++.-.[++>---<]>++.[->+++<]>-.[---->+<]>+++.--[->++++<]>+.----------.++++++.-[---->+<]>+++.++[->+++<]>.++++++++++++.---.++++++++.---------.[----->++<]>.>++++++++++.+++[->+++++<]>.[--->+<]>+++.----------.-[--->+<]>-.+[->+++<]>+.+++++++++++.-.[++>---<]>++.[->+++<]>-.[---->+<]>+++.--[->++++<]>+.----------.++++++.-[---->+<]>+++.++[->+++<]>.++++++++++++.---.++++++++.---------.[----->++<]>.>++++++++++.++[++++>---<]>.-[->++++<]>.+[->++<]>+.-[-->+++<]>--.--[--->+<]>.++[->+++<]>++.+.++++++++++++.[---->+<]>+++.---[->++++<]>.------------.-------.--[--->+<]>-.[---->+<]>+++.[->+++<]>++.[--->+<]>----.+++[->+++<]>++.+++++++++++++.-----------.+++++.----[->+++<]>.>++++++++++.++[++++>---<]>.-[->++++<]>.+[->++<]>+.-[-->+++<]>--.--[--->+<]>.++[->+++<]>++.+.++++++++++++.[---->+<]>+++.---[->++++<]>.------------.-------.--[--->+<]>-.[---->+<]>+++.[->+++<]>++.[--->+<]>----.+++[->+++<]>++.+++++++++++++.-----------.+++++.----[->+++<]>.>++++++++++.[->++++++++<]>-.--[--->+<]>-.-[->+++++<]>-.---[->++++<]>.------------.---.--[--->+<]>-.--[->++++<]>-.-[->+++<]>-.+[--->+<]>+++.-[---->+<]>++.[->+++<]>++.-.++.++++++++.-[++>---<]>+.+[->+++<]>+.+++++++++++.++++++++.---------.-[->+++++<]>.[--->+<]>-.[->++++++++<]>-.--[--->+<]>-.-[->+++++<]>-.---[->++++<]>.------------.---.--[--->+<]>-.--[->++++<]>-.-[->+++<]>-.+[--->+<]>+++.-[---->+<]>++.[->+++<]>++.-.++.++++++++.-[++>---<]>+.+[->+++<]>+.+++++++++++.++++++++.---------.-[->+++++<]>.[--->+<]>-..+++[->++++++<]>.-[--->+<]>.++++++++.+[---->+<]>++.+[->+++<]>+.+++++++++++.-.[++>---<]>++.[->+++<]>-.[---->+<]>+++.--[->++++<]>+.----------.++++++.-[---->+<]>+++.++[->+++<]>.++++++++++++.-------------.[--->+<]>---.[++>---<]>--.>++++++++++.+++[->+++++<]>.[--->+<]>+++.----------.-[--->+<]>-.+[->+++<]>+.+++++++++++.-.[++>---<]>++.[->+++<]>-.[---->+<]>+++.--[->++++<]>+.----------.++++++.-[---->+<]>+++.++[->+++<]>.++++++++++++.---.++++++++.---------.[----->++<]>.>++++++++++.++[++++>---<]>.-[->++++<]>.+[->++<]>+.-[-->+++<]>--.--[--->+<]>.++[->+++<]>++.+.++++++++++++.[---->+<]>+++.---[->++++<]>.------------.-------.--[--->+<]>-.[---->+<]>+++.[->+++<]>++.[--->+<]>----.+++[->+++<]>++.+++++++++++++.-----------.+++++.----[->+++<]>.>++++++++++.[->++++++++<]>-.--[--->+<]>-.-[->+++++<]>-.---[->++++<]>.------------.---.--[--->+<]>-.--[->++++<]>-.-[->+++<]>-.+[--->+<]>+++.-[---->+<]>++.[->+++<]>++.-.++.++++++++.-[++>---<]>+.+[->+++<]>+.+++++++++++.++++++++.---------.-[->+++++<]>.[--->+<]>-..>-[--->+<]>-.[---->+++++<]>-.+.++++++++++.+[---->+<]>+++.-[--->++<]>-.++++++++++.+[---->+<]>+++.---[->++++<]>.------------.---.--[--->+<]>-.+[->+++<]>++.+++++++++.----------.[->+++<]>.>++++++++++.>-[--->+<]>-.[---->+++++<]>-.+.++++++++++.+[---->+<]>+++.-[--->++<]>-.++++++++++.+[---->+<]>+++.---[->++++<]>.------------.---.--[--->+<]>-.+[->+++<]>++.+++++++++.----------.[->+++<]>.>++++++++++.>-[--->+<]>-.[---->+++++<]>-.---.+++++++++++++.-------------.--[--->+<]>-.[->+++<]>+.++++++++.+++++.++++++.[---->+<]>+++.+[----->+<]>+.+.[--->+<]>-----.+[----->+<]>.++.+++.-------------.-[->+++<]>.>++++++++++.>-[--->+<]>-.[---->+++++<]>-.---.+++++++++++++.-------------.--[--->+<]>-.[->+++<]>+.++++++++.+++++.++++++.[---->+<]>+++.+[----->+<]>+.+.[--->+<]>-----.+[----->+<]>.++.+++.-------------.-[->+++<]>.>++++++++++.>-[--->+<]>.--[--->+<]>---.--.-------.[--->+<]>----..+[---->+<]>+++.++++[->++<]>+.-[->++++<]>.---[->++++<]>-.++++[->+++<]>..-[->+++<]>.>++++++++++.>-[--->+<]>.--[--->+<]>---.--.-------.[--->+<]>----..+[---->+<]>+++.++++[->++<]>+.-[->++++<]>.---[->++++<]>-.++++[->+++<]>..-[->+++<]>.>++++++++++.>-[--->+<]>-.[---->+++++<]>-.-------.--[--->+<]>-.[---->+<]>+++.[->+++<]>++.+++.----.--[--->+<]>---.[-->+++++<]>+++.+++++[->+++<]>.-.-----------.++.--[--->+<]>-.+[----->+<]>.++.+++.-------------.[->+++<]>-.>++++++++++.>-[--->+<]>-.[---->+++++<]>-.-------.--[--->+<]>-.[---->+<]>+++.[->+++<]>++.+++.----.--[--->+<]>---.[-->+++++<]>+++.+++++[->+++<]>.-.-----------.++.--[--->+<]>-.+[----->+<]>.++.+++.-------------.[->+++<]>-.>++++++++++..>-[--->+<]>-.[---->+++++<]>-.+.++++++++++.+[---->+<]>+++.-[--->++<]>-.++++++++++.+[---->+<]>+++.---[->++++<]>.------------.---.--[--->+<]>-.+[->+++<]>++.+++++++++.----------.[->+++<]>.>++++++++++.>-[--->+<]>-.[---->+++++<]>-.---.+++++++++++++.-------------.--[--->+<]>-.[->+++<]>+.++++++++.+++++.++++++.[---->+<]>+++.+[----->+<]>+.+.[--->+<]>-----.+[----->+<]>.++.+++.-------------.-[->+++<]>.>++++++++++.>-[--->+<]>.--[--->+<]>---.--.-------.[--->+<]>----..+[---->+<]>+++.++++[->++<]>+.-[->++++<]>.---[->++++<]>-.++++[->+++<]>..-[->+++<]>.>++++++++++.>-[--->+<]>-.[---->+++++<]>-.-------.--[--->+<]>-.[---->+<]>+++.[->+++<]>++.+++.----.--[--->+<]>---.[-->+++++<]>+++.+++++[->+++<]>.-.-----------.++.--[--->+<]>-.+[----->+<]>.++.+++.-------------.[->+++<]>-.

```

Try it online!

Did I win?

# Answer
> 6 votes
# SOGL, 395 bytes

```
ev~½ΠΥ≠ļ‚ļ╚■.ō1Τ⁾⁶J1⅓⁶ζ⅝:‚$η╬Μīβ╚ø○θωΔβ}%⁴šσƧxeρ}∙-Pē§′ī□0▼⅞∫╤Κī,└#%℮Δ:╤╝XN3¾3≤Β╚⌡ææ3─λ²‰7y⅜Η⁸‘→≥℮⅓ƨ9$►,cS|kņ═C⁷Ρv ητΕ▓«⁸○!FΩ§@f▒2čļΓμ±'aΖ[A±wdM∙ξ↓I┐η)℮∙↕↑|G-█lz◄xΖp⁴╤§¬╝╔5ξΣ█⅟Q╗Πψū→iT\]ļ⌡Kōnō╗═↓ΝX~⁶←±;ΔÆ▼η╤→=ō>○ξlζ║╥⌠čø▼e≤ā‼1²ζ∑%′`u¤¹ZΕ⅓╚Ƨ╚═′ž⁽μOģΤΒΨs⅜≡8γ¾:╝ss1⅟p?╬¾⌡░WƧΛφ].zΜ╔D/dσ←╝ΣΡ  $β]¤λƨ█‼□nZ⁰⁴ERāv⅔⅔Lv<-ε÷׀@∫νυPθšΦ‚Υ«HΠ¤⅝⅓→∙UWv∞⁵⁾JΕ∙9ø(»≡ΧVδ█∙~³A⁄└υ℮‘+ ¶ΘL{øO4{aIAawa8«-?⁾}≥}≥4{tt≥}≥øO4{O

```

pastebin of the code because tabs

Explanation:

```
...‘...‘+                                     push two compressed strings and joins them together (dunno why one doesn't work)
          ¶Θ                                  split on newlines
            L{                                repeat 10 times
              øO                               output a newline
                4{             }               repeat 4 times
                  aIA                           increase variable A, current line of the 40 (default = 0)
                     aw                         get the Ath (1-indexed) item of the lines
                       a8«-                     subtract from A 16
                           ? }                  if [isn't 0]
                            ⁾                    sentence-case it
                              ≥                 put the top item of the stack at the bottom (so ontop would be the line array)
                                ≥              put the top item (line array) of the stack at the bottom, so 1st line is ontop
                                 4{   }        4 times do
                                   tt           output the current line twice
                                     ≥          put the top item (current line) on the bottom (so next line is ontop)
                                       ≥       put the top item (line array) of the stack at the bottom, so 1st line is ontop
                                        øO     output a newline
                                          4{O  4 times output current line

```

# Answer
> 4 votes
# PHP, 636 Bytes

String representation of the 2D array compressed and base64 encoded

```
foreach(explode(8,gzinflate(base64_decode("VVK7ktswDPwVnBo3GtVWlXFSJG5yRZy5mjZhkrFE3PAxGuXrs6CUONeJwALYhy6eSYrnRNas/XimmQsZurJJ/Xgil9gUuga3V149LWYlqYV0iIfjN6ZJ5MGWAJxZVzzfPsz9CEQOv1Go7zvg3xP9tiGbYKlIa3dvfiUr8VBolUqpxk86wtyeJqDRj18FLONKrsahO6Jt1qwL2sHu4k05ZMhwIpaCZTN0Y/ddFprYZXKQ6CRE14/6OXPTI3dSRS/d8RQtZaEzJRNhggq+J5k3xf34GeAUnIcv7AOwyvrN4L5Xr+DTcDxHHYltq7YvOgrrlFRJzB+93Srw1k2SVqx4OWIAPi6cgQCNm99PMBYzSNf3fvyhHIuXqlzOB0u/6oyy0i+pYnJeaaq3x/BUpAi2yCDCLOiBn2lThORDzohlU7HfPLW4kdSetnr4zOaeuGz3/q/JEjXkL6bx+rDuNbajuvNqbg+MLVG1hkwhtxZH+9ctRF0o4qcQdf1nnDhnan+CInarSeKNG2T4Aw==")))as$z)
echo strtr("0
0
1
1
2
2
3
3

0
1
2
3

",explode(9,$z));

```

Try it online!

# PHP, 651 Bytes

Json encoding of the unique array compressed and base64 encoded

```
foreach(json_decode(gzinflate(base64_decode("XVK7UgMxDPwVcU2aTH6BCRSQBgpgKBIKJ1ZskzuJ8WNujq9HspMLUHq9knZX2m67V4/A2WMEa6Zlt+w2MGAGA3s0Ud9rcBFNhn1wM/bsYTQTcMmgpbjqPpbb7hGhZz6hBaEP2JpdER8GhYSVwrdA5WsmzYBw5l7JBAuZz6Rd9+4nsEyLDBMXiIVuWy1iBUyQL2U+sMinCVyh1a6r3YRlpqTNziJ24tvkRRKfjtlCsGiUrD9PPEKPLoGTHBwHclqhjwGrZT6Cmr45N1+ThcSwgWioBqbRHCMPLRuF7qQqBuclRfRB+M3TuxFNXrOVXJvvDWkp1SGN9KpNJG7VmiPi/51cMNmJ6zlO0uymttLN9jxiEp5IO/h5JMoQFD/lS6EX1Z49F9W3WVj4LEP9UGM5FqkfJujL4bT661d5aOsGSaIVt7KEePErdxRSkrU2h7OCdT0d2fWvy9HIr6s9RsyX+b9RHqmdy72pWv81fqYqQbvvzeEkpSNdkggJQqrfSPaaqtxMBpIT47anN+oxJahH1Vjn5QDTAStNBH/8AA==")))as$z)
echo strtr("0
0
1
1
2
2
3
3

0
1
2
3

",$z);

```

Try it online!

# PHP, 720 Bytes

Only compressed and base64 encoded

```
<?=gzinflate(base64_decode("lZTBkpswDIbvPIWSSy4Mr9BJe2i5dA+ls2cnKLYbsHZsMwx9+srebBOIKe4t/2dbvyIkNQqBvEILrZjKopnLGnr0IOCEwi7VEaRF4eGk5Sp5UTCKCWjwEIJilSD/9syJWXxD6Iiu2ALf7LF8BvWDVrpPAH7i9G8Gw9tHiJmu75LvV086w3MrZLwgdAue/qbwIPevaoKWzMHDRAPYwXxKMg6LGKXQfFA+g6/EBTYTyMFU+4XKcd0IGM7F5EKEW61nct8o4Q+OP7EkakG3KPjRCv1OI3QoHUhuCknayDINw88eY1vQBUJj7PZpmJlPtklxNC04ghqsMOVShV69WOrfmzUBPnMwq6XiHkel+XG/Bl8FJ63CMPAgVEu5ZZwTsqhNeGPi34stutBNiMXzF6rlLSbJ48iuER5i2ZGd2Hc3FxmWG+HiQuloRMdXuBZnVaZQ/OvIZsgfdXhLgB+hmF7REIpWH1r4NfTrOJTf24Ed+gm64XytUigrk3yH+0cPV7Atn0FtuNG5B3hW7VKFnuB9q53jNfTeB7ec1k+Ocf3yzrpt36XeyiA/chFG8L56LhZ51aRYcHxkNJoVWMMXEas6M07TFxOTDjmdxPnKwUazW6H5af2PFzeLdqBdPEPTlikQpoPXsAfDC5ssptlP06FzEDf3UjUfCwDInDE+qNIwz387+h8="));

```

Try it online!

# PHP, 870 Bytes

```
$b="t branch,";$h=here;foreach([["The other day,","I met a bear,","A great big bear,","Oh way out t$h."],["He looked at me,","I looked at him,","He sized up me,","I sized up him."],["He said to me,",'"Why don\'t you run?',"I see you ain't,",'Got any gun."'],["I says to him,",'"That\'s a good idea."','"Now legs get going,','get me out of $h!"'],["And so I ran,","Away from t$h,","But right behind me,","Was that bear."],["In front of me,","There was a tree,","A great big tree,","Oh glory be!"],["The lowes$b","Was ten feet up,","So I thought I'd jump,","And trust my luck."],["And so I jumped,","Into the air,","But I missed tha$b","A way up there."],["Now don't you fret,","And don't you frown,","I Caught tha$b","On the way back down!"],["This is the end,","T$h aint no more,","Unless I see,","That bear once more."]]as$z)echo strtr("0
0
1
1
2
2
3
3

0
1
2
3

",$z);

```

Try it online!

Expanded

```
$b="t branch,";$h=here;
foreach([["The other day,","I met a bear,","A great big bear,","Oh way out t$h."]
,["He looked at me,","I looked at him,","He sized up me,","I sized up him."]
,["He said to me,",'"Why don\'t you run?',"I see you ain't,",'Got any gun."']
,["I says to him,",'"That\'s a good idea."','"Now legs get going,','get me out of $h!"']
,["And so I ran,","Away from t$h,","But right behind me,","Was that bear."]
,["In front of me,","There was a tree,","A great big tree,","Oh glory be!"]
,["The lowes$b","Was ten feet up,","So I thought I'd jump,","And trust my luck."]
,["And so I jumped,","Into the air,","But I missed tha$b","A way up there."]
,["Now don't you fret,","And don't you frown,","I Caught tha$b","On the way back down!"]
,["This is the end,","T$h aint no more,","Unless I see,","That bear once more."]]as$z)
echo strtr("0
0
1
1
2
2
3
3

0
1
2
3

",$z);

```

# Answer
> 2 votes
# JS (ES6), ~~909~~ 905 bytes

```
x=>(n=`
`,a=[[`The other day,`,`I met a bear,`,`A great big bear,`,`Oh way out there.`],[`He looked at me,`,`I looked at him,`,`He sized up me,`,`I sized up him.`],[`He said to me,`,`"Why don't you run?`,`I see you ain't,`,`Got any gun."`],[`I says to him,`,`"That's a good idea."`,`"Now legs get going,`,`get me out of here!"`],[`And so I ran,`,`Away from there,`,`But right behind me,`,`Was that bear.`],[`In front of me,`,`There was a tree,`,`A great big tree,`,`Oh glory be!`],[`The lowest branch,`,`Was ten feet up,`,`So I thought I'd jump,`,`And trust my luck.`],[`And so I jumped,`,`Into the air,`,`But I missed that branch,`,`A way up there.`],[`Now don't you fret,`,`And don't you frown,`,`I Caught that branch,`,`On the way back down!`],[`This is the end,`,`There aint no more,`,`Unless I see,`,`That bear once more.`]],s="",a.map(i=>(i.map(z=>s+=(z+n).repeat(2),s+=n,i.map(z=>s+=z+n)),s+=n)),s)

```

# Answer
> 2 votes
# C, ~~961~~ 952 bytes

```
#define P(s)puts(s)+
char*s="The other day,I met a bear,A great big bear,Oh way out there.He looked at me,I looked at him,He sized up me,I sized up him.He said to me,_Why don't you run?I see you ain't,Got any gun._I says to him,_That's a good idea.__Now legs get going,get me out of here!_And so I ran,Away from there,But right behind me,Was that bear.In front of me,There was a tree,A great big tree,Oh glory be!The lowest branch,Was ten feet up,So I thought I'd jump,And trust my luck.And so I jumped,Into the air,But I missed that branch,A way up there.Now don't you fret,And don't you frown,I Caught that branch,On the way back down!This is the end,There aint no more,Unless I see,That bear once more.";char a[99],b[99],c[99],d[99];i,j,k,l;f(){char*t[4]={a,b,c,d};for(i=j=k=0;l=s[i++];){t[j][k++]=l-95?l:34;if(l<65&&l-32&&l-39){if(s[i]==95&&l-44)t[j][k++]=34,++i;k=t[j++][k]=0;(j%=4)||P(a)P(a)P(b)P(b)P(c)P(c)P(d)P(d)P("")P(a)P(b)P(c)P(d)P("")0;}}}

```

Try it online!

```
#define P(s)puts(s)+
char*s="The other day,I met a bear,A great big bear,Oh way out there.He looked at me,I looked at him,He sized up me,I sized up him.He said to me,_Why don't you run?I see you ain't,Got any gun._I says to him,_That's a good idea.__Now legs get going,get me out of here!_And so I ran,Away from there,But right behind me,Was that bear.In front of me,There was a tree,A great big tree,Oh glory be!The lowest branch,Was ten feet up,So I thought I'd jump,And trust my luck.And so I jumped,Into the air,But I missed that branch,A way up there.Now don't you fret,And don't you frown,I Caught that branch,On the way back down!This is the end,There aint no more,Unless I see,That bear once more.";
char a[99],b[99],c[99],d[99];
i,j,k,l;f()
{
    char*t[4]={a,b,c,d};
    for(i=j=k=0;l=s[i++];)
    {
        t[j][k++]=l-95?l:34;
        if(l<65&&l-32&&l-39)
        {
            if(s[i]==95&&l-44)t[j][k++]=34,++i;
            k=t[j++][k]=0;
            (j%=4)||P(a)P(a)P(b)P(b)P(c)P(c)P(d)P(d)P("")P(a)P(b)P(c)P(d)P("")0;
        }
    }
}

```

# Answer
> 2 votes
## Batch, ~~984~~ 923 bytes

```
@echo off
set s="The other day,_I met a bear,_A great big bear,_Oh way out there._He looked at me,_I looked at him,_He sized up me,_I sized up him._He said to me,_""Why don't you run?_I see you ain't,_Got any gun.""_I says to him,_""That's a good idea.""_""Now legs get going,_get me out of here!""_And so I ran,_Away from there,_But right behind me,_Was that bear._In front of me,_There was a tree,_A great big tree,_Oh glory be!_The lowest branch_Was ten feet up,_So I thought I'd jump,_And trust my luck._And so I jumped,_Into the air,_But I missed that branch_A way up there._Now don't you fret,_And don't you frown,_I Caught that branch_On the way back down!_This is the end,_There aint no more,_Unless I see,_That bear once more."
call:c %s:_=" "%
exit/b
:c
for %%l in (%1 %1 %2 %2 %3 %3 %4 %4 "" %1 %2 %3 %4 "")do call:l %%l
shift
shift
shift
shift
if "%~1"=="" exit/b
goto c
:l
set s=(%~1
echo%s:""="%

```

The quotes really messed me up, but that gave me an idea that saved 61 bytes.

# Answer
> 2 votes
# Python3.6, ~~707~~ 648bytes

First attempt at code-golf, adopting @uriel's answer to include compression of the string

```
import zlib,base64
n='\n'
for x in zlib.decompress(base64.a85decode("Gaqc3]9:o&%.*X%3&PS1qM!!^OgrLJETV#iKLs/rEPohAPcrDb;W:q/!XiBX3dW2&SeG85%c)sW/nF1_-4Sdn>[gXq'&6f=p%0pg8M-`*4AOe$As#/Z!cVRRnU15<$lom>r'mBomsom`o\\5+:Ju'Znh7rcNXMdK\"<@Xg`5NrGpH^]K)d!ZY5N%;FWa*pA0XB?@HKDjJmEla@$6nAMbB'd//]0'b=QcVOfP7ZQsl0#oXO5*8@^%Bc.>09/Z8g_CX'mrZ[Cl4#91VbG!%q!ro@$UDS_0rLn_5D9673.5%X1$>8$L<pU8^&9ih(%pFc&u,/GaU5c+!7#(!0+&::G<P?8D!U0qk5!fQ`=:c#>;hsK!NfXWFBmNBs-(bpf+$p[`BT./EhYWBiB]G6dCL!;mG4B[^_ILT!it?biY5$D\"mq4aWkQA?VKMQ@GP^87s4\"6>jiMV7+E22L\"oiOm9d=6FeOV`6Ib\#ETWdjr<\A6XX8m+DNOB!%e&\J)")).decode().split('@'):print(*(y+n+y for y in x.split(n)),'',x,'',sep=n)

```

# edit

* Changed from base64 to base85
* removed some unnecessary escapes in the compressed string
* removed the `ansi` argument from the `decode()`
* changed from `$` between verses to `\n` (from @alexis' answer)

So this has become a hybrid of my orignal submission, @uriel's and @alexis's

# Compression

make one big `bytes`, seperating lines in a verse by `$` and verses by `@`

```
begin_s = """The other day,','I met a bear,','A great big bear,','Oh way out there.'],['He looked at me,','I looked at him,','He sized up me,','I sized up him.'],['He said to me,','"Why don\'t you run?',"I see you ain't,",'Got any gun."'],['I says to him,','"That\'s a good idea."','"Now legs get going,','get me out of here!"'],['And so I ran,','Away from there,','But right behind me,','Was that bear.'],['In front of me,','There was a tree,','A great big tree,','Oh glory be!'],['The lowest branch,','Was ten feet up,',"So I thought I'd jump,",'And trust my luck.'],['And so I jumped,','Into the air,','But I missed that branch,','A way up there.'],["Now don't you fret,","And don't you frown,",'I Caught that branch,','On the way back down!'],['This is the end,','There aint no more,','Unless I see,','That bear once more."""
new_line = '\n'
new_s = begin_s.replace("','",new_line).replace('","',new_line).replace("',\"",new_line).replace("\",'",new_line).replace("'],['",'@').replace("\"],['",'@').replace("'],[\"",'@')

```

then compress this with zlib

```
comp_s = base64.a85encode(zlib.compress(new_s.encode())).decode()

```

I tried other algorithms, but this seemed smallest

Afterwards checked which characters needed escaping. There were 4`"` and 6 `'` in the string so I used a `"`string.

## base64 vs base85

Base64 gives these lengths

```
original 715
lzma     500 677
zlib     400 544
bz2      436 592

```

Base85

```
original 715
lzma     500 625
zlib     400 500
bz2      436 545

```

lists the `len` of the resulting `bytes` after compression and then after conversion to `base64`

# Answer
> 1 votes
# C#, ~~560~~ 532 bytes

```
using System;using B=System.IO.MemoryStream;using System.IO.Compression;using System.Text;class p{static void Main(){B i=new B(Convert.FromBase64String("lZXBktowDIbvzPAOgguXTF6hs+2hzaV7aDp7NkTELom9YzuTSZ++khlKIDaYG/pi6xfKL6WWCMZLtNCIqViv6ru4gh49CNijsMvwDVqLwsNetQ/Qu4RRTGAGD5wZyyh6qp2Xeb36gdAZc8IG6HCPRYxUMyBVHyV0y6m/RIbP/2luQXWN6UoZAXnazxOfzwjVgDfXYubx9kNO0Bi98zCZAeygvyQgJUcMsVD0pIiR74YarydoB11uF2Gm+tO04YiYHKe5vIXbeFtL4XeOTNAa04BqUPDFFP5pRuiwddCScVqjdFukKP/uMVjHHIHNs9mmaH5dL0iRoXUDzkAFVuhiGbKzj9b0Z2tHyVdKaVUraShQKrrfp+mHoPolzw/NTrmMMwrIS0zd0nxPh7979vM9qDkjzS530FtMoPnEpxEtgbYzdiL9zX2UJ/006Xk3dWZER6eoPQdZxFloBpIm0ksfPqPkF/fYSzNwJ6tdA3+G/hHn9+LtQDL9BN1wOJVxllvRKzozV/ApbIoYqTRNBrmEBt0uQ7YN7XLlHK20s1MuxT149BZWO23Ay2ZfgIxKXsm/XvH0XpfY0SLvrChk4Tk0o07SCr6J0Opb/QR+16F8rm0vDifKN+pNEr9U3muK7CblQLnwFHVTxAlPE+13D5q+BcZiCv7WHToH4aOwDOvLAgGjDxjulCmaXUeGxj8="));B o=new B();DeflateStream d=new DeflateStream(i,CompressionMode.Decompress);d.CopyTo(o);Console.WriteLine(Encoding.ASCII.GetString(o.ToArray()));}}

```

My second time code golfing! The code converts base64 to byte array then decompress the result in binary. The code of the compression is not displayed. This could be golfed more though! Feel free to suggest.

# Answer
> 0 votes
# Bash, 863 Bytes

```
echo "/Td6WFoAAATm1rRGAgAhARwAAAAQz1jM4Ah2AjFdACoaCKIDFOe+dP7cKbcEyTzAAg/QvMEQtP11rhlXqhWE7NPlaNhmeElNuKpOqq6JMNkqj/pQaRrgjApagvENO+FmVZT3Wj6eCMH0j29MwN052EeRFsBXigZDjw7DuGAAef52a68lQCl1tH9dnkYyu8k93NXn5exbhDpGUPbcH4kY5+aVF/SCLBHspumKrlX/uqfuYLKPPX+YE7UTFSJ9zPi4Vd2qjgQAbBIIPLx+m2f6ubLOMyS+Bx8OskndeGJ+NL5Hs7/ZK+5yQY9xYTFDPVtEosrkl6WmXgE+UYWkggu+hDaYM+4ci8czabYN5t8lGZVasz1iH4lBS4OzKzj0k/bspdOUXCgDdjBQzazQ82H4fSOX43X6Lp4KnpMV2NoSs334m0s/tuHadQtfRtrHhbjWT2+VPptrA3VMfnBhOYVe6PSmQOhr7s8Oaogin9CtoQmCnmqfhC0Ee8Wn8wnKqy53Vm5vXnl2nkdlciwS+6doHAJAxFWDIo9n+4CxwR6zEd3hy1fdjii5htgnIE4UTCTzBsu/29ftkam+/LBQgL5/VMD/l7rveujYLqwkJEb/OBkd02+Bh7jDA+9DSNEBzCFDTswMAjPb/E18Y8+YhkgWTV953E3n6AgygJhf73EQOJLq8fIjC3Ugn686kpPX2mUlAMVjqOIwlDV7vxXGKCveA2vUXn4t7FGIN/JGYQXKkQgeLnKsi7A9wX+wqMWVmVil61Y0iG717WRjApb+0MtpBgAAAABf85wHBdXu8QABzQT3EAAAGfI0nLHEZ/sCAAAAAARZWg=="|base64 -d|xz -d

```

# Answer
> 0 votes
# Python 3.4, ~~779~~ ~~651~~ 649 bytes

```
import zlib,base64
n='\n'
for x in zlib.decompress(base64.a85decode("Gaqc3]9:o&%.*X%3&PS1qM!!^OgrLJETV#iKLs/rEPohAPcrDb;W:q/!XiBX3dW2&SeG85%c)sW/nF1_-4Sdn>[gXq'&6f=p%0pg8M-`*4AOe$As#/Z!cVRRnU15<$lom>r'mBomsom`o\\5+:Ju'Znh7rcNXMdK\"<@Xg`5NrGpH^]K)d!ZY5N%;FWa*pA0XB?@HKDjJmEla@$6nAMbB'd//]0'b=QcVOfP7ZQsl0#oXO5*8@^%Bc.>09/Z8g_CX'mrZ[Cl4#91VbG!%q!ro@$UDS_0rLn_5D9673.5%X1$>8$L<pU8^&9ih(%pFc&u,/GaU5c+!7#(!0+&::G<P?8D!U0qk5!fQ`=:c#>;hsK!NfXWFBmNBs-(bpf+$p[`BT./EhYWBiB]G6dCL!;mG4B[^_ILT!it?biY5$D\"mq4aWkQA?VKMQ@GP^87s4\"6>jiMV7+E22L\"oiOm9d=6FeOV`6Ib\\#ETWdjr<\\A6XX8m+DNOB!%e&\\J")).decode().split("@"):print(n.join(y+n+y for y in x.split(n))+n+n+x+n)

```

Try it online

**Approach**

Here's the version without compression: 796 bytes, already a lot shorter than the original Python answer, by @Uriel. That's mainly due to using a single string for the song: An extra `split()` is much more economical than all the brackets of a long list. As a bonus, the non-repeating stanzas are ready to print without reassembly: just print `x`.

```
n='\n'
for x in'''The other day,
I met a bear,
A great big bear,
Oh way out there.@He looked at me,
I looked at him,
He sized up me,
I sized up him.@He said to me,
"Why don't you run?
I see you ain't,
Got any gun."@I says to him,
"That's a good idea."
"Now legs get going,
get me out of here!"@And so I ran,
Away from there,
But right behind me,
Was that bear.@In front of me,
There was a tree,
A great big tree,
Oh glory be!@The lowest branch,
Was ten feet up,
So I thought I'd jump,
And trust my luck.@And so I jumped,
Into the air,
But I missed that branch,
A way up there.@Now don't you fret,
And don't you frown,
I Caught that branch,
On the way back down!@This is the end,
There aint no more,
Unless I see,
That bear once more.'''.split("@"):print(n.join(y+n+y for y in x.split(n))+n+n+x+n)

```

I ran the above string literal through `base64.a85encode(zlib.compress(...))` to get the encoded string of the final solution.

### Previous version

This version cut the size down to 779 bytes by abbreviating some letter sequences common enough to make up for a huge `replace(...)` to unabbreviate them. No more-- that's what compression software is for.

```
n='\n'
for x in'''The other day,I me~a bear,A grea~big bear,Oh way out%ere.@He looked a~me,I looked a~him,He sized up me,I sized up him.@He said to me,"Why don'~you run?
I see you ain't,Go~any gun."@I says to him,"That's a good idea."
"Now legs ge~going,ge~me ou~of here!"@And so I ran,Away from%ere,Bu~righ~behind me,Was%a~bear.@In fron~of me,There was a tree,A grea~big tree,Oh glory be!@The lowes~branch,Was ten fee~up,So I%ough~I'd jump,And trus~my luck.@And so I jumped,Into%e air,Bu~I missed%a~branch,A way up%ere.@Now don'~you fret,And don'~you frown,I Caught%a~branch,On%e way back down!@This is%e end,There ain~no more,Unless I see,Tha~bear once more.'''.replace("~","t ").replace("%"," th").replace(",",",\n").split("@"):print(n.join(y+n+y for y in x.split(n))+n+n+x+n)

```

# Answer
> 0 votes
## C, ~~889~~ 874 bytes

```
char*s="The other day,\0I met a bear,\0A great big bear,\0Oh way out there.\0He looked at me,\0I looked at him,\0He sized up me,\0I sized up him.\0He said to me,\0\"Why don't you run?\0I see you ain't,\0Got any gun.\"\0I says to him,\0\"That's a good idea.\"\0\"Now legs get going,\0get me out of here!\"\0And so I ran,\0Away from there,\0But right behind me,\0Was that bear.\0In front of me,\0There was a tree,\0A great big tree,\0Oh glory be!\0The lowest branch,\0Was ten feet up,\0So I thought I'd jump,\0And trust my luck.\0And so I jumped,\0Into the air,\0But I missed that branch,\0A way up there.\0Now don't you fret,\0And don't you frown,\0I Caught that branch,\0On the way back down!\0This is the end,\0There aint no more,\0Unless I see,\0That bear once more.\0",*p,*w;i;f(){for(w=p=s;*p;++i%4||puts(""),p=(i+4)%8?p+=strlen(p)+1:w,w=i%8?w:p)i%8>3||puts(p),puts(p);}

```

Compile with enabled signed integers wrap-around(-fwrapv).

This is needed because function answers must produce repeated output on subsequent calls, and the function could conceivably be called repeatedly until global variable i overflows. Since the code only cares about the whether the remainder of division i by 4 and 8 is 0, it doesn't matter what the actual value of i is as long as it is left divisible by 8 after the function returns (and of course it is left divisible by 8).

See it work here.

# Answer
> 0 votes
# Groovy, ~~769~~ 745 bytes

```
a="The other day,xI met a bear,xA great big bear,xOh way out there.xHe looked at me,xI looked at him,xHe sized up me,xI sized up him.xHe said to me,x\"Why don't you run?xI see you ain't,xGot any gun.\"xI says to him,x\"That's a good idea.\"x\"Now legs get going,xget me out of here!\"xAnd so I ran,xAway from there,xBut right behind me,xWas that bear.xIn front of me,xThere was a tree,xA great big tree,xOh glory be!xThe lowest branch,xWas ten feet up,xSo I thought I'd jump,xAnd trust my luck.xNow don't you fret,xAnd don't you frown,xI Caught that branch,xOn the way back down!xThis is the end,xThere aint no more,xUnless I see,xThat bear once more.".split("x")
x=0
f={g->x.upto(x+3){print((a[it]+"\n")*g)};println""}
1.upto(9){f(2);f(1);x+=4}

```

Doesn't use any compression. Still working hard on this.

**Explaination**

```
a="super long string...".split("x") //a string containing all different verses that gets splitted at each character "x", creating an array with one verse at each position
x=0 //used to index the verse array. Starts at 0
f={g->x.upto(x+3){print((a[it]+"\n")*g)};println""} //a shortcut function that prints four consecutives verses starting from verse at position x in the array.  The argument g says how many times each verse will be printed. Then adds a new line (stanza finished)
1.upto(9){ //a loop that repeats 8 times
f(2) //print a group of four verses two times each one
f(1) //print a group of four verses one time each one
x+=4 //go to the next group of four
}

```

---
Tags: code-golf, string, kolmogorov-complexity
---


title: Whose rep is tied?

text:
# Question
Title: Whose rep is tied?
Your challenge is to query the SE API and find out whose rep on PPCG is tied, and output it. If these were all the users on PPCG:

```
Martin Ender: 10000 rep
Dennis: 10000 rep
xnor: 5000 rep
sp3000: 3000 rep

```

You should output `Martin Ender, Dennis`. If these were the only users:

```
Jon Skeet: 1000000 rep
Martin Ender: 10000 rep
Dennis: 10000 rep
xnor: 5000 rep
sp3000: 3000 rep
Digital Trauma: 2000 rep
Luis Mendo: 2000 rep
Helka Homba: 2000 rep

```

You should output:

```
Martin Ender, Dennis
Digital Trauma, Luis Mendo, Helka Homba

```

Note that **you can use different output formats**, as long as it is clear whose rep is tied and who they are tied with. **Users with \<200 rep can be ignored.**

# Answer
> 2 votes
# JavaScript (ES6), ~~259~~ ~~257~~ ~~248~~ 241 bytes

Returns a `Promise` object containing `\n` separated groups, in ascending order of reputation, of profile links for users with the same rep, with each link separated by a comma. As the question only states that users with 200 reputation or less *can* be ignored (rather than *should* be ignored), this solution includes a couple of users who do have \<200 rep.

```
f=(x=95,s="",c=0)=>fetch(`//api.stackexchange.com/users?page=${x}&site=codegolf`).then(a=>a.json()).then(j=>(i=j.items.reverse()).map(x=>(r=x.reputation)>c?(c=r,t.length-1&&(s+=t+`
`),t=[x.link]):t.push(x.link),t=[i[0].link])&--p?f(p,s,c):s)

```

---

## Caveat

Between this challenge, "Martin vs. Dennis" and a couple of others, I've managed to get myself (temporarily) booted from the API for a few hours! I was, therefore, unable to run my final tests on this but it *should* be working (although, I suspect it might not include users from page 1 in the output). There's probably a bit more I can golf off it, so I'll come back to it when my ban is lifted.

---

## Try it

**WARNING:** The first Snippet below will submit *95*(!) requests to the SE API - running it a couple of times may result in you also having your access to the API temporarily revoked. If you'd prefer to test this with a reduced number of API calls and, therefore, a reduced result set, change the value of the first parameter to something *much* lower than 95. Alternatively, you can test it with no API calls, using the second batch of sample data from the question by using the second Snippet below, which returns usernames instead of profile links (for now).

---

```
f=(x=95,s="",c=0)=>fetch(`//api.stackexchange.com/users?page=${x}&site=codegolf`).then(a=>a.json()).then(j=>(i=j.items.reverse()).map(x=>(r=x.reputation)>c?(c=r,t.length-1&&(s+=t+`
`),t=[x.link]):t.push(x.link),t=[i[0].link])&--p?f(p,s,c):s)
f().then(console.log)
```

---

```
f=(x=95,s="",c=0)=>Promise.resolve(JSON.parse(`{"items":[{"display_name":"John Skeet","reputation":1000000},{"display_name":"Martin Ender","reputation":10000},{"display_name":"Dennis","reputation":10000},{"display_name":"xnor","reputation":5000},{"display_name":"sp3000","reputation":3000},{"display_name":"Digital Trauma","reputation":2000},{"display_name":"Luis Mendo","reputation":2000},{"display_name":"Helka Homba","reputation":2000}]}`)).then(j=>(i=j.items.reverse()).map(y=>(r=y.reputation)>c?(c=r,t.length-1&&(s+=t+`
`),t=[y.display_name]):t.push(y.display_name),t=[i[0].display_name])&--x?f(x,s,c):s)
f().then(console.log)
```

---
Tags: code-golf, internet, stack-exchange-api
---