Title: Golf all the 16 logic gates with 2 inputs and 1 output!

Body:
For example, the gate A and B is a logic gate with 2 inputs and 1 output.

There are exactly 16 of them, because:

each logic gate takes two inputs, which can be truthy or falsey, giving us 4 possible inputs

of the 4 possible inputs, each can have an output of truthy and falsey

therefore, there are 2^4 possible logic gates, which is 16.

Your task is to write 16 programs/functions which implement all of them separately.

Your functions/programs must be independent.

They are valid as long as they output truthy/falsey values, meaning that you can implement A or B in Python as lambda a,b:a+b, even if 2 is produced for A=True and B=True.

Score is total bytes used for each function/program.

List of logic gates

0,0,0,0 (false)

0,0,0,1 (and)

0,0,1,0 (A and not B)

0,0,1,1 (A)

0,1,0,0 (not A and B)

0,1,0,1 (B)

0,1,1,0 (xor)

0,1,1,1 (or)

1,0,0,0 (nor)

1,0,0,1 (xnor)

1,0,1,0 (not B)

1,0,1,1 (B implies A)

1,1,0,0 (not A)

1,1,0,1 (A implies B)

1,1,1,0 (nand)

1,1,1,1 (true)

Where the first number is the output for A=false, B=false,
the second number is the output for A=false, B=true,
the third number is the output for A=true, B=false,
the fourth number is the output for A=true, B=true.

Leaderboard

var QUESTION_ID=82938,OVERRIDE_USER=48934;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+(?:\.\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

```

Body:
Brainfuck, 1757 bytes

This is my first golfing solution, please be gentle. :)

Inputs may be '0' (ASCII 48) or '1' (ASCII 49). Inputs are entered as AB (eg. 01 or 11). Truthy output values are 'T' (ASCII 84) or 'F' (ASCII 70).

1.

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

2.

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

3.

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

4.

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

5.

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

6.

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

7.

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

8.

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

9.

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

10.

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

11.

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

12.

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

13.

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

14.

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

15.

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

16.

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


问:
Lithp Tranthlator
My friend made a lisp translator the other day, that is to say it took a string and converted s=>th and S=>Th. It was quite long and I thought that it could be golfed.

So the task is to make a program/function that takes an input string, translates it in to lisp and outputs the string

Test case

```<code>Sam and Sally like Sheep        Tham and Thally like Thheep
Sally likes sausages            Thally liketh thauthageth
Sally sells seashells           Thally thellth theathhellth
</code>```

Note that it doesn't matter that h gets repeated all the time

This is code golf so shortest answer wins

答:
MATL, 17 bytes

```<code>115'th'YX83'Th'YX
</code>```

Try it online!

Explanation

```<code>115    % 's' (ASCII)
'th'   % String 'th'
YX     % Regex replacement
83     % 'S' (ASCII)
'Th'   % String 'Th'
YX     % Regex replacement
</code>```

ContentLicense: CC BY-SA 3.0

Title: Lithp Tranthlator

Body:
MATL, 17 bytes

115'th'YX83'Th'YX

Try it online!

Explanation

115    % 's' (ASCII)
'th'   % String 'th'
YX     % Regex replacement
83     % 'S' (ASCII)
'Th'   % String 'Th'
YX     % Regex replacement


答:
V, 11 byteth

```<code>Ís/th
ÍS/Th
</code>```

Try it online!

V ith a language I made. It'th not finithed, but it'th really good at regekth.

Title: Lithp Tranthlator

Body:
My friend made a lisp translator the other day, that is to say it took a string and converted s=>th and S=>Th. It was quite long and I thought that it could be golfed.

So the task is to make a program/function that takes an input string, translates it in to lisp and outputs the string

Test case

```<code>Sam and Sally like Sheep        Tham and Thally like Thheep
Sally likes sausages            Thally liketh thauthageth
Sally sells seashells           Thally thellth theathhellth
</code>```

Note that it doesn't matter that h gets repeated all the time

This is code golf so shortest answer wins

Body:
V, 11 byteth

Ís/th
ÍS/Th

Try it online!

V ith a language I made. It'th not finithed, but it'th really good at regekth.


答:
PHP, 42 Bytes

if run from a file:

```<code><?=strtr($argv[1],["s"=>"th","S"=>"Th"]);
</code>```

Run as:

```<code>~$ php [file] "This is Silly"
</code>```

Title: Lithp Tranthlator

Body:
PHP, 42 Bytes

if run from a file:

<?=strtr($argv[1],["s"=>"th","S"=>"Th"]);

Run as:

~$ php [file] "This is Silly"


答:
Python 3, 53 bytes

```<code>def l(s):return s.replace("s","th").replace("S","Th")
</code>```

Usage:

```<code>>> l('Sam and Sally like Sheep')

Tham and Thally like Thheep
</code>```

Title: Lithp Tranthlator

Body:
Python 3, 53 bytes

def l(s):return s.replace("s","th").replace("S","Th")

Usage:

>> l('Sam and Sally like Sheep')

Tham and Thally like Thheep


答:
Rust, 46 bytes

```<code>|s:&str|s.replace("s","th").replace("S","Th");
</code>```

Try it online!

Title: Lithp Tranthlator

Body:
Rust, 46 bytes

|s:&str|s.replace("s","th").replace("S","Th");

Try it online!


答:
Befunge 98, <s>37</s> 49 bytes

Original version :

```<code>~:"s"- #v_$"ht",>,
_;#-"S":<;$"hT",^
</code>```

Terminating edition, as per consensus :

```<code>~:a-!#@_:"s"-#v_$"ht",>,
_;#-"S":      <;$"hT",^
</code>```

This leaves a big honking hole in the code grid that I'm not very happy about. I'll look into that when I have the time.

The 49th byte is a space at the end of the second line, included to have a rectangular grid, required to prevent ccbi (and probably other interpreters) from bugging out and printing an infinite line of "Th"s.

Title: Lithp Tranthlator

Body:
Befunge 98, <s>37</s> 49 bytes

Original version :

~:"s"- #v_$"ht",>,
_;#-"S":<;$"hT",^

Terminating edition, as per consensus :

~:a-!#@_:"s"-#v_$"ht",>,
_;#-"S":      <;$"hT",^

This leaves a big honking hole in the code grid that I'm not very happy about. I'll look into that when I have the time.

The 49th byte is a space at the end of the second line, included to have a rectangular grid, required to prevent ccbi (and probably other interpreters) from bugging out and printing an infinite line of "Th"s.


答:
TI-Basic, 126 bytes

```<code>Input Str1
inString(Str1,"s
While Ans
sub(Str1,1,Ans-1)+"th"+sub(Str1,Ans+1,length(Str1)-Ans->Str1
inString(Str1,"s
End
inString(Str1,"S
While Ans
sub(Str1,1,Ans-1)+"Th"+sub(Str1,Ans+1,length(Str1)-Ans->Str1
inString(Str1,"S
End
Str1
</code>```

Title: Lithp Tranthlator

Body:
TI-Basic, 126 bytes

Input Str1
inString(Str1,"s
While Ans
sub(Str1,1,Ans-1)+"th"+sub(Str1,Ans+1,length(Str1)-Ans->Str1
inString(Str1,"s
End
inString(Str1,"S
While Ans
sub(Str1,1,Ans-1)+"Th"+sub(Str1,Ans+1,length(Str1)-Ans->Str1
inString(Str1,"S
End
Str1


答:
GameMaker Language, 74 bytes

```<code>return string_replace_all(string_replace_all(argument0,'s','th'),'S','Th')
</code>```

Title: Lithp Tranthlator

Body:
GameMaker Language, 74 bytes

return string_replace_all(string_replace_all(argument0,'s','th'),'S','Th')


答:
<s>SpecBAS</s> ThpecBATh - 53 bytes

```<code>1 INPUT a$: ?REPLACE$(REPLACE$(a$,"S","Th"),"s","th")
</code>```

Title: Lithp Tranthlator

Body:
<s>SpecBAS</s> ThpecBATh - 53 bytes

1 INPUT a$: ?REPLACE$(REPLACE$(a$,"S","Th"),"s","th")


答:
Python 3 - 40 byteth

First golfing!

```<code>lambda s:s.translate({115:'th',83:'Th'})
</code>```

It uses the str module's translate method which accepts a translation table. The translation table is a simple dict with keycode as keys and the str in place of it as value.

Title: Lithp Tranthlator

Body:
Python 3 - 40 byteth

First golfing!

lambda s:s.translate({115:'th',83:'Th'})

It uses the str module's translate method which accepts a translation table. The translation table is a simple dict with keycode as keys and the str in place of it as value.


问:
Wait a minute – in less than ten seconds

Task

Using any type of parallelisation, wait multiple periods, for a total sleep time of at least a minute (but less than a minute and a half).

The program/function must terminate within 10 seconds and return (by any means and in any format) two values: the total elapsed time, and the total executed sleep time. Both time values have to have a precision of at least 0.1 seconds.

This is similar to the concept of man-hours: a job that takes 60 hours can be completed in only 6 hours if 10 workers are splitting the job. Here we can have 60 seconds of sleep time e.g. in 10 parallel threads, thus requiring only 6 seconds for the whole job to be completed.

Example

The program MyProgram creates 14 threads, each thread sleeps for 5 seconds:

MyProgram → [5.016,70.105]

The execution time is greater than 5 seconds, and the total sleep time is greater than 70 seconds because of overhead.

答:
Elixir, 168 bytes

```<code>import Task;import Enum;IO.puts elem(:timer.tc(fn->IO.puts(map(map(1..16,fn _->async(fn->:timer.tc(fn->:timer.sleep(4000)end)end)end),&(elem(await(&1),0)))|>sum)end),0)
</code>```

Sample run:

```<code>$ elixir thing.exs
64012846
4007547
</code>```

The output is the total time waited followed by the time the program has run for, in microseconds.

The program spawns 14 Tasks, and awaits each of them by mapping over them, and then finds the sum of their elapsed time.  It uses Erlang's timer for measuring time.

Body:
Elixir, 168 bytes

import Task;import Enum;IO.puts elem(:timer.tc(fn->IO.puts(map(map(1..16,fn _->async(fn->:timer.tc(fn->:timer.sleep(4000)end)end)end),&(elem(await(&1),0)))|>sum)end),0)

Sample run:

$ elixir thing.exs
64012846
4007547

The output is the total time waited followed by the time the program has run for, in microseconds.

The program spawns 14 Tasks, and awaits each of them by mapping over them, and then finds the sum of their elapsed time.  It uses Erlang's timer for measuring time.


答:
R + Snowfall, 67 UTF-8 bytes

```<code>library(snowfall)
sfInit(T,8)
sfSapply(1:8,function(j)Sys.sleep(8))
</code>```

Title: Wait a minute – in less than ten seconds

Body:
Task

Using any type of parallelisation, wait multiple periods, for a total sleep time of at least a minute (but less than a minute and a half).

The program/function must terminate within 10 seconds and return (by any means and in any format) two values: the total elapsed time, and the total executed sleep time. Both time values have to have a precision of at least 0.1 seconds.

This is similar to the concept of man-hours: a job that takes 60 hours can be completed in only 6 hours if 10 workers are splitting the job. Here we can have 60 seconds of sleep time e.g. in 10 parallel threads, thus requiring only 6 seconds for the whole job to be completed.

Example

The program MyProgram creates 14 threads, each thread sleeps for 5 seconds:

MyProgram → [5.016,70.105]

The execution time is greater than 5 seconds, and the total sleep time is greater than 70 seconds because of overhead.

Body:
R + Snowfall, 67 UTF-8 bytes

library(snowfall)
sfInit(T,8)
sfSapply(1:8,function(j)Sys.sleep(8))


答:
C#, 131 bytes

The following start 9 threads that each wait 6667 milliseconds.

The program run in 6.73 secondes and has the following output :  00:00:06.7116711|604140408

Where "604140408" is the number of tick.

There are 10 000ticks is a millisecond.

So this give ~60.414 seconds.
Total execution time and wait time don't have the same output format for golfing reason.

```<code>using t=DateTime;var s=t.Now;Task.WhenAll(new t[9].Select(y=>Task.Delay(6667))).Wait();Debug.Write(t.Now-s+"|"+(t.Now-s).Ticks*9);
</code>```

Here is a fiddle that exceed the limit of execution of time of fiddle. Lower "6667" so that it fix fiddle's criteria if you want to run it.

Body:
C#, 131 bytes

The following start 9 threads that each wait 6667 milliseconds.

The program run in 6.73 secondes and has the following output :  00:00:06.7116711|604140408

Where "604140408" is the number of tick.

There are 10 000ticks is a millisecond.

So this give ~60.414 seconds.
Total execution time and wait time don't have the same output format for golfing reason.

using t=DateTime;var s=t.Now;Task.WhenAll(new t[9].Select(y=>Task.Delay(6667))).Wait();Debug.Write(t.Now-s+"|"+(t.Now-s).Ticks*9);

Here is a fiddle that exceed the limit of execution of time of fiddle. Lower "6667" so that it fix fiddle's criteria if you want to run it.


答:
Jelly, 13 bytes

```<code>“Ss”,“Th“th”y
</code>```

Thhowing off Jelly'th thhiny new tranthlate atom. Try it online!

Title: Lithp Tranthlator

Body:
Jelly, 13 bytes

“Ss”,“Th“th”y

Thhowing off Jelly'th thhiny new tranthlate atom. Try it online!


问:
Reverse the consonants
The program should take a string as input and reverse the consonants in it, while keeping the order of vowels. All the letters will be lowercase, so you don't have to worry about casing. Examples follow.

Input: a test case.

The consonants here are t,s,t,c,s. They should come in reversed order, i.e. s,c,t,s,t and inserted back into the string to the same positions where the pre-reversed characters were located: a sect sate.

Input: well-done. Output: nedl-lowe.

Input: reverse the consonants. Output: setenne sne cohtosarvr.

This is the code golf, the shortest solution wins.

Y should be considered vowel regardless of what it is and not reversed.

Anything, as well as numbers, punctuation, quotes, and other symbols (@#$%^&*(){}[]\|/<>~-_+=`), could potentially appear in the input.

答:
Pyth, <s>26</s> <s>25</s> <s>24</s> 23 bytes

```
<s>s.i:Q++\[J-G"aeiouy"\]3_@J</s>
J-G"aeiouy"sm?@dJ@_@JQ~hZ     <-- just keeping this because of the @_@
<s>J-G"aeiouy"sm?@dJ@@JQ=tZ</s>
sm?@dJ-G"aeiouy"@@JQ=tZ
sm|-dJ-G"aeiouy"@@JQ=tZ
```

Test suite.

Title: Reverse the consonants

Body:
Pyth, <s>26</s> <s>25</s> <s>24</s> 23 bytes

<s>s.i:Q++\[J-G"aeiouy"\]3_@J</s>
J-G"aeiouy"sm?@dJ@_@JQ~hZ     <-- just keeping this because of the @_@
<s>J-G"aeiouy"sm?@dJ@@JQ=tZ</s>
sm?@dJ-G"aeiouy"@@JQ=tZ
sm|-dJ-G"aeiouy"@@JQ=tZ

Test suite.


答:
Jelly, <s>22</s> 20 bytes

```<code>Øaḟ“<1Ṛż»
e€¢œpżf¢Ṛ$
</code>```

Try it online!

How it works

```<code>Øaḟ“<1Ṛż»   Helper link. No arguments.

Øa          Yield the lowercase alphabet/
   “<1Ṛż»   Decompress that string, yielding "oui aye".
  ḟ         Filter; remove the characters from the right string from the left one.

e€¢œpżf¢Ṛ$  Main link. Argument: s (string)

  ¢         Call the helper link, yielding the string of all consonants.
e€          Test each character of s for membership.
   œp       Partition s at members/consonants.
         $  Combine the three links to the left into a monadic chain.
      f¢    Filter by presence in the consonant string.
        Ṛ   Reverse the result.
     ż      Zipwith; interleave chunks of non-consonants and reversed consonants.
</code>```

Title: Reverse the consonants

Body:
The program should take a string as input and reverse the consonants in it, while keeping the order of vowels. All the letters will be lowercase, so you don't have to worry about casing. Examples follow.

Input: a test case.

The consonants here are t,s,t,c,s. They should come in reversed order, i.e. s,c,t,s,t and inserted back into the string to the same positions where the pre-reversed characters were located: a sect sate.

Input: well-done. Output: nedl-lowe.

Input: reverse the consonants. Output: setenne sne cohtosarvr.

This is the code golf, the shortest solution wins.

Y should be considered vowel regardless of what it is and not reversed.

Anything, as well as numbers, punctuation, quotes, and other symbols (@#$%^&*(){}[]\|/<>~-_+=`), could potentially appear in the input.

Body:
Jelly, <s>22</s> 20 bytes

Øaḟ“<1Ṛż»
e€¢œpżf¢Ṛ$

Try it online!

How it works

Øaḟ“<1Ṛż»   Helper link. No arguments.

Øa          Yield the lowercase alphabet/
   “<1Ṛż»   Decompress that string, yielding "oui aye".
  ḟ         Filter; remove the characters from the right string from the left one.

e€¢œpżf¢Ṛ$  Main link. Argument: s (string)

  ¢         Call the helper link, yielding the string of all consonants.
e€          Test each character of s for membership.
   œp       Partition s at members/consonants.
         $  Combine the three links to the left into a monadic chain.
      f¢    Filter by presence in the consonant string.
        Ṛ   Reverse the result.
     ż      Zipwith; interleave chunks of non-consonants and reversed consonants.


答:
JavaScript ES6, <s>82</s> <s>81</s> <s>80</s> 78 bytes

Saved a byte thanks to each of Martin and Leaky Nun, and 2 bytes to Neil!

```<code>a=>a.replace(r=/(?[_aeiouy])\w/g,e=>[...a].reverse().join``.match(r)[i++],i=0)
</code>```

Testing

f=
a=>a.replace(r=/(?![aeiouy])[a-z]/g,e=>[...a].reverse().join``.match(r)[i++],i=0)
;
q.onchange=q.onkeydown=q.onkeyup=function(){
  o.innerHTML = "";
  o.appendChild(document.createTextNode(f(q.value)));
}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>*{font-family:Consolas,monospace;}</code>```

<input autocomplete="off" id=q>

```

Title: Reverse the consonants

Body:
JavaScript ES6, <s>82</s> <s>81</s> <s>80</s> 78 bytes

Saved a byte thanks to each of Martin and Leaky Nun, and 2 bytes to Neil!

a=>a.replace(r=/(?[_aeiouy])\w/g,e=>[...a].reverse().join``.match(r)[i++],i=0)

Testing

f=
a=>a.replace(r=/(?![aeiouy])[a-z]/g,e=>[...a].reverse().join``.match(r)[i++],i=0)
;
q.onchange=q.onkeydown=q.onkeyup=function(){
  o.innerHTML = "";
  o.appendChild(document.createTextNode(f(q.value)));
}

*{font-family:Consolas,monospace;}

<input autocomplete="off" id=q>
<div id=o></div>


答:
Retina, 22 21 20 17

```<code>O#^`[b-z-[eiouy]]
</code>```

Try it online!

1 byte thanks to Leaky Nun!

4 bytes thanks to Martin!

O means sort, and # means to sort by numeric value. Since none of the matched characters will ever have a numeric value, all letters have the same weight: 0. ^ means to reverse the order of the sorted values, which thanks to stable sorting means the values are reversed.

The -[...] means to do the setwise difference between the outer character class and this inner class. This is part of .NET and you can read more at the MSDN.

Title: Reverse the consonants

Body:
Retina, 22 21 20 17

O#^`[b-z-[eiouy]]

Try it online!

1 byte thanks to Leaky Nun!

4 bytes thanks to Martin!

O means sort, and # means to sort by numeric value. Since none of the matched characters will ever have a numeric value, all letters have the same weight: 0. ^ means to reverse the order of the sorted values, which thanks to stable sorting means the values are reversed.

The -[...] means to do the setwise difference between the outer character class and this inner class. This is part of .NET and you can read more at the MSDN.


答:
Pyke, 18 bytes

```<code>FD~c{IK_#~c{)oR@(s
</code>```

Try it here!

or 16 bytes with the new version:

(Change so if for returns all string output and had string input, return string instead of a list)

```<code>FD~c{IK_#~c{)oR@
</code>```

Try it here!

~c contains the consonants: bcdfghjklmnpqrstvwxz

```<code>F                - For i in input:
  ~c{I           -  if i in "bcdfghjklmnpqrstvwxz":
       _#~c{)    -    filter(reversed(input), <-- in "bcdfghjklmnpqrstvwxz")
             oR@ -   ^[o++]
</code>```

Title: Reverse the consonants

Body:
Pyke, 18 bytes

FD~c{IK_#~c{)oR@(s

Try it here!

or 16 bytes with the new version:

(Change so if for returns all string output and had string input, return string instead of a list)

FD~c{IK_#~c{)oR@

Try it here!

~c contains the consonants: bcdfghjklmnpqrstvwxz

F                - For i in input:
  ~c{I           -  if i in "bcdfghjklmnpqrstvwxz":
       _#~c{)    -    filter(reversed(input), <-- in "bcdfghjklmnpqrstvwxz")
             oR@ -   ^[o++]


答:
MATL, <s>18</s> <s>22</s> 21 bytes

```<code>tt2Y211Y2'y'hX-m)P5M(
</code>```

1 byte saved thanks to @Luis

Unfortunately the longest part of this is getting the list of consonants (2Y211Y2'y'hX-).

Try it Online!

Explanation

```<code>            % Implicitly grab the input
tt          % Duplicate twice
2Y2         % Grab the pre-defined list of all lower-case letters
llY2        % Grab the pre-defined list of lower-case vowels (excluding 'y')
'y'h        % Add 'y' to the list of vowels
X-          % Find the set difference between these two lists (the consonants)
m           % Create a boolean array the size of the input that is true for all consonants
)           % Use this as an index to grab all consonants
P           % Reverse the order of the consonants
5M          % Get the boolean array again
(           % Re-assign the flipped consonants with the original consonant locations
            % Implicitly dislpay the result
</code>```

Title: Reverse the consonants

Body:
MATL, <s>18</s> <s>22</s> 21 bytes

tt2Y211Y2'y'hX-m)P5M(

1 byte saved thanks to @Luis

Unfortunately the longest part of this is getting the list of consonants (2Y211Y2'y'hX-).

Try it Online!

Explanation

            % Implicitly grab the input
tt          % Duplicate twice
2Y2         % Grab the pre-defined list of all lower-case letters
llY2        % Grab the pre-defined list of lower-case vowels (excluding 'y')
'y'h        % Add 'y' to the list of vowels
X-          % Find the set difference between these two lists (the consonants)
m           % Create a boolean array the size of the input that is true for all consonants
)           % Use this as an index to grab all consonants
P           % Reverse the order of the consonants
5M          % Get the boolean array again
(           % Re-assign the flipped consonants with the original consonant locations
            % Implicitly dislpay the result


答:
Matlab, 67 chars

For an input 'this is a string of- stuff.'

```<code>s=input('','s');si=regexp(s,'[b-df-hj-np-tv-xz]');s(si)=s(flip(si))
</code>```

produces s = ffit is a fgnirt os- ssuht.

si is the indices of the consonants in the input string. The final statement replaces those characters with the same characters but in reverse order by indexing.

Title: Reverse the consonants

Body:
Matlab, 67 chars

For an input 'this is a string of- stuff.'

s=input('','s');si=regexp(s,'[b-df-hj-np-tv-xz]');s(si)=s(flip(si))

produces s = ffit is a fgnirt os- ssuht.

si is the indices of the consonants in the input string. The final statement replaces those characters with the same characters but in reverse order by indexing.


答:
GNU sed, 73

Score includes +1 for the -r flag passed to sed.

```<code>:
s/([b-df-hj-np-tv-xz])(.*)([b-df-hj-np-tv-xz])/\u\3\2\u\1/
t
s/./\l&/g
</code>```

Ideone.

Repeatedly switches the first and the last lowercase consonant and converts them to upper case, until there are no more matches.  Then convert the whole string back to lowercase.

Title: Reverse the consonants

Body:
GNU sed, 73

Score includes +1 for the -r flag passed to sed.

:
s/([b-df-hj-np-tv-xz])(.*)([b-df-hj-np-tv-xz])/\u\3\2\u\1/
t
s/./\l&/g

Ideone.

Repeatedly switches the first and the last lowercase consonant and converts them to upper case, until there are no more matches.  Then convert the whole string back to lowercase.


答:
Matlab, 38 42 bytes

```<code>@(t)regexprep(t,{'s','S'},{'th','Th'})
</code>```

Shout out to @LuisMendo for the tip about cell arrays!

For 'Miss Sissy' yields ans = Mithth Thiththy.

Title: Lithp Tranthlator

Body:
My friend made a lisp translator the other day, that is to say it took a string and converted s=>th and S=>Th. It was quite long and I thought that it could be golfed.

So the task is to make a program/function that takes an input string, translates it in to lisp and outputs the string

Test case

```<code>Sam and Sally like Sheep        Tham and Thally like Thheep
Sally likes sausages            Thally liketh thauthageth
Sally sells seashells           Thally thellth theathhellth
</code>```

Note that it doesn't matter that h gets repeated all the time

This is code golf so shortest answer wins

Body:
Matlab, 38 42 bytes

@(t)regexprep(t,{'s','S'},{'th','Th'})

Shout out to @LuisMendo for the tip about cell arrays!

For 'Miss Sissy' yields ans = Mithth Thiththy.


问:
Golf the repeated totient function
You will take two positive integers n and x as input, and output Euler's totient function (number of positive integers less than x co-prime to x) applied n times.

Testcases

```<code>n x   result
1 10  4
2 10  2
3 10  1
1 100 40
2 100 16
3 100 8
4 100 4
5 100 2
6 100 1
</code>```

答:
Javascript, 88 <s>95</s>

```<code>g=(a,b)=>b?g(b,a%b):a==1
t=(x,n=x,o=0)=>n?t(x,--n,o+g(x,n)):o
f=(n,x)=>n?f(n-1,t(x)):x
</code>```

The first function returns true/false if the greatest commom divisor is 1. The second function calculates the totient. The third function is a simple recursion to do the totient n times.

I took this idea from the wikipedia link:

It can be defined more formally as the number of integers k in the range 1 ≤ k ≤ n for which the greatest common divisor gcd(n, k) = 1;

Title: Golf the repeated totient function

Body:
Javascript, 88 <s>95</s>

g=(a,b)=>b?g(b,a%b):a==1
t=(x,n=x,o=0)=>n?t(x,--n,o+g(x,n)):o
f=(n,x)=>n?f(n-1,t(x)):x

The first function returns true/false if the greatest commom divisor is 1. The second function calculates the totient. The third function is a simple recursion to do the totient n times.

I took this idea from the wikipedia link:

It can be defined more formally as the number of integers k in the range 1 ≤ k ≤ n for which the greatest common divisor gcd(n, k) = 1;


问:
"Hello, World!"
So... uh... this is a bit embarrassing. But we don't have a plain "Hello, World!" challenge yet (despite having 35 variants tagged with hello-world, and counting). While this is not the most interesting code golf in the common languages, finding the shortest solution in certain esolangs can be a serious challenge. For instance, to my knowledge it is not known whether the shortest possible Brainfuck solution has been found yet.

Furthermore, while all of <s>Wikipedia</s> (the Wikipedia entry has been deleted but there is a copy at archive.org
), esolangs and Rosetta Code have lists of "Hello, World!" programs, none of these are interested in having the shortest for each language (there is also this GitHub repository). If we want to be a significant site in the code golf community, I think we should try and create the ultimate catalogue of shortest "Hello, World!" programs (similar to how our basic quine challenge contains some of the shortest known quines in various languages). So let's do this!

The Rules

Each submission must be a full program.

The program must take no input, and print Hello, World! to STDOUT (this exact byte stream, including capitalization and punctuation) plus an optional trailing newline, and nothing else.

The program must not write anything to STDERR.

If anyone wants to abuse this by creating a language where the empty program prints Hello, World!, then congrats, they just paved the way for a very boring answer.

Note that there must be an interpreter so the submission can be tested. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language.

Submissions are scored in bytes, in an appropriate (pre-existing) encoding, usually (but not necessarily) UTF-8. Some languages, like Folders, are a bit tricky to score - if in doubt, please ask on Meta.

This is not about finding the language with the shortest "Hello, World!" program. This is about finding the shortest "Hello, World!" program in every language. Therefore, I will not mark any answer as "accepted".

If your language of choice is a trivial variant of another (potentially more popular) language which already has an answer (think BASIC or SQL dialects, Unix shells or trivial Brainfuck-derivatives like Alphuck), consider adding a note to the existing answer that the same or a very similar solution is also the shortest in the other language.

As a side note, please don't downvote boring (but valid) answers in languages where there is not much to golf - these are still useful to this question as it tries to compile a catalogue as complete as possible. However, do primarily upvote answers in languages where the authors actually had to put effort into golfing the code.

For inspiration, check the Hello World Collection.

The Catalogue

The Stack Snippet at the bottom of this post generates the catalogue from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.

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

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

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

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

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

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

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

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

/* Configuration */

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

/* App */

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

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

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

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

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

getAnswers();

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

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

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

function process() {
  var valid = [];

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

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

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

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

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

    var lang = a.language;
    lang = jQuery(''+lang+'').text();

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

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

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

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

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

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

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

table thead {
  font-weight: bold;
}

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

答:
Apps Script + Google Sheets, 39 bytes

Script

```<code>function Q(){return"Hello, World!"}
</code>```

Sheet

```<code>=q()
</code>```

Original, 40 bytes

Script

```<code>function Q(){return "Hello, World!"}
</code>```

Sheet

```<code>=q()
</code>```

ContentLicense: CC BY-SA 4.0

Title: "Hello, World!"

Body:
Apps Script + Google Sheets, 39 bytes

Script

function Q(){return"Hello, World!"}

Sheet

=q()

Original, 40 bytes

Script

function Q(){return "Hello, World!"}

Sheet

=q()


答:
Thue, Full program: 27 byteth, function: 13 byteth

```<code>s::=th
S::=Th
</code>```

<s>Thince Thue can read input, a correct input routine will be too long. Tho i potht it ath a "function"</s>

EDIT: I have forgotten, Thue read lineth from thtdin, not characterth

Tho, here ith a full program:

```<code>s::=th
S::=Th
I::=:::
::=
I
</code>```

Title: Lithp Tranthlator

Body:
Thue, Full program: 27 byteth, function: 13 byteth

s::=th
S::=Th

<s>Thince Thue can read input, a correct input routine will be too long. Tho i potht it ath a "function"</s>

EDIT: I have forgotten, Thue read lineth from thtdin, not characterth

Tho, here ith a full program:

s::=th
S::=Th
I::=:::
::=
I


答:
Pyke, 14 byteth

```<code>\s"th":\S"Th":
</code>```

Try it here!

Thith anthwer ith very thimple and boring.

Title: Lithp Tranthlator

Body:
Pyke, 14 byteth

\s"th":\S"Th":

Try it here!

Thith anthwer ith very thimple and boring.


问:
Simple cat program
One of the most common standard tasks (especially when showcasing esoteric programming languages) is to implement a "cat program": read all of STDIN and print it to STDOUT. While this is named after the Unix shell utility cat it is of course much less powerful than the real thing, which is normally used to print (and concatenate) several files read from disc.

Task

You should write a full program which reads the contents of the standard input stream and writes them verbatim to the standard output stream. If and only if your language does not support standard input and/or output streams (as understood in most languages), you may instead take these terms to mean their closest equivalent in your language (e.g. JavaScript's prompt and alert). These are the only admissible forms of I/O, as any other interface would largely change the nature of the task and make answers much less comparable.

The output should contain exactly the input and nothing else. The only exception to this rule is constant output of your language's interpreter that cannot be suppressed, such as a greeting, ANSI color codes or indentation. This also applies to trailing newlines. If the input does not contain a trailing newline, the output shouldn't include one either! (The only exception being if your language absolutely always prints a trailing newline after execution.)

Output to the standard error stream is ignored, so long as the standard output stream contains the expected output. In particular, this means your program can terminate with an error upon hitting the end of the stream (EOF), provided that doesn't pollute the standard output stream. If you do this, I encourage you to add an error-free version to your answer as well (for reference).

As this is intended as a challenge within each language and not between languages, there are a few language specific rules:

If it is at all possible in your language to distinguish null bytes in the standard input stream from the EOF, your program must support null bytes like any other bytes (that is, they have to be written to the standard output stream as well).

If it is at all possible in your language to support an arbitrary infinite input stream (i.e. if you can start printing bytes to the output before you hit EOF in the input), your program has to work correctly in this case. As an example yes | tr -d \\n | ./my_cat should print an infinite stream of ys. It is up to you how often you print and flush the standard output stream, but it must be guaranteed to happen after a finite amount of time, regardless of the stream (this means, in particular, that you cannot wait for a specific character like a linefeed before printing).

Please add a note to your answer about the exact behaviour regarding null-bytes, infinite streams, and extraneous output.

Additional rules

This is not about finding the language with the shortest solution for this (there are some where the empty program does the trick) - this is about finding the shortest solution in every language. Therefore, no answer will be marked as accepted.

Submissions in most languages will be scored in bytes in an appropriate preexisting encoding, usually (but not necessarily) UTF-8.

Some languages, like Folders, are a bit tricky to score. If in doubt, please ask on Meta.

Feel free to use a language (or language version) even if it's newer than this challenge. Languages specifically written to submit a 0-byte answer to this challenge are fair game but not particularly interesting.

Note that there must be an interpreter so the submission can be tested. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language.

Also note that languages do have to fulfil our usual criteria for programming languages.

If your language of choice is a trivial variant of another (potentially more popular) language which already has an answer (think BASIC or SQL dialects, Unix shells or trivial Brainfuck derivatives like Headsecks or Unary), consider adding a note to the existing answer that the same or a very similar solution is also the shortest in the other language.

Unless they have been overruled earlier, all standard code-golf rules apply, including the http://meta.codegolf.stackexchange.com/q/1061.

As a side note, please don't downvote boring (but valid) answers in languages where there is not much to golf; these are still useful to this question as it tries to compile a catalogue as complete as possible. However, do primarily upvote answers in languages where the author actually had to put effort into golfing the code.

Catalogue

The Stack Snippet at the bottom of this post generates the catalogue from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.

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

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

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

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

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

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

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

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

答:
Apps Script + Google Sheets, 29 bytes

Script

```<code>function Q(s){return s}
</code>```

Sheet

```<code>=q(B1)
</code>```

Cell B1 is the input.

Title: Simple cat program

Body:
Apps Script + Google Sheets, 29 bytes

Script

function Q(s){return s}

Sheet

=q(B1)

Cell B1 is the input.


答:
Java, 101 byteth

```<code>interface a{static void main(String[]A){System.out.print(A[0].replace("S","Th").replace("s","th"));}}
</code>```

Note that this is a complete program unlike the previous Java answer.

Bonus (has to be fed to the C preprocessor THEE preprothethor first):

```<code>#define interfaith interface
#define thtatic static
#define Thtring String
#define Thythtem System
#define replaith(x,y) replace(x,y)

interfaith a{thtatic void main(Thtring[]A){Thythtem.out.print(A[0].replaith("S","Th").replaith("s","th"));}}
</code>```

Title: Lithp Tranthlator

Body:
Java, 101 byteth

interface a{static void main(String[]A){System.out.print(A[0].replace("S","Th").replace("s","th"));}}

Note that this is a complete program unlike the previous Java answer.

Bonus (has to be fed to the C preprocessor THEE preprothethor first):

#define interfaith interface
#define thtatic static
#define Thtring String
#define Thythtem System
#define replaith(x,y) replace(x,y)

interfaith a{thtatic void main(Thtring[]A){Thythtem.out.print(A[0].replaith("S","Th").replaith("s","th"));}}


答:
JavaScript (ES6), 72 bytes

```<code>s=>s.split(/([^\W\d_aeiouy])/).map((c,i,a)=>i&1?a[a.length+~i]:c).join``
</code>```

Splitting on /([^\W\d_aeiouy])/ results in the consonants falling in the odd-numbered entries in the array. It then suffices to switch those entries with the equivalent entry counting back from the end of the array and join the result together.

Title: Reverse the consonants

Body:
JavaScript (ES6), 72 bytes

s=>s.split(/([^\W\d_aeiouy])/).map((c,i,a)=>i&1?a[a.length+~i]:c).join``

Splitting on /([^\W\d_aeiouy])/ results in the consonants falling in the odd-numbered entries in the array. It then suffices to switch those entries with the equivalent entry counting back from the end of the array and join the result together.


答:
Matlab, 39 byteth

A straitforward approach:

```<code>@(t)strrep(strrep(t,'s','th'),'S','Th')
</code>```

Title: Lithp Tranthlator

Body:
Matlab, 39 byteth

A straitforward approach:

@(t)strrep(strrep(t,'s','th'),'S','Th')


问:
The handshake problem
The handshake problem is the classic problem that for n people in a room, if they all shake hands, what's the total number of handshakes that occur.

You code should take an input of any number and output the number of handshakes, both in base ten.

Also the code should not let non-integers through. You should output a falsey in this case. The only expected inputs are positive whole integers and positive real numbers - you don't need to worry about complex numbers or strings as inputs.
This should mean that you should expect n >= 0

Test cases

```<code>(N:handshakes)
0:0
10:45
20:190
10.5:0
1337:893116
</code>```

Normal golfing rules apply and shortest code wins.
If your code isn't self explanatory, please explain.

Jelly and 05AB1E are the winners, both at 2 bytes

答:
Google Sheets, <s>17</s> 14 bytes

```<code>=((B1^2)-B1)/2
</code>```

Cell B1 is the input.

Title: The handshake problem

Body:
Google Sheets, <s>17</s> 14 bytes

=((B1^2)-B1)/2

Cell B1 is the input.


答:
Python 2.7, 144 bytes

```<code>def f(a):c='bcdfghjklmnpqrstvwxz';b=[x for x in list(a[::-1])if x in c];[b.insert(x,a[x])for x in range(len(a))if a[x]not in c];return''.join(b)
</code>```

This first builds a reversed list of the consonants, then inserts each of the other characters back in at their original index.

Un-golfed:

```<code>s = 'well-done'
reverse = list(s[::-1])
consonants = [i for i in reverse if i in 'bcdfghjklmnpqrstvwxz']

for x in range(len(s)):
    if s[x] not in 'bcdfghjklmnpqrstvwxz':
        consonants.insert(x,s[x])

print(''.join(consonants))
</code>```

https://repl.it/C30O

Title: Reverse the consonants

Body:
The program should take a string as input and reverse the consonants in it, while keeping the order of vowels. All the letters will be lowercase, so you don't have to worry about casing. Examples follow.

Input: a test case.

The consonants here are t,s,t,c,s. They should come in reversed order, i.e. s,c,t,s,t and inserted back into the string to the same positions where the pre-reversed characters were located: a sect sate.

Input: well-done. Output: nedl-lowe.

Input: reverse the consonants. Output: setenne sne cohtosarvr.

This is the code golf, the shortest solution wins.

Y should be considered vowel regardless of what it is and not reversed.

Anything, as well as numbers, punctuation, quotes, and other symbols (@#$%^&*(){}[]\|/<>~-_+=`), could potentially appear in the input.

Body:
Python 2.7, 144 bytes

def f(a):c='bcdfghjklmnpqrstvwxz';b=[x for x in list(a[::-1])if x in c];[b.insert(x,a[x])for x in range(len(a))if a[x]not in c];return''.join(b)

This first builds a reversed list of the consonants, then inserts each of the other characters back in at their original index.

Un-golfed:

s = 'well-done'
reverse = list(s[::-1])
consonants = [i for i in reverse if i in 'bcdfghjklmnpqrstvwxz']

for x in range(len(s)):
    if s[x] not in 'bcdfghjklmnpqrstvwxz':
        consonants.insert(x,s[x])

print(''.join(consonants))

https://repl.it/C30O


答:
Python 2, <s>103</s> <s>98</s> 100 bytes

```<code>import re
def r(s):a=re.split("([^\W\d_aeiouy])",s);print''.join(sum(zip(a[::2],a[-2::-2]+['']),()))
</code>```

Port of my JavaScript answer. Edit: Saved 5 bytes thanks to @Dennis♦, of which I promptly had to spend two fixing digits.

Title: Reverse the consonants

Body:
Python 2, <s>103</s> <s>98</s> 100 bytes

import re
def r(s):a=re.split("([^\W\d_aeiouy])",s);print''.join(sum(zip(a[::2],a[-2::-2]+['']),()))

Port of my JavaScript answer. Edit: Saved 5 bytes thanks to @Dennis♦, of which I promptly had to spend two fixing digits.


问:
What is the smallest positive base 10 integer that can be printed by a program shorter (in characters) than itself?
I think the question as above is clear, but just in case:

Write a full program (not just a function) which prints a positive base 10 integer, optionally followed by a single newline.

Qualifying programs will be those whose output is longer (in bytes) than the source code of the program, measured in bytes (assuming ASCII or UTF-8 encoding for the program source code).

I.e. the code must be shorter than the number of digits in the resulting number.

Leading zeros are disallowed under all circumstances. Counting leading zeroes trivialises the problem; ignoring leading zeros unnecessarily complicates the question.

The winning program will be the qualifying program which prints the integer with the smallest magnitude.

Leaderboard snippet

var QUESTION_ID = 67921;
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe"; var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;
function answersUrl(index) { return "https://api.stackexchange.com/2.2/questions/" + QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER; }
function commentUrl(index, answers) { return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER; }
function getAnswers() { jQuery.ajax({ url: answersUrl(answer_page++), method: "get", dataType: "jsonp", crossDomain: true, success: function (data) { answers.push.apply(answers, data.items); answers_hash = []; answer_ids = []; data.items.forEach(function(a) { a.comments = []; var id = +a.share_link.match(/\d+/); answer_ids.push(id); answers_hash[id] = a; }); if (!data.has_more) more_answers = false; comment_page = 1; getComments(); } }); } function getComments() { jQuery.ajax({ url: commentUrl(comment_page++, answer_ids), method: "get", dataType: "jsonp", crossDomain: true, success: function (data) { if (data.has_more) getComments(); else if (more_answers) getAnswers(); else process(); } }); }
getAnswers();
var SCORE_REG = /<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*)(?:,|[-\u2013] ).*?([\d,^!e+]+)(?=\:?[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;
var OVERRIDE_REG = /^Override\s*header:\s*/i;
function getAuthorName(a) { return a.owner.display_name; }
function process() { var valid = []; answers.forEach(function(a) { var body = a.body; a.comments.forEach(function(c) { if(OVERRIDE_REG.test(c.body)) body = '
' + c.body.replace(OVERRIDE_REG, '') + '
'; }); var match = body.replace(/([^\n<]*)<\/sup>/g, "^$1").replace(/\(\d+(?:\^\d+,)? [\w\s]+\)/g, "").replace(/floor\(10\^(\d+)\/9\)/g, "$1 ones").replace(/(\d+) ones/g, function (_, x) { return Array(+x + 1).join(1); }).match(SCORE_REG); if (match) valid.push({ user: getAuthorName(a), size: +match[2].replace(/,/g, "").replace(/(\d+)\s*\^\s*(\d+)/, function (_, a, b) { return Math.pow(a, b); }).replace(/(\d+)!/, function (_, n) { for (var i = 1, j = 1; i <= n; i++) j *= i; return j; }), language: match[1], link: a.share_link, }); else console.log(body); }); valid.sort(function (a, b) { var aB = a.size, bB = b.size; return aB - bB }); var languages = {}; var place = 1; var lastSize = null; var lastPlace = 1; valid.forEach(function (a) { if (a.size != lastSize) lastPlace = place; lastSize = a.size; ++place; var answer = jQuery("#answer-template").html(); answer = answer.replace("{{PLACE}}", lastPlace + ".") .replace("{{NAME}}", a.user) .replace("{{LANGUAGE}}", a.language) .replace("{{SIZE}}", a.size) .replace("{{LINK}}", a.link); answer = jQuery(answer); jQuery("#answers").append(answer); var lang = a.language; lang = jQuery(''+lang+'').text(); languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang.toLowerCase(), user: a.user, size: a.size, link: a.link}; }); var langs = []; for (var lang in languages) if (languages.hasOwnProperty(lang)) langs.push(languages[lang]); langs.sort(function (a, b) { if (a.lang_raw > b.lang_raw) return 1; if (a.lang_raw < b.lang_raw) 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-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<style>body { text-align: left !important} #answer-list { padding: 10px; width: 290px; float: left; } #language-list { padding: 10px; width: 290px; float: left; } table thead { font-weight: bold; } table td { padding: 5px; }</style>
<link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">
<div id="language-list"> <h2>Shortest Solution by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr> </thead> <tbody id="languages"> </tbody> </table> </div> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr> </thead> <tbody id="answers"> </tbody> </table> </div> <table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td>Link</td></tr> </tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td>Link</td></tr> </tbody> </table></code>```

答:
Google Sheets, 15625

```<code>=5^6
</code>```

equals 15625

Body:
Google Sheets, 15625

=5^6

equals 15625


答:
Haskell, 15 bytes

```<code>f x=sum[1..x-1]
</code>```

[x..y] ranges are inclusive...

Oh and I don't know how to handle the non-integers...

Title: The handshake problem

Body:
The handshake problem is the classic problem that for n people in a room, if they all shake hands, what's the total number of handshakes that occur.

You code should take an input of any number and output the number of handshakes, both in base ten.

Also the code should not let non-integers through. You should output a falsey in this case. The only expected inputs are positive whole integers and positive real numbers - you don't need to worry about complex numbers or strings as inputs.
This should mean that you should expect n >= 0

Test cases

```<code>(N:handshakes)
0:0
10:45
20:190
10.5:0
1337:893116
</code>```

Normal golfing rules apply and shortest code wins.
If your code isn't self explanatory, please explain.

Jelly and 05AB1E are the winners, both at 2 bytes

Body:
Haskell, 15 bytes

f x=sum[1..x-1]

[x..y] ranges are inclusive...

Oh and I don't know how to handle the non-integers...


答:
Python 2, 106 bytes

```<code>s=input()
b=[x for x in s if x in'bcdfghjklmnpqrstvwxz']*2
print''.join(x in b and b.pop()or x for x in s)
</code>```

Expects input in "quotes", which I think is allowed.

Title: Reverse the consonants

Body:
Python 2, 106 bytes

s=input()
b=[x for x in s if x in'bcdfghjklmnpqrstvwxz']*2
print''.join(x in b and b.pop()or x for x in s)

Expects input in "quotes", which I think is allowed.


答:
Ruby, <s>53</s> 50 bytes

-3 bytes from @manatwork

```<code>->s{i=0;s.gsub(r=/[^\Waeiouy_]/){s.scan(r)[i-=1]}}
</code>```

Try it here

Title: Reverse the consonants

Body:
Ruby, <s>53</s> 50 bytes

-3 bytes from @manatwork

->s{i=0;s.gsub(r=/[^\Waeiouy_]/){s.scan(r)[i-=1]}}

Try it here


答:
Clojure, 135 120 111 109 bytes

```<code>(let[t #(System/nanoTime)s(t)f #(-(t)%)][(apply +(pmap #(let[s(t)](Thread/sleep 7e3)%(f s))(range 9)))(f s)])
</code>```

Formatted version with named variables:

```<code>(let [time #(System/currentTimeMillis)
      start (time)
      fmt #(- (time) %)]
  [(apply +
           (pmap #(let [thread-start (time)]
                   (Thread/sleep 7e3)
                   %
                   (fmt thread-start)) (range 9)))
   (fmt start)])
</code>```

output (in nanoseconds):

```<code>[62999772966 7001137032]
</code>```

Changed format. Thanks Adám, I might have missed that format specification in the question when I read it.

Changed to nanoTime for golfing abilities.

Thanks cliffroot, I totally forgot about scientific notation and can't believe I didn't see apply. I think I used that in something I was golfing yesterday but never posted. You saved me 2 bytes.

Body:
Task

Using any type of parallelisation, wait multiple periods, for a total sleep time of at least a minute (but less than a minute and a half).

The program/function must terminate within 10 seconds and return (by any means and in any format) two values: the total elapsed time, and the total executed sleep time. Both time values have to have a precision of at least 0.1 seconds.

This is similar to the concept of man-hours: a job that takes 60 hours can be completed in only 6 hours if 10 workers are splitting the job. Here we can have 60 seconds of sleep time e.g. in 10 parallel threads, thus requiring only 6 seconds for the whole job to be completed.

Example

The program MyProgram creates 14 threads, each thread sleeps for 5 seconds:

MyProgram → [5.016,70.105]

The execution time is greater than 5 seconds, and the total sleep time is greater than 70 seconds because of overhead.

Body:
Clojure, 135 120 111 109 bytes

(let[t #(System/nanoTime)s(t)f #(-(t)%)][(apply +(pmap #(let[s(t)](Thread/sleep 7e3)%(f s))(range 9)))(f s)])

Formatted version with named variables:

(let [time #(System/currentTimeMillis)
      start (time)
      fmt #(- (time) %)]
  [(apply +
           (pmap #(let [thread-start (time)]
                   (Thread/sleep 7e3)
                   %
                   (fmt thread-start)) (range 9)))
   (fmt start)])

output (in nanoseconds):

[62999772966 7001137032]

Changed format. Thanks Adám, I might have missed that format specification in the question when I read it.

Changed to nanoTime for golfing abilities.

Thanks cliffroot, I totally forgot about scientific notation and can't believe I didn't see apply. I think I used that in something I was golfing yesterday but never posted. You saved me 2 bytes.


答:
Python 2, 130 bytes

```<code>import thread as H,time as T
m=T.clock;T.z=m()
def f(k):T.sleep(k);T.z+=m()
exec"H.start_new_thread(f,(7,));"*9
f(8);print m(),T.z
</code>```

This is a derivation of Mego's answer, but it's sufficiently different that I thought it should be a separate answer. It is tested to work on Windows.

Basically, it forks off 9 threads, which sleep for 7 seconds while the parent sleeps for 8. Then it prints out the times. Sample output:

```<code>8.00059192923 71.0259046024
</code>```

On Windows, time.clock measures wall time since the first call.

Body:
Python 2, 130 bytes

import thread as H,time as T
m=T.clock;T.z=m()
def f(k):T.sleep(k);T.z+=m()
exec"H.start_new_thread(f,(7,));"*9
f(8);print m(),T.z

This is a derivation of Mego's answer, but it's sufficiently different that I thought it should be a separate answer. It is tested to work on Windows.

Basically, it forks off 9 threads, which sleep for 7 seconds while the parent sleeps for 8. Then it prints out the times. Sample output:

8.00059192923 71.0259046024

On Windows, time.clock measures wall time since the first call.


答:
Forth, 1073741824 (2^30)

```<code>1 30 << .
</code>```

Try it online

If the result could be left on the stack:

100663296

```<code>96 20 <<
</code>```

Title: What is the smallest positive base 10 integer that can be printed by a program shorter (in characters) than itself?

Body:
I think the question as above is clear, but just in case:

Write a full program (not just a function) which prints a positive base 10 integer, optionally followed by a single newline.

Qualifying programs will be those whose output is longer (in bytes) than the source code of the program, measured in bytes (assuming ASCII or UTF-8 encoding for the program source code).

I.e. the code must be shorter than the number of digits in the resulting number.

Leading zeros are disallowed under all circumstances. Counting leading zeroes trivialises the problem; ignoring leading zeros unnecessarily complicates the question.

The winning program will be the qualifying program which prints the integer with the smallest magnitude.

Leaderboard snippet

var QUESTION_ID = 67921;
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe"; var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;
function answersUrl(index) { return "https://api.stackexchange.com/2.2/questions/" + QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER; }
function commentUrl(index, answers) { return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER; }
function getAnswers() { jQuery.ajax({ url: answersUrl(answer_page++), method: "get", dataType: "jsonp", crossDomain: true, success: function (data) { answers.push.apply(answers, data.items); answers_hash = []; answer_ids = []; data.items.forEach(function(a) { a.comments = []; var id = +a.share_link.match(/\d+/); answer_ids.push(id); answers_hash[id] = a; }); if (!data.has_more) more_answers = false; comment_page = 1; getComments(); } }); } function getComments() { jQuery.ajax({ url: commentUrl(comment_page++, answer_ids), method: "get", dataType: "jsonp", crossDomain: true, success: function (data) { if (data.has_more) getComments(); else if (more_answers) getAnswers(); else process(); } }); }
getAnswers();
var SCORE_REG = /<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*)(?:,|[-\u2013] ).*?([\d,^!e+]+)(?=\:?[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;
var OVERRIDE_REG = /^Override\s*header:\s*/i;
function getAuthorName(a) { return a.owner.display_name; }
function process() { var valid = []; answers.forEach(function(a) { var body = a.body; a.comments.forEach(function(c) { if(OVERRIDE_REG.test(c.body)) body = '
' + c.body.replace(OVERRIDE_REG, '') + '
'; }); var match = body.replace(/([^\n<]*)<\/sup>/g, "^$1").replace(/\(\d+(?:\^\d+,)? [\w\s]+\)/g, "").replace(/floor\(10\^(\d+)\/9\)/g, "$1 ones").replace(/(\d+) ones/g, function (_, x) { return Array(+x + 1).join(1); }).match(SCORE_REG); if (match) valid.push({ user: getAuthorName(a), size: +match[2].replace(/,/g, "").replace(/(\d+)\s*\^\s*(\d+)/, function (_, a, b) { return Math.pow(a, b); }).replace(/(\d+)!/, function (_, n) { for (var i = 1, j = 1; i <= n; i++) j *= i; return j; }), language: match[1], link: a.share_link, }); else console.log(body); }); valid.sort(function (a, b) { var aB = a.size, bB = b.size; return aB - bB }); var languages = {}; var place = 1; var lastSize = null; var lastPlace = 1; valid.forEach(function (a) { if (a.size != lastSize) lastPlace = place; lastSize = a.size; ++place; var answer = jQuery("#answer-template").html(); answer = answer.replace("{{PLACE}}", lastPlace + ".") .replace("{{NAME}}", a.user) .replace("{{LANGUAGE}}", a.language) .replace("{{SIZE}}", a.size) .replace("{{LINK}}", a.link); answer = jQuery(answer); jQuery("#answers").append(answer); var lang = a.language; lang = jQuery(''+lang+'').text(); languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang.toLowerCase(), user: a.user, size: a.size, link: a.link}; }); var langs = []; for (var lang in languages) if (languages.hasOwnProperty(lang)) langs.push(languages[lang]); langs.sort(function (a, b) { if (a.lang_raw > b.lang_raw) return 1; if (a.lang_raw < b.lang_raw) 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-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<style>body { text-align: left !important} #answer-list { padding: 10px; width: 290px; float: left; } #language-list { padding: 10px; width: 290px; float: left; } table thead { font-weight: bold; } table td { padding: 5px; }</style>
<link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">
<div id="language-list"> <h2>Shortest Solution by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr> </thead> <tbody id="languages"> </tbody> </table> </div> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr> </thead> <tbody id="answers"> </tbody> </table> </div> <table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td>Link</td></tr> </tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td>Link</td></tr> </tbody> </table></code>```

Body:
Forth, 1073741824 (2^30)

1 30 << .

Try it online

If the result could be left on the stack:

100663296

96 20 <<


答:
Python 3, 100000000000

One digit shorter than the current python 3

```<code>print(1e11)
</code>```

prints 1*(10^11)

Body:
Python 3, 100000000000

One digit shorter than the current python 3

print(1e11)

prints 1*(10^11)


答:
PowerThhell, 41 bytes

```<code>$args.replace('S','Th').replace('s','th')
</code>```

I can't beat this simple approach; there is a string.translate buried in XPath and there are map style approaches in the Linq library - but they're wordy. Can't easily do a dictionary lookup per character because PS is case insensitive and thinks 's' and 'S' are duplicate keys.

Best novelty alternative so far:

```<code>$OFS='Th';''+$args.split('S')-replace's','th'
</code>```

Title: Lithp Tranthlator

Body:
My friend made a lisp translator the other day, that is to say it took a string and converted s=>th and S=>Th. It was quite long and I thought that it could be golfed.

So the task is to make a program/function that takes an input string, translates it in to lisp and outputs the string

Test case

```<code>Sam and Sally like Sheep        Tham and Thally like Thheep
Sally likes sausages            Thally liketh thauthageth
Sally sells seashells           Thally thellth theathhellth
</code>```

Note that it doesn't matter that h gets repeated all the time

This is code golf so shortest answer wins

Body:
PowerThhell, 41 bytes

$args.replace('S','Th').replace('s','th')

I can't beat this simple approach; there is a string.translate buried in XPath and there are map style approaches in the Linq library - but they're wordy. Can't easily do a dictionary lookup per character because PS is case insensitive and thinks 's' and 'S' are duplicate keys.

Best novelty alternative so far:

$OFS='Th';''+$args.split('S')-replace's','th'


答:
Perl 5, 18 byteth

The obviouth anthwer; I don't thee anything thhorter. 17 byteth, pluth 1 for -pe inthtead of -e.

```<code>s/s/th/g;s/S/Th/g
</code>```

I wathn't thure whether, tho ath to follow the thandard for anthwerth of thith quethtion, I thhould lithpify my code ath well ath my prothe. Jutht in cathe, here'th the lithpy verthion:

```<code>th/th/th/g;th/Th/Th/g
</code>```

Title: Lithp Tranthlator

Body:
Perl 5, 18 byteth

The obviouth anthwer; I don't thee anything thhorter. 17 byteth, pluth 1 for -pe inthtead of -e.

s/s/th/g;s/S/Th/g

I wathn't thure whether, tho ath to follow the thandard for anthwerth of thith quethtion, I thhould lithpify my code ath well ath my prothe. Jutht in cathe, here'th the lithpy verthion:

th/th/th/g;th/Th/Th/g


问:
The Ackermann function
The Ackermann function is notable for being the one of the simplest examples of a total, computable function that isn't primitive recursive.

We will use the definition of \$A(m,n)\$ taking in two nonnegative integers where

$$\begin{align}
A(0,n) & = n+1 \\
A(m,0) & = A(m-1,1) \\
A(m,n) & = A(m-1,A(m,n-1))
\end{align}$$

You may implement

a named or anonymous function taking two integers as input, returning an integer, or

a program taking two space- or newline-separated integers on STDIN, printing a result to STDOUT.

You may not use an Ackermann function or hyperexponentiation function from a library, if one exists, but you may use any other function from any other library. Regular exponentiation is allowed.

Your function must be able to find the value of \$A(m,n)\$ for \$m \le 3\$ and \$n \le 10\$ in less than a minute. It must at least theoretically terminate on any other inputs: given infinite stack space, a native Bigint type, and an arbitrarily long period of time, it would return the answer. Edit: If your language has a default recursion depth that is too restrictive, you may reconfigure that at no character cost.

The submission with the shortest number of characters wins.

Here are some values, to check your answer:

$$\begin{array}{c|cccccccccc}
A & n = 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 \\
\hline
m=0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 \\
1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 \\
2 & 3 & 5 & 7 & 9 & 11 & 13 & 15 & 17 & 19 & 21 & 23 \\
3 & 5 & 13 & 29 & 61 & 125 & 253 & 509 & 1021 & 2045 & 4093 & 8189 \\
4 & 13 & 65533 & \text{big}
\end{array}$$

答:
Java, 274 bytes

```<code>import java.math.*;class a{BigInteger A(BigInteger b,BigInteger B){if(b.equals(BigInteger.ZERO))return B.add(BigInteger.ONE);if(B.equals(BigInteger.ZERO))return A(b.subtract(BigInteger.ONE),BigInteger.ONE);return A(b.subtract(BigInteger.ONE),A(b,B.subtract(BigInteger.ONE)));}}
</code>```

It calculates A(3,10) in a few seconds, and given infinite memory and stack space, it can calculate any combination of b and B as long as the result is below 22147483647-1.

Title: The Ackermann function

Body:
Java, 274 bytes

import java.math.*;class a{BigInteger A(BigInteger b,BigInteger B){if(b.equals(BigInteger.ZERO))return B.add(BigInteger.ONE);if(B.equals(BigInteger.ZERO))return A(b.subtract(BigInteger.ONE),BigInteger.ONE);return A(b.subtract(BigInteger.ONE),A(b,B.subtract(BigInteger.ONE)));}}

It calculates A(3,10) in a few seconds, and given infinite memory and stack space, it can calculate any combination of b and B as long as the result is below 22147483647-1.


答:
Python 2, 86 bytes

s='';c=()
for x in input():b='{'>x not in'aeiouy'<x;s+=b*'%s'or x;c=(x,)*b+c
print s%c
```

Takes input as a string in quotes. Iterates through the input, replacing each consonant with %s in s. The tuple c stores the consonants encountered in reversed order. Then, string formatting replaces the %s's in s with the consonants in c.

Thanks to Sp3000 for the consonant check, which saved 4 bytes over listing the consonants.

Title: Reverse the consonants

Body:
The program should take a string as input and reverse the consonants in it, while keeping the order of vowels. All the letters will be lowercase, so you don't have to worry about casing. Examples follow.

Input: a test case.

The consonants here are t,s,t,c,s. They should come in reversed order, i.e. s,c,t,s,t and inserted back into the string to the same positions where the pre-reversed characters were located: a sect sate.

Input: well-done. Output: nedl-lowe.

Input: reverse the consonants. Output: setenne sne cohtosarvr.

This is the code golf, the shortest solution wins.

Y should be considered vowel regardless of what it is and not reversed.

Anything, as well as numbers, punctuation, quotes, and other symbols (@#$%^&*(){}[]\|/<>~-_+=`), could potentially appear in the input.

Body:
Python 2, 86 bytes

s='';c=()
for x in input():b='{'>x not in'aeiouy'<x;s+=b*'%s'or x;c=(x,)*b+c
print s%c

Takes input as a string in quotes. Iterates through the input, replacing each consonant with %s in s. The tuple c stores the consonants encountered in reversed order. Then, string formatting replaces the %s's in s with the consonants in c.

Thanks to Sp3000 for the consonant check, which saved 4 bytes over listing the consonants.


答:
J, 53 bytes

```<code>C.~[:~.<@~.@/:~"1@(,.|.)@I.@e.&'bcdfghjklmnpqrstvwxz'
</code>```

Maybe the not the best way but I wanted to use C. since this can be solved using permutations.

Usage

```<code>   f =: C.~[:~.<@~.@/:~"1@(,.|.)@I.@e.&'bcdfghjklmnpqrstvwxz'
   f 'a test case'
a sect sate
   f 'well-done'
nedl-lowe
   f 'reverse the consonants'
setenne sne cohtosarvr
</code>```

Explanation

```<code>C.~[:~.<@~.@/:~"1@(,.|.)@I.@e.&'...'  Input: s
                               '...'  The list of consonants
                            e.&'...'  Generate a boolean mask where an index is true
                                      if the char at that index in s is a consonant
                         I.@          Get a list of the true indices
                  (  |.)@             Reverse that list
                  (,.  )@             Join the original and reversed list as columns
            /:~"1@                    Sort each row of that 2d list
         ~.@                          Take the distinct values in each row
       <@                             Box them
   [:~.                               Take the distinct boxes - Now represents the
                                      permutation needed to solve this in cycle notation
C.~                                   Permute s according the cycles and return
</code>```

Title: Reverse the consonants

Body:
J, 53 bytes

C.~[:~.<@~.@/:~"1@(,.|.)@I.@e.&'bcdfghjklmnpqrstvwxz'

Maybe the not the best way but I wanted to use C. since this can be solved using permutations.

Usage

   f =: C.~[:~.<@~.@/:~"1@(,.|.)@I.@e.&'bcdfghjklmnpqrstvwxz'
   f 'a test case'
a sect sate
   f 'well-done'
nedl-lowe
   f 'reverse the consonants'
setenne sne cohtosarvr

Explanation

C.~[:~.<@~.@/:~"1@(,.|.)@I.@e.&'...'  Input: s
                               '...'  The list of consonants
                            e.&'...'  Generate a boolean mask where an index is true
                                      if the char at that index in s is a consonant
                         I.@          Get a list of the true indices
                  (  |.)@             Reverse that list
                  (,.  )@             Join the original and reversed list as columns
            /:~"1@                    Sort each row of that 2d list
         ~.@                          Take the distinct values in each row
       <@                             Box them
   [:~.                               Take the distinct boxes - Now represents the
                                      permutation needed to solve this in cycle notation
C.~                                   Permute s according the cycles and return


答:
J, 38 bytes

```<code>load'strings'
rplc&('s';'th';'S';'Th')
</code>```

In J, rplc is the string replace verb in the strings addon, and it takes a list of boxes where each pair [x, y] represents the string x to be replaced with y.

Usage

```<code>   f =: rplc&('s';'th';'S';'Th')
   f 'Sam and Sally like Sheep'
Tham and Thally like Thheep
   f 'Sally likes sausages'
Thally liketh thauthageth
   f 'Sally sells seashells'
Thally thellth theathhellth
</code>```

Title: Lithp Tranthlator

Body:
J, 38 bytes

load'strings'
rplc&('s';'th';'S';'Th')

In J, rplc is the string replace verb in the strings addon, and it takes a list of boxes where each pair [x, y] represents the string x to be replaced with y.

Usage

   f =: rplc&('s';'th';'S';'Th')
   f 'Sam and Sally like Sheep'
Tham and Thally like Thheep
   f 'Sally likes sausages'
Thally liketh thauthageth
   f 'Sally sells seashells'
Thally thellth theathhellth


问:
Let's build a Staircase
We don't have enough (semi-)easy challenges for beginners. More and more of the easy ones are already taken. So I tried to come up with something that might be achievable by beginners, but that isn't a duplicate.

Input:

A single string separated with your OS new-line (i.e. \r\n),

or an array with multiple strings.

Output - The Stairs:

Remove all non-alphabetic and non-numeric symbols. So all that's left is [A-Za-z0-9]. And then 'build a stairs'; basically ordering them on length with the smallest at top and widest at the bottom.

Challenge rules:

When two strings are of equal length, we merge them with each other as one big string (the order doesn't matter, so it could be from first to last or last to first, whichever of the two you prefer).

The rule above can stack when the merged strings are of equal length again (see test case 2).

General rules:

The input is STDIN and contains only ASCII characters. And the output is STDOUT.

The case of the output must be the same as the input.

<s>Each submission must be a full program able to compile and run, so not just a method/function.</s> EDIT: I'm rather new, so perhaps it's indeed better to use the default from now on, even though I prefer a full program myself. Sorry for everyone that has already posted a full program. Feel free to edit, and I'll try to not change the post mid-challenge next time.

This is code-golf, so the shortest answer in bytes wins. I probably accept the shortest answer in a year from now.

Don't let code-golf answers discourage you from posting golfed non-codegolf languages like C# and alike! Try to come up with the shortest answer for any programming language.

Feel free to use newer languages than this question.

Test cases:

Input 1:

```<code>This is a sample text,
that you will have to use to build stairs.
The wood may be of excellent quality,
or pretty crappy almost falling apart and filled with termites.
Bla bla bla - some more text
Ok, that will do
</code>```

Output 1:

```<code>Okthatwilldo
Thisisasampletext
Blablablasomemoretext
Thewoodmaybeofexcellentquality
thatyouwillhavetousetobuildstairs
orprettycrappyalmostfallingapartandfilledwithtermites
</code>```

Input 2:

```<code>A
small
one
that
contains
equal
length
strings
for
the
special
rule
</code>```

Output 2:

```<code>A                   Or alternatively:       A
length                                      length
oneforthe                                   theforone
smallequal                                  equalsmall
stringsspecial                              specialstrings
thatrulecontains                            containsrulethat
</code>```

Steps explained of 2:

First order on length:

```<code>A
one
for
the
that
rule
small
equal
length
strings
special
contains
</code>```

First merge:

```<code>A
oneforthe
thatrule
smallequal
length
stringsspecial
contains
</code>```

Second order on length:

```<code>A
length
thatrule
contains
oneforthe
smallequal
stringsspecial
</code>```

Second merge:

```<code>A
length
thatrulecontains
oneforthe
smallequal
stringsspecial
</code>```

Third order on length:

```<code>A
length
oneforthe
smallequal
stringsspecial
thatrulecontains
</code>```

Input 3:

```<code>Test,
test.
This
is
a
test.
</code>```

Output 3:

```<code>Okthatwilldo
Thisisasampletext
Blablablasomemoretext
Thewoodmaybeofexcellentquality
thatyouwillhavetousetobuildstairs
orprettycrappyalmostfallingapartandfilledwithtermites
</code>```0

Input 4:

```<code>Okthatwilldo
Thisisasampletext
Blablablasomemoretext
Thewoodmaybeofexcellentquality
thatyouwillhavetousetobuildstairs
orprettycrappyalmostfallingapartandfilledwithtermites
</code>```1

Output 4:

```<code>Okthatwilldo
Thisisasampletext
Blablablasomemoretext
Thewoodmaybeofexcellentquality
thatyouwillhavetousetobuildstairs
orprettycrappyalmostfallingapartandfilledwithtermites
</code>```2

答:
Python 3, <s>184</s> 180 bytes

```<code>def f(x):l=len;m=filter;y=sorted([''.join(m(str.isalnum,i))for i in x],key=l);*z,=m(l,[''.join(i for i in y if-~j==l(i))for j in range(l(y[-1]))]);y==z and+print(*z,sep='\n')or f(z)
</code>```

A function that takes input, by argument, as a list of strings and prints the result to STDOUT. Execution raises an error (due to the use of the + operator before the print statement), but not before the output has been printed.

How it works

```<code>def f(x):                              Function with input of list of strings
l=len;m=filter                         Redefine much-used functions: len gives the length
                                       of an object and filter chooses those items from an
                                       iterable for which a function is true
[''.join(m(str.isalnum,i))for i in x]  Strip to leave only alphanumeric characters...
y=sorted(...,key=l)                    ...and sort by length, into y
''.join(i for i in y if-~j==l(i))      Concatenate equal length strings...
[...for j in range(l(y[-1]))]          ...for all possible string lengths...
*z,=(m(l,...))                         ...and remove empty strings by filtering by length
                                       (the empty string has length 0, and is thus false),
                                       into z
y==z and+print(*z,sep='\n')...         If no change after concatenation, no more equal
                                       length strings exist, so print result to STDOUT...
...or f(z)                             ...else pass new list to function
</code>```

Try it on Ideone

Title: Let's build a Staircase

Body:
Python 3, <s>184</s> 180 bytes

def f(x):l=len;m=filter;y=sorted([''.join(m(str.isalnum,i))for i in x],key=l);*z,=m(l,[''.join(i for i in y if-~j==l(i))for j in range(l(y[-1]))]);y==z and+print(*z,sep='\n')or f(z)

A function that takes input, by argument, as a list of strings and prints the result to STDOUT. Execution raises an error (due to the use of the + operator before the print statement), but not before the output has been printed.

How it works

def f(x):                              Function with input of list of strings
l=len;m=filter                         Redefine much-used functions: len gives the length
                                       of an object and filter chooses those items from an
                                       iterable for which a function is true
[''.join(m(str.isalnum,i))for i in x]  Strip to leave only alphanumeric characters...
y=sorted(...,key=l)                    ...and sort by length, into y
''.join(i for i in y if-~j==l(i))      Concatenate equal length strings...
[...for j in range(l(y[-1]))]          ...for all possible string lengths...
*z,=(m(l,...))                         ...and remove empty strings by filtering by length
                                       (the empty string has length 0, and is thus false),
                                       into z
y==z and+print(*z,sep='\n')...         If no change after concatenation, no more equal
                                       length strings exist, so print result to STDOUT...
...or f(z)                             ...else pass new list to function

Try it on Ideone