问:
Unzip some numbers
Your task is to create a program or function that generates a zipper with a length of 10 lines. Each line of the zipper is represented by two dashes --:

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

The program/function will take a percentage (divisible by 10) as input, and the output will be the zipper "unzipped" (dashes separated) from the top by the percentage, revealing the 1-indexed, lowest level repeated 2 times, with all prior levels repeated 4, 6, 8, ...etc. times, while keeping the bottom of the zipper centered.

Examples

```<code>>>10%
-11-
 --
 --
 --
 --
 --
 --
 --
 --
 --

>>50%
-1111111111-
 -22222222-
  -333333-
   -4444-
    -55-
     --
     --
     --
     --
     --

>>100%
-11111111111111111111-
 -222222222222222222-
  -3333333333333333-
   -44444444444444-
    -555555555555-
     -6666666666-
      -77777777-
       -888888-
        -9999-
         -10-
</code>```

The input (percentage) can be formatted however you like (50%, .5, 50, 5 [zero implied], etc), and it will always be in the range of 0 to 100 and divisible by 10. The spacing in the examples must be preserved in your output.

答:
APL, 46 bytes

```<code>{↑(⍳10){(''↑⍨1-⍺⌊a+1),1⌽'--',⍵⍴⍕⍺}¨10↑2×⌽⍳a←⍵}
</code>```

The argument should be given as the percentage divided by 10 (that is: a simple integer, in the range [0,10]).

Title: Unzip some numbers

Body:
APL, 46 bytes

{↑(⍳10){(''↑⍨1-⍺⌊a+1),1⌽'--',⍵⍴⍕⍺}¨10↑2×⌽⍳a←⍵}

The argument should be given as the percentage divided by 10 (that is: a simple integer, in the range [0,10]).


问:
Inverting lists of lists of indices
Inspired by this StackOverflow post.

Introduction

Bob's job is to create spreadsheets and organize them.  The way he organizes them is known to very few except for Bob, but he creates a list of each of the spreadsheets that fall under the same group.  There's a bunch of data in the spreadsheet he creates, but there's only one piece of data that we're looking at right now: The number of days between the day he started this job and the day he made the spreadsheet.  The first day he created two spreadsheets, noted them both as 0 and sorted them in to their proper locations.

Now, his boss is asking for a review of what kinds of spreadsheet happened each day, and it's your job to write some code that will figure that out for Bob; he has far too many spreadsheets to do it by hand.

Input

Bob's info that he gives you comes in the form of a (0-or-1 indexed) jagged array where each datum is of the form x = a[i][j].  a is what I'm calling the jagged array itself, i is the type of spreadsheet, and x is the date the array was created.  j is unimportant.

The task

Given a jagged array of spreadsheet creation days organized by their type, return a jagged array of spreadsheet types organized by spreadsheet creation day.

Examples

Bob isn't going to just leave you with this abstract data. He's given me a subset of some of his spreadsheets to help you out with figuring out what everything is supposed to be.

Example input (0-indexed):

```<code>a = [
[3,2,5,0], # Bob doesn't necessarily sort his lists
[1,3],
[2,1,0,4],
[4,5,3],
[6,6]
]
</code>```

Example output (with commentary, which of course is not required):

```<code>output = [
[0,2] # On day 0, Bob made one type 0 and one type 2 spreadsheet
[1,2] # On day 1, Bob made one type 1 and one type 2 spreadsheet
[0,2] # On day 2, Bob made one type 0 and one type 2 spreadsheet
[0,1,3] # On day 3, Bob made one type 0, one type 1, and one type 3 spreadsheet
[2,3] # On day 4, Bob made one type 2 and one type 3 spreadsheet
[0,3] # On day 5, Bob made one type 0 and one type 3 spreadsheet
[4,4] # On day 6, Bob made two type 4 spreadsheets
]
</code>```

Note that Bob doesn't always make two spreadsheets every day, and so the output may be jagged as well. But he always makes at least one spreadsheet every day, so the output will never need to contain empty arrays - although if your output has empty arrays at the end, you don't need to remove them.

More test cases:

```<code>[[3,5,6,2],[0,0,0],[1,0,3,4]] -> [[1,1,1,2],[2],[0],[0,2],[2],[0],[0]]
[[-1]] -> Undefined behavior, as all input numbers will be non-negative integers.
[[0],[0],[],[0]] -> [[0,1,3]]
</code>```

The output's inner lists do not need to be sorted.

As always, no standard loopholes, and of course shortest code wins.

(As this is my first question, please let me know of anything I can do to improve it.)

ContentLicense: CC BY-SA 3.0

Title: Inverting lists of lists of indices

Body:
Perl 5, 48 bytes

A subroutine:

{for$i(0..@_){map{push@{$b[$_]},$i}@{$_[$i]}}@b}

See it in action like this:

perl -e'print "@$_$/" for sub{for$i(0..@_){map{push@{$b[$_]},$i}@{$_[$i]}}@b}->([3,2,5,0],[1,3],[2,1,0,4],[4,5,3],[6,6])'


问:
Generate Pascal's Braid
This is Pascal's Braid:

```<code> 1 4  15  56   209   780    2911    10864     40545      151316      564719
1 3 11  41  153   571   2131    7953     29681     110771      413403      1542841
 1 4  15  56   209   780    2911    10864     40545      151316      564719
</code>```

I totally made that up. Blaise Pascal didn't have a braid as far as I can tell, and if he did it was probably made of hair instead of numbers.

It's defined like this:

The first column has a single 1 in the middle.

The second column has a 1 at the top and at the bottom.

Now we alternate between putting a number in the middle or two copies of a number at the top and bottom.

If the number goes on the top or the bottom, it will be the sum of the two adjacent numbers (e.g. 56 = 15 + 41). If you tilt your head a little, this is like a step in Pascal's triangle.

If the number goes in the middle, it will be the sum of all three adjacent numbers (e.g. 41 = 15 + 11 + 15).

Your task will be to print (some part of) this braid.

Input

You should write a program or function, which receives a single integer n, giving the index of the last column to be output.

You may choose whether the first column (printing only a single 1 on the middle line) corresponds to n = 0 or n = 1. This has to be a consistent choice across all possible inputs.

Output

Output Pascal's Braid up to the nth column. The whitespace has to match exactly the example layout above, except that you may pad the shorter line(s) to the length of the longer line(s) with spaces and you may optionally output a single trailing linefeed.

In other words, every column should be exactly as wide as the number (or pair of equal numbers) in that column, numbers in successive columns should not overlap and there should be no spaces between columns.

You may either print the result to STDOUT (or the closest alternative), or if you write a function you may return either a string with the same contents or a list of three strings (one for each line).

Further Details

You may assume that n won't be less than the index of the first column (so not less than 0 or 1 depending on your indexing). You may also assume that the last number in the braid is less than 256 or the largest number representable by your language's native integer type, whichever is greater. So if your native integer type can only store bytes, you can assume that the largest n is 9 or 10 (depending on whether you use 0- or 1-based n) and if it can store signed 32-bit integers, n will be at most 33 or 34.

Standard code-golf rules apply. The shortest code wins.

OEIS

Here are a few relevant OEIS links. Of course, these contain spoilers for different ways to generate the numbers in the braid:

Top/bottom: A001353 or A010905 or A106707 or A195503

Middle: A001835 or A079935

Both: A002530

Test Cases

These test cases use 1-base indexing. Each test case is four lines, with the first being the input and the remaining three being the output.

```<code>1

1

---
2
 1
1
 1
---
3
 1
1 3
 1
---
5
 1 4
1 3 11
 1 4
---
10
 1 4  15  56   209
1 3 11  41  153
 1 4  15  56   209
---
15
 1 4  15  56   209   780    2911
1 3 11  41  153   571   2131    7953
 1 4  15  56   209   780    2911
---
24
 1 4  15  56   209   780    2911    10864     40545      151316      564719       2107560
1 3 11  41  153   571   2131    7953     29681     110771      413403      1542841
 1 4  15  56   209   780    2911    10864     40545      151316      564719       2107560
</code>```

答:
Pyth, 44 bytes

The number generation took 20 bytes, and the formatting took 24 bytes.

```<code>jsMC+Led.e.<bkC,J<s.u+B+hNyeNeNQ,1 1Qm*;l`dJ
</code>```

Try it online!

```<code>jsMC+Led.e.<bkC,J<s.u+B+hNyeNeNQ,1 1Qm*;l`dJ   input as Q
                   .u          Q,1 1           repeat Q times, starting with [1,1],
                                               collecting all intermediate results,
                                               current value as N:
                                               (this will generate
                                                more than enough terms)
                       +hNyeN                  temp <- N[0] + 2*N[-1]
                     +B      eN                temp <- [temp+N[-1], temp]

now, we would have generated [[1, 1], [3, 4], [11, 15], [41, 56], ...]

jsMC+Led.e.<bkC,J<s                 Qm*;l`dJ
                  s                            flatten
                 <                  Q          first Q items
                J                              store in J
                                     m    dJ   for each item in J:
                                         `     convert to string
                                        l      length
                                      *;       repeat " " that many times

jsMC+Led.e.<bkC,
              C,     transpose, yielding:
[[1, ' '], [1, ' '], [3, ' '], [4, ' '], [11, '  '], ...]
(each element with as many spaces as its length.)
        .e            for each sub-array (index as k, sub-array as b):
          .<bk            rotate b as many times as k

[[1, ' '], [' ', 1], [3, ' '], [' ', 4], [11, '  '], ...]

jsMC+Led
    +Led              add to each sub-array on the left, the end of each sub-array
   C                  transpose
 sM                   sum of each sub-array (reduced concatenation)
j                     join by new-lines
</code>```

Title: Generate Pascal's Braid

Body:
Pyth, 44 bytes

The number generation took 20 bytes, and the formatting took 24 bytes.

jsMC+Led.e.<bkC,J<s.u+B+hNyeNeNQ,1 1Qm*;l`dJ

Try it online!

jsMC+Led.e.<bkC,J<s.u+B+hNyeNeNQ,1 1Qm*;l`dJ   input as Q
                   .u          Q,1 1           repeat Q times, starting with [1,1],
                                               collecting all intermediate results,
                                               current value as N:
                                               (this will generate
                                                more than enough terms)
                       +hNyeN                  temp <- N[0] + 2*N[-1]
                     +B      eN                temp <- [temp+N[-1], temp]

now, we would have generated [[1, 1], [3, 4], [11, 15], [41, 56], ...]

jsMC+Led.e.<bkC,J<s                 Qm*;l`dJ
                  s                            flatten
                 <                  Q          first Q items
                J                              store in J
                                     m    dJ   for each item in J:
                                         `     convert to string
                                        l      length
                                      *;       repeat " " that many times

jsMC+Led.e.<bkC,
              C,     transpose, yielding:
[[1, ' '], [1, ' '], [3, ' '], [4, ' '], [11, '  '], ...]
(each element with as many spaces as its length.)
        .e            for each sub-array (index as k, sub-array as b):
          .<bk            rotate b as many times as k

[[1, ' '], [' ', 1], [3, ' '], [' ', 4], [11, '  '], ...]

jsMC+Led
    +Led              add to each sub-array on the left, the end of each sub-array
   C                  transpose
 sM                   sum of each sub-array (reduced concatenation)
j                     join by new-lines


问:
Print all alphanumeric characters plus underscore
Write a program or function that prints or returns a string of the alphanumeric characters plus underscore, in any order. To be precise, the following characters need to be output, and no more:

```<code>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_
</code>```

When printing to stdout, an optional trailing newline after your output is permitted.

Built-in constants that contain 9 or more of the above characters are disallowed.

Shortest code in bytes wins.

This is a very simple challenge, which I believe will generate some interesting answers nevertheless.

Leaderboards

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

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

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

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

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

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

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

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

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

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
PHP, 40 bytes

_0<?for(;$a++^9?$a^q:$a=A;)echo" $a"|$a;
```

Online Demo.

Body:
PHP, 40 bytes

_0<?for(;$a++^9?$a^q:$a=A;)echo" $a"|$a;

Online Demo.


问:
Calculate the Super-Logarithm
This should be a simple challenge.

Given a number \$n \ge 0\$, output the super-logarithm (or the \$\log^*\$, log-star, or iterated logarithm, which are equivalent since \$n\$ is never negative for this challenge.) of \$n\$.

$$\log^*(n) = \begin{cases}
0  & \text{ if } n \le 1 \\
1 + \log^*(\log(n)) & \text{ if } n > 1
\end{cases}$$

This is one of the two inverse functions to tetration. The other is the super-root, which is in a related question.

Examples

```<code>Input       Output
0           0
1           0
2           1
3           2
4           2
...
15          2
16          3
...
3814279     3
3814280     4
</code>```

Rules

You do not need to support decimals, though you may.

You need to support input of at least \$3814280 =  \left\lceil e^{e^e} \right\rceil\$.

You may not hard-code the values like 3814280. (Your program must theoretically support higher numbers.) I want an algorithm to be implemented.

Shortest code wins.

Related OEIS

答:
MATLAB / Octave, 44 bytes

function a=g(n);a=0;if n>1;a=1+g(log(n));end

Tried to do it all as one anonymous function, but I forgot that MATLAB/Octave continues to evaluate expressions even if they are multiplied by a boolean false (zero) value:

f=@(n)(n>1)*(1+f(log(n)))

ContentLicense: CC BY-SA 4.0

Title: Calculate the Super-Logarithm


Title: Generate Pascal's Braid

Body:
This is Pascal's Braid:

```<code> 1 4  15  56   209   780    2911    10864     40545      151316      564719
1 3 11  41  153   571   2131    7953     29681     110771      413403      1542841
 1 4  15  56   209   780    2911    10864     40545      151316      564719
</code>```

I totally made that up. Blaise Pascal didn't have a braid as far as I can tell, and if he did it was probably made of hair instead of numbers.

It's defined like this:

The first column has a single 1 in the middle.

The second column has a 1 at the top and at the bottom.

Now we alternate between putting a number in the middle or two copies of a number at the top and bottom.

If the number goes on the top or the bottom, it will be the sum of the two adjacent numbers (e.g. 56 = 15 + 41). If you tilt your head a little, this is like a step in Pascal's triangle.

If the number goes in the middle, it will be the sum of all three adjacent numbers (e.g. 41 = 15 + 11 + 15).

Your task will be to print (some part of) this braid.

Input

You should write a program or function, which receives a single integer n, giving the index of the last column to be output.

You may choose whether the first column (printing only a single 1 on the middle line) corresponds to n = 0 or n = 1. This has to be a consistent choice across all possible inputs.

Output

Output Pascal's Braid up to the nth column. The whitespace has to match exactly the example layout above, except that you may pad the shorter line(s) to the length of the longer line(s) with spaces and you may optionally output a single trailing linefeed.

In other words, every column should be exactly as wide as the number (or pair of equal numbers) in that column, numbers in successive columns should not overlap and there should be no spaces between columns.

You may either print the result to STDOUT (or the closest alternative), or if you write a function you may return either a string with the same contents or a list of three strings (one for each line).

Further Details

You may assume that n won't be less than the index of the first column (so not less than 0 or 1 depending on your indexing). You may also assume that the last number in the braid is less than 256 or the largest number representable by your language's native integer type, whichever is greater. So if your native integer type can only store bytes, you can assume that the largest n is 9 or 10 (depending on whether you use 0- or 1-based n) and if it can store signed 32-bit integers, n will be at most 33 or 34.

Standard code-golf rules apply. The shortest code wins.

OEIS

Here are a few relevant OEIS links. Of course, these contain spoilers for different ways to generate the numbers in the braid:

Top/bottom: A001353 or A010905 or A106707 or A195503

Middle: A001835 or A079935

Both: A002530

Test Cases

These test cases use 1-base indexing. Each test case is four lines, with the first being the input and the remaining three being the output.

```<code>1

1

---
2
 1
1
 1
---
3
 1
1 3
 1
---
5
 1 4
1 3 11
 1 4
---
10
 1 4  15  56   209
1 3 11  41  153
 1 4  15  56   209
---
15
 1 4  15  56   209   780    2911
1 3 11  41  153   571   2131    7953
 1 4  15  56   209   780    2911
---
24
 1 4  15  56   209   780    2911    10864     40545      151316      564719       2107560
1 3 11  41  153   571   2131    7953     29681     110771      413403      1542841
 1 4  15  56   209   780    2911    10864     40545      151316      564719       2107560
</code>```

Body:
Python 2, 120 bytes

a=1,1,3,4
n=input()
y=0
exec"y+=1;t='';x=0;%sprint t;"%(n*"a+=a[-2]*4-a[-4],;v=`a[x]`;t+=[v,len(v)*' '][x+y&1];x+=1;")*3

Try it on Ideone.


问:
Decompose string into blocks
Your program's input is a string containing whitespaces, parentheses, and other characters. The string is assumed to be parenthesed correctly, i.e. each right parenthesis matches a unique left parenthesis and vice versa : so the program is allowed to do anything on incorrectly parenthesed strings, such as )abc, (abc or )abc(.
The character interval between a left parenthesis and the corresponding right parenthesis (including the parentheses) is called a parenthesed interval.
Your program's job is to decompose the string into blocks according to the rules below, and output the result as a "vertical list", with one block per line.

Now, two characters in the string are in the same block if either

(a) there is no whitespace character strictly between them

or

(b) there is a parenthesed interval containing them both.

Also,

(c) Whitespaces not in any parenthesed interval  are mere separators
and to be discarded in the decomposition. All the other characters (including whitespaces) are retained.

For example, if the input is

```<code>I guess     () if(you say ( so)), I'll have((  ))to pack my (((things))) and go
</code>```

The output should be

```<code>I
guess
()
if(you say ( so)),
I'll
have((  ))to
pack
my
(((things)))
and
go
</code>```

Another useful test (thanks to NinjaBearMonkey) :

```<code>Hit the ( Road (Jack Don't) come ) back (no (more ) ) no more
</code>```

The output should be

```<code>Hit
the
( Road (Jack Don't) come )
back
(no (more ) )
no
more
</code>```

The shortest code in bytes wins.

答:
APL, 55 53 bytes

```<code>{⍵⊂⍨((⍵≠' ')∨~b)×+\1,¯1↓(b←0=+\1 ¯1 0['()'⍳⍵])∧⍵=' '}
</code>```

To be run in ⎕ml←3. Usual trick: cumulative scans of 1s and -1s to identify the areas enclosed by parentheses. Where the cumulative sum is 0, then we are outside parentheses. Boolean and the vector with the boolean vector with 1s where there are spaces. Rotate by 1 to the right inserting a 1 on the left. Build another running sum where each change identifies a segment. We're almost done, but we still need to remove the spaces at level 0. That's what the left side of the multiplication does: it zeroes out the level 0 spaces in the running sum. The dyadic enclose ⊂⍨ splits every time the running sum changes while throwing away the zeroes.

Title: Decompose string into blocks

Body:
APL, 55 53 bytes

{⍵⊂⍨((⍵≠' ')∨~b)×+\1,¯1↓(b←0=+\1 ¯1 0['()'⍳⍵])∧⍵=' '}

To be run in ⎕ml←3. Usual trick: cumulative scans of 1s and -1s to identify the areas enclosed by parentheses. Where the cumulative sum is 0, then we are outside parentheses. Boolean and the vector with the boolean vector with 1s where there are spaces. Rotate by 1 to the right inserting a 1 on the left. Build another running sum where each change identifies a segment. We're almost done, but we still need to remove the spaces at level 0. That's what the left side of the multiplication does: it zeroes out the level 0 spaces in the running sum. The dyadic enclose ⊂⍨ splits every time the running sum changes while throwing away the zeroes.


问:
Miniature Faking
As any amateur photographer can tell you, extreme post-processing is always good. One such technique is called "miniature-faking".

The object is to make an image look like a photograph of a miniaturized, toy version of itself. This works best for photographs taken from a moderate/high angle to the ground, with a low variance in subject height, but can be applied with varying effectiveness to other images.

The challenge: Take a photograph and apply a miniature-faking algorithm to it. There are many ways to do this, but for the purposes of this challenge, it boils down to:

Selective blur

Some part of the image should be blurred to simulate a shallow depth-of-field. This is usually done along some gradient, whether linear or shaped. Choose whatever blur/gradient algorithm you like, but between 15-85% of the image must have "noticeable" blur.

Saturation boost

Pump up the color to make things appear they were painted by hand. Output must have an average saturation level of > +5% when compared to input. (using HSV saturation)

Contrast Boost

Increase the contrast to simulate harsher lighting conditions (such as you see with an indoor/studio light rather than the sun). Output must have a contrast of > +5% when compared to input. (using RMS algorithm)

Those three alterations must be implemented, and no other enhancements/alterations are allowed. No cropping, sharpening, white balance adjustments, nothing.

Input is an image, and can be read from a file or memory. You may use external libraries to read and write the image, but you cannot use them to process the image. Supplied functions are also disallowed for this purpose (you can't just call Image.blur() for example)

There is no other input. The processing strengths, levels, etc, must be determined by the program, not by a human.

Output can be displayed or saved as a file in a standardized image format (PNG, BMP, etc).

Try to generalize. It should not work on only one image, but it's understandable that it won't work on all images. Some scenes simply do not respond well to this technique, no matter how good the algorithm. Apply common sense here, both when answering and voting on answers.

Behavior is undefined for invalid inputs, and those images which are impossible to satisfy the spec. For example, a grayscale image cannot be saturated (there is no base hue), a pure white imaged cannot have increased contrast, etc.

Include at least two output images in your answer:

One must be generated from one of the images in this dropbox folder. There are six to choose from, but I tried to make them all viable to varying degrees. You can see sample outputs for each in the example-outputs subfolder. Please note that these are full 10MP JPG images straight out of the camera, so you have a lot of pixels to work on.

The other can be any image of your choice. Obviously, try to choose images that are freely usable. Also, include either the original image or a link to it for comparison.

For example, from this image:

You might output something like:

For reference, the example above was processed in GIMP with an angular box-shaped gradient gaussian blur, saturation +80, contrast +20. (I don't know what units GIMP uses for those)

For more inspiration, or to get a better idea what you're trying to achieve, check out this site, or this one. You can also search for miniature faking and tilt shift photography for examples.

This is a popularity contest. Voters, vote for the entries you feel look the best while staying true to the objective.

Clarification:

Clarifying what functions are disallowed, it was not my intent to ban math functions. It was my intent to ban image manipulation functions. Yes, there's some overlap there, but things like FFT, convolutions, matrix math, etc, are useful in many other areas. You should not be using a function that simply takes an image and blurs. If you find a suitably mathy way to create a blur, that fair game.

答:
J

This was a nice challenge. The settings for blur, saturation, and contrast are hard-coded but can be easily changed if desired. However, the area in focus is hard-coded as a horizontal line in the center. It can not be  simply modified like the other settings. It was chosen since most of the test images feature views across a city.

After performing a Gaussian blur, I split the image horizontally into 5 regions. The top and bottom regions will receive 100% of the blur. The middle region will receive 0% of the blur. The two remaining regions will both scale proportionally to the inverse cube from 0% to 100%.

The code is to be used as a script in J and that script will be in the same folder as input.bmp which will be the input image. It will create output.bmp which will be a fake miniature of the input.

The performance is good and on my pc using an i7-4770k, it takes about 20 seconds to process an image from the OP's set. Previously, it took about 70 seconds to process an image using standard convolution with the ;._3 subarray operator. The performance was improved by using FFT to perform convolution.

This code requires the bmp and math/fftw addons to be installed. You can install them using install 'bmp' and install 'math/fftw'. Your system may also need the fftw library to be installed.

```<code>load 'bmp math/fftw'

NB. Define 2d FFT
fft2d =: 4 : 0
  s =. $ y
  i =. zzero_jfftw_ + , y
  o =. 0 * i
  p =. createplan_jfftw_ s;i;o;x;FFTW_ESTIMATE_jfftw_
  fftwexecute_jfftw_ p
  destroyplan_jfftw_ p
  r =. s $ o
  if. x = FFTW_BACKWARD_jfftw_ do.
    r =. r % */ s
  end.
  r
)

fft2 =: (FFTW_FORWARD_jfftw_ & fft2d) :. (FFTW_BACKWARD_jfftw & fft2d)
ifft2 =: (FFTW_BACKWARD_jfftw_ & fft2d) :. (FFTW_FORWARD_jfftw & fft2d)

NB. Settings: Blur radius - Saturation - Contrast
br =: 15
s =: 3
c =: 1.5

NB. Read image and extract rgb channels
i =: 255 %~ 256 | (readbmp 'input.bmp') <.@%"_ 0 ] 2 ^ 16 8 0
'h w' =: }. $ i

NB. Pad each channel to fit Gaussian blur kernel
'hp wp' =: (+: br) + }. $ i
ip =: (hp {. wp {."1 ])"_1 i

NB. Gaussian matrix verb
gm =: 3 : '(%+/@,)s%~2p1%~^(s=.*:-:y)%~-:-+&*:/~i:y'

NB. Create a Gaussian blur kernel
gk =: fft2 hp {. wp {."1 gm br

NB. Blur each channel using FFT-based convolution and unpad
ib =: (9 o. (-br) }. (-br) }."1 br }. br }."1 [: ifft2 gk * fft2)"_1 ip

NB. Create the blur gradient to emulate tilt-shift
m =: |: (w , h) $ h ({. >. (({.~ -)~ |.)) , 1 ,: |. (%~i.) 0.2 I.~ (%~i.) h

NB. Tilt-shift each channel
it =: i ((m * ]) + (-. m) * [)"_1 ib

NB. Create the saturation matrix
sm =: |: ((+ ] * [: =@i. 3:)~ 3 3 |:@$ 0.299 0.587 0.114 * -.) s

NB. Saturate and clamp
its =: 0 >. 1 <. sm +/ .*"1 _ it

NB. Contrast and clamp
itsc =: 0 >. 1 <. 0.5 + c * its - 0.5

NB. Output the image
'output.bmp' writebmp~ (2 <.@^ 16 8 0) +/ .* 255 <.@* itsc

exit ''
</code>```

Title: Miniature Faking

Body:
J

This was a nice challenge. The settings for blur, saturation, and contrast are hard-coded but can be easily changed if desired. However, the area in focus is hard-coded as a horizontal line in the center. It can not be  simply modified like the other settings. It was chosen since most of the test images feature views across a city.

After performing a Gaussian blur, I split the image horizontally into 5 regions. The top and bottom regions will receive 100% of the blur. The middle region will receive 0% of the blur. The two remaining regions will both scale proportionally to the inverse cube from 0% to 100%.

The code is to be used as a script in J and that script will be in the same folder as input.bmp which will be the input image. It will create output.bmp which will be a fake miniature of the input.

The performance is good and on my pc using an i7-4770k, it takes about 20 seconds to process an image from the OP's set. Previously, it took about 70 seconds to process an image using standard convolution with the ;._3 subarray operator. The performance was improved by using FFT to perform convolution.

This code requires the bmp and math/fftw addons to be installed. You can install them using install 'bmp' and install 'math/fftw'. Your system may also need the fftw library to be installed.

load 'bmp math/fftw'

NB. Define 2d FFT
fft2d =: 4 : 0
  s =. $ y
  i =. zzero_jfftw_ + , y
  o =. 0 * i
  p =. createplan_jfftw_ s;i;o;x;FFTW_ESTIMATE_jfftw_
  fftwexecute_jfftw_ p
  destroyplan_jfftw_ p
  r =. s $ o
  if. x = FFTW_BACKWARD_jfftw_ do.
    r =. r % */ s
  end.
  r
)

fft2 =: (FFTW_FORWARD_jfftw_ & fft2d) :. (FFTW_BACKWARD_jfftw & fft2d)
ifft2 =: (FFTW_BACKWARD_jfftw_ & fft2d) :. (FFTW_FORWARD_jfftw & fft2d)

NB. Settings: Blur radius - Saturation - Contrast
br =: 15
s =: 3
c =: 1.5

NB. Read image and extract rgb channels
i =: 255 %~ 256 | (readbmp 'input.bmp') <.@%"_ 0 ] 2 ^ 16 8 0
'h w' =: }. $ i

NB. Pad each channel to fit Gaussian blur kernel
'hp wp' =: (+: br) + }. $ i
ip =: (hp {. wp {."1 ])"_1 i

NB. Gaussian matrix verb
gm =: 3 : '(%+/@,)s%~2p1%~^(s=.*:-:y)%~-:-+&*:/~i:y'

NB. Create a Gaussian blur kernel
gk =: fft2 hp {. wp {."1 gm br

NB. Blur each channel using FFT-based convolution and unpad
ib =: (9 o. (-br) }. (-br) }."1 br }. br }."1 [: ifft2 gk * fft2)"_1 ip

NB. Create the blur gradient to emulate tilt-shift
m =: |: (w , h) $ h ({. >. (({.~ -)~ |.)) , 1 ,: |. (%~i.) 0.2 I.~ (%~i.) h

NB. Tilt-shift each channel
it =: i ((m * ]) + (-. m) * [)"_1 ib

NB. Create the saturation matrix
sm =: |: ((+ ] * [: =@i. 3:)~ 3 3 |:@$ 0.299 0.587 0.114 * -.) s

NB. Saturate and clamp
its =: 0 >. 1 <. sm +/ .*"1 _ it

NB. Contrast and clamp
itsc =: 0 >. 1 <. 0.5 + c * its - 0.5

NB. Output the image
'output.bmp' writebmp~ (2 <.@^ 16 8 0) +/ .* 255 <.@* itsc

exit ''


问:
Validating a CPR number

Validating a CPR number

A Danish CPR number (Person Identification Number) is date of birth followed by 4 digits (the last one being a control digit): DDMMYY-XXXX

The final digit validates the CPR number using Modulo 11 by satisfying the following equation:

where the  are the ten digits of the complete ID number, and the coefficients (4, 3, 2, 7, …) are all nonzero in the finite field of order 11.

Input

A CPR number formatted like this DDMMYY-XXXX where YY indicates a year within the last 100 years (between 1917 and 2016).

Output

Indication whether CPR number is valid (1 or true) or invalid (0 or false)

Examples

```<code>  290215-2353 --> false
  140585-2981 --> true
  311217-6852 --> true
  121200-0004 --> false
  140322-5166 --> false
  111111-1118 --> true
</code>```

Scoring

This is code-golf - fewest bytes win!

Date validation

All years refer to a period within the last 100 years. A valid date is a date that exists within it's calendar year.

290215 is not a valid date because 29/2 wasn't a date in 2015.

301216 is a valid date because 30/12 is a date in 2016.

答:
Mathematica, 130 bytes

```<code>DateObject[a={10#5+#6+4,10#3+#4,10#+#2}][[1]]==a&&11∣Tr[{4,3,2,7,6,5,4,3,2,1}{##}]&@@IntegerDigits@FromDigits[#~StringDrop~{7}]&
</code>```

Anonymous function. Takes a string as input and returns True or False as output. The Unicode character is U+2223 DIVIDES, representing \[Divides].

Title: Validating a CPR number

Body:
Mathematica, 130 bytes

DateObject[a={10#5+#6+4,10#3+#4,10#+#2}][[1]]==a&&11∣Tr[{4,3,2,7,6,5,4,3,2,1}{##}]&@@IntegerDigits@FromDigits[#~StringDrop~{7}]&

Anonymous function. Takes a string as input and returns True or False as output. The Unicode character is U+2223 DIVIDES, representing \[Divides].


答:
MATL, 38 bytes

```<code>1ti:"yy@oQ*+]vG:)!"@Vt~oX@o?w]&v]&hZ}y
</code>```

Try it online!

Computing an array with the (unique) numbers takes the first 17 bytes. Formatting takes the remaining 21 bytes.

Explanation

Part 1: generate the numbers

This generates an array with the numbers from the first and second rows in increasing order: [1; 1; 3; 4; 11; 15; ...]. It starts with 1, 1. Each new number is iteratively obtained from the preceding two. Of those, the second is multiplied by 1 or 2 depending on the iteration index, and then summed to the first to produce the new number.

The number of iterations is equal to the input n. This means that n+2 numbers are generated. Once generated, the array needs to be trimmed so only the first n entries are kept.

```<code>1t      % Push 1 twice
i:      % Take input n. Generage array [1 2 ... n]
"       % For each
  yy    %   Duplicate the two most recent numbers
  @o    %   Parity of the iteration index (0 or 1)
  Q     %   Add 1: gives 1 for even iteration index, 2 for odd
  *+    %   Multiply this 1 or 2 by the most recent number in the sequence, and add
       %    to the second most recent. This produces a new number in the sequence
]       % End for each
v       % Concatenate all numbers in a vertical array
G:)     % Keep only the first n entries
</code>```

Part 2: format the output

For each number in the obtained array, this generates two strings: string representation of the number, and a string of the same length consisting of character 0 repeated (character 0 is displayed as a space in MATL). For even iterations, these two strings are swapped.

The two strings are then concatenated vertically. So n 2D char arrays are produced as follows (using · to represent character 0):

```<code>·
1

1
·

·
3

4
·

··
11

15
··
</code>```

These arrays are then concatenated horizontally to produce

```<code>·1·4··15
1·3·11··
</code>```

Finally, this 2D char array is split into its two rows, and the first is duplicated onto the top of the stack. The three strings are displayed in order, each on a different line, producing the desired output

```<code>!       % Transpose into a horizontal array [1 1 3 4 11 15 ...]
"       % For each
  @V    %   Push current number and convert to string
  t~o   %   Duplicate, negate, convert to double: string of the same length consisting
        %   of character 0 repeated
  X@o   %   Parity of the iteration index (1 or 0)
  ?     %   If index is odd
    w   %     Swap
  ]     %   End if
  &v    %   Concatenate the two strings vertically. Gives a 2D char array representing
        %   a "numeric column" of the output (actually several columns of characters)
]       % End for
&h      % Concatenate all 2D char arrays horizontally. Gives a 2D char array with the
        % top two rows of the output
Z}      % Split this array into its two rows
y       % Push a copy of the first row. Implicitly display
</code>```

Title: Generate Pascal's Braid

Body:
MATL, 38 bytes

1ti:"yy@oQ*+]vG:)!"@Vt~oX@o?w]&v]&hZ}y

Try it online!

Computing an array with the (unique) numbers takes the first 17 bytes. Formatting takes the remaining 21 bytes.

Explanation

Part 1: generate the numbers

This generates an array with the numbers from the first and second rows in increasing order: [1; 1; 3; 4; 11; 15; ...]. It starts with 1, 1. Each new number is iteratively obtained from the preceding two. Of those, the second is multiplied by 1 or 2 depending on the iteration index, and then summed to the first to produce the new number.

The number of iterations is equal to the input n. This means that n+2 numbers are generated. Once generated, the array needs to be trimmed so only the first n entries are kept.

1t      % Push 1 twice
i:      % Take input n. Generage array [1 2 ... n]
"       % For each
  yy    %   Duplicate the two most recent numbers
  @o    %   Parity of the iteration index (0 or 1)
  Q     %   Add 1: gives 1 for even iteration index, 2 for odd
  *+    %   Multiply this 1 or 2 by the most recent number in the sequence, and add
       %    to the second most recent. This produces a new number in the sequence
]       % End for each
v       % Concatenate all numbers in a vertical array
G:)     % Keep only the first n entries

Part 2: format the output

For each number in the obtained array, this generates two strings: string representation of the number, and a string of the same length consisting of character 0 repeated (character 0 is displayed as a space in MATL). For even iterations, these two strings are swapped.

The two strings are then concatenated vertically. So n 2D char arrays are produced as follows (using · to represent character 0):

·
1

1
·

·
3

4
·

··
11

15
··

These arrays are then concatenated horizontally to produce

·1·4··15
1·3·11··

Finally, this 2D char array is split into its two rows, and the first is duplicated onto the top of the stack. The three strings are displayed in order, each on a different line, producing the desired output

!       % Transpose into a horizontal array [1 1 3 4 11 15 ...]
"       % For each
  @V    %   Push current number and convert to string
  t~o   %   Duplicate, negate, convert to double: string of the same length consisting
        %   of character 0 repeated
  X@o   %   Parity of the iteration index (1 or 0)
  ?     %   If index is odd
    w   %     Swap
  ]     %   End if
  &v    %   Concatenate the two strings vertically. Gives a 2D char array representing
        %   a "numeric column" of the output (actually several columns of characters)
]       % End for
&h      % Concatenate all 2D char arrays horizontally. Gives a 2D char array with the
        % top two rows of the output
Z}      % Split this array into its two rows
y       % Push a copy of the first row. Implicitly display


问:
Draw a ladder and slide
Your task is to create a program or function that takes, as input, a natural number (n) between 1 and 25 (inclusive) and prints an isometric representation of a slide and ladder with n number of rungs.

Ladder and slide specifications

The ladder is always oriented on the left and the slide on the right. We're viewing it from the ladder side, so part of the slide is obscured at the top three levels. The rungs are represented by four dashes (----) and the sides of the ladder and slide by slashes (/ and \). The following is a diagram to represent the patterns of spaces needed for a slide with five rungs.

```<code>Slide              Blank space count
    /----/\        1234/----/\
   /----/  \       123/----/12\
  /----/    \      12/----/1234\
 /----/ \    \     1/----/1\1234\
/----/   \    \    /----/123\1234\
</code>```

Examples

```<code>>>1
/----/\

>>3
  /----/\
 /----/  \
/----/    \

>>4
   /----/\
  /----/  \
 /----/    \
/----/ \    \

>>10
         /----/\
        /----/  \
       /----/    \
      /----/ \    \
     /----/   \    \
    /----/     \    \
   /----/       \    \
  /----/         \    \
 /----/           \    \
/----/             \    \
</code>```

This is code-golf, so the answer with the lowest byte count wins.

Note: trailing white space is acceptable in the output, as long as it doesn't exceed the length of the line.

答:
V, <s>38, 37, 36, 34, 33, 32, 31, 30</s> 29 bytes

```<code>Àé r\2é/4é-òhYpX$2P^ò3GEòjlr\
</code>```

Try it online!

<s>I might catch up with Osabie. One byte shorter than Osabie. \o/ Tied with 2sable!</s> One byte shorter!

In other news, this is definitely the longest strikethrough header I've ever made.

Explanation:

```<code>Àé              "Insert 'arg1' spaces
   r\           "Turn the last one into a '\'
     2é/        "Insert 2 '/'
        4é-     "Insert 4 '-'

ò        ò      "Recursivly:
 h              "  Move one to the left
  Yp            "  Duplicate this line
    X           "  Delete one space from the left
     $2P        "  Paste two spaces at the end of this line
        ^       "  Move back to the beginning of this line.
</code>```

This will run until an error occurs, which thanks to the "move left" command ('h'), will be 'arg1' times.

Now we just need to add the inner leg

```<code>3GE             "Move to the second slash of line 3
   ò    ò       "Recursively: (The second 'ò' is implicit)
    jl          "  Move down and to the right
      r\        "  And replace the character under the cursor with a '\'
</code>```

Non-competing version (28 bytes)

Title: Draw a ladder and slide

Body:
V, <s>38, 37, 36, 34, 33, 32, 31, 30</s> 29 bytes

Àé r\2é/4é-òhYpX$2P^ò3GEòjlr\

Try it online!

<s>I might catch up with Osabie. One byte shorter than Osabie. \o/ Tied with 2sable!</s> One byte shorter!

In other news, this is definitely the longest strikethrough header I've ever made.

Explanation:

Àé              "Insert 'arg1' spaces
   r\           "Turn the last one into a '\'
     2é/        "Insert 2 '/'
        4é-     "Insert 4 '-'

ò        ò      "Recursivly:
 h              "  Move one to the left
  Yp            "  Duplicate this line
    X           "  Delete one space from the left
     $2P        "  Paste two spaces at the end of this line
        ^       "  Move back to the beginning of this line.

This will run until an error occurs, which thanks to the "move left" command ('h'), will be 'arg1' times.

Now we just need to add the inner leg

3GE             "Move to the second slash of line 3
   ò    ò       "Recursively: (The second 'ò' is implicit)
    jl          "  Move down and to the right
      r\        "  And replace the character under the cursor with a '\'

Non-competing version (28 bytes)


问:
Which ghosts are missing?
In this challenge, given a list of ghosts from Pac-Man, you must output which ghosts are missing. You must do it in as few bytes as you can

Input

Input will consist of a string or list, which will include a number ghosts, which could include:

Blinky

Inky

Pinky

Clyde

However, input may also include Pac-Man (with that punctuation). So, the maximum amount of items in a list will be five, in any order. It can be assumed that no invalid items will be in the list

Output

Output will consist of a string, or list. This will include of all the ghosts that are not in the input, in any order. However, if Pac-Man is in the input, all ghosts will be considered missing (because he eats them).

Test cases

```<code>input: Clyde
output: Blinky, Inky, Pinky
alternate output: Inky, Pinky, Blinky
or one of the other 4 permutations

input: Clyde, Blinky # or however you delimit it
output: Inky, Pinky
alt: Pinky, Inky

input: Pac-Man, Clyde
Output: Blinky, Inky, Pinky, Clyde
or you could output one of the other 23 permutations

input:[null]
Output: Blinky, Inky, Pinky, Clyde
or you could output one of the other 23 permutations
</code>```

This is codegolf, so the lower the bytecount, the better.

答:
TSQL(sqlserver 2016), 114 bytes

Golfed:

```<code>DECLARE @ VARCHAR(99) = 'Blinky,Inky,Pinky,Clyde'

SELECT*FROM STRING_SPLIT('Blinky,Inky,Pinky,Clyde',',')EXCEPT SELECT*FROM STRING_SPLIT(@,','WHERE @ NOT LIKE'%-%'
</code>```

Ungolfed:

```<code>DECLARE @ VARCHAR(99) = 'Blinky,Inky,Pinky,Clyde'

SELECT * FROM STRING_SPLIT('Blinky,Inky,Pinky,Clyde',',')
EXCEPT
SELECT * FROM STRING_SPLIT(@,',')
WHERE @ NOT LIKE'%-%'
</code>```

Fiddle

Title: Which ghosts are missing?

Body:
TSQL(sqlserver 2016), 114 bytes

Golfed:

DECLARE @ VARCHAR(99) = 'Blinky,Inky,Pinky,Clyde'

SELECT*FROM STRING_SPLIT('Blinky,Inky,Pinky,Clyde',',')EXCEPT SELECT*FROM STRING_SPLIT(@,','WHERE @ NOT LIKE'%-%'

Ungolfed:

DECLARE @ VARCHAR(99) = 'Blinky,Inky,Pinky,Clyde'

SELECT * FROM STRING_SPLIT('Blinky,Inky,Pinky,Clyde',',')
EXCEPT
SELECT * FROM STRING_SPLIT(@,',')
WHERE @ NOT LIKE'%-%'

Fiddle


问:
Convert 1, 2, 3, 4, 5, 6, 7, 8, and 9 to "one", "two", "three", etc

Winner: professorfish's bash answer! An entire 9 bytes! Wow!

You may continue to submit your answer, however you can no longer win. Original post kept for posterity:

Your goal is to convert a whole number between 1-9 into the word it represents.

You will not need to worry about decimals

The user will input a number. Assume that they will never enter anything 10 or higher

The user must type the number at some point, however the method the program reads it does not matter. It can be with stdin, reading a text file, etc, however the user must press the 9 button on their keyboard (for example) at some point

It is not case sensitive (ie, "one", "One", "oNe", "OnE", etc are all acceptable)

HTTP/etc requests are allowed, however any code executed by the server the request is made to counts towards the byte count of your final code (e.g. if I had a C++ program make a HTTP request, the PHP code used in the HTTP request counts)

Anything that can compile and run is acceptable

This contest has ended on June 27th, 2014 (7 days from posting).

This is a code-golf, so the shortest code wins

答:
C, <s>92</s> 89 bytes Japanese(Hiragana , Katakana)

Hiragana (ひらがな)

```<code>h(n){char*h="いちに　さんし　ご　ろくななはちきゅ";printf("%.6s%s",h+--n*6,n^9?"":"う");}
</code>```

Katakana (カタカナ)

```<code>k(n){char*k="イチニ　サンシ　ゴ　ロクシチハチキュ";printf("%.6s%s",k+--n*6,n^9?"":"ウ");}
</code>```

http://sp.cis.iwate-u.ac.jp/sp/lesson/j/doc/numbers.html

ideone it!

Body:
C, <s>92</s> 89 bytes Japanese(Hiragana , Katakana)

Hiragana (ひらがな)

h(n){char*h="いちに　さんし　ご　ろくななはちきゅ";printf("%.6s%s",h+--n*6,n^9?"":"う");}

Katakana (カタカナ)

k(n){char*k="イチニ　サンシ　ゴ　ロクシチハチキュ";printf("%.6s%s",k+--n*6,n^9?"":"ウ");}

http://sp.cis.iwate-u.ac.jp/sp/lesson/j/doc/numbers.html

ideone it!


问:
Polar Bear, Polar Bear, what do you hear?
The text of the children's book Polar Bear, Polar Bear, What Do You Hear?  has a very simple pattern.  You might use the text to teach introductory programming concepts.

My son was quickly bored by this idea, so I decided to play some golf with it instead.

The Challenge

In your programming language of choice, write the smallest program possible which will print the following text.  Output should match exactly, including case, spacing, and punctuation.

```<code>Polar Bear, Polar Bear, what do you hear?
I hear a lion roaring in my ear.

Lion, Lion, what do you hear?
I hear a hippopotamus snorting in my ear.

Hippopotamus, Hippopotamus, what do you hear?
I hear a flamingo fluting in my ear.

Flamingo, Flamingo, what do you hear?
I hear a zebra braying in my ear.

Zebra, Zebra, what do you hear?
I hear a boa constrictor hissing in my ear.

Boa Constrictor, Boa Constrictor, what do you hear?
I hear an elephant trumpeting in my ear.

Elephant, Elephant, what do you hear?
I hear a leopard snarling in my ear.

Leopard, Leopard, what do you hear?
I hear a peacock yelping in my ear.

Peacock, Peacock, what do you hear?
I hear a walrus bellowing in my ear.

Walrus, Walrus, what do you hear?
I hear a zookeeper whistling in my ear.

Zookeeper, Zookeeper, what do you hear?
I hear children...

...growling like a polar bear,
roaring like a lion,
snorting like a hippopotamus,
fluting like a flamingo,
braying like a zebra,
hissing like a boa constrictor,
trumpeting like an elephant,
snarling like a leopard,
yelping like a peacock,
bellowing like a walrus...
that's what I hear.
</code>```

答:
Haskell 537 499 497 Bytes

```<code>import Data.Char
a&b=a++b
b=putStr
c=concat
d=init
e('E':s)="an e"&s
e s="a "&map toLower s
f="I hear "
l=zip(lines"Polar Bear\nLion\nHippopotamus\nFlamingo\nZebra\nBoa Constrictor\nElephant\nLeopard\nPeacock\nWalrus\nZookeeper")$words"growl roar snort flut bray hiss trumpet snarl yelp bellow whistl"
main=(b.drop 41.c)[f&e n&" "&v&"ing in my ear.\n\n"&n&", "&n&", what do you hear?\n"|(n,v)<-l]>>b(f&"children...\n\n..."&(d.d.c)[v&"ing like "&e n&",\n"|(n,v)<-d l]&"...\nthat's what I hear.\n")
</code>```

Using the convention that a solution does not have be executable, only produce the output via some function, this can be shortened to 479 Bytes. The output is in g:

```<code>import Data.Char
a&b=a++b
c=concat
d=init
e('E':s)="an e"&s
e s="a "&map toLower s
f="I hear "
l=zip(lines"Polar Bear\nLion\nHippopotamus\nFlamingo\nZebra\nBoa Constrictor\nElephant\nLeopard\nPeacock\nWalrus\nZookeeper")$words"growl roar snort flut bray hiss trumpet snarl yelp bellow whistl"
g=(drop 41.c)[f&e n&" "&v&"ing in my ear.\n\n"&n&", "&n&", what do you hear?\n"|(n,v)<-l]&f&"children...\n\n..."&(d.d.c)[v&"ing like "&e n&",\n"|(n,v)<-d l]&"...\nthat's what I hear.\n"
</code>```

Body:
Haskell 537 499 497 Bytes

import Data.Char
a&b=a++b
b=putStr
c=concat
d=init
e('E':s)="an e"&s
e s="a "&map toLower s
f="I hear "
l=zip(lines"Polar Bear\nLion\nHippopotamus\nFlamingo\nZebra\nBoa Constrictor\nElephant\nLeopard\nPeacock\nWalrus\nZookeeper")$words"growl roar snort flut bray hiss trumpet snarl yelp bellow whistl"
main=(b.drop 41.c)[f&e n&" "&v&"ing in my ear.\n\n"&n&", "&n&", what do you hear?\n"|(n,v)<-l]>>b(f&"children...\n\n..."&(d.d.c)[v&"ing like "&e n&",\n"|(n,v)<-d l]&"...\nthat's what I hear.\n")

Using the convention that a solution does not have be executable, only produce the output via some function, this can be shortened to 479 Bytes. The output is in g:

import Data.Char
a&b=a++b
c=concat
d=init
e('E':s)="an e"&s
e s="a "&map toLower s
f="I hear "
l=zip(lines"Polar Bear\nLion\nHippopotamus\nFlamingo\nZebra\nBoa Constrictor\nElephant\nLeopard\nPeacock\nWalrus\nZookeeper")$words"growl roar snort flut bray hiss trumpet snarl yelp bellow whistl"
g=(drop 41.c)[f&e n&" "&v&"ing in my ear.\n\n"&n&", "&n&", what do you hear?\n"|(n,v)<-l]&f&"children...\n\n..."&(d.d.c)[v&"ing like "&e n&",\n"|(n,v)<-d l]&"...\nthat's what I hear.\n"


答:
Ruby, 61 bytes

->n{n.times{|i|puts"%*s\\    \\\r%*s----/"% [n+i,"",n-i,?/]}}
```

<h3>Ungolfed</h3>

<pre class="lang-ruby prettyprint-override"><code>->(num_rows) {
  num_rows.times {|row_idx|
    puts "%*s\\    \\\r%*s----/" % [ num_rows + row_idx, "", num_rows - row_idx, "/" ]
  }
}
</code>```

I could save two bytes by using '%*s\    \^M%*s----/' (where ^M is a literal carriage return) for the format string, but then Ruby prints the warning "warning: encountered \r in middle of line, treated as a mere space". ¯\_(ツ)_/¯

Previous solution (64 bytes)

->n{n.times{|i|puts" "*(n+i)+"\\    \\\r"+" "*(n-i-1)+"/----/"}}
```

Title: Draw a ladder and slide

Body:
Your task is to create a program or function that takes, as input, a natural number (n) between 1 and 25 (inclusive) and prints an isometric representation of a slide and ladder with n number of rungs.

Ladder and slide specifications

The ladder is always oriented on the left and the slide on the right. We're viewing it from the ladder side, so part of the slide is obscured at the top three levels. The rungs are represented by four dashes (----) and the sides of the ladder and slide by slashes (/ and \). The following is a diagram to represent the patterns of spaces needed for a slide with five rungs.

```<code>Slide              Blank space count
    /----/\        1234/----/\
   /----/  \       123/----/12\
  /----/    \      12/----/1234\
 /----/ \    \     1/----/1\1234\
/----/   \    \    /----/123\1234\
</code>```

Examples

```<code>>>1
/----/\

>>3
  /----/\
 /----/  \
/----/    \

>>4
   /----/\
  /----/  \
 /----/    \
/----/ \    \

>>10
         /----/\
        /----/  \
       /----/    \
      /----/ \    \
     /----/   \    \
    /----/     \    \
   /----/       \    \
  /----/         \    \
 /----/           \    \
/----/             \    \
</code>```

This is code-golf, so the answer with the lowest byte count wins.

Note: trailing white space is acceptable in the output, as long as it doesn't exceed the length of the line.

Body:
Ruby, 61 bytes

->n{n.times{|i|puts"%*s\\    \\\r%*s----/"% [n+i,"",n-i,?/]}}

Ungolfed

->(num_rows) {
  num_rows.times {|row_idx|
    puts "%*s\\    \\\r%*s----/" % [ num_rows + row_idx, "", num_rows - row_idx, "/" ]
  }
}

I could save two bytes by using '%*s\    \^M%*s----/' (where ^M is a literal carriage return) for the format string, but then Ruby prints the warning "warning: encountered \r in middle of line, treated as a mere space". ¯\_(ツ)_/¯

Previous solution (64 bytes)

->n{n.times{|i|puts" "*(n+i)+"\\    \\\r"+" "*(n-i-1)+"/----/"}}


问:
m3ph1st0s's programming puzzle 4 (C/C++): “3-way swap”
My last puzzle has generated some confusion and controversy so I decided to give up, for now, on those "replace one character"-type puzzles.

Hope this 4th puzzle will redeem myself after all the edits in puzzle 3 and will put your brains at work once more.

I've really put up all the effort to make this one as clear as possible and hope you will enjoy it!

So here it goes:

We start from a very short C program:

```<code>int main() {
   int a = 93;
   int b = 11;
   int c = 22528;

   // insert your code here

}
</code>```

Your job will be to swap the values of the variables a,b,c like this: a <= b, b <= c, c <= a. To make it even more clear: new a = old b, new b = old c, new c = old a.

You are required to do this by inserting one single instruction in the line indicated by the comment in the code. To be clear once again, this line will contain only one semicolon (;) indicating the end of the lone instruction. After the execution of this program, a will contain 11, b will contain 22528, c will contain 93.
However, there are some conditions that need to be met. So we'll have 4 different puzzles with different cryteria.

4.1. Do it by using whatever you want. Just one statement. -> most creative solution wins this one.

4.2. Do it without using any comma (,). -> most creative wins

4.3. Do it without any comma and with no more than 4 letters (+any other characters). -> shortest code wins

4.4. Do it without any comma and with no more than 4 letters and no more than 4 digits (+any other characters). -> shortest code wins

To make sure you understood, here's some code that is valid under the condition required but does not solve the problem:

4.1:

```<code>I_hereby_call_my_beautiful_function(nice_argument), int q=w, who_the_hell_is(w)+1;
</code>```

4.2:

```<code>one = single + assignment;
</code>```

4.3:

```<code>int w=12345678;
</code>```

4.4:

```<code>int w=1234;
</code>```

P.S. In case you haven't already noticed, 4.4 is the tough one here (I hope :D).

答:
Classic inplace exchange (20 chars without spaces, category 4.1, 4.2):

```<code>c ^= b ^= c ^= b ^= a ^= b ^= a;
</code>```

Total exist 9 xor-chains that implement this 3-way exchange

```<code>c ^= b ^= c ^= b ^= a ^= b ^= a;
c ^= a ^= c ^= b ^= c ^= b ^= a;
c ^= b ^= a ^= b ^= a ^= c ^= a;
a ^= c ^= b ^= c ^= b ^= a ^= b;
a ^= b ^= a ^= c ^= a ^= c ^= b;
a ^= c ^= a ^= c ^= b ^= c ^= b;
b ^= c ^= b ^= a ^= b ^= a ^= c;
b ^= a ^= b ^= a ^= c ^= a ^= c;
b ^= a ^= c ^= a ^= c ^= b ^= c;
</code>```

and to continue of Gareth idea (No commas, 3 letters, 4 digits)

```<code>c=(b<<=a>>=3)/242;
</code>```

Body:
Classic inplace exchange (20 chars without spaces, category 4.1, 4.2):

c ^= b ^= c ^= b ^= a ^= b ^= a;

Total exist 9 xor-chains that implement this 3-way exchange

c ^= b ^= c ^= b ^= a ^= b ^= a;
c ^= a ^= c ^= b ^= c ^= b ^= a;
c ^= b ^= a ^= b ^= a ^= c ^= a;
a ^= c ^= b ^= c ^= b ^= a ^= b;
a ^= b ^= a ^= c ^= a ^= c ^= b;
a ^= c ^= a ^= c ^= b ^= c ^= b;
b ^= c ^= b ^= a ^= b ^= a ^= c;
b ^= a ^= b ^= a ^= c ^= a ^= c;
b ^= a ^= c ^= a ^= c ^= b ^= c;

and to continue of Gareth idea (No commas, 3 letters, 4 digits)

c=(b<<=a>>=3)/242;


答:
Batch, 194 bytes

```<code>@echo off
for /l %%i in (1,1,%1)do call:l %1 %%i
exit/b
:l
set s=\    \
for /l %%j in (1,1,%2)do call set s=  %%s%%
set s=/----/%s:~7%
for /l %%j in (%2,1,%1)do call set s= %%s%%
echo%s%
</code>```

Turned out to be reasonably straightforward: indent the slide, remove the first 7 characters, indent the ladder, remove the leading space. This last bit does involve a little trickery though!

Title: Draw a ladder and slide

Body:
Batch, 194 bytes

@echo off
for /l %%i in (1,1,%1)do call:l %1 %%i
exit/b
:l
set s=\    \
for /l %%j in (1,1,%2)do call set s=  %%s%%
set s=/----/%s:~7%
for /l %%j in (%2,1,%1)do call set s= %%s%%
echo%s%

Turned out to be reasonably straightforward: indent the slide, remove the first 7 characters, indent the ladder, remove the leading space. This last bit does involve a little trickery though!


答:
Haskell, 101 bytes

```<code>a=1:1:t
t=3:4:zipWith((-).(4*))t a
g(i,x)=min(cycle" 9"!!i)<$>show x
f n=[zip[y..y+n]a>>=g|y<-[0..2]]
</code>```

Defines a function f :: Int → [String].

Michael Klein reminded me I didn’t need to call unlines on the result, saving 7 bytes. Thanks!

I saved a byte by replacing " 9"!!mod i 2 with cycle" 9"!!i.

Three more bytes by writing two corecursive lists instead of using drop.

My girlfriend pointed out I can save two more bytes by starting my answers at 0 instead of 1.

Title: Generate Pascal's Braid

Body:
Haskell, 101 bytes

a=1:1:t
t=3:4:zipWith((-).(4*))t a
g(i,x)=min(cycle" 9"!!i)<$>show x
f n=[zip[y..y+n]a>>=g|y<-[0..2]]

Defines a function f :: Int → [String].

Michael Klein reminded me I didn’t need to call unlines on the result, saving 7 bytes. Thanks!

I saved a byte by replacing " 9"!!mod i 2 with cycle" 9"!!i.

Three more bytes by writing two corecursive lists instead of using drop.

My girlfriend pointed out I can save two more bytes by starting my answers at 0 instead of 1.


答:
Hexagony, 33

```<code>"A}_8_47<='>({a/_x.@.9!\356);');
</code>```

Expanded:

```<code>    " A }
  _ 8 _ 4 7
 < = ' > ( {
a / _ x . @ .
 9 ! \ 3 5 6
  ) ; ' ) ;
   . . . .
</code>```

Output:

```<code>aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ1203568479_
</code>```

Try it online!

Note that there is an unprintable character 0x1A as the first byte of the program. This also makes the first row of the expanded Hexagon look sort of off. Many thanks to Martin for showing me this trick, as well as for suggesting the algorithm for printing the alphabet!

This prints the alphabet by storing a and A on two edges of a hexagon and the number 26 on the edge of the hexagon that touches the joint between the letters. This looks something like this:

```<code>A \ / a
   |
   26
</code>```

Then it enters a loops that prints the letters and then increments them, and then decrements the number. After one iteration we would have:

```<code>B \ / b
   |
   25
</code>```

And so on. The linear code for the initialisation is: 0x1A " A } a. The linear code for the loops outside of control flow changes is: ; ) ' ; ) { ( ' =.

Once the counter reaches zero, we follow a different path to print the numbers and an underscore. Written out linearly this is: x 3 5 6 8 4 7 9 ! ; { @. This replaces the current memory edge's value with the number 1203568479 (note that x's ASCII code is 120), which contains all of the decimal digits. We print out this number and then we use a neat feature of Hexagony: we print out the number mod 256 as an ASCII character. This just happens to be 95, or underscore.

Title: Print all alphanumeric characters plus underscore

Body:
Write a program or function that prints or returns a string of the alphanumeric characters plus underscore, in any order. To be precise, the following characters need to be output, and no more:

```<code>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_
</code>```

When printing to stdout, an optional trailing newline after your output is permitted.

Built-in constants that contain 9 or more of the above characters are disallowed.

Shortest code in bytes wins.

This is a very simple challenge, which I believe will generate some interesting answers nevertheless.

Leaderboards

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

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

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

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

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

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

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

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

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

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
Hexagony, 33

"A}_8_47<='>({a/_x.@.9!\356);');

Expanded:

    " A }
  _ 8 _ 4 7
 < = ' > ( {
a / _ x . @ .
 9 ! \ 3 5 6
  ) ; ' ) ;
   . . . .

Output:

aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ1203568479_

Try it online!

Note that there is an unprintable character 0x1A as the first byte of the program. This also makes the first row of the expanded Hexagon look sort of off. Many thanks to Martin for showing me this trick, as well as for suggesting the algorithm for printing the alphabet!

This prints the alphabet by storing a and A on two edges of a hexagon and the number 26 on the edge of the hexagon that touches the joint between the letters. This looks something like this:

A \ / a
   |
   26

Then it enters a loops that prints the letters and then increments them, and then decrements the number. After one iteration we would have:

B \ / b
   |
   25

And so on. The linear code for the initialisation is: 0x1A " A } a. The linear code for the loops outside of control flow changes is: ; ) ' ; ) { ( ' =.

Once the counter reaches zero, we follow a different path to print the numbers and an underscore. Written out linearly this is: x 3 5 6 8 4 7 9 ! ; { @. This replaces the current memory edge's value with the number 1203568479 (note that x's ASCII code is 120), which contains all of the decimal digits. We print out this number and then we use a neat feature of Hexagony: we print out the number mod 256 as an ASCII character. This just happens to be 95, or underscore.


答:
PowerShell v2+, 133 bytes

```<code>param($n)$a=1,1;1..$n|%{$a+=$a[$_-1]+$a[$_]*($_%2+1)};$a[0..$n]|%{$z=" "*$l+$_;if($i++%2){$x+=$z}else{$y+=$z}$l="$_".Length};$x;$y;$x
</code>```

44 bytes to calculate the values, 70 bytes to formulate the ASCII

Takes input $n as the zero-indexed column. Sets the start of our sequence array $a=1,1. We then loop up to $n with 1..$n|%{...} to construct the array. Each iteration, we concatenate on the sum of (two elements ago) + (the previous element)*(whether we're odd or even index). This will generate $a=1,1,3,4,11... up to $n+2.

So, we need to slice $a to only take the first 0..$n elements, and pipe those through another loop |%{...}. Each iteration we set helper $z equal to a number of spaces plus the current element as a string. Then, we're splitting out whether that gets concatenated onto $x (the top and bottom rows) or $y (the middle row) by a simple odd-even if/else. Then, we calculate the number of spaces for $l by taking the current number, stringifying it, and taking its .Length.

Finally, we put $x, $y, and $x again on the pipeline, and output is implicit. Since the default .ToString() separator for an array when printing to STDOUT is a newline, we get that for free.

Example

```<code>PS C:\Tools\Scripts\golfing> .\pascal-braid.ps1 27
 1 4  15  56   209   780    2911    10864     40545      151316      564719       2107560       7865521        29354524
1 3 11  41  153   571   2131    7953     29681     110771      413403      1542841       5757961       21489003
 1 4  15  56   209   780    2911    10864     40545      151316      564719       2107560       7865521        29354524
</code>```

Title: Generate Pascal's Braid

Body:
This is Pascal's Braid:

```<code> 1 4  15  56   209   780    2911    10864     40545      151316      564719
1 3 11  41  153   571   2131    7953     29681     110771      413403      1542841
 1 4  15  56   209   780    2911    10864     40545      151316      564719
</code>```

I totally made that up. Blaise Pascal didn't have a braid as far as I can tell, and if he did it was probably made of hair instead of numbers.

It's defined like this:

The first column has a single 1 in the middle.

The second column has a 1 at the top and at the bottom.

Now we alternate between putting a number in the middle or two copies of a number at the top and bottom.

If the number goes on the top or the bottom, it will be the sum of the two adjacent numbers (e.g. 56 = 15 + 41). If you tilt your head a little, this is like a step in Pascal's triangle.

If the number goes in the middle, it will be the sum of all three adjacent numbers (e.g. 41 = 15 + 11 + 15).

Your task will be to print (some part of) this braid.

Input

You should write a program or function, which receives a single integer n, giving the index of the last column to be output.

You may choose whether the first column (printing only a single 1 on the middle line) corresponds to n = 0 or n = 1. This has to be a consistent choice across all possible inputs.

Output

Output Pascal's Braid up to the nth column. The whitespace has to match exactly the example layout above, except that you may pad the shorter line(s) to the length of the longer line(s) with spaces and you may optionally output a single trailing linefeed.

In other words, every column should be exactly as wide as the number (or pair of equal numbers) in that column, numbers in successive columns should not overlap and there should be no spaces between columns.

You may either print the result to STDOUT (or the closest alternative), or if you write a function you may return either a string with the same contents or a list of three strings (one for each line).

Further Details

You may assume that n won't be less than the index of the first column (so not less than 0 or 1 depending on your indexing). You may also assume that the last number in the braid is less than 256 or the largest number representable by your language's native integer type, whichever is greater. So if your native integer type can only store bytes, you can assume that the largest n is 9 or 10 (depending on whether you use 0- or 1-based n) and if it can store signed 32-bit integers, n will be at most 33 or 34.

Standard code-golf rules apply. The shortest code wins.

OEIS

Here are a few relevant OEIS links. Of course, these contain spoilers for different ways to generate the numbers in the braid:

Top/bottom: A001353 or A010905 or A106707 or A195503

Middle: A001835 or A079935

Both: A002530

Test Cases

These test cases use 1-base indexing. Each test case is four lines, with the first being the input and the remaining three being the output.

```<code>1

1

---
2
 1
1
 1
---
3
 1
1 3
 1
---
5
 1 4
1 3 11
 1 4
---
10
 1 4  15  56   209
1 3 11  41  153
 1 4  15  56   209
---
15
 1 4  15  56   209   780    2911
1 3 11  41  153   571   2131    7953
 1 4  15  56   209   780    2911
---
24
 1 4  15  56   209   780    2911    10864     40545      151316      564719       2107560
1 3 11  41  153   571   2131    7953     29681     110771      413403      1542841
 1 4  15  56   209   780    2911    10864     40545      151316      564719       2107560
</code>```

Body:
PowerShell v2+, 133 bytes

param($n)$a=1,1;1..$n|%{$a+=$a[$_-1]+$a[$_]*($_%2+1)};$a[0..$n]|%{$z=" "*$l+$_;if($i++%2){$x+=$z}else{$y+=$z}$l="$_".Length};$x;$y;$x

44 bytes to calculate the values, 70 bytes to formulate the ASCII

Takes input $n as the zero-indexed column. Sets the start of our sequence array $a=1,1. We then loop up to $n with 1..$n|%{...} to construct the array. Each iteration, we concatenate on the sum of (two elements ago) + (the previous element)*(whether we're odd or even index). This will generate $a=1,1,3,4,11... up to $n+2.

So, we need to slice $a to only take the first 0..$n elements, and pipe those through another loop |%{...}. Each iteration we set helper $z equal to a number of spaces plus the current element as a string. Then, we're splitting out whether that gets concatenated onto $x (the top and bottom rows) or $y (the middle row) by a simple odd-even if/else. Then, we calculate the number of spaces for $l by taking the current number, stringifying it, and taking its .Length.

Finally, we put $x, $y, and $x again on the pipeline, and output is implicit. Since the default .ToString() separator for an array when printing to STDOUT is a newline, we get that for free.

Example

PS C:\Tools\Scripts\golfing> .\pascal-braid.ps1 27
 1 4  15  56   209   780    2911    10864     40545      151316      564719       2107560       7865521        29354524
1 3 11  41  153   571   2131    7953     29681     110771      413403      1542841       5757961       21489003
 1 4  15  56   209   780    2911    10864     40545      151316      564719       2107560       7865521        29354524


答:
JavaScript (ES6), 79 bytes

f=
n=>" ".repeat(n).replace(/./g,"$'/$`$`\\    \\\n").replace(/\/...../g,"/----/")
;```
<pre class="snippet-code-html lang-html prettyprint-override"><code><input type=number min=0 oninput=o.textContent=f(this.value)><pre id=o></code>```

Works by taking a string of n spaces, then doing some exotic substitution to get the slide with a support, then replacing the support with a ladder.

Title: Draw a ladder and slide

Body:
JavaScript (ES6), 79 bytes

f=
n=>" ".repeat(n).replace(/./g,"$'/$`$`\\    \\\n").replace(/\/...../g,"/----/")
;

<input type=number min=0 oninput=o.textContent=f(this.value)><pre id=o>

Works by taking a string of n spaces, then doing some exotic substitution to get the slide with a support, then replacing the support with a ladder.


问:
Count of "a"s and "b"s must be equal. Did you get it computer?
In the popular (and essential) computer science book, An Introduction to Formal Languages and Automata by Peter Linz, the following formal language is frequently stated:

$$\large{L=\{a^n b^n:n\in\mathbb{Z}^+\}}$$

mainly because this language can not be processed with finite-state automata.
This expression mean "Language L consists all strings of 'a's followed by 'b's, in which the number of 'a's and 'b's are equal and non-zero".

Challenge

Write a working program/function which gets a string, containing "a"s and "b"s only, as input and returns/outputs a truth value, saying if this string is valid the formal language L.

Your program cannot use any external computation tools, including network, external programs, etc. Shells are an exception to this rule; Bash, e.g., can use command line utilities.

Your program must return/output the result in a "logical" way, for example: returning 10 instead of 0, "beep" sound, outputting to stdout etc. More info here.

Standard code golf rules apply.

This is a code-golf. Shortest code in bytes wins. Good luck!

Truthy test cases

```<code>"ab"
"aabb"
"aaabbb"
"aaaabbbb"
"aaaaabbbbb"
"aaaaaabbbbbb"
</code>```

Falsy test cases

```<code>""
"a"
"b"
"aa"
"ba"
"bb"
"aaa"
"aab"
"aba"
"abb"
"baa"
"bab"
"bba"
"bbb"
"aaaa"
"aaab"
"aaba"
"abaa"
"abab"
"abba"
"abbb"
"baaa"
"baab"
"baba"
"babb"
"bbaa"
"bbab"
"bbba"
"bbbb"
</code>```

Leaderboard

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

/* Configuration */

var QUESTION_ID = 85994; // 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 = '
' + c.body.replace(OVERRIDE_REG, '') + '
';
    });

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

  });

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

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

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

    var lang = a.language;
    if (/ 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);
  }

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

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

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

table thead {
  font-weight: bold;
}

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
Grime, 12 bytes

```<code>A=\aA?\b
e`A
</code>```

Try it online!

Explanation

The first line defines a nonterminal A, which matches one letter a, possibly the nonterminal A, and then one letter b. The second line matches the entire input (e) against the nonterminal A.

8-byte noncompeting version

```<code>e`\a_?\b
</code>```

After writing the first version of this answer, I updated Grime to consider _ as the name of the top-level expression. This solution is equivalent to the above, but avoids repeating the label A.

Body:
Grime, 12 bytes

A=\aA?\b
e`A

Try it online!

Explanation

The first line defines a nonterminal A, which matches one letter a, possibly the nonterminal A, and then one letter b. The second line matches the entire input (e) against the nonterminal A.

8-byte noncompeting version

e`\a_?\b

After writing the first version of this answer, I updated Grime to consider _ as the name of the top-level expression. This solution is equivalent to the above, but avoids repeating the label A.


问:
Fibonacci function or sequence
The Fibonacci sequence is a sequence of numbers, where every number in the sequence is the sum of the two numbers preceding it.  The first two numbers in the sequence are both 1. Here are the first few terms:

```<code>1 1 2 3 5 8 13 21 34 55 89 ...
</code>```

Write the shortest code that either:

Generates the Fibonacci sequence without end.

Given n calculates the nth term of the sequence. (Either 1 or zero indexed)

You may use standard forms of input and output.

(I gave both options in case one is easier to do in your chosen language than the other.)

For the function that takes an n, a reasonably large return value (the largest Fibonacci number that fits your computer's normal word size, at a minimum) has to be supported.

Leaderboard

/* Configuration */

var QUESTION_ID = 85; // 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 = 3; // 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,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

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

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

function process() {
  var valid = [];

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

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

  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;
    lang = jQuery(''+lang+'').text();

    languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang, 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_raw.toLowerCase() > b.lang_raw.toLowerCase()) return 1;
    if (a.lang_raw.toLowerCase() < b.lang_raw.toLowerCase()) return -1;
    return 0;
  });

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

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

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

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

table thead {
  font-weight: bold;
}

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

答:
GolfScript, 13 chars

```<code>2,~{..p@+.}do
</code>```

(My answer from a previous Stack Overflow question.)

Title: Fibonacci function or sequence

Body:
GolfScript, 13 chars

2,~{..p@+.}do

(My answer from a previous Stack Overflow question.)

ContentLicense: CC BY-SA 2.5


答:
4.4 21 19 characters

Edit: Now meets all the criteria for 4.4.

```<code>c=(b<<=a>>=3)>>8|5;
</code>```

Title: m3ph1st0s's programming puzzle 4 (C/C++): “3-way swap”

Body:
My last puzzle has generated some confusion and controversy so I decided to give up, for now, on those "replace one character"-type puzzles.

Hope this 4th puzzle will redeem myself after all the edits in puzzle 3 and will put your brains at work once more.

I've really put up all the effort to make this one as clear as possible and hope you will enjoy it!

So here it goes:

We start from a very short C program:

```<code>int main() {
   int a = 93;
   int b = 11;
   int c = 22528;

   // insert your code here

}
</code>```

Your job will be to swap the values of the variables a,b,c like this: a <= b, b <= c, c <= a. To make it even more clear: new a = old b, new b = old c, new c = old a.

You are required to do this by inserting one single instruction in the line indicated by the comment in the code. To be clear once again, this line will contain only one semicolon (;) indicating the end of the lone instruction. After the execution of this program, a will contain 11, b will contain 22528, c will contain 93.
However, there are some conditions that need to be met. So we'll have 4 different puzzles with different cryteria.

4.1. Do it by using whatever you want. Just one statement. -> most creative solution wins this one.

4.2. Do it without using any comma (,). -> most creative wins

4.3. Do it without any comma and with no more than 4 letters (+any other characters). -> shortest code wins

4.4. Do it without any comma and with no more than 4 letters and no more than 4 digits (+any other characters). -> shortest code wins

To make sure you understood, here's some code that is valid under the condition required but does not solve the problem:

4.1:

```<code>I_hereby_call_my_beautiful_function(nice_argument), int q=w, who_the_hell_is(w)+1;
</code>```

4.2:

```<code>one = single + assignment;
</code>```

4.3:

```<code>int w=12345678;
</code>```

4.4:

```<code>int w=1234;
</code>```

P.S. In case you haven't already noticed, 4.4 is the tough one here (I hope :D).

Body:
4.4 21 19 characters

Edit: Now meets all the criteria for 4.4.

c=(b<<=a>>=3)>>8|5;


答:
C (Ansi), <s>65</s> 75 Bytes

Golfed:

```<code>l(b,i,j,k)char*b;{for(i=j=0;(k=b[i++])>0&k<=b[i];)j+=2*(k>97)-1;return !j;}
</code>```

Explanation:

Sets a value j and increments j on each b and decrements j on anything else.
Checked if the letter before is less than or equal the next letter so prevent abab from working

Edits

Added checks for abab cases.

Title: Count of "a"s and "b"s must be equal. Did you get it computer?

Body:
In the popular (and essential) computer science book, An Introduction to Formal Languages and Automata by Peter Linz, the following formal language is frequently stated:

$$\large{L=\{a^n b^n:n\in\mathbb{Z}^+\}}$$

mainly because this language can not be processed with finite-state automata.
This expression mean "Language L consists all strings of 'a's followed by 'b's, in which the number of 'a's and 'b's are equal and non-zero".

Challenge

Write a working program/function which gets a string, containing "a"s and "b"s only, as input and returns/outputs a truth value, saying if this string is valid the formal language L.

Your program cannot use any external computation tools, including network, external programs, etc. Shells are an exception to this rule; Bash, e.g., can use command line utilities.

Your program must return/output the result in a "logical" way, for example: returning 10 instead of 0, "beep" sound, outputting to stdout etc. More info here.

Standard code golf rules apply.

This is a code-golf. Shortest code in bytes wins. Good luck!

Truthy test cases

```<code>"ab"
"aabb"
"aaabbb"
"aaaabbbb"
"aaaaabbbbb"
"aaaaaabbbbbb"
</code>```

Falsy test cases

```<code>""
"a"
"b"
"aa"
"ba"
"bb"
"aaa"
"aab"
"aba"
"abb"
"baa"
"bab"
"bba"
"bbb"
"aaaa"
"aaab"
"aaba"
"abaa"
"abab"
"abba"
"abbb"
"baaa"
"baab"
"baba"
"babb"
"bbaa"
"bbab"
"bbba"
"bbbb"
</code>```

Leaderboard

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

/* Configuration */

var QUESTION_ID = 85994; // 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 = '
' + c.body.replace(OVERRIDE_REG, '') + '
';
    });

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

  });

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

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

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

    var lang = a.language;
    if (/ 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);
  }

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

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

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

table thead {
  font-weight: bold;
}

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
C (Ansi), <s>65</s> 75 Bytes

Golfed:

l(b,i,j,k)char*b;{for(i=j=0;(k=b[i++])>0&k<=b[i];)j+=2*(k>97)-1;return !j;}

Explanation:

Sets a value j and increments j on each b and decrements j on anything else.
Checked if the letter before is less than or equal the next letter so prevent abab from working

Edits

Added checks for abab cases.