(The other day) I met a bear

16

4

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.

programmer5000

Posted 2017-05-09T14:08:54.080

Reputation: 7 828

Question was closed 2017-05-19T17:19:16.743

Is there any reason you don't think this is a duplicate of the rickroll challenge? – FryAmTheEggman – 2017-05-09T14:12:34.407

6@Riker this challenge has a different repetition pattern and answers should be very diffrent. – programmer5000 – 2017-05-09T14:16:34.880

9@programmer5000 aside from the simple repeat each line twice, then repeat the paragraph, it doesn't really have any other patterns. I think that's a pretty trivial difference, personally. – Rɪᴋᴇʀ – 2017-05-09T14:30:54.400

11There is no logical connection between "this challenge has a different repetition pattern" and "answers should be very different". If you take the time to understand the answers to the rickroll challenge you'll discover that they nearly all use an approach which is near-optimal for any repetition pattern more complicated than "no repetition". – Peter Taylor – 2017-05-09T15:40:01.037

1Just looking at the pattern here, it's more structured than the rickroll, meaning that you can apply an extra problem-specific level of compression here that you can't there. However, the problem is that that's only a small part of the challenge, and the bulk of the challenge is identical to that of the rickroll. Or in other words, this is a rickroll + 1 extra step. It might have been a better challenge as the extra step on its own. (I don't have much of a strong opinion as to whether this is a dupe.) – None – 2017-05-09T23:10:16.580

May we output ain't in the final two stanzas (it is written correctly earlier in the song)? – Jonathan Allan – 2017-05-10T15:28:17.777

1@JonathanAllan yes. – programmer5000 – 2017-05-10T15:28:58.100

Can there be prepending whitespace? – dzaima – 2017-05-10T15:34:00.133

1@dzaima yes, there can. – programmer5000 – 2017-05-10T15:35:16.120

1I call dibs on the ~503 byte bubblegum answer once I get the compression to give me the right text. – Christopher – 2017-05-10T15:50:56.410

3Personally I believe marking questions like these as duplicates is disappointing. It's very uncommon for someone to find the original challenge asked almost 5 years ago ago post their answer there. A spin off such as this should be perfectly acceptable as it reanimates this type of challenge in new light. – Graviton – 2017-05-10T19:22:38.310

@YamB agreed. And it looks like it is finally open! Thanks if that last vote was yours! – programmer5000 – 2017-05-10T19:52:26.457

1If two different gold code-golf members have dupe closed this don't you think that is a sign? – Christopher – 2017-05-11T10:28:20.490

3Just as a note, this question has now been to reopen review three times, and received a total of 7 "leave closed" votes and 3 "reopen" votes. (This is in addition to all the close and reopen votes that have been made on the question directly.) At this point, it may be worth discussing this on Meta rather than trying to use the review system. – None – 2017-05-11T11:49:37.287

Answers

21

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 "~":

compression format

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)

Arnauld

Posted 2017-05-09T14:08:54.080

Reputation: 111 334

I love the compression method! – Neil – 2017-05-10T08:30:44.963

I have no idea how you come up with this stuff! +1 – Shaggy – 2017-05-10T08:46:36.170

1

@Shaggy I should have added some explanation in my initial post, but it was late. This compression method is quite popular in the demo-scene and in middle-size JS golfing competitions such as JS1K. Answer now updated. :-)

– Arnauld – 2017-05-10T12:40:31.417

@Neil It's pretty cool indeed, but just to clarify: I didn't invent it -- although I did write a few variations along the same lines. (See my edited answer.) – Arnauld – 2017-05-10T13:09:30.307

Thanks for the excellent explanation, @Arnauld, definitely quicker than trying to decipher it myself! – Shaggy – 2017-05-10T16:26:27.997

10

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.

Emigna

Posted 2017-05-09T14:08:54.080

Reputation: 50 798

1I've never been so happy to see a challenge already completed in 05AB1E, glad I didn't have to do this one hahaahahahahaa. Amazing that you took the time to +1. – Magic Octopus Urn – 2017-05-16T21:07:29.120

9

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')

Uriel

Posted 2017-05-09T14:08:54.080

Reputation: 11 708

You can save a couple of bytes by looping over the list directly instead of assigning it to m. You should also remove the last newline to both save bytes and match the correct output. – Emigna – 2017-05-09T15:28:56.893

@Emigna thanks! also, trailing whtespace is allowed – Uriel – 2017-05-09T15:44:21.223

Yes, but only at the end of the output. You had an extra newline after each section of text (8+4 rows). Fixed now :) – Emigna – 2017-05-09T15:52:32.227

Which Python version are you using? I'm getting a Syntax Error at the *x (Python 3.4.4) – alexis – 2017-05-10T11:16:03.057

@alexis this needs 3.5+, see this: https://www.python.org/dev/peps/pep-0448/

– Uriel – 2017-05-10T11:18:48.847

Thanks! Yeah it cost me a few bytes without this feature, but I managed pretty well by not using a list, check it out :-)

– alexis – 2017-05-10T14:03:02.767

8

brainfuck, 23913 bytes

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

Try it online!

Did I win?

Graviton

Posted 2017-05-09T14:08:54.080

Reputation: 2 295

2A formatted version of the code would be nice. ;) – raznagul – 2017-05-10T11:46:52.337

1Define formatted @raznagul – Graviton – 2017-05-10T19:18:07.073

7

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

dzaima

Posted 2017-05-09T14:08:54.080

Reputation: 19 048

Oh, I'm pretty sure that lowercase g on the 16th unique line is a typo. – Jonathan Allan – 2017-05-10T16:07:41.013

@JonathanAllan Well it is lowercase on the top google search result, but I agree that it's weird that it's lowercase.

– dzaima – 2017-05-10T16:11:03.497

Looks like the source of the aint vs ain't typo too. – Jonathan Allan – 2017-05-10T16:12:56.047

5

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);

Jörg Hülsermann

Posted 2017-05-09T14:08:54.080

Reputation: 13 026

using of base64 is so clever – hucancode – 2017-05-10T03:08:00.620

3

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;
        }
    }
}

Steadybox

Posted 2017-05-09T14:08:54.080

Reputation: 15 798

Suggest #define P(s)+puts(s) instead of #define P(s)puts(s)+ and ,a[99],b[99],c[99],d[99],*t[]={a,b,c,d};i,j,k;f(l){for(i=j=k=0;l=s[i++];l<65&&l-32&&l-39?s[i]==95&&l-44?t[j][k++]=34,++i:0,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)t[j][k++]=l-95?l:34;} instead of ;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;}}} – ceilingcat – 2018-12-12T03:40:14.433

3

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.

Neil

Posted 2017-05-09T14:08:54.080

Reputation: 95 035

3

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

Maarten Fabré

Posted 2017-05-09T14:08:54.080

Reputation: 131

The len is probably finding things like \n in the string and counting only one byte where there are two. Notepad++ will count an extra \r by default I believe. The actual count is 707 (here is a UTF-8 byte counter).

– Jonathan Allan – 2017-05-10T15:55:01.400

Hello, and welcome! Great first post! – programmer5000 – 2017-05-10T15:55:09.867

Take a look at my answer; it's much shorter than Uriel's because it starts with a single string, not a list. If you apply compression to that, you should be able to do even better.

– alexis – 2017-05-10T18:41:25.743

This is a string. The part about compression etc is to show how I arrived at the compressed string and the choice of algorithm – Maarten Fabré – 2017-05-11T07:17:38.323

2

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)

programmer5000

Posted 2017-05-09T14:08:54.080

Reputation: 7 828

2

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.

Adola

Posted 2017-05-09T14:08:54.080

Reputation: 131

In my meaning it is not the whole Output – Jörg Hülsermann – 2017-05-10T20:44:43.120

@JörgHülsermann What's not the whole output? – Adola – 2017-05-11T06:56:46.723

You have only copy the visible text in the task window. If you scroll it you will see the rest. – Jörg Hülsermann – 2017-05-11T09:51:21.560

@JörgHülsermann Ohh, let me fix it! Thanks for reminding – Adola – 2017-05-11T10:26:53.900

1

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

Evan Chen

Posted 2017-05-09T14:08:54.080

Reputation: 131

1

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)

alexis

Posted 2017-05-09T14:08:54.080

Reputation: 432

you could shave some off with import base64 as b – Maarten Fabré – 2017-05-11T07:28:32.060

I'd already tried that! :-) It shaves off exactly as many characters as it costs. Same for from base64 import a85decompress as a, etc. – alexis – 2017-05-11T08:54:54.963

I could shave off one character by using @Uriel's * approach, which requires Python 3.5.5. I decided to stick with Python 3.4. – alexis – 2017-05-11T08:58:11.747

1

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.

2501

Posted 2017-05-09T14:08:54.080

Reputation: 748

Suggest omitting the final \0 in the string. – ceilingcat – 2018-12-04T18:29:47.033

1

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
}

staticmethod

Posted 2017-05-09T14:08:54.080

Reputation: 191