问:
Invalid Invali Inval
This idea is loosely based upon @TùxCräftîñg's chat message.

Take a look at the below example sequence:

INVALID0, INVALID1, INVALID2 INVALID3, INVALID4... INVALID9

After INVALID9, it goes on like this:

INVALI0, INVALI1, INVALI2, INVALI3... INVALI9

And after INVALI9, it's like this:

INVAL0,INVAL1, INVAL2, INVAL3... INVAL9

After, INVAL9, it's like this:

INVA0, INVA1, INVA2, INVA3, ... INVA9

Notice how we we kept removing a letter from the word INVALID each time.

You'll keep repeating this until you reach a single letter, that is, the letter I:

I0, I1, I2, I3, I4 ... I9

Now, your task is, to take an input of a word, and produce a sequence from it like the above example. Your code must also work with single letters, and in that case the resulting sequence will be shorter.

You may choose any input and output format that you prefer (with or without a separator, as you wish), but you must specify which one you have chosen.

The sequence needs to be in the exact specified order.

The shortest code, in bytes, that successfully completes this challenge, wins the challenge.

Full sequence in the above example:

```<code>INVALID0, INVALID1, INVALID2, INVALID3, INVALID4, INVALID5, INVALID6, INVALID7, INVALID8, INVALID9, INVALI0, INVALI1, INVALI2, INVALI3, INVALI4, INVALI5, INVALI6, INVALI7, INVALI8, INVALI9, INVAL0, INVAL1, INVAL2, INVAL3, INVAL4, INVAL5, INVAL6, INVAL7, INVAL8, INVAL9, INVA0, INVA1, INVA2, INVA3, INVA4, INVA5, INVA6, INVA7, INVA8, INVA9, INV0, INV1, INV2, INV3, INV4, INV5, INV6, INV7, INV8, INV9, IN0, IN1, IN2, IN3, IN4, IN5, IN6, IN7, IN8, IN9, I0, I1, I2, I3, I4, I5, I6, I7, I8, I9
</code>```

Other examples:

Input: MAYBE (Uppercase and lowercase don't matter)

Output:

```<code>MAYBE0, MAYBE1, MAYBE2, MAYBE3, MAYBE4, MAYBE5, MAYBE6, MAYBE7, MAYBE8, MAYBE9, MAYB0, MAYB1, MAYB2, MAYB3, MAYB4, MAYB5, MAYB6, MAYB7, MAYB8, MAYB9, MAY0, MAY1, MAY2, MAY3, MAY4, MAY5, MAY6, MAY7, MAY8, MAY9, MA0, MA1, MA2, MA3, MA4, MA5, MA6, MA7, MA8, MA9, M0, M1, M2, M3, M4, M5, M6, M7, M8, M9
</code>```

Input: AFTER

Output:

```<code>AFTER0, AFTER1, AFTER2, AFTER3, AFTER4, AFTER5, AFTER6, AFTER7, AFTER8, AFTER9, AFTE0, AFTE1, AFTE2, AFTE3, AFTE4, AFTE5, AFTE6, AFTE7, AFTE8, AFTE9, AFT0, AFT1, AFT2, AFT3, AFT4, AFT5, AFT6, AFT7, AFT8, AFT9, AF0, AF1, AF2, AF3, AF4, AF5, AF6, AF7, AF8, AF9, A0, A1, A2, A3, A4, A5, A6, A7, A8, A9
</code>```

Input: WHAT ARE YOU DOING

```<code>WHAT ARE YOU DOING0, WHAT ARE YOU DOING1, WHAT ARE YOU DOING2, WHAT ARE YOU DOING3, WHAT ARE YOU DOING4, WHAT ARE YOU DOING5, WHAT ARE YOU DOING6, WHAT ARE YOU DOING7, WHAT ARE YOU DOING8, WHAT ARE YOU DOING9, WHAT ARE YOU DOIN0, WHAT ARE YOU DOIN1, WHAT ARE YOU DOIN2, WHAT ARE YOU DOIN3, WHAT ARE YOU DOIN4, WHAT ARE YOU DOIN5, WHAT ARE YOU DOIN6, WHAT ARE YOU DOIN7, WHAT ARE YOU DOIN8, WHAT ARE YOU DOIN9, WHAT ARE YOU DOI0, WHAT ARE YOU DOI1, WHAT ARE YOU DOI2, WHAT ARE YOU DOI3, WHAT ARE YOU DOI4, WHAT ARE YOU DOI5, WHAT ARE YOU DOI6, WHAT ARE YOU DOI7, WHAT ARE YOU DOI8, WHAT ARE YOU DOI9, WHAT ARE YOU DO0, WHAT ARE YOU DO1, WHAT ARE YOU DO2, WHAT ARE YOU DO3, WHAT ARE YOU DO4, WHAT ARE YOU DO5, WHAT ARE YOU DO6, WHAT ARE YOU DO7, WHAT ARE YOU DO8, WHAT ARE YOU DO9, WHAT ARE YOU D0, WHAT ARE YOU D1, WHAT ARE YOU D2, WHAT ARE YOU D3, WHAT ARE YOU D4, WHAT ARE YOU D5, WHAT ARE YOU D6, WHAT ARE YOU D7, WHAT ARE YOU D8, WHAT ARE YOU D9, WHAT ARE YOU 0, WHAT ARE YOU 1, WHAT ARE YOU 2, WHAT ARE YOU 3, WHAT ARE YOU 4, WHAT ARE YOU 5, WHAT ARE YOU 6, WHAT ARE YOU 7, WHAT ARE YOU 8, WHAT ARE YOU 9, WHAT ARE YOU0, WHAT ARE YOU1, WHAT ARE YOU2, WHAT ARE YOU3, WHAT ARE YOU4, WHAT ARE YOU5, WHAT ARE YOU6, WHAT ARE YOU7, WHAT ARE YOU8, WHAT ARE YOU9, WHAT ARE YO0, WHAT ARE YO1, WHAT ARE YO2, WHAT ARE YO3, WHAT ARE YO4, WHAT ARE YO5, WHAT ARE YO6, WHAT ARE YO7, WHAT ARE YO8, WHAT ARE YO9, WHAT ARE Y0, WHAT ARE Y1, WHAT ARE Y2, WHAT ARE Y3, WHAT ARE Y4, WHAT ARE Y5, WHAT ARE Y6, WHAT ARE Y7, WHAT ARE Y8, WHAT ARE Y9, WHAT ARE 0, WHAT ARE 1, WHAT ARE 2, WHAT ARE 3, WHAT ARE 4, WHAT ARE 5, WHAT ARE 6, WHAT ARE 7, WHAT ARE 8, WHAT ARE 9, WHAT ARE0, WHAT ARE1, WHAT ARE2, WHAT ARE3, WHAT ARE4, WHAT ARE5, WHAT ARE6, WHAT ARE7, WHAT ARE8, WHAT ARE9, WHAT AR0, WHAT AR1, WHAT AR2, WHAT AR3, WHAT AR4, WHAT AR5, WHAT AR6, WHAT AR7, WHAT AR8, WHAT AR9, WHAT A0, WHAT A1, WHAT A2, WHAT A3, WHAT A4, WHAT A5, WHAT A6, WHAT A7, WHAT A8, WHAT A9, WHAT 0, WHAT 1, WHAT 2, WHAT 3, WHAT 4, WHAT 5, WHAT 6, WHAT 7, WHAT 8, WHAT 9, WHAT0, WHAT1, WHAT2, WHAT3, WHAT4, WHAT5, WHAT6, WHAT7, WHAT8, WHAT9, WHA0, WHA1, WHA2, WHA3, WHA4, WHA5, WHA6, WHA7, WHA8, WHA9, WH0, WH1, WH2, WH3, WH4, WH5, WH6, WH7, WH8, WH9, W0, W1, W2, W3, W4, W5, W6, W7, W8, W9
</code>```

Leaderboard

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
Groovy (58 Bytes)

No idea why I'm even bothering to post a Groovy answer... The minimum required size for a Groovy golf is 2 based on needing a closure, so the best answer here is double my minimum size.

```<code>   {s->(s.length()-1..0).each{c->10.times{print s[0..c]+it}}}
</code>```

Try it here: https://groovyconsole.appspot.com/script/5148433803378688

Title: Invalid Invali Inval

Body:
Groovy (58 Bytes)

No idea why I'm even bothering to post a Groovy answer... The minimum required size for a Groovy golf is 2 based on needing a closure, so the best answer here is double my minimum size.

   {s->(s.length()-1..0).each{c->10.times{print s[0..c]+it}}}

Try it here: https://groovyconsole.appspot.com/script/5148433803378688


问:
Faux Source Code
Output one random character for each character of source code (as illustrated below). The probability of each character is its frequency in the original source code. Thus the output will be fake source code resembling a quine.

Specification

Restrictions

Standard quine constrains apply. No empty programs or functions. Also no reading your own source.

Output

The number of characters output should be exactly the number of characters in the source code

Each output character should be randomly choosen

The probability of choosing any character is equal to (occurrences in source) / (length of source)

This means that even a unary solution needs to 'randomly' choose 1 with probability 1. Which is to say that the output can't be hard coded.

Winning

This is code golf, so fewest bytes wins

Example

```<code>Program           Frequency           Probability           Possible Output
-------           ---------           -----------           ---------------
 a@!@              a - 1               a - 25%               @@a@
                   ! - 1               ! - 25%
                   @ - 2               @ - 50%
</code>```

```<code>Program           Frequency           Probability           Possible Output
-------           ---------           -----------           ---------------
caBaDBcDaBDB       a - 3               a - 25%               aaaBBBBccDDD
                   B - 4               B - 33%
                   c - 2               c - 17%
                   D - 3               D - 25%
</code>```

答:
Dyalog APL, 20 bytes

f←{(,⎕CR'f')[?⍴⍨20]}
```
<p><code>f←{</code>...<code>}</code> define <strong>f</strong> as</p>
<p><code>(,⎕CR'f')</code> listified (<code>,</code>) <strong>C</strong>haracter (table) <strong>R</strong>epresentation (<code>⎕CR</code>) of <strong>f</strong> (<code>'f'</code>)</p>
<p><code>[?⍴⍨20]</code> indexed with (<code>[</code>...<code>]</code>) random-up-to (<code>?</code>) repeat-itself-times (<code>⍴⍨</code>) of twenty</p>
<p>Let us run it (with a dummy argument) a few times:</p>
<pre class="lang-apl prettyprint-override"><code>      f⍬
)0'0](⍨(([],}⎕))⎕'f2
      f⍬
{'['}f[←R[)2←?}⍨]}C2
      f⍬
,,⍨←?2}⍴?'⍨}C,'{⎕(C0
</code>```

Fine, but is the distribution correct? Let us run it on 10,000 dummy arguments and see how many times each character occurs:

      {⍺ , 1E¯4× ⍴⍵}⌸ ∊ f¨ ⍳1E4
C 0.9952
⎕ 0.9996
' 1.9777
f 2.004
← 1.0018
⍨ 1.0173
0 1.0213
] 1.0049
[ 0.9988
2 0.9943
{ 0.9895
) 1.0093
R 1.0054
, 1.0029
? 0.9943
} 0.9861
⍴ 1.0032
( 0.9944
```
<p>Clearly, <code>f</code> and <code>'</code> occur twice as often as the other characters, just like in the original source code.</p>
<p>How did we do it?</p>
<pre class="lang-apl prettyprint-override"><code>{⍺ , 1E¯4× ⍴⍵}⌸ ∊ f¨ ⍳1E4`
</code>```

⍳1E4 generates the first 10,000 integers

f¨ runs f on each of those numbers

∊ flattens all the pseudo-quines into a single 200,000-character string

⌸ is a higher-order function which for each unique character in the right side  data, feeds the left-side function the unique element as left-argument and the indices where that character occurs as right-argument. The left-side function is

{⍺ , 1E¯4× ⍴⍵}
```

⍺ left-argument, i.e. the unique character

, followed by

1E¯4× 1×10⁻⁴ times

⍴⍵ the shape of the right-argument (the occurrence indices), i.e.how many times it occurs

Finally, ⌸ puts it all together in a table.

ContentLicense: CC BY-SA 3.0

Title: Faux Source Code

Body:
Dyalog APL, 20 bytes

f←{(,⎕CR'f')[?⍴⍨20]}

f←{...} define f as

(,⎕CR'f') listified (,) Character (table) Representation (⎕CR) of f ('f')

[?⍴⍨20] indexed with ([...]) random-up-to (?) repeat-itself-times (⍴⍨) of twenty

Let us run it (with a dummy argument) a few times:

      f⍬
)0'0](⍨(([],}⎕))⎕'f2
      f⍬
{'['}f[←R[)2←?}⍨]}C2
      f⍬
,,⍨←?2}⍴?'⍨}C,'{⎕(C0

Fine, but is the distribution correct? Let us run it on 10,000 dummy arguments and see how many times each character occurs:

      {⍺ , 1E¯4× ⍴⍵}⌸ ∊ f¨ ⍳1E4
C 0.9952
⎕ 0.9996
' 1.9777
f 2.004
← 1.0018
⍨ 1.0173
0 1.0213
] 1.0049
[ 0.9988
2 0.9943
{ 0.9895
) 1.0093
R 1.0054
, 1.0029
? 0.9943
} 0.9861
⍴ 1.0032
( 0.9944

Clearly, f and ' occur twice as often as the other characters, just like in the original source code.

How did we do it?

{⍺ , 1E¯4× ⍴⍵}⌸ ∊ f¨ ⍳1E4`

⍳1E4 generates the first 10,000 integers

f¨ runs f on each of those numbers

∊ flattens all the pseudo-quines into a single 200,000-character string

⌸ is a higher-order function which for each unique character in the right side  data, feeds the left-side function the unique element as left-argument and the indices where that character occurs as right-argument. The left-side function is

{⍺ , 1E¯4× ⍴⍵}

⍺ left-argument, i.e. the unique character

, followed by

1E¯4× 1×10⁻⁴ times

⍴⍵ the shape of the right-argument (the occurrence indices), i.e.how many times it occurs

Finally, ⌸ puts it all together in a table.


问:
Output "Lorem ipsum" with minimal number of characters
I remember people saying that code size should be measured in bytes, and not in characters, because it's possible to store information with weird Unicode characters, which have no visual meaning.

How bad can it be?

In this challenge, you should output the following Lorem Ipsum text, taken from Wikipedia:

```<code>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</code>```

Please specify the number of characters (not bytes) in your code. Code with the minimal number of characters wins.

Your code should only contain valid Unicode characters, as described here, that is:

Code points up to U+10FFFF

No surrogates (the range D800–DBFF is forbidden)

No characters FFFE and FFFF

No null characters (code 0)

If your code cannot be displayed, provide a version with offending characters redacted, and a hexdump.

Some notes:

The output must be one long line (445 characters). If your system cannot do that (e.g. you're printing it on paper), output a closest approximation. Trailing linebreaks don't matter.

Built-in functions that generate Lorem Ipsum text are not allowed

Please specify a valid text encoding for your code, if relevant

答:
MATL, 354 characters

```<code>'8 sxAI($ltZ>2<xa`vYf:s2e9]c&^KtD%e{C*XEpQ]]>dwmi>2;{sUCIZ{V(}Yj 7K&)|,%JD/Pz^:3$*@vVJw)4pgvz4s_$,%pVGu~|PS/Qr7pz5Z2[VV{Lyq}{l!yGiKNg.zFJxL75 sT1]eL2f3iVe~11!|6c+O9.kMWFQYvEp^w0p oH,?Ey"nbV>0g`#)kqTq""" z_AYmyJutvg:o9&AT{#(<42wu.b7" QoOn\#])]ISdH$yc{eM> .[~/`"#2:7C4Mk@eRW8L*_!xjo\cO)!LHK=g:P?&Uc];KdnE(%K7J-z9:7&rhxHl/KZ8\t_C|rT#%28[%+#u.?'F2Y2' ,.DEL'hZa
</code>```

This decodes from base-94 (using the printable ASCII chars except single quote; so only Unicode characters up to 126 are used) to the alphabet of required characters, formed by most lowercase letters, some uppercase letters, space, comma, and period.

It takes a few seconds in the online compiler.

Try it online!

Body:
MATL, 354 characters

'8 sxAI($ltZ>2<xa`vYf:s2e9]c&^KtD%e{C*XEpQ]]>dwmi>2;{sUCIZ{V(}Yj 7K&)|,%JD/Pz^:3$*@vVJw)4pgvz4s_$,%pVGu~|PS/Qr7pz5Z2[VV{Lyq}{l!yGiKNg.zFJxL75 sT1]eL2f3iVe~11!|6c+O9.kMWFQYvEp^w0p oH,?Ey"nbV>0g`#)kqTq""" z_AYmyJutvg:o9&AT{#(<42wu.b7" QoOn\#])]ISdH$yc{eM> .[~/`"#2:7C4Mk@eRW8L*_!xjo\cO)!LHK=g:P?&Uc];KdnE(%K7J-z9:7&rhxHl/KZ8\t_C|rT#%28[%+#u.?'F2Y2' ,.DEL'hZa

This decodes from base-94 (using the printable ASCII chars except single quote; so only Unicode characters up to 126 are used) to the alphabet of required characters, formed by most lowercase letters, some uppercase letters, space, comma, and period.

It takes a few seconds in the online compiler.

<a href="http://matl.tryitonline.net/#code=JyU5PmQiX300c1BzZEIrZU1uI3F5bzElS1ExZDc3VkhGeTY0JEUoPXhOYiRXTHZvTWlcbnNyVHcjKyJrR0tkYE51XD1VZWlefXJaU3EiYS1LLnZ7T3YwNG84bTw5fD5wUiIzeHMsVFkldk5bYGAgSCh8IE8heFxlMFoydnMzYm86dSgwNmRrJiR6JSA_JCVVPW0sPTpXJWp8KEVAKCVhNk0qP30xU2pCMz1VYmZHLjQ0c2orLmcmbjYiSEg7RUcxZFI6d11pQ31WYEZAKnFwNnR3RVJgVyJ6al86LjMuTkxGLUVGSVBsUjxIcjBYZ2slV1tiTigqeyAkOT5OYCg4IztMeildK0ZNdkB1flIrQGlaN119SDVMOm1EOHBPWU4qYVIhZC41UVJ-OUhSIyJjLy8tfTs0e15ENTRiWXd-IWB1dHlNXWBNbCdGMlkyJ2prd3l6J1gtJyAsLkRFTFUnaFph&input=" rel="nofollow">Try it online!


问:
Sample win/loss data generator based on certain criteria
Lets say we have this existing data:

```<code>Total - 10
Won   -  7
Lost  -  3
Longest Winning Streak - 5
Longest Losing Streak - 2
</code>```

Now you need to write a function which generates an array of random boolean values (true representing a win and false representing a loss) which fulfills the above criteria.

So, in this case the output can be any of the following:

```<code>0011011111
1111101100
1010011111
..........
</code>```

Rules:

Solution must be function which takes in Won, Lost, Longest Winning Streak and Longest Losing Streak and returns a boolean array or string formed of a boolean array like (110011001010). It can also display output instead of returning the generated data.

You can safely assume there are no ties/draws/no-results.

This is code-golf so shortest code wins.

Input format can be in any form (Standard Input/Command-Line,etc.). And the real input format should be - <Won> <Lost> <LWS> <LLS> where <..> are place-holders or they can be separate parameters for the function.. whatever you deem best for your code. The parameter Total is unnecessary. So you needn't use it.

As far as random is concerned, you can see that in the example, there are three (and more) possible outputs. Just output any one at random.

If you have any other question, ask in the comments below.

Important - Not any answer as of now is correct.

I provide another example (this one's real data) which is possible but not working with the codes in the current answers:

```<code>Total - 171
Won   - 111
Lost  -  60
Longest Winning Streak - 10
Longest Losing Streak  - 4
</code>```

Real Data:

```<code>1110110100111111010000101111111100110001100110111101101011111011011011011111111110110001111011010001101011100101111101001011011110101101001100001111101010110001111110111111
</code>```

Another possible output (Basically the same, just the third and fourth digits are interchanged):

```<code>1101110100111111010000101111111100110001100110111101101011111011011011011111111110110001111011010001101011100101111101001011011110101101001100001111101010110001111110111111
</code>```

答:
R - (I don't know how to calculate bytes)

```<code> a <- read.csv("a.csv")
 b <- seq(1,1, seq.length = a$3)
 a$1 <- a$1-a$3
 c <- seq(0,0, seq.length = a$4)
 a$2 <- a$2 - a$4
 append(b,c)
 d <- a$1 + a$2
 while(d >= 0){append(b,c(1,0)); d <- d-2}
 d
</code>```

where a.csv is a file with the four inputs separated by commas. This program will output a long string of 1's (for the win streak), and then a long string of 0's for the loss streak, and finally a long string of 0,1 for the rest of the games.

Body:
R - (I don't know how to calculate bytes)

 a <- read.csv("a.csv")
 b <- seq(1,1, seq.length = a$3)
 a$1 <- a$1-a$3
 c <- seq(0,0, seq.length = a$4)
 a$2 <- a$2 - a$4
 append(b,c)
 d <- a$1 + a$2
 while(d >= 0){append(b,c(1,0)); d <- d-2}
 d

where a.csv is a file with the four inputs separated by commas. This program will output a long string of 1's (for the win streak), and then a long string of 0's for the loss streak, and finally a long string of 0,1 for the rest of the games.


问:
Convert to Bubble Letters
So I was playing around with my compose key, and found some cool things, one of them being that by pressing compose + ( + alphanumeric + ), you get that character inside a bubble, like so: ⓐ.

Your task in this challenge is simple, to convert ordinary text to bubble letter text.

Here are the ascii chars, the bubble characters and their Unicode code points:

```<code>0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
⓪①②③④⑤⑥⑦⑧⑨ⓐⓑⓒⓓⓔⓕⓖⓗⓘⓙⓚⓛⓜⓝⓞⓟⓠⓡⓢⓣⓤⓥⓦⓧⓨⓩⒶⒷⒸⒹⒺⒻⒼⒽⒾⒿⓀⓁⓂⓃⓄⓅⓆⓇⓈⓉⓊⓋⓌⓍⓎⓏ
9450 9312 9313 9314 9315 9316 9317 9318 9319 9320 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423
</code>```

Your input will contain only printable ascii characters, and if a character cannot be bubbleified, leave it as is.

This is code-golf, so shortest code in bytes wins!

Note: This is not isomorphic to my earlier challenge about small-caps conversion since unlike small-caps, bubble letters are in a mostly contiguous segment of code-points, allowing for more interesting approaches.

Title: Convert to Bubble Letters

Body:
Groovy (135 Bytes)

b=(9312..9320)+(9424..9450)+(9398..9423);r=('0'..'9')+('a'..'z')+('A'..'Z');x={s->s.collect{(x=r.indexOf(it))>=0?(char)b[x]:it}}.join()

https://groovyconsole.appspot.com/script/5189010641125376


问:
Bubble sorting in progress
Create a function or program that takes two inputs:

A list of integers that shall be sorted (less than 20 elements)

A positive integer, N, saying how many comparisons you should take

The function shall stop, and output the resulting list of integers after N comparisons. If the list is fully sorted before N comparisons are made, then the sorted list should be outputted.

The Bubble sort algorithm is well known, and I guess most people know it. The following Pseudo-code and animation (both from the linked Wikipedia-article) should provide the necessary details:

```<code>procedure bubbleSort( A : list of sortable items )
   n = length(A)
   repeat
     swapped = false
     for i = 1 to n-1 inclusive do
       /* if this pair is out of order */
       if A[i-1] > A[i] then
         /* swap them and remember something changed */
         swap( A[i-1], A[i] )
         swapped = true
       end if
     end for
   until not swapped
end procedure
</code>```

The animation below shows the progress:

An example (taken directly from the linked Wikipedia article) shows the steps when sorting the list: ( 5 1 4 2 8 ):

First Pass

```<code>1: ( 5 1 4 2 8 ) ->  ( 1 5 4 2 8 ) // Here, algorithm compares the first two elements,
                                   // and swaps since 5 > 1.
2: ( 1 5 4 2 8 ) ->  ( 1 4 5 2 8 ) // Swap since 5 > 4
3: ( 1 4 5 2 8 ) ->  ( 1 4 2 5 8 ) // Swap since 5 > 2
4: ( 1 4 2 5 8 ) ->  ( 1 4 2 5 8 ) // Now, since these elements are already in order
                                   // (8 > 5), algorithm does not swap them.
</code>```

Second Pass

```<code>5: ( 1 4 2 5 8 ) ->  ( 1 4 2 5 8 )
6: ( 1 4 2 5 8 ) ->  ( 1 2 4 5 8 ) // Swap since 4 > 2
7: ( 1 2 4 5 8 ) ->  ( 1 2 4 5 8 )
8: ( 1 2 4 5 8 ) ->  ( 1 2 4 5 8 )
</code>```

Now, the array is already sorted, but the algorithm does not know if it is completed. The algorithm needs one whole pass without any swap to know it is sorted.

Third Pass

```<code>9: ( 1 2 4 5 8 ) ->  ( 1 2 4 5 8 )
10:( 1 2 4 5 8 ) ->  ( 1 2 4 5 8 )
11:( 1 2 4 5 8 ) ->  ( 1 2 4 5 8 )
12:( 1 2 4 5 8 ) ->  ( 1 2 4 5 8 )
</code>```

Test cases:

Format: Number of comparisons (N): List after N comparisons

```<code>Input list:
5  1  4  2  8
Test cases:
1: 1  5  4  2  8
2: 1  4  5  2  8
3: 1  4  2  5  8
4: 1  4  2  5  8
5: 1  4  2  5  8
6: 1  2  4  5  8
10: 1  2  4  5  8
14: 1  2  4  5  8

Input list:
0: 15  18  -6  18   9  -7  -1   7  19  19  -5  20  19   5  15  -5   3  18  14  19
Test cases:
1: 15  18  -6  18   9  -7  -1   7  19  19  -5  20  19   5  15  -5   3  18  14  19
21: -6  15  18   9  -7  -1   7  18  19  -5  19  19   5  15  -5   3  18  14  19  20
41: -6   9  -7  15  -1   7  18  18  -5  19  19   5  15  -5   3  18  14  19  19  20
60: -6  -7  -1   9   7  15  18  -5  18  19   5  15  -5   3  18  14  19  19  19  20
61: -6  -7  -1   7   9  15  18  -5  18  19   5  15  -5   3  18  14  19  19  19  20
81: -7  -6  -1   7   9  15  -5  18  18   5  15  -5   3  18  14  19  19  19  19  20
119: -7  -6  -1  -5   7   9  15   5  15  -5   3  18  14  18  18  19  19  19  19  20
120: -7  -6  -1  -5   7   9  15   5  15  -5   3  18  14  18  18  19  19  19  19  20
121: -7  -6  -1  -5   7   9   5  15  15  -5   3  18  14  18  18  19  19  19  19  20
122: -7  -6  -1  -5   7   9   5  15  15  -5   3  18  14  18  18  19  19  19  19  20
123: -7  -6  -1  -5   7   9   5  15  -5  15   3  18  14  18  18  19  19  19  19  20
201: -7  -6  -5  -1  -5   3   5   7   9  14  15  15  18  18  18  19  19  19  19  20
221: -7  -6  -5  -5  -1   3   5   7   9  14  15  15  18  18  18  19  19  19  19  20
</code>```

Yes, built-in Bubble sort algorithms are permitted.

No, you can not assume only positive integers, or unique integers.

The sorting must be in the order described above. You can't start at the end of the list

答:
JavaScript (ES6), <s>102</s> <s>82</s> <s>80</s> <s>86</s> 80 bytes

Bug fix and 1 byte saved thanks to @edc65

```<code>(a,m)=>eval("for(i=0;m;a[j=i-1]>(b=a[i])?a[a[i]=a[j],j]=b:0)1/a[++i]?m--:i=0;a")
</code>```

Recursion <s>may not be</s> <s>is definitely not</s> is probably the best approach, but I'm sticking with a loop for now.

Try it out:

f=(a,m)=>eval("for(i=0;m;a[j=i-1]>(b=a[i])?a[a[i]=a[j],j]=b:0)1/a[++i]?m--:i=0;a")```
<pre class="snippet-code-html lang-html prettyprint-override"><code>Enter your numbers:<br>
<input id=A rows=10 value="5 1 4 2 8"><br>
Enter the number of steps:<br>
<input type="number" min=0 id=B rows=10 value="1"><br>
<button onclick="C.innerHTML=f((A.value.match(/-?\d+/g)||[]).map(Number),B.value)">Run</button><br>
<pre id=C>``````

Title: Bubble sorting in progress

Body:
JavaScript (ES6), <s>102</s> <s>82</s> <s>80</s> <s>86</s> 80 bytes

Bug fix and 1 byte saved thanks to @edc65

(a,m)=>eval("for(i=0;m;a[j=i-1]>(b=a[i])?a[a[i]=a[j],j]=b:0)1/a[++i]?m--:i=0;a")

Recursion <s>may not be</s> <s>is definitely not</s> is probably the best approach, but I'm sticking with a loop for now.

Try it out:

f=(a,m)=>eval("for(i=0;m;a[j=i-1]>(b=a[i])?a[a[i]=a[j],j]=b:0)1/a[++i]?m--:i=0;a")

Enter your numbers:<br>
<input id=A rows=10 value="5 1 4 2 8"><br>
Enter the number of steps:<br>
<input type="number" min=0 id=B rows=10 value="1"><br>
<button onclick="C.innerHTML=f((A.value.match(/-?\d+/g)||[]).map(Number),B.value)">Run</button><br>
<pre id=C></pre>


答:
Groovy (101 Bytes)

```<code>{l,n->(l.size()..0).each{i->(0..i-2).each{if(l[it]>l[it+1] && n>0 && it>-1){l.swap(it,it+1)};n--}};l}
</code>```

EDIT: I didn't need to write my own swap closure, groovy had this built in.

Try it here: https://groovyconsole.appspot.com/script/5104724189642752

Example Output Trace:

```<code>4:[1, 5, 4, 2, 8]
3:[1, 4, 5, 2, 8]
2:[1, 4, 2, 5, 8]
1:[1, 4, 2, 5, 8]
0:[1, 4, 2, 5, 8] - Locks in the final answer.
-1:[1, 4, 2, 5, 8]
-2 (Return):[1, 4, 2, 5, 8]
</code>```

Old Implementation (122 Bytes)

```<code>m={l,n->s={x,y->t=l[x];l[x]=l[y];l[y]=t};((l.size()-2)..2).each{i->(0..i).each{if(l[it]>l[it+1] && n){s(it,it+1)};n--}};l}
</code>```

Try it here: https://groovyconsole.appspot.com/script/6316871066320896

Title: Bubble sorting in progress

Body:
Create a function or program that takes two inputs:

A list of integers that shall be sorted (less than 20 elements)

A positive integer, N, saying how many comparisons you should take

The function shall stop, and output the resulting list of integers after N comparisons. If the list is fully sorted before N comparisons are made, then the sorted list should be outputted.

The Bubble sort algorithm is well known, and I guess most people know it. The following Pseudo-code and animation (both from the linked Wikipedia-article) should provide the necessary details:

```<code>procedure bubbleSort( A : list of sortable items )
   n = length(A)
   repeat
     swapped = false
     for i = 1 to n-1 inclusive do
       /* if this pair is out of order */
       if A[i-1] > A[i] then
         /* swap them and remember something changed */
         swap( A[i-1], A[i] )
         swapped = true
       end if
     end for
   until not swapped
end procedure
</code>```

The animation below shows the progress:

An example (taken directly from the linked Wikipedia article) shows the steps when sorting the list: ( 5 1 4 2 8 ):

First Pass

```<code>1: ( 5 1 4 2 8 ) ->  ( 1 5 4 2 8 ) // Here, algorithm compares the first two elements,
                                   // and swaps since 5 > 1.
2: ( 1 5 4 2 8 ) ->  ( 1 4 5 2 8 ) // Swap since 5 > 4
3: ( 1 4 5 2 8 ) ->  ( 1 4 2 5 8 ) // Swap since 5 > 2
4: ( 1 4 2 5 8 ) ->  ( 1 4 2 5 8 ) // Now, since these elements are already in order
                                   // (8 > 5), algorithm does not swap them.
</code>```

Second Pass

```<code>5: ( 1 4 2 5 8 ) ->  ( 1 4 2 5 8 )
6: ( 1 4 2 5 8 ) ->  ( 1 2 4 5 8 ) // Swap since 4 > 2
7: ( 1 2 4 5 8 ) ->  ( 1 2 4 5 8 )
8: ( 1 2 4 5 8 ) ->  ( 1 2 4 5 8 )
</code>```

Now, the array is already sorted, but the algorithm does not know if it is completed. The algorithm needs one whole pass without any swap to know it is sorted.

Third Pass

```<code>9: ( 1 2 4 5 8 ) ->  ( 1 2 4 5 8 )
10:( 1 2 4 5 8 ) ->  ( 1 2 4 5 8 )
11:( 1 2 4 5 8 ) ->  ( 1 2 4 5 8 )
12:( 1 2 4 5 8 ) ->  ( 1 2 4 5 8 )
</code>```

Test cases:

Format: Number of comparisons (N): List after N comparisons

```<code>Input list:
5  1  4  2  8
Test cases:
1: 1  5  4  2  8
2: 1  4  5  2  8
3: 1  4  2  5  8
4: 1  4  2  5  8
5: 1  4  2  5  8
6: 1  2  4  5  8
10: 1  2  4  5  8
14: 1  2  4  5  8

Input list:
0: 15  18  -6  18   9  -7  -1   7  19  19  -5  20  19   5  15  -5   3  18  14  19
Test cases:
1: 15  18  -6  18   9  -7  -1   7  19  19  -5  20  19   5  15  -5   3  18  14  19
21: -6  15  18   9  -7  -1   7  18  19  -5  19  19   5  15  -5   3  18  14  19  20
41: -6   9  -7  15  -1   7  18  18  -5  19  19   5  15  -5   3  18  14  19  19  20
60: -6  -7  -1   9   7  15  18  -5  18  19   5  15  -5   3  18  14  19  19  19  20
61: -6  -7  -1   7   9  15  18  -5  18  19   5  15  -5   3  18  14  19  19  19  20
81: -7  -6  -1   7   9  15  -5  18  18   5  15  -5   3  18  14  19  19  19  19  20
119: -7  -6  -1  -5   7   9  15   5  15  -5   3  18  14  18  18  19  19  19  19  20
120: -7  -6  -1  -5   7   9  15   5  15  -5   3  18  14  18  18  19  19  19  19  20
121: -7  -6  -1  -5   7   9   5  15  15  -5   3  18  14  18  18  19  19  19  19  20
122: -7  -6  -1  -5   7   9   5  15  15  -5   3  18  14  18  18  19  19  19  19  20
123: -7  -6  -1  -5   7   9   5  15  -5  15   3  18  14  18  18  19  19  19  19  20
201: -7  -6  -5  -1  -5   3   5   7   9  14  15  15  18  18  18  19  19  19  19  20
221: -7  -6  -5  -5  -1   3   5   7   9  14  15  15  18  18  18  19  19  19  19  20
</code>```

Yes, built-in Bubble sort algorithms are permitted.

No, you can not assume only positive integers, or unique integers.

The sorting must be in the order described above. You can't start at the end of the list

Body:
Groovy (101 Bytes)

{l,n->(l.size()..0).each{i->(0..i-2).each{if(l[it]>l[it+1] && n>0 && it>-1){l.swap(it,it+1)};n--}};l}

EDIT: I didn't need to write my own swap closure, groovy had this built in.

Try it here: https://groovyconsole.appspot.com/script/5104724189642752

Example Output Trace:

4:[1, 5, 4, 2, 8]
3:[1, 4, 5, 2, 8]
2:[1, 4, 2, 5, 8]
1:[1, 4, 2, 5, 8]
0:[1, 4, 2, 5, 8] - Locks in the final answer.
-1:[1, 4, 2, 5, 8]
-2 (Return):[1, 4, 2, 5, 8]

Old Implementation (122 Bytes)

m={l,n->s={x,y->t=l[x];l[x]=l[y];l[y]=t};((l.size()-2)..2).each{i->(0..i).each{if(l[it]>l[it+1] && n){s(it,it+1)};n--}};l}

Try it here: https://groovyconsole.appspot.com/script/6316871066320896


问:
Count to 100 in Danish
Print all the numbers from 0-100 in the right order using the Danish way of counting

How they count

Like English, they have dedicated words for 0-20, 30, 40 and 100

Instead of saying twenty-one and twenty-two, they say one and twenty and two and twenty

Starting with fifty they say multiples of 10 as n*20

```<code>50 = half third times twenty = half way to the 3rd multiple of 20
60 = three times twenty
70 = half fourth times twenty
80 = four times twenty
90 = half fifth times twenty
</code>```

So for instance, 55 would be five and half third times twenty.

Expected output

```<code>zero
one
two
three
four
five
six
seven
eight
nine
ten
eleven
twelve
thirteen
fourteen
fifteen
sixteen
seventeen
eighteen
nineteen
twenty
one and twenty
two and twenty
three and twenty
four and twenty
five and twenty
six and twenty
seven and twenty
eight and twenty
nine and twenty
thirty
one and thirty
two and thirty
three and thirty
four and thirty
five and thirty
six and thirty
seven and thirty
eight and thirty
nine and thirty
forty
one and forty
two and forty
three and forty
four and forty
five and forty
six and forty
seven and forty
eight and forty
nine and forty
half third times twenty
one and half third times twenty
two and half third times twenty
three and half third times twenty
four and half third times twenty
five and half third times twenty
six and half third times twenty
seven and half third times twenty
eight and half third times twenty
nine and half third times twenty
three times twenty
one and three times twenty
two and three times twenty
three and three times twenty
four and three times twenty
five and three times twenty
six and three times twenty
seven and three times twenty
eight and three times twenty
nine and three times twenty
half fourth times twenty
one and half fourth times twenty
two and half fourth times twenty
three and half fourth times twenty
four and half fourth times twenty
five and half fourth times twenty
six and half fourth times twenty
seven and half fourth times twenty
eight and half fourth times twenty
nine and half fourth times twenty
four times twenty
one and four times twenty
two and four times twenty
three and four times twenty
four and four times twenty
five and four times twenty
six and four times twenty
seven and four times twenty
eight and four times twenty
nine and four times twenty
half fifth times twenty
one and half fifth times twenty
two and half fifth times twenty
three and half fifth times twenty
four and half fifth times twenty
five and half fifth times twenty
six and half fifth times twenty
seven and half fifth times twenty
eight and half fifth times twenty
nine and half fifth times twenty
one hundred
</code>```

Rules

You may use any separator to separate the numbers

Due to a typo in the original specification, you may use forth instead of fourth.

You may write a function or write to std-out

Standard loopholes apply

This is codegolf; shortest code in bytes win!

答:
Python 2, with num2words, 206 bytes

Even with num2words it takes quite a few bytes!

This is a full program.

```<code>from num2words import num2words as w
for i in range(1,101):d=i/10;e=w(i).split('-');print' and '.join(e[1:]+[10>d>4 and((d%2 and'half '+{5:'third',7:'forth',9:'fifth'}[d]or w(d/2))+' times twenty')or e[0]])
</code>```

Here is a mocked version on ideone

(By mocked I mean that since the online interpreter does not have num2words I replaced w with a lambda which looks up num2word's output in a list)

ungolfed and with 'fourth' rather than the allowed 'forth' (which saves a byte):

```<code>from num2words import num2words
for i in range(1,101):
    d = i / 10 # i div 10
    e = num2words(i).split('-') # i in English words with a "-" separator, split into parts
    if d > 4 and d < 10:
        if d % 2:
            p = 'half '+ {5:'third', 7:'fourth', 9:'fifth'}[d] + ' times twenty'
        else:
            p = num2words(d / 2) + ' times twenty'
    else:
        p = e[0]
    print' and '.join(e[1:]+[p])
</code>```

Note that the separator used by num2words(100) is a space, whereas for the other numbers it is a "-", so we don't need to do anything fancy for that case other than stop it from being "five times twenty".

Aside

If the challenge were to actually produce the numbers in Danish one could take the lang_DK.py from the github page and use:

```<code>from num2words import*
[num2words(i,lang='dk')for i in range(1,101)]
</code>```

for 68 bytes, yielding:

```<code>['et', 'to', 'tre', 'fire', 'fem', 'seks', 'syv', 'otte', 'ni', 'ti', 'elleve', 'tolv', 'tretten', 'fjorten', 'femten', 'seksten', 'sytten', 'atten', 'nitten', 'tyve', 'enogtyve', 'toogtyve', 'treogtyve', 'fireogtyve', 'femogtyve', 'seksogtyve', 'syvogtyve', 'otteogtyve', 'niogtyve', 'tredive', 'enogtredive', 'toogtredive', 'treogtredive', 'fireogtredive', 'femogtredive', 'seksogtredive', 'syvogtredive', 'otteogtredive', 'niogtredive', 'fyrre', 'enogfyrre', 'toogfyrre', 'treogfyrre', 'fireogfyrre', 'femogfyrre', 'seksogfyrre', 'syvogfyrre', 'otteogfyrre', 'niogfyrre', 'halvtreds', 'enoghalvtreds', 'tooghalvtreds', 'treoghalvtreds', 'fireoghalvtreds', 'femoghalvtreds', 'seksoghalvtreds', 'syvoghalvtreds', 'otteoghalvtreds', 'nioghalvtreds', 'treds', 'enogtreds', 'toogtreds', 'treogtreds', 'fireogtreds', 'femogtreds', 'seksogtreds', 'syvogtreds', 'otteogtreds', 'niogtreds', 'halvfjerds', 'enoghalvfjerds', 'tooghalvfjerds', 'treoghalvfjerds', 'fireoghalvfjerds', 'femoghalvfjerds', 'seksoghalvfjerds', 'syvoghalvfjerds', 'otteoghalvfjerds', 'nioghalvfjerds', 'firs', 'enogfirs', 'toogfirs', 'treogfirs', 'fireogfirs', 'femogfirs', 'seksogfirs', 'syvogfirs', 'otteogfirs', 'niogfirs', 'halvfems', 'enoghalvfems', 'tooghalvfems', 'treoghalvfems', 'fireoghalvfems', 'femoghalvfems', 'seksoghalvfems', 'syvoghalvfems', 'otteoghalvfems', 'nioghalvfems', 'ethundrede']
</code>```

Title: Count to 100 in Danish

Body:
Python 2, with num2words, 206 bytes

Even with num2words it takes quite a few bytes!

This is a full program.

from num2words import num2words as w
for i in range(1,101):d=i/10;e=w(i).split('-');print' and '.join(e[1:]+[10>d>4 and((d%2 and'half '+{5:'third',7:'forth',9:'fifth'}[d]or w(d/2))+' times twenty')or e[0]])

Here is a mocked version on ideone

(By mocked I mean that since the online interpreter does not have num2words I replaced w with a lambda which looks up num2word's output in a list)

ungolfed and with 'fourth' rather than the allowed 'forth' (which saves a byte):

from num2words import num2words
for i in range(1,101):
    d = i / 10 # i div 10
    e = num2words(i).split('-') # i in English words with a "-" separator, split into parts
    if d > 4 and d < 10:
        if d % 2:
            p = 'half '+ {5:'third', 7:'fourth', 9:'fifth'}[d] + ' times twenty'
        else:
            p = num2words(d / 2) + ' times twenty'
    else:
        p = e[0]
    print' and '.join(e[1:]+[p])

Note that the separator used by num2words(100) is a space, whereas for the other numbers it is a "-", so we don't need to do anything fancy for that case other than stop it from being "five times twenty".

Aside

If the challenge were to actually produce the numbers in Danish one could take the lang_DK.py from the github page and use:

from num2words import*
[num2words(i,lang='dk')for i in range(1,101)]

for 68 bytes, yielding:

['et', 'to', 'tre', 'fire', 'fem', 'seks', 'syv', 'otte', 'ni', 'ti', 'elleve', 'tolv', 'tretten', 'fjorten', 'femten', 'seksten', 'sytten', 'atten', 'nitten', 'tyve', 'enogtyve', 'toogtyve', 'treogtyve', 'fireogtyve', 'femogtyve', 'seksogtyve', 'syvogtyve', 'otteogtyve', 'niogtyve', 'tredive', 'enogtredive', 'toogtredive', 'treogtredive', 'fireogtredive', 'femogtredive', 'seksogtredive', 'syvogtredive', 'otteogtredive', 'niogtredive', 'fyrre', 'enogfyrre', 'toogfyrre', 'treogfyrre', 'fireogfyrre', 'femogfyrre', 'seksogfyrre', 'syvogfyrre', 'otteogfyrre', 'niogfyrre', 'halvtreds', 'enoghalvtreds', 'tooghalvtreds', 'treoghalvtreds', 'fireoghalvtreds', 'femoghalvtreds', 'seksoghalvtreds', 'syvoghalvtreds', 'otteoghalvtreds', 'nioghalvtreds', 'treds', 'enogtreds', 'toogtreds', 'treogtreds', 'fireogtreds', 'femogtreds', 'seksogtreds', 'syvogtreds', 'otteogtreds', 'niogtreds', 'halvfjerds', 'enoghalvfjerds', 'tooghalvfjerds', 'treoghalvfjerds', 'fireoghalvfjerds', 'femoghalvfjerds', 'seksoghalvfjerds', 'syvoghalvfjerds', 'otteoghalvfjerds', 'nioghalvfjerds', 'firs', 'enogfirs', 'toogfirs', 'treogfirs', 'fireogfirs', 'femogfirs', 'seksogfirs', 'syvogfirs', 'otteogfirs', 'niogfirs', 'halvfems', 'enoghalvfems', 'tooghalvfems', 'treoghalvfems', 'fireoghalvfems', 'femoghalvfems', 'seksoghalvfems', 'syvoghalvfems', 'otteoghalvfems', 'nioghalvfems', 'ethundrede']


Title: Bubble sorting in progress

Body:
PowerShell v2+, <s>135</s> 129 bytes

param($a,$n)for($s=1;$s){($s=0)..($a.count-2)|%{if($a[$_]-gt$a[$_+1]){$a[$_],$a[$_+1]=$a[$_+1],$a[$_];$s=1}if(!--$n){$a;exit}}}$a

So. Many. Dollars.

(Saved six bytes by realizing that this challenge doesn't include the "for free" optimization of skipping the last element(s) on each pass since that's guaranteed sorted, and instead runs through a full pass each time. This moved the $a.count into the for loop and eliminated the $z variable.)

Straight up bubble sort, with one nifty spot, doing the swap in one step --

$a[$_],$a[$_+1]=$a[$_+1],$a[$_]

The exiting logic is handled via if(!--$n){$a;exit}

Test Cases

(The array is shown as space-separated here because the default Output Field Separator for stringifying an array is a space. The stringification happens because we're concatenating with the labels "$_ -> ".)

PS C:\Tools\Scripts\golfing> 1,2,3,4,5,6,10,14|%{"$_ -> "+(.\bubble-sorting-in-progress.ps1 @(5,1,4,2,8) $_)}
1 -> 1 5 4 2 8
2 -> 1 4 5 2 8
3 -> 1 4 2 5 8
4 -> 1 4 2 5 8
5 -> 1 4 2 5 8
6 -> 1 2 4 5 8
10 -> 1 2 4 5 8
14 -> 1 2 4 5 8

PS C:\Tools\Scripts\golfing> 1,21,41,60,61,81,119,120,121,122,123,201,221|%{"$_ -> "+(.\bubble-sorting-in-progress.ps1 @(15,18,-6,18,9,-7,-1,7,19,19,-5,20,19,5,15,-5,3,18,14,19) $_)}
1 -> 15 18 -6 18 9 -7 -1 7 19 19 -5 20 19 5 15 -5 3 18 14 19
21 -> -6 15 18 9 -7 -1 7 18 19 -5 19 19 5 15 -5 3 18 14 19 20
41 -> -6 9 -7 15 -1 7 18 18 -5 19 19 5 15 -5 3 18 14 19 19 20
60 -> -6 -7 -1 9 7 15 18 -5 18 19 5 15 -5 3 18 14 19 19 19 20
61 -> -6 -7 -1 7 9 15 18 -5 18 19 5 15 -5 3 18 14 19 19 19 20
81 -> -7 -6 -1 7 9 15 -5 18 18 5 15 -5 3 18 14 19 19 19 19 20
119 -> -7 -6 -1 -5 7 9 15 5 15 -5 3 18 14 18 18 19 19 19 19 20
120 -> -7 -6 -1 -5 7 9 15 5 15 -5 3 18 14 18 18 19 19 19 19 20
121 -> -7 -6 -1 -5 7 9 5 15 15 -5 3 18 14 18 18 19 19 19 19 20
122 -> -7 -6 -1 -5 7 9 5 15 15 -5 3 18 14 18 18 19 19 19 19 20
123 -> -7 -6 -1 -5 7 9 5 15 -5 15 3 18 14 18 18 19 19 19 19 20
201 -> -7 -6 -5 -1 -5 3 5 7 9 14 15 15 18 18 18 19 19 19 19 20
221 -> -7 -6 -5 -5 -1 3 5 7 9 14 15 15 18 18 18 19 19 19 19 20


答:
Haskell, <s>83</s> <s>82</s> 81 bytes

```<code>y%x@(a:b:c)=(y++x):(y++[min a b])%(max a b:c)
y%x=[]%(y++x)
[x]!_=[x]
x!n=[]%x!!n
</code>```

Usage example: [5,1,4,2,8] ! 5 -> [1,4,2,5,8].

In function % y keeps track of the elements visited so far during the current pass, x are ones yet to examine. a and b are the next two, i.e. the candidates to swap. If we reach the end of the list, we start from the beginning: y%x = []%(y++x). All steps are stored in a list where the main function picks the nth element.

Edit: previous versions didn't work for single element lists, luckily the new version is even shorter.

Title: Bubble sorting in progress

Body:
Haskell, <s>83</s> <s>82</s> 81 bytes

y%x@(a:b:c)=(y++x):(y++[min a b])%(max a b:c)
y%x=[]%(y++x)
[x]!_=[x]
x!n=[]%x!!n

Usage example: [5,1,4,2,8] ! 5 -> [1,4,2,5,8].

In function % y keeps track of the elements visited so far during the current pass, x are ones yet to examine. a and b are the next two, i.e. the candidates to swap. If we reach the end of the list, we start from the beginning: y%x = []%(y++x). All steps are stored in a list where the main function picks the nth element.

Edit: previous versions didn't work for single element lists, luckily the new version is even shorter.


问:
Bitflip and negate
Given an integer, make an expression that produces it from 0 using unary negation - and bitwise complement ~ (~n = -n-1), with the operators applied right to left.

```<code>...
-3  = ~-~-~0
-2  = ~-~0
-1  = ~0
 0  = 0
 1  = -~0
 2  = -~-~0
 3  = -~-~-~0
...
</code>```

Your expression must be as short as possible, which means no redundant parts of ~~, --, -0, or 00. Output or print the expression as a string or a sequence of characters.

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
Vim - 31 keystrokes

First vim golf, prolly missed a ton of stuff.

```<code>`i-~<esc>:s/-\~-/\~-/dwp<left>ii<esc><left>d$@"<esc>a0`
</code>```

Title: Bitflip and negate

Body:
Vim - 31 keystrokes

First vim golf, prolly missed a ton of stuff.

`i-~<esc>:s/-\~-/\~-/dwp<left>ii<esc><left>d$@"<esc>a0`


答:
C#, <s>337</s> <s>333</s> 331 characters

```<code>_=>{var q="";foreach(var c in"潌敲彭灩畳彭潤潬彲楳彴浡瑥弬潣獮捥整畴彲摡灩獩楣杮敟楬ⱴ獟摥摟彯楥獵潭彤整灭牯楟据摩摩湵彴瑵江扡牯彥瑥摟汯牯彥慭湧彡污煩慵弮瑕敟楮彭摡浟湩浩癟湥慩Ɑ煟極彳潮瑳畲彤硥牥楣慴楴湯畟汬浡潣江扡牯獩湟獩彩瑵慟楬畱灩敟彸慥损浯潭潤损湯敳畱瑡弮畄獩慟瑵彥物牵彥潤潬彲湩牟灥敲敨摮牥瑩楟彮潶畬瑰瑡彥敶楬彴獥敳损汩畬彭潤潬敲敟彵畦楧瑡湟汵慬灟牡慩畴ⅲ䕟捸灥整牵獟湩彴捯慣捥瑡损灵摩瑡瑡湟湯灟潲摩湥ⱴ獟湵彴湩损汵慰煟極潟晦捩慩摟獥牥湵彴潭汬瑩慟楮彭摩敟瑳江扡牯浵ਡ")q=q+(char)(c&255)+(char)(c>>8);return q.Replace("!",".").Replace("_"," ");};
</code>```

-4 characters by replacing the .s after "pariatur" and "laborum" with ! before combining the chars to wide chars and adding a trailing new line.

-2 characters by re-assigning the output var rather than appending with +=.

How it works:

The lorem ipsum string was converted to that mess by replacing . with !,   with _ so when the ascii chars are placed next to each other to make a wide char each wide char is a single character.

```<code>/*Func<object, string> Lorem = */ _=> // unused parameter
{
    // Output var
    var q = "";

    // Enumerate each wide char
    foreach (var c in "潌敲彭灩畳彭潤潬彲楳彴浡瑥弬潣獮捥整畴彲摡灩獩楣杮敟楬ⱴ獟摥摟彯楥獵潭彤整灭牯楟据摩摩湵彴瑵江扡牯彥瑥摟汯牯彥慭湧彡污煩慵弮瑕敟楮彭摡浟湩浩癟湥慩Ɑ煟極彳潮瑳畲彤硥牥楣慴楴湯畟汬浡潣江扡牯獩湟獩彩瑵慟楬畱灩敟彸慥损浯潭潤损湯敳畱瑡弮畄獩慟瑵彥物牵彥潤潬彲湩牟灥敲敨摮牥瑩楟彮潶畬瑰瑡彥敶楬彴獥敳损汩畬彭潤潬敲敟彵畦楧瑡湟汵慬灟牡慩畴ⅲ䕟捸灥整牵獟湩彴捯慣捥瑡损灵摩瑡瑡湟湯灟潲摩湥ⱴ獟湵彴湩损汵慰煟極潟晦捩慩摟獥牥湵彴潭汬瑩慟楮彭摩敟瑳江扡牯浵ਡ")
        // Split each wide char into two ascii chars
        q = q + (char)(c&255) + (char)(c>>8);

    // Restore the replaced periods and spaces
    return q.Replace("!",".").Replace("_"," ");
};
</code>```

Title: Output "Lorem ipsum" with minimal number of characters

Body:
I remember people saying that code size should be measured in bytes, and not in characters, because it's possible to store information with weird Unicode characters, which have no visual meaning.

How bad can it be?

In this challenge, you should output the following Lorem Ipsum text, taken from Wikipedia:

```<code>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</code>```

Please specify the number of characters (not bytes) in your code. Code with the minimal number of characters wins.

Your code should only contain valid Unicode characters, as described here, that is:

Code points up to U+10FFFF

No surrogates (the range D800–DBFF is forbidden)

No characters FFFE and FFFF

No null characters (code 0)

If your code cannot be displayed, provide a version with offending characters redacted, and a hexdump.

Some notes:

The output must be one long line (445 characters). If your system cannot do that (e.g. you're printing it on paper), output a closest approximation. Trailing linebreaks don't matter.

Built-in functions that generate Lorem Ipsum text are not allowed

Please specify a valid text encoding for your code, if relevant

Body:
C#, <s>337</s> <s>333</s> 331 characters

_=>{var q="";foreach(var c in"潌敲彭灩畳彭潤潬彲楳彴浡瑥弬潣獮捥整畴彲摡灩獩楣杮敟楬ⱴ獟摥摟彯楥獵潭彤整灭牯楟据摩摩湵彴瑵江扡牯彥瑥摟汯牯彥慭湧彡污煩慵弮瑕敟楮彭摡浟湩浩癟湥慩Ɑ煟極彳潮瑳畲彤硥牥楣慴楴湯畟汬浡潣江扡牯獩湟獩彩瑵慟楬畱灩敟彸慥损浯潭潤损湯敳畱瑡弮畄獩慟瑵彥物牵彥潤潬彲湩牟灥敲敨摮牥瑩楟彮潶畬瑰瑡彥敶楬彴獥敳损汩畬彭潤潬敲敟彵畦楧瑡湟汵慬灟牡慩畴ⅲ䕟捸灥整牵獟湩彴捯慣捥瑡损灵摩瑡瑡湟湯灟潲摩湥ⱴ獟湵彴湩损汵慰煟極潟晦捩慩摟獥牥湵彴潭汬瑩慟楮彭摩敟瑳江扡牯浵ਡ")q=q+(char)(c&255)+(char)(c>>8);return q.Replace("!",".").Replace("_"," ");};

-4 characters by replacing the .s after "pariatur" and "laborum" with ! before combining the chars to wide chars and adding a trailing new line.

-2 characters by re-assigning the output var rather than appending with +=.

How it works:

The lorem ipsum string was converted to that mess by replacing . with !,   with _ so when the ascii chars are placed next to each other to make a wide char each wide char is a single character.

/*Func<object, string> Lorem = */ _=> // unused parameter
{
    // Output var
    var q = "";

    // Enumerate each wide char
    foreach (var c in "潌敲彭灩畳彭潤潬彲楳彴浡瑥弬潣獮捥整畴彲摡灩獩楣杮敟楬ⱴ獟摥摟彯楥獵潭彤整灭牯楟据摩摩湵彴瑵江扡牯彥瑥摟汯牯彥慭湧彡污煩慵弮瑕敟楮彭摡浟湩浩癟湥慩Ɑ煟極彳潮瑳畲彤硥牥楣慴楴湯畟汬浡潣江扡牯獩湟獩彩瑵慟楬畱灩敟彸慥损浯潭潤损湯敳畱瑡弮畄獩慟瑵彥物牵彥潤潬彲湩牟灥敲敨摮牥瑩楟彮潶畬瑰瑡彥敶楬彴獥敳损汩畬彭潤潬敲敟彵畦楧瑡湟汵慬灟牡慩畴ⅲ䕟捸灥整牵獟湩彴捯慣捥瑡损灵摩瑡瑡湟湯灟潲摩湥ⱴ獟湵彴湩损汵慰煟極潟晦捩慩摟獥牥湵彴潭汬瑩慟楮彭摩敟瑳江扡牯浵ਡ")
        // Split each wide char into two ascii chars
        q = q + (char)(c&255) + (char)(c>>8);

    // Restore the replaced periods and spaces
    return q.Replace("!",".").Replace("_"," ");
};


问:
Conjugate a Turkish verb

Input

verb, a string that matches the regular expression ([a-pr-vyzıöüçğş]*[aeıioöuü][bcçdfgğhj-nprsştvyz]+|([a-pr-vyzıöüçğş]*[aeıioöuü]){2})(mak|mek)

plural, a truthy or falsy value

person, an integer having value either 1, 2, or 3

tense, an integer having value either 1, 2, or 3

Output

The conjugated form of the Turkish verb verb, in personst/nd/rd person, plural if plural is TRUE and singular if it is not, in

If tense is 1, the simple present;

If tense is 2, the continuing present;

If tense is 3, the future.

Rules

Turkish verbs are conjugated in three elements, which are in order:

The stem, formed by removing mak or mek from the end of the infinitive;

The sign of the tense, which is:

For the simple present:

-r if the stem ends in a vowel;

-ir according to vowel harmony rules (see below) if the stem contains more than one syllable (i.e. vowel), or is from one of the following irregular verbs: almak, bilmek, bulmak, durmak, gelmek, görmek, kalmak, olmak, ölmek, sanmak, vermek, varmak, vurmak;

-er according to vowel harmony rules if the stem contains one syllable and is not listed in the irregular verbs above.

For the continuing present, -iyor, where the i changes according to vowel harmony rules. Stems that end in a vowel drop this vowel before adding this suffix, whereupon the suffix harmonizes with the next-to-last vowel in the word (guaranteed to exist by the regular expression).

For the future:

-ecek according to vowel harmony rules if the stem ends in a consonant;

-yecek according to vowel harmony rules if the stem ends in a vowel.

The personal suffix to indicate the performer of the action, in all cases according to vowel harmony rules:

```<code>    |Singular|Plural|
|---|--------|------|
|1st|    -im |   -iz|
|2nd|   -sin |-siniz|
|3rd| (none) |  -ler|
</code>```

The final k of the future tense becomes ğ before -im and -iz, so for example (almak, TRUE, 1, 3) would yield alacağız.

Vowel harmony rules

Turkish vowels are divided into two groups: back (a ı o u) and front (e i ö ü) by where in the mouth they are pronounced. The suffixes of a word change vowels according to the vowels of the root.

All suffixes listed above that have i as a vowel instead use:

-ı if the last vowel before the suffix is ı or a (both these vowels are back and unrounded);

-i if the last vowel before the suffix is i or e (both these vowels are front and unrounded; note here Turkish's distinction between dotted and dotless I);

-u if the last vowel before the suffix is u or o (both these vowels are back and rounded); or

-ü if the last vowel before the suffix is ü or ö (both these vowels are front and rounded).

Take careful note of the present continuous suffix -iyor. The i harmonizes, but the o does not change. The personal suffixes will thus harmonize with the o.

All the suffixes listed above that have e as a vowel instead use:

-e if the last vowel before the suffix is a front vowel; or

-a if the last vowel before the suffix is a back vowel.

Irregular verbs

The verbs gitmek, tatmak, ditmek, gütmek, and etmek change the final t to a d before any endings that begin with a vowel (which includes all the endings in this challenge). Any verb that ends in -etmek likewise changes the t to a d, and appends -er for the simple present (though this is not so for the other verbs).

Test cases

```<code>gütmek, FALSE, 1, 2 -> güdüyorum
almak, TRUE, 3, 3 -> alacaklar
boğmak, TRUE, 2, 1 -> boğarsınız
ölmek, FALSE, 3, 1 -> ölür
boyamak, TRUE, 1, 2 -> boyuyoruz
affetmek, FALSE, 2, 1 -> affedersin
söylemek, TRUE, 3, 1 -> söylerler
söylemek, FALSE, 3, 2 -> söylüyor
söylemek, FALSE, 1, 3 -> söyleyeceğim
</code>```

答:
sed, 583 bytes

sed -E 's/^((bul|dur|k?al|ol|san|v[au]r)ma|(bil|gel|gör|öl|ver)me)k( . .) 1/\2\3Ir\4/;s/etmek( . .) 1/edEr\1/;s/etmek /ed /;s/^((ta)tma|([dg]i|gü)tme)k /\2\3d /;s/m[ae]k / /;s/([aıoueiöüEI])/V\1/g;s/(V.)( . .) 1/\1r\2/;s/(V.+V.+)( . .) 1/\1VIr\2/;s/( . .) 1/VEr\1/;s/(V.)?( . .) 2/VIyVor\2/;s/(V.)( . . 3)/\1y\2/;s/( . .) 3/VEcVEk\1/;s/k( . 1)/ğ\1/;s/ 0 1/VIm/;s/ 1 1/VIz/;s/ 0 2/sVIn/;s/ 1 2/sVInVIz/;s/ 0 3//;s/ 1 3/lVEr/;:l
s/([ıa][^V]*V)I/\1ı/;s/([ie][^V]*V)I/\1i/;s/([uo][^V]*V)I/\1u/;s/([üö][^V]*V)I/\1ü/;s/([aıou][^V]*V)E/\1a/;s/(V[^aEI][^V]*V)E/\1e/;t l
s/V//g'
```

<p>Like my answer to the closely-related Dactylic Hexameter question, this is really just translating the rules as given into regular expressions.</p>

<h3>Usage:</h3>

<p>Takes input in the form:</p>

```word [01] [123] [123]
```

<p>So the test cases are:</p>

<pre class="lang-sh prettyprint-override"><code>printf 'gütmek 0 1 2
almak 1 3 3
boğmak 1 2 1
ölmek 0 3 1
boyamak 1 1 2
affetmek 0 2 1
söylemek 1 3 1
söylemek 0 3 2
söylemek 0 1 3' | sed -E '<...>';
</code>```

Breakdown:

sed -E "
# special cases for simple present tense
 s/^((bul|dur|k?al|ol|san|v[au]r)ma|(bil|gel|gör|öl|ver)me)k( . .) 1/\2\3Ir\4/;

# stemming
# always uses -er rule if simple present
 s/etmek( . .) 1/edEr\1/;
 s/etmek /ed /;
 s/^((ta)tma|([dg]i|gü)tme)k /\2\3d /;
 s/m[ae]k / /;

# mark vowels for easier expressions later
 s/([aıoueiöüEI])/V\1/g;

# simple present
 s/(V.)( . .) 1/\1r\2/;
 s/(V.+V.+)( . .) 1/\1VIr\2/;
 s/( . .) 1/VEr\1/;

# continuing present
 s/(V.)?( . .) 2/VIyVor\2/;

# future
 s/(V.)( . . 3)/\1y\2/;
 s/( . .) 3/VEcVEk\1/;

# personal suffix
 s/k( . 1)/ğ\1/;
 s/ 0 1/VIm/;
 s/ 1 1/VIz/;
 s/ 0 2/sVIn/;
 s/ 1 2/sVInVIz/;
 s/ 0 3//;
 s/ 1 3/lVEr/;

# vowel harmony
 :l
 s/([ıa][^V]*V)I/\1ı/;
 s/([ie][^V]*V)I/\1i/;
 s/([uo][^V]*V)I/\1u/;
 s/([üö][^V]*V)I/\1ü/;

 s/([aıou][^V]*V)E/\1a/;
 s/(V[^aEI][^V]*V)E/\1e/;
# keep looping until all vowels are known
 t l

# unmark vowels
 s/V//g
"
```

<h3>Results for test cases:</h3>

```güdüyorum
alacaklar
boğarsınız
ölür
boyuyoruz
affedersin
söylerler
söylüyor
söyleyeceğim
```

Title: Conjugate a Turkish verb

Body:
sed, 583 bytes

sed -E 's/^((bul|dur|k?al|ol|san|v[au]r)ma|(bil|gel|gör|öl|ver)me)k( . .) 1/\2\3Ir\4/;s/etmek( . .) 1/edEr\1/;s/etmek /ed /;s/^((ta)tma|([dg]i|gü)tme)k /\2\3d /;s/m[ae]k / /;s/([aıoueiöüEI])/V\1/g;s/(V.)( . .) 1/\1r\2/;s/(V.+V.+)( . .) 1/\1VIr\2/;s/( . .) 1/VEr\1/;s/(V.)?( . .) 2/VIyVor\2/;s/(V.)( . . 3)/\1y\2/;s/( . .) 3/VEcVEk\1/;s/k( . 1)/ğ\1/;s/ 0 1/VIm/;s/ 1 1/VIz/;s/ 0 2/sVIn/;s/ 1 2/sVInVIz/;s/ 0 3//;s/ 1 3/lVEr/;:l
s/([ıa][^V]*V)I/\1ı/;s/([ie][^V]*V)I/\1i/;s/([uo][^V]*V)I/\1u/;s/([üö][^V]*V)I/\1ü/;s/([aıou][^V]*V)E/\1a/;s/(V[^aEI][^V]*V)E/\1e/;t l
s/V//g'

Like my answer to the closely-related Dactylic Hexameter question, this is really just translating the rules as given into regular expressions.

Usage:

Takes input in the form:

word [01] [123] [123]

So the test cases are:

printf 'gütmek 0 1 2
almak 1 3 3
boğmak 1 2 1
ölmek 0 3 1
boyamak 1 1 2
affetmek 0 2 1
söylemek 1 3 1
söylemek 0 3 2
söylemek 0 1 3' | sed -E '<...>';

Breakdown:

sed -E "
# special cases for simple present tense
 s/^((bul|dur|k?al|ol|san|v[au]r)ma|(bil|gel|gör|öl|ver)me)k( . .) 1/\2\3Ir\4/;

# stemming
# always uses -er rule if simple present
 s/etmek( . .) 1/edEr\1/;
 s/etmek /ed /;
 s/^((ta)tma|([dg]i|gü)tme)k /\2\3d /;
 s/m[ae]k / /;

# mark vowels for easier expressions later
 s/([aıoueiöüEI])/V\1/g;

# simple present
 s/(V.)( . .) 1/\1r\2/;
 s/(V.+V.+)( . .) 1/\1VIr\2/;
 s/( . .) 1/VEr\1/;

# continuing present
 s/(V.)?( . .) 2/VIyVor\2/;

# future
 s/(V.)( . . 3)/\1y\2/;
 s/( . .) 3/VEcVEk\1/;

# personal suffix
 s/k( . 1)/ğ\1/;
 s/ 0 1/VIm/;
 s/ 1 1/VIz/;
 s/ 0 2/sVIn/;
 s/ 1 2/sVInVIz/;
 s/ 0 3//;
 s/ 1 3/lVEr/;

# vowel harmony
 :l
 s/([ıa][^V]*V)I/\1ı/;
 s/([ie][^V]*V)I/\1i/;
 s/([uo][^V]*V)I/\1u/;
 s/([üö][^V]*V)I/\1ü/;

 s/([aıou][^V]*V)E/\1a/;
 s/(V[^aEI][^V]*V)E/\1e/;
# keep looping until all vowels are known
 t l

# unmark vowels
 s/V//g
"

Results for test cases:

güdüyorum
alacaklar
boğarsınız
ölür
boyuyoruz
affedersin
söylerler
söylüyor
söyleyeceğim


答:
ISOLADOS, 44016 bytes

http://pastebin.com/raw/Y2aAhdpi

Push the ASCII code for every character in the Lorem Ipsum string, concatenate everything, and output.


问:
We're no strangers to code golf, you know the rules, and so do I
Write the shortest program that prints the entire lyrics of "Never Gonna Give You Up" by Rick Astley.

Rules:

Must output the lyrics exactly as they appear in the above pastebin*. Here's the raw dump: http://pastebin.com/raw/wwvdjvEj

Cannot rely on any external resources - all lyrics must be generated by / embedded in code.

No use of existing compression algorithms (e.g. gzip / bzip2) unless you include the full algorithm in your code.

Use any language, shortest code wins.

Update, 1st June 2012:

For solutions containing non-ASCII text, the size of your solution will be counted in bytes, based on UTF-8 encoding. If you use codepoints that cannot be encoded in UTF-8, your solution will not be judged as valid.

Update, 7th June 2012:

Thank you all for your awesome solutions! I'll be accepting the shortest answer tomorrow afternoon. Right now, Peter Taylor's GolfScript answer is winning, so get cracking on some improvements if you want to beat him! :)

*There is a typo in the Pastebin (line 46, "know" should be "known").  You may either replicate it or not at your discretion.

答:
///, <s>692</s> <s>682</s> <s>666</s> 656 bytes

<s>666 bytes lol.</s>

```<code>/1/ know //+/ you//>/You//=/Never gonna //!/I just wanna tell+ how I'm feeling
Gotta make+ understand
//@/=give+ up
=let+ down
=run around and desert+
=make+ cry
=say goodbye
=tell a lie and hurt+
//#/We've1each other for so long
>r heart's been aching but
>'re too shy to say it
Inside we both1what's been going on
We1the game and we're gonna play it//%/(Ooh, give+ up)//&/(Ooh)//*/=give, never gonna give//-/(Give+ up)/We're no strangers to love
>1the rules and so do I
A full commitment's what I'm thinking of
> wouldn't get this from any other guy
!
@
#
And if+ ask me how I'm feeling
Don't tell me+'re too blind to see

@
@
%
%
&
*
-
&
*
-

#

!
@
@
@
</code>```

-10 bytes thanks to Flp.Tkc/Erik the Outgolfer

Try it online!

ContentLicense: CC BY-SA 4.0

Body:
///, <s>692</s> <s>682</s> <s>666</s> 656 bytes

<s>666 bytes lol.</s>

/1/ know //+/ you//>/You//=/Never gonna //!/I just wanna tell+ how I'm feeling
Gotta make+ understand
//@/=give+ up
=let+ down
=run around and desert+
=make+ cry
=say goodbye
=tell a lie and hurt+
//#/We've1each other for so long
>r heart's been aching but
>'re too shy to say it
Inside we both1what's been going on
We1the game and we're gonna play it//%/(Ooh, give+ up)//&/(Ooh)//*/=give, never gonna give//-/(Give+ up)/We're no strangers to love
>1the rules and so do I
A full commitment's what I'm thinking of
> wouldn't get this from any other guy
!
@
#
And if+ ask me how I'm feeling
Don't tell me+'re too blind to see

@
@
%
%
&
*
-
&
*
-

#

!
@
@
@

-10 bytes thanks to Flp.Tkc/Erik the Outgolfer

<a href="https://tio.run/nexus/slashes#XVHbauMwEH2fr5hS2nTrliEfYJPCQslL@xj2UY7Hl0bWFF1i/PXZkdKWZRFYZi7npgttCU9OFiSqCFdJRA39yVdNb3xmj4M4Z7R9Q3v8SCHiYnIhsrUVjrq538zYM9vJDfAqMRqczYkrTK5jH6JxHRDtqB6mc65@Qm05VtjJ4qD2yaHxorOog9hxYB8rqK8QR79CHcyqIqRrV4Y606JBO3GZH1OeJrqlA2/OvGVzHFHiqLp78RgEraisxuPIxsdNwJZZGY@jqsU2RWg2njGKYBhXvTGzTRH2Lkwd48LYKtx2Gc3P8iB5VxwceKtMOJj5KmbhjHXN69MWHKI7eniX8Qm/3f8iui8l/Xm8hvKE7p@kc4XomR5efzYOBdipuOiNGzTVrNTKmaEpEnyyHIoGddwJ7uEF@6RJHWWepzizy@qzifJaUd2fiokeGlwk2c5tIg4ccytg72VWtPUrySGtcAM7uIUXZZj6Ck04oZr@//V/S4YpTzRz9R1sq72uRMsMCrODOz338AjPX19FLgR6Lpe/" rel="nofollow noreferrer">Try it online!


问:
C: replace AES FIPS-197 SubBytes table by constant-time code
In FIPS-197 (the Advanced Encryption Standard, known as AES), it is made heavy use of SubBytes, which could be implemented as

```<code>unsigned char SubBytes(unsigned char x) {
static const unsigned char t[256] = {
  0x63,0x7C,0x77,0x7B,0xF2,0x6B,0x6F,0xC5,0x30,0x01,0x67,0x2B,0xFE,0xD7,0xAB,0x76,
  0xCA,0x82,0xC9,0x7D,0xFA,0x59,0x47,0xF0,0xAD,0xD4,0xA2,0xAF,0x9C,0xA4,0x72,0xC0,
  0xB7,0xFD,0x93,0x26,0x36,0x3F,0xF7,0xCC,0x34,0xA5,0xE5,0xF1,0x71,0xD8,0x31,0x15,
  0x04,0xC7,0x23,0xC3,0x18,0x96,0x05,0x9A,0x07,0x12,0x80,0xE2,0xEB,0x27,0xB2,0x75,
  0x09,0x83,0x2C,0x1A,0x1B,0x6E,0x5A,0xA0,0x52,0x3B,0xD6,0xB3,0x29,0xE3,0x2F,0x84,
  0x53,0xD1,0x00,0xED,0x20,0xFC,0xB1,0x5B,0x6A,0xCB,0xBE,0x39,0x4A,0x4C,0x58,0xCF,
  0xD0,0xEF,0xAA,0xFB,0x43,0x4D,0x33,0x85,0x45,0xF9,0x02,0x7F,0x50,0x3C,0x9F,0xA8,
  0x51,0xA3,0x40,0x8F,0x92,0x9D,0x38,0xF5,0xBC,0xB6,0xDA,0x21,0x10,0xFF,0xF3,0xD2,
  0xCD,0x0C,0x13,0xEC,0x5F,0x97,0x44,0x17,0xC4,0xA7,0x7E,0x3D,0x64,0x5D,0x19,0x73,
  0x60,0x81,0x4F,0xDC,0x22,0x2A,0x90,0x88,0x46,0xEE,0xB8,0x14,0xDE,0x5E,0x0B,0xDB,
  0xE0,0x32,0x3A,0x0A,0x49,0x06,0x24,0x5C,0xC2,0xD3,0xAC,0x62,0x91,0x95,0xE4,0x79,
  0xE7,0xC8,0x37,0x6D,0x8D,0xD5,0x4E,0xA9,0x6C,0x56,0xF4,0xEA,0x65,0x7A,0xAE,0x08,
  0xBA,0x78,0x25,0x2E,0x1C,0xA6,0xB4,0xC6,0xE8,0xDD,0x74,0x1F,0x4B,0xBD,0x8B,0x8A,
  0x70,0x3E,0xB5,0x66,0x48,0x03,0xF6,0x0E,0x61,0x35,0x57,0xB9,0x86,0xC1,0x1D,0x9E,
  0xE1,0xF8,0x98,0x11,0x69,0xD9,0x8E,0x94,0x9B,0x1E,0x87,0xE9,0xCE,0x55,0x28,0xDF,
  0x8C,0xA1,0x89,0x0D,0xBF,0xE6,0x42,0x68,0x41,0x99,0x2D,0x0F,0xB0,0x54,0xBB,0x16};
return t[x];}
</code>```

This function is not arbitrary; it is a reversible mapping, consisting of an inversion in a Galois Field followed by an affine transformation. All the details are in FIPS-197 section 5.1.1 or here section 4.2.1 (under a slightly different name).

One problem with implementation as a table is that it opens to so-called cache-timing attacks.

Thus your mission is to devise an exact replacement for the above SubBytes() function, that exhibits constant-time behavior; we'll assume that's the case when nothing depending on the input x of SubBytes is used  either:

as an array index,

as the control operand of if, while, for, case, or operator ?:;

as any operand of operators &&, ||, !, ==, !=, <, >, <=, >=, *, /, %;

as the right operand of operators >>, <<, *=, /=, %=, <<=, >>=.

The winning entry will be one with the lowest cost, obtained from the number of operators executed in the input-dependent data path, with a weight of 5 for unary operators - and ~ as well as for <<1, >>1, +1, -1; weight of 7 for all other operators, shifts with other counts, or adds/subs of other constants (type casts and promotions are free). By principle, that cost is unchanged by unrolling loops (if any), and independent of the input x. As a tie-breaker, the answer with the shortest code after removing whitespace and comments wins.

I plan to designate an entry as answer as early as I can in year 2013, UTC. I will consider answers in languages that I've some knowledge of, ranking them as a straight translation to C not optimized for size.

Apologies for the initial omission of +1 and -1 in the favored operators, of free casts and promotions, and ranking of size. Note that * is prohibited both when unary, and as multiplication.

Body:
Score: 256*(7+(8*(7+7+7)-(2+2))+5+7+7)=48640 (assuming loops unrolled)

unsigned char SubBytes(unsigned char x) {
static const unsigned char t[256] = {
  0x63,0x7C,0x77,0x7B,0xF2,0x6B,0x6F,0xC5,0x30,0x01,0x67,0x2B,0xFE,0xD7,0xAB,0x76,
  0xCA,0x82,0xC9,0x7D,0xFA,0x59,0x47,0xF0,0xAD,0xD4,0xA2,0xAF,0x9C,0xA4,0x72,0xC0,
  0xB7,0xFD,0x93,0x26,0x36,0x3F,0xF7,0xCC,0x34,0xA5,0xE5,0xF1,0x71,0xD8,0x31,0x15,
  0x04,0xC7,0x23,0xC3,0x18,0x96,0x05,0x9A,0x07,0x12,0x80,0xE2,0xEB,0x27,0xB2,0x75,
  0x09,0x83,0x2C,0x1A,0x1B,0x6E,0x5A,0xA0,0x52,0x3B,0xD6,0xB3,0x29,0xE3,0x2F,0x84,
  0x53,0xD1,0x00,0xED,0x20,0xFC,0xB1,0x5B,0x6A,0xCB,0xBE,0x39,0x4A,0x4C,0x58,0xCF,
  0xD0,0xEF,0xAA,0xFB,0x43,0x4D,0x33,0x85,0x45,0xF9,0x02,0x7F,0x50,0x3C,0x9F,0xA8,
  0x51,0xA3,0x40,0x8F,0x92,0x9D,0x38,0xF5,0xBC,0xB6,0xDA,0x21,0x10,0xFF,0xF3,0xD2,
  0xCD,0x0C,0x13,0xEC,0x5F,0x97,0x44,0x17,0xC4,0xA7,0x7E,0x3D,0x64,0x5D,0x19,0x73,
  0x60,0x81,0x4F,0xDC,0x22,0x2A,0x90,0x88,0x46,0xEE,0xB8,0x14,0xDE,0x5E,0x0B,0xDB,
  0xE0,0x32,0x3A,0x0A,0x49,0x06,0x24,0x5C,0xC2,0xD3,0xAC,0x62,0x91,0x95,0xE4,0x79,
  0xE7,0xC8,0x37,0x6D,0x8D,0xD5,0x4E,0xA9,0x6C,0x56,0xF4,0xEA,0x65,0x7A,0xAE,0x08,
  0xBA,0x78,0x25,0x2E,0x1C,0xA6,0xB4,0xC6,0xE8,0xDD,0x74,0x1F,0x4B,0xBD,0x8B,0x8A,
  0x70,0x3E,0xB5,0x66,0x48,0x03,0xF6,0x0E,0x61,0x35,0x57,0xB9,0x86,0xC1,0x1D,0x9E,
  0xE1,0xF8,0x98,0x11,0x69,0xD9,0x8E,0x94,0x9B,0x1E,0x87,0xE9,0xCE,0x55,0x28,0xDF,
  0x8C,0xA1,0x89,0x0D,0xBF,0xE6,0x42,0x68,0x41,0x99,0x2D,0x0F,0xB0,0x54,0xBB,0x16};

unsigned char ret_val = 0;
int i,j;
for(i=0;i<256;i++) {
  unsigned char is_index = (x ^ ((unsigned char) i));
  for(j=0;j<8;j++) {
   is_index |= (is_index << (1 << j)) | (is_index >> (1 << j));
  }
  is_index = ~is_index;
  ret_val |= is_index & t[i];
}

return ret_val;}

Explanation:

Essentially an array lookup reimplemented using bitwise operators and always processing the entire array.  We loop through the array, and xor x with each index, then use bitwise operators to logically negate the result, so we get 255 when x=i and 0 otherwise. We bitwise-and this with the array-value, so that the chosen value is unchanged and the others become 0.  Then we take the bitwise-or of this array, thereby pulling out only the chosen value.

The two 1 << j operations would go away as part of unrolling the loop, replacing them with the powers of 2 from 1 through 128.


问:
"Cut and Paste Sorting"
The Challenge

Given a string containing a random sequence of unique characters A to Z (all upper case, no duplicates), determine the cut-and-paste" sort and output the sort sequence to a specific format (detailed below).

Definition of Cut-And-Paste Sort, by Example

Example string:
AKJCFEGHDBI

This string contains 11 characters, of which A, C, E, G, H, and I form the longest "lengthy sequence" from left to right that is in alphabetic order. So we base the cut-and-paste around these key letters.

If there is more than one "lengthy sequence" of equal length, the code will always favor the lengthy sequence with the biggest "stretch" across the entire string.

In the case of a slightly different string than our original example, AKGHJCFDEBI, there are three lengthy sequences of ACDE, AGHJ, and AGHI, but the code will favor the sequence with the greatest stretch, which in this case is AGHI because the distance between A and I is greatest amongst the three as opposed to the A to E in the first sequence and the A to J in the second sequence. If there happens to be more than one lengthy sequence with the same stretch length, the first lengthy sequence in alphabetic order will be chosen, just to make it easy.

The cut-and-paste sort is simply a case of plucking the appropriate letters not within the key letters and placing them back in their respective positions in alphabetic order.

Then the sort from our original example would occur as follows:

```<code>Step 1: AKJCFEGHDBI
Step 2: ABKJCFEGHDI (B gets cut and takes 8 steps to the left and gets pasted after A)
Step 3: ABKJCDFEGHI (D gets cut and takes 4 steps to the left and gets pasted after C)
Step 4: ABKJCDEFGHI (F gets cut and takes 1 step to the right and gets pasted after E)
Step 5: ABKCDEFGHIJ (J gets cut and takes 7 steps to the right and gets pasted after I)
Step 6: ABCDEFGHIJK (K gets cut and takes 8 steps to the right and gets pasted after J)
</code>```

To make it easier for the purpose of this challenge we can rewrite this sort as:

B<<<<<<<<D<<<<F>J>>>>>>>K>>>>>>>>

where each letter represents the letter being cut, followed by a series of left or right arrows, represented by the < and > characters. When the arrows end, it is implied that the letter is pasted.

Bear in mind that the number of letters being cut at any one time can be more than one, so long as the letters are sequential. So if there is a string that can have two or more letters cut at any one time, the code should favor using the larger rather than perform two or more individual cut-and-pastes as this will provide a more efficient cut-paste sort.

For example:

```<code>AKGHJCFDEBI
Lengthy sequences: ACDE AGHJ AGHI; AGHI is chosen (longest stretch)
Step 1: AKGHJCFDEBI
Step 2: ABKGHJCFDEI (B<<<<<<<<)
Step 3: ABCKGHJFDEI (C<<<<)
Step 4: ABCDEKGHJFI (DE<<<<<)
        Note two or more letters can be moved as long as they are side-by-side
Step 5: ABCDEFKGHJI (F<<<<)
Step 6: ABCDEFKGHIJ (J>)
Step 7: ABCDEFGHIJK (K>>>>)

End result: B<<<<<<<<C<<<<DE<<<<<F<<<<J>K>>>>
</code>```

Code Behavior

The code must take an alphabetic upper case string with unique letters (Please assume that this string will always be upper case and with all unique letters, i.e. no dupliates), and perform a cut-paste sort according to the above rules and provide a formatted string simliar to B<<<<<<<<C<<<<DE<<<<<F<<<<J>K>>>> providing the method of cutting and pasting respective letters to achieve a string in alphabetic order.

Test Cases

AKJCFEGHDBI
Result: B<<<<<<<<D<<<<F>J>>>>>>>K>>>>>>>>

AKGHJCFDEBI
Result: B<<<<<<<<C<<<<DE<<<<<F<<<<J>K>>>>

BDEFHGI
Result: H>

ABC
Result:  (already sorted)

CBA
Result: B>C>>

Rules

Code Golf: Shortest code wins...

Code must be in the form of a piece of STDIN/STDOUT code, or a function taking the input string as a parameter and returning the output string

Code must be suported by a working version of the code or verified execution of test cases.

In the event that there are two or more with the same character count, the winner will be chosen by the most upvotes.

No silly loopholes

答:
PHP, 859 bytes

not the shortest code (yet?), but for shorter output.

Added line breaks for a little reading convenience.

```<code>function s($u,$a=''){$r=[];for($i=$k=0;$i<strlen($u);$i++)if($u[$i]>substr($a,-1))$r=array_merge($r,s(substr($u,$i+1),$a.$u[$i]));return$r?:[chr(59-strlen($a)).$a];}$w=s($a=$argv[1]);sort($w);$r=preg_split('#_+#',preg_replace("#[$w[0]]#",'_$0_',$a),-1,1);$v=substr;$x=strlen;
for($i=count($r);$i--;)if(!strpos($w[0],$q=&$r[$i]))for($o=0;++$o<$x($q);)if($q[$o-1]>$c=$q[$p=$o]){for(;++$p<$x($q) & $q[$p]>$c & $q[$p]<$q[$o-1];)$c.=$q[$p];echo$c;for(;$q[$o-1]>$v($c,-1);echo'<')$q[--$p]=$q[--$o];$q=$v($q,0,$o).$c.$v($q,$p);$o-=2;}
for(;$n<count($r);$n=count($r),$r=str_split(join($r),1))for($i=-1;++$i<count($r);)if(!strpos($w[0],$r[$i])){$s=array_splice($r,$i,1);for($e=0,$k=$i;$v($s[0],-1)<$r[--$k][0];)$e-=$x($r[$k]);for(;++$k<count($r) & $s[0][0]>$v($r[$k],-1);)$e+=$x($r[$k]);if($e)echo$s[0].str_repeat('><'[$e<0],abs($e));array_splice($r,$k,0,$s);$i-=$k>$i;}
</code>```

examples

```<code>INPUT           KEY     OUTPUT                      RESULT
AKJCFEGHDBI     ACEGHI  B<J<JK>>>>>>>>F>BD<<<<B<    ABCDEFGHIJK
AKGHJCFDEBI     ACDEI   GHJ<GHJK>>>>>F>>>B<<<K>     BCDEFGHJIK
BDEFHGI         BDEFGI  H>                          BDEFGHI
ABC             ABC     _empty_                     ABC
CBA             A       B<BC>                       ABC
PHCODER         CDER    H<HP>O>>P>>>                CHDEOPR
XTREMGOD        EGO     T<R<<RTX>>>>>M>D<<<<        DEGMORTX        (I love it)
</code>```

Yup. It fails for PHCODER. It´s buggy, but it´s nice.

btw: The shortest possible output for that is O
>HOP>>> (for example).

Title: "Cut and Paste Sorting"

Body:
PHP, 859 bytes

not the shortest code (yet?), but for shorter output.

Added line breaks for a little reading convenience.

function s($u,$a=''){$r=[];for($i=$k=0;$i<strlen($u);$i++)if($u[$i]>substr($a,-1))$r=array_merge($r,s(substr($u,$i+1),$a.$u[$i]));return$r?:[chr(59-strlen($a)).$a];}$w=s($a=$argv[1]);sort($w);$r=preg_split('#_+#',preg_replace("#[$w[0]]#",'_$0_',$a),-1,1);$v=substr;$x=strlen;
for($i=count($r);$i--;)if(!strpos($w[0],$q=&$r[$i]))for($o=0;++$o<$x($q);)if($q[$o-1]>$c=$q[$p=$o]){for(;++$p<$x($q) & $q[$p]>$c & $q[$p]<$q[$o-1];)$c.=$q[$p];echo$c;for(;$q[$o-1]>$v($c,-1);echo'<')$q[--$p]=$q[--$o];$q=$v($q,0,$o).$c.$v($q,$p);$o-=2;}
for(;$n<count($r);$n=count($r),$r=str_split(join($r),1))for($i=-1;++$i<count($r);)if(!strpos($w[0],$r[$i])){$s=array_splice($r,$i,1);for($e=0,$k=$i;$v($s[0],-1)<$r[--$k][0];)$e-=$x($r[$k]);for(;++$k<count($r) & $s[0][0]>$v($r[$k],-1);)$e+=$x($r[$k]);if($e)echo$s[0].str_repeat('><'[$e<0],abs($e));array_splice($r,$k,0,$s);$i-=$k>$i;}

examples

INPUT           KEY     OUTPUT                      RESULT
AKJCFEGHDBI     ACEGHI  B<J<JK>>>>>>>>F>BD<<<<B<    ABCDEFGHIJK
AKGHJCFDEBI     ACDEI   GHJ<GHJK>>>>>F>>>B<<<K>     BCDEFGHJIK
BDEFHGI         BDEFGI  H>                          BDEFGHI
ABC             ABC     _empty_                     ABC
CBA             A       B<BC>                       ABC
PHCODER         CDER    H<HP>O>>P>>>                CHDEOPR
XTREMGOD        EGO     T<R<<RTX>>>>>M>D<<<<        DEGMORTX        (I love it)

Yup. It fails for PHCODER. It´s buggy, but it´s nice.

btw: The shortest possible output for that is O<P>>HOP>>> (for example).


问:
Print This Question ↓
The basic idea of a kolmogorov-complexity challenge is to print a set output in the shortest code (though that meaning has changed now). We have had many of them, from Borromean Rings to The Gettysburg Address.

##Your Task

This question is similar, except that it requires printing of a special text - the text of this question. Specifically, the very Markdown code that I am typing right now.

To prevent an infinite recursion in the question, the exact text you have to print can be found here.

##Clarifications

You are not allowed to use any external sources like the internet.

This means that the purpose of this question is not to download this question text and parse it, but instead to store it in you program.

This is code-golf, so shortest code in bytes wins!

答:
///, <s>976</s> 961 bytes

```<code>/?/ code //_/shortest?//^/text //@/the//$/ the //&/ to //`/question//~/codegolf.stackexchange.com/The basic idea of a [tag:kolmogorov-complexity] challenge is&print a set output in$_(though that meaning has changed now). We have had many of @m, from [Borromean Rings](http:\/\/~\/questions\/53417\/ascii-borromean-rings)&[The Gettysburg Address](http:\/\/~\/questions\/15395\/how-random-is-@-gettysburg-address).

##Your Task

This ` is similar, except that it requires printing of a special ^-$^of this `. Specifically,$very Markdown?that I am typing right now.

To prevent an infinite recursion in$`,$exact ^you have&print can be found [here](http:\/\/~\/revisions\/1f731ea3-0950-4b03-ae95-24fa812a9a28\/view-source).

##Clarifications

- You are not allowed&use any external sources like$internet.
- This means that$purpose of this ` is not&download this ` ^and parse it, but instead&store it in you program.
- This is [tag:code-golf], so _in **bytes** wins!
</code>```

-15 bytes thanks to steenbergh

Try it online!

Title: Print This Question ↓

Body:
///, <s>976</s> 961 bytes

/?/ code //_/shortest?//^/text //@/the//$/ the //&/ to //`/question//~/codegolf.stackexchange.com/The basic idea of a [tag:kolmogorov-complexity] challenge is&print a set output in$_(though that meaning has changed now). We have had many of @m, from [Borromean Rings](http:\/\/~\/questions\/53417\/ascii-borromean-rings)&[The Gettysburg Address](http:\/\/~\/questions\/15395\/how-random-is-@-gettysburg-address).

##Your Task

This ` is similar, except that it requires printing of a special ^-$^of this `. Specifically,$very Markdown?that I am typing right now.

To prevent an infinite recursion in$`,$exact ^you have&print can be found [here](http:\/\/~\/revisions\/1f731ea3-0950-4b03-ae95-24fa812a9a28\/view-source).

##Clarifications

- You are not allowed&use any external sources like$internet.
- This means that$purpose of this ` is not&download this ` ^and parse it, but instead&store it in you program.
- This is [tag:code-golf], so _in **bytes** wins!

-15 bytes thanks to steenbergh

<a href="https://tio.run/nexus/slashes#dZPBbtswDIbveQoONYI2iKKmadCml3bbYdhhly7AMCRNS9u0LcS2XIlO4ktfvaOcLsAOAwzLJvT/pD6K7/peQ2JTAq2ftS@sY/J8r/VGMx1Yog@aC9I60iCr/A/lw8r6ol9b2WpsrfWbDha5LbOJZ0y2dEgKrHOaJLbSS5HF6E0CJiUEmwHCijG/29qysrl1dqdkX1PSwXD3BCItSxI1GD9snKlZBJ4YbMtNy2Dq6PmcC9vmhZSEDBVhbeocCvRwzJtCbfcXE/hFEtyFVwoV1l1I/lCNIXO2gtUX62QVMTyK3D@dF8zN3Vqv9dv6dDi/1vPZ9fRmrdEnxqj4r0i5ILoYrsL5vhFz5@PW5fA5TR35/7tN57PFfK0Lu1cO69RWynj1oPKTg8Kjw8VkMDg7@21bB0v028FgWRgPL0IFvKlMiW4MApoaPmIwDI5eWyNa6LEFJj1t31BisISNijYS4N5nAj9DODOJ4O7G0Y5cBz/QbVO7r@97x@@AFXDXBCNn8oIDVqlqaSUB7Sh0ppZ@ZKY2TJI9aZ2XU4YWvYwjOmDCsOls23fho5eJSGKCzLZ1CquCHP2LSoyN/0CV3cymhDN1uZhfquv4cqaQFnN1dZ3h7fQKF3h1u9Y7Q3vlBVNCR2RfBU1/rp74YKBAIAI6kvKl4rK0e0qHrScIV0JuObla6BwtPJRmS5FUKlHiiah77qHlvgcdNa1rrKhPKENLxHoYyJVW7tpHeCP9hQad7DU8hri/vJ4J06Fn60JUAhAANc7mDqtTOnn6GQlzpcJgPY2lQHiW7aNR3MmQjkawF7dP7@9/AA" rel="nofollow noreferrer" title="/// – TIO Nexus">Try it online!


答:
Python 3, <s>77</s> 74 bytes

-3 bytes thanks to @Maltysen (init j in declaration)

```<code>lambda l,n,j=0:exec('j*=j<len(l)-1;l[j:j+2]=sorted(l[j:j+2]);j+=1;'*n)or l
</code>```

Test cases at ideone

Uses sorted to do each compare and swap operation, but it is performing a bubble sort.

Sets j=0 (the left index), then performs n compare and swaps of adjacent list items, resetting j to 0 whenever this window goes out of bounds.

The j*=j<len(l)-1 will multiply j by False (i.e. 0) at that point, whereas every other time it will multiply j by True (i.e. 1).

(It will still work for an empty list too.)

Title: Bubble sorting in progress

Body:
Python 3, <s>77</s> 74 bytes

-3 bytes thanks to @Maltysen (init j in declaration)

lambda l,n,j=0:exec('j*=j<len(l)-1;l[j:j+2]=sorted(l[j:j+2]);j+=1;'*n)or l

Test cases at ideone

Uses sorted to do each compare and swap operation, but it is performing a bubble sort.

Sets j=0 (the left index), then performs n compare and swaps of adjacent list items, resetting j to 0 whenever this window goes out of bounds.

The j*=j<len(l)-1 will multiply j by False (i.e. 0) at that point, whereas every other time it will multiply j by True (i.e. 1).

(It will still work for an empty list too.)


答:
R, <s>132</s> <s>131</s> <s>112</s> 136 bytes

The programme receives the input as follows: first N, then the vector itself. For example, if you want v = [5 1 4 2 8] and n = 1, the input that goes into the scan is 1 5 1 4 2 8. So in order to run this programme, you run the first line, feed the numbers one by one in the console, and then run the rest (this is a REPL answer).

Then the following code does the trick:

```<code>v=scan()
s=m=0
while(!s){s=T;for(i in 3:length(v)){m=m+1
if(m>v[1]){s=T;break}
if(v[i-1]>v[i]){v[c(i-1,i)]=v[c(i,i-1)];s=F}}}
cat(v[-1])
</code>```

Test:

```<code>Input: a vector with N first and the elements to be sorted next
1 5 1 4 2 8
5 5 1 4 2 8
14 5 1 4 2 8
60 15 18 -6 18  9 -7 -1  7 19 19 -5 20 19  5 15 -5  3 18 14 19

Output:
1 5 4 2 8
1 4 2 5 8
1 2 4 5 8
-6 -7 -1  9  7 15 18 -5 18 19  5 15 -5  3 18 14 19 19 19 20
</code>```

Update: golfed 1 byte owing to Vlo.

Title: Bubble sorting in progress

Body:
R, <s>132</s> <s>131</s> <s>112</s> 136 bytes

The programme receives the input as follows: first N, then the vector itself. For example, if you want v = [5 1 4 2 8] and n = 1, the input that goes into the scan is 1 5 1 4 2 8. So in order to run this programme, you run the first line, feed the numbers one by one in the console, and then run the rest (this is a REPL answer).

Then the following code does the trick:

v=scan()
s=m=0
while(!s){s=T;for(i in 3:length(v)){m=m+1
if(m>v[1]){s=T;break}
if(v[i-1]>v[i]){v[c(i-1,i)]=v[c(i,i-1)];s=F}}}
cat(v[-1])

Test:

Input: a vector with N first and the elements to be sorted next
1 5 1 4 2 8
5 5 1 4 2 8
14 5 1 4 2 8
60 15 18 -6 18  9 -7 -1  7 19 19 -5 20 19  5 15 -5  3 18 14 19

Output:
1 5 4 2 8
1 4 2 5 8
1 2 4 5 8
-6 -7 -1  9  7 15 18 -5 18 19  5 15 -5  3 18 14 19 19 19 20

Update: golfed 1 byte owing to Vlo.


问:
Golf you a quine for great good!
Using your language of choice, golf a quine.

A quine is a non-empty computer program which takes no input and produces a copy of its own source code as its only output.

No cheating -- that means that you can't just read the source file and print it. Also, in many languages, an empty file is also a quine: that isn't considered a legit quine either.

No error quines -- there is already a separate challenge for error quines.

Points for:

Smallest code (in bytes)

Most obfuscated/obscure solution

Using esoteric/obscure languages

Successfully using languages that are difficult to golf in

The following Stack Snippet can be used to get a quick view of the current score in each language, and thus to know which languages have existing answers and what sort of target you have to beat:

var QUESTION_ID=69;
var OVERRIDE_USER=98;

var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";var COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk";var answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,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:!0,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=!1;comment_page=1;getComments()}})}
function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,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=(function(){var headerTag=String.raw `h\d`
var score=String.raw `\-?\d+\.?\d*`
var normalText=String.raw `[^\n<>]*`
var strikethrough=String.raw `<s>${normalText}</s>|<strike>${normalText}</strike>|<del>${normalText}</del>`
var noDigitText=String.raw `[^\n\d<>]*`
var htmlTag=String.raw `<[^\n<>]+>`
return new RegExp(String.raw `<${headerTag}>`+String.raw `\s*([^\n,]*[^\s,]),.*?`+String.raw `(${score})`+String.raw `(?=`+String.raw `${noDigitText}`+String.raw `(?:(?:${strikethrough}|${htmlTag})${noDigitText})*`+String.raw `</${headerTag}>`+String.raw `)`)})();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;lang=jQuery(''+a.language+'').text().toLowerCase();languages[lang]=languages[lang]||{lang:a.language,user:a.user,size:a.size,link:a.link,uniq:lang}});var langs=[];for(var lang in languages)
if(languages.hasOwnProperty(lang))
langs.push(languages[lang]);langs.sort(function(a,b){if(a.uniq>b.uniq)return 1;if(a.uniq<b.uniq)return-1;return 0});for(var i=0;i<langs.length;++i)
{var language=jQuery("#language-template").html();var lang=langs[i];language=language.replace("{{LANGUAGE}}",lang.lang).replace("{{NAME}}",lang.user).replace("{{SIZE}}",lang.size).replace("{{LINK}}",lang.link);language=jQuery(language);jQuery("#languages").append(language)}}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list{padding:10px;float:left}#language-list{padding:10px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

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

Winners by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

 ```

答:
Vim, <s>17</s>, 14 keystrokes

Someone randomly upvoted this, so I remembered that it exists. When I re-read it, I thought "Hey, I can do better than that!", so I golfed two bytes off. It's still not the shortest, but at least it's an improvement.

For a long time, I've been wondering if a vim quine is possible. On one hand, it must be possible, since vim is turing complete. But after looking for a vim quine for a really long time, I was unable to find one. I did find this PPCG challenge, but it's closed and not exactly about literal quines. So I decided to make one, since I couldn't find one.

I'm really proud of this answer, because of two firsts:

This is the first quine I have ever made, and

As far as I know, this is the worlds first vim-quine to ever be published! I could be wrong about this, so if you know of one, please let me know.

So, after that long introduction, here it is:

```<code>qqX"qpAq@q<esc>q@q
</code>```

Try it online!

Note that when you type this out, it will display the <esc> keystroke as ^[. This is still accurate, since ^[ represents 0x1B, which is escape in ASCII, and the way vim internally represents the <esc> key.

Also note, that testing this might fail if you load an existing vim session. I wrote a tips answer explaining that here, if you want more information, but basically you need to launch vim with

```<code>vim -u NONE -N -i NONE
</code>```

or type qqq before running this.

Explanation:

```<code>qq                  " Start recording into register 'q'
  X                 " Delete one character before the cursor (Once we play this back, it will delete the '@')
   "qp              " Paste register 'q'
      Aq@q<esc>     " Append 'q@q' to this line
               q    " Stop recording
                @q  " Playback register 'q'
</code>```

On a side note, this answer is probably a world record for most 'q's in a PPCG answer, or something.

Title: Golf you a quine for great good!

Body:
Vim, <s>17</s>, 14 keystrokes

Someone randomly upvoted this, so I remembered that it exists. When I re-read it, I thought "Hey, I can do better than that!", so I golfed two bytes off. It's still not the shortest, but at least it's an improvement.

For a long time, I've been wondering if a vim quine is possible. On one hand, it must be possible, since vim is turing complete. But after looking for a vim quine for a really long time, I was unable to find one. I did find this PPCG challenge, but it's closed and not exactly about literal quines. So I decided to make one, since I couldn't find one.

I'm really proud of this answer, because of two firsts:

This is the first quine I have ever made, and

As far as I know, this is the worlds first vim-quine to ever be published! I could be wrong about this, so if you know of one, please let me know.

So, after that long introduction, here it is:

qqX"qpAq@q<esc>q@q

Try it online!

Note that when you type this out, it will display the <esc> keystroke as ^[. This is still accurate, since ^[ represents 0x1B, which is escape in ASCII, and the way vim internally represents the <esc> key.

Also note, that testing this might fail if you load an existing vim session. I wrote a tips answer explaining that here, if you want more information, but basically you need to launch vim with

vim -u NONE -N -i NONE

or type qqq before running this.

Explanation:

qq                  " Start recording into register 'q'
  X                 " Delete one character before the cursor (Once we play this back, it will delete the '@')
   "qp              " Paste register 'q'
      Aq@q<esc>     " Append 'q@q' to this line
               q    " Stop recording
                @q  " Playback register 'q'

On a side note, this answer is probably a world record for most 'q's in a PPCG answer, or something.


答:
Javascript (ES6), <s>261</s> <s>255</s> 254 characters

Saved 1 byte, thanks to ETHproductions

```<code>_=>'L'+"⫒㠰拳␰䨒堵̎⨦W䙨ⅶ嵷˘㥆姳䗨⠬巯堡Ŋɩ懪䨶尩个˒≎㥎䜩怷㰷䤆ŵ̊㹩⫒ᨠᩌ㳠抮f̅㩊ᠰ䀩㩎搰㩊ئ抠ˮ婱拗⠩啺巨㬆ɒ㸘∦㰲䤆姵㩀Ƕ̘㨆㬴⠳⠺…䈲䥒䤠⫱᬴w㬣ᠶ⬘嗠⫘䥀噯䗠⫀⫓䕭啩̎Ɏ㹹庘⬆⭀巯奠Ŷ㷨䌯䥀噯⠪ⰸ㦸̆㼱ï哳峮૘梠䵨慷堵幎≠⣨峨愠◳ᬆ䐷ɒ䫓⥎ܑ拠̑Ɏ㼨ó㬴⹠⇫î奩拊̑㹰巯䓠ȮŎ廪ᨀ噧ਸ".replace(/./g,c=>(s=" ,.DEUabcdefghilmnopqrstuvx")[(c=c.charCodeAt()-32)&31]+s[c>>5&31]+s[c>>10])
</code>```

Breakdown

Payload: 148 Unicode characters

Code: 107 bytes

How it works

We first remove the leading 'L' from the original message so that we're left with 444 = 148 * 3 characters.

Without the leading 'L', the character set is made of the 27 following characters:

```<code>" ,.DEUabcdefghilmnopqrstuvx"
</code>```

Each group of 3 characters is encoded as:

```<code>n = 32 + a + b * 32 + c * 32^2
</code>```

where a, b and c are the indices of the characters in the above character set.

This leads to a Unicode code point in the range U+0020 to U+801F, ending somewhere in the "CJK Unified Ideographs".

let f =
_=>'L'+"⫒㠰拳␰䨒堵̎⨦W䙨ⅶ嵷˘㥆姳䗨⠬巯堡Ŋɩ懪䨶尩个˒≎㥎䜩怷㰷䤆ŵ̊㹩⫒ᨠᩌ㳠抮f̅㩊ᠰ䀩㩎搰㩊ئ抠ˮ婱拗⠩啺巨㬆ɒ㸘∦㰲䤆姵㩀Ƕ̘㨆㬴⠳⠺…䈲䥒䤠⫱᬴w㬣ᠶ⬘嗠⫘䥀噯䗠⫀⫓䕭啩̎Ɏ㹹庘⬆⭀巯奠Ŷ㷨䌯䥀噯⠪ⰸ㦸̆㼱ï哳峮૘梠䵨慷堵幎≠⣨峨愠◳ᬆ䐷ɒ䫓⥎ܑ拠̑Ɏ㼨ó㬴⹠⇫î奩拊̑㹰巯䓠ȮŎ廪ᨀ噧ਸ".replace(/./g,c=>(s=" ,.DEUabcdefghilmnopqrstuvx")[(c=c.charCodeAt()-32)&31]+s[c>>5&31]+s[c>>10])

console.log(f())```

Body:
Javascript (ES6), <s>261</s> <s>255</s> 254 characters

Saved 1 byte, thanks to ETHproductions

_=>'L'+"⫒㠰拳␰䨒堵̎⨦W䙨ⅶ嵷˘㥆姳䗨⠬巯堡Ŋɩ懪䨶尩个˒≎㥎䜩怷㰷䤆ŵ̊㹩⫒ᨠᩌ㳠抮f̅㩊ᠰ䀩㩎搰㩊ئ抠ˮ婱拗⠩啺巨㬆ɒ㸘∦㰲䤆姵㩀Ƕ̘㨆㬴⠳⠺…䈲䥒䤠⫱᬴w㬣ᠶ⬘嗠⫘䥀噯䗠⫀⫓䕭啩̎Ɏ㹹庘⬆⭀巯奠Ŷ㷨䌯䥀噯⠪ⰸ㦸̆㼱ï哳峮૘梠䵨慷堵幎≠⣨峨愠◳ᬆ䐷ɒ䫓⥎ܑ拠̑Ɏ㼨ó㬴⹠⇫î奩拊̑㹰巯䓠ȮŎ廪ᨀ噧ਸ".replace(/./g,c=>(s=" ,.DEUabcdefghilmnopqrstuvx")[(c=c.charCodeAt()-32)&31]+s[c>>5&31]+s[c>>10])

Breakdown

Payload: 148 Unicode characters

Code: 107 bytes

How it works

We first remove the leading 'L' from the original message so that we're left with 444 = 148 * 3 characters.

Without the leading 'L', the character set is made of the 27 following characters:

" ,.DEUabcdefghilmnopqrstuvx"

Each group of 3 characters is encoded as:

n = 32 + a + b * 32 + c * 32^2

where a, b and c are the indices of the characters in the above character set.

This leads to a Unicode code point in the range U+0020 to U+801F, ending somewhere in the "CJK Unified Ideographs".

let f =
_=>'L'+"⫒㠰拳␰䨒堵̎⨦W䙨ⅶ嵷˘㥆姳䗨⠬巯堡Ŋɩ懪䨶尩个˒≎㥎䜩怷㰷䤆ŵ̊㹩⫒ᨠᩌ㳠抮f̅㩊ᠰ䀩㩎搰㩊ئ抠ˮ婱拗⠩啺巨㬆ɒ㸘∦㰲䤆姵㩀Ƕ̘㨆㬴⠳⠺…䈲䥒䤠⫱᬴w㬣ᠶ⬘嗠⫘䥀噯䗠⫀⫓䕭啩̎Ɏ㹹庘⬆⭀巯奠Ŷ㷨䌯䥀噯⠪ⰸ㦸̆㼱ï哳峮૘梠䵨慷堵幎≠⣨峨愠◳ᬆ䐷ɒ䫓⥎ܑ拠̑Ɏ㼨ó㬴⹠⇫î奩拊̑㹰巯䓠ȮŎ廪ᨀ噧ਸ".replace(/./g,c=>(s=" ,.DEUabcdefghilmnopqrstuvx")[(c=c.charCodeAt()-32)&31]+s[c>>5&31]+s[c>>10])

console.log(f())


答:
Pyth, <s>34</s> 32 Bytes

```<code>AQVH=*<ZtlGZ=GsXJcG,Zh=hZ1ShtJ;G
</code>```

A translation of Jonathan Allan's Python answer.

Try it here!

Title: Bubble sorting in progress

Body:
Create a function or program that takes two inputs:

A list of integers that shall be sorted (less than 20 elements)

A positive integer, N, saying how many comparisons you should take

The function shall stop, and output the resulting list of integers after N comparisons. If the list is fully sorted before N comparisons are made, then the sorted list should be outputted.

The Bubble sort algorithm is well known, and I guess most people know it. The following Pseudo-code and animation (both from the linked Wikipedia-article) should provide the necessary details:

```<code>procedure bubbleSort( A : list of sortable items )
   n = length(A)
   repeat
     swapped = false
     for i = 1 to n-1 inclusive do
       /* if this pair is out of order */
       if A[i-1] > A[i] then
         /* swap them and remember something changed */
         swap( A[i-1], A[i] )
         swapped = true
       end if
     end for
   until not swapped
end procedure
</code>```

The animation below shows the progress:

An example (taken directly from the linked Wikipedia article) shows the steps when sorting the list: ( 5 1 4 2 8 ):

First Pass

```<code>1: ( 5 1 4 2 8 ) ->  ( 1 5 4 2 8 ) // Here, algorithm compares the first two elements,
                                   // and swaps since 5 > 1.
2: ( 1 5 4 2 8 ) ->  ( 1 4 5 2 8 ) // Swap since 5 > 4
3: ( 1 4 5 2 8 ) ->  ( 1 4 2 5 8 ) // Swap since 5 > 2
4: ( 1 4 2 5 8 ) ->  ( 1 4 2 5 8 ) // Now, since these elements are already in order
                                   // (8 > 5), algorithm does not swap them.
</code>```

Second Pass

```<code>5: ( 1 4 2 5 8 ) ->  ( 1 4 2 5 8 )
6: ( 1 4 2 5 8 ) ->  ( 1 2 4 5 8 ) // Swap since 4 > 2
7: ( 1 2 4 5 8 ) ->  ( 1 2 4 5 8 )
8: ( 1 2 4 5 8 ) ->  ( 1 2 4 5 8 )
</code>```

Now, the array is already sorted, but the algorithm does not know if it is completed. The algorithm needs one whole pass without any swap to know it is sorted.

Third Pass

```<code>9: ( 1 2 4 5 8 ) ->  ( 1 2 4 5 8 )
10:( 1 2 4 5 8 ) ->  ( 1 2 4 5 8 )
11:( 1 2 4 5 8 ) ->  ( 1 2 4 5 8 )
12:( 1 2 4 5 8 ) ->  ( 1 2 4 5 8 )
</code>```

Test cases:

Format: Number of comparisons (N): List after N comparisons

```<code>Input list:
5  1  4  2  8
Test cases:
1: 1  5  4  2  8
2: 1  4  5  2  8
3: 1  4  2  5  8
4: 1  4  2  5  8
5: 1  4  2  5  8
6: 1  2  4  5  8
10: 1  2  4  5  8
14: 1  2  4  5  8

Input list:
0: 15  18  -6  18   9  -7  -1   7  19  19  -5  20  19   5  15  -5   3  18  14  19
Test cases:
1: 15  18  -6  18   9  -7  -1   7  19  19  -5  20  19   5  15  -5   3  18  14  19
21: -6  15  18   9  -7  -1   7  18  19  -5  19  19   5  15  -5   3  18  14  19  20
41: -6   9  -7  15  -1   7  18  18  -5  19  19   5  15  -5   3  18  14  19  19  20
60: -6  -7  -1   9   7  15  18  -5  18  19   5  15  -5   3  18  14  19  19  19  20
61: -6  -7  -1   7   9  15  18  -5  18  19   5  15  -5   3  18  14  19  19  19  20
81: -7  -6  -1   7   9  15  -5  18  18   5  15  -5   3  18  14  19  19  19  19  20
119: -7  -6  -1  -5   7   9  15   5  15  -5   3  18  14  18  18  19  19  19  19  20
120: -7  -6  -1  -5   7   9  15   5  15  -5   3  18  14  18  18  19  19  19  19  20
121: -7  -6  -1  -5   7   9   5  15  15  -5   3  18  14  18  18  19  19  19  19  20
122: -7  -6  -1  -5   7   9   5  15  15  -5   3  18  14  18  18  19  19  19  19  20
123: -7  -6  -1  -5   7   9   5  15  -5  15   3  18  14  18  18  19  19  19  19  20
201: -7  -6  -5  -1  -5   3   5   7   9  14  15  15  18  18  18  19  19  19  19  20
221: -7  -6  -5  -5  -1   3   5   7   9  14  15  15  18  18  18  19  19  19  19  20
</code>```

Yes, built-in Bubble sort algorithms are permitted.

No, you can not assume only positive integers, or unique integers.

The sorting must be in the order described above. You can't start at the end of the list

Body:
Pyth, <s>34</s> 32 Bytes

AQVH=*<ZtlGZ=GsXJcG,Zh=hZ1ShtJ;G

A translation of Jonathan Allan's Python answer.

Try it here!