问:
Compute the RFC 2550 timestamp
RFC 2550 is a satirical proposal (published on April 1, 1999) for a space-efficient ASCII representation of timestamps that can support any date (even those prior to the beginning of the universe and those past the predicted end of the universe). The algorithm for computing a RFC 2550-compliant timestamp is as follows (note: all ranges include the start but exclude the end - 0 to 10,000 means all n where 0 <= n < 10000):

Year format

Years 0 to 10,000: a 4-digit decimal number, left-padded with zeroes.

Years 10,000 to 100,000: a 5-digit decimal number, prefixed with the character A.

Years 100,000 to 1030: the decimal number for the year, prefixed with the uppercase ASCII letter whose index in the English alphabet is equal to the number of digits in the decimal year, minus 5 (B for 6-digit years, C for 7-digit years, etc.).

Years 1030 to 1056: the same format as 10,000 to 1030, starting the letters over with A, and additionally prefixing a caret (^) to the string (so the year 1030 is represented by ^A1000000000000000000000000000000, and the year 1031 is represented by ^B10000000000000000000000000000000).

Years 1056 to 10732: the year is prefixed by two carets and two ASCII uppercase letters. The uppercase letters form a base-26 number representing the number of digits in the year, minus 57.

Years 10732 onwards: the same format for 1056 to 10732 is used, extending it by adding an additional caret and uppercase letter when necessary.

BCE years (prior to Year 0): compute the year string of the absolute value of the year. Then, replace all letters by their base-26 complement (A <-> Z, B <-> Y, etc.), replace all digits by their base-10 complement (0 <-> 9, 1 <-> 8, etc.), and replace carets with exclamation marks (!). If the year string is 4 digits or less (i.e. -1 to -10,000), prepend a forward slash (/). If the year string is not prefixed by a forward slash or an exclamation mark, prepend an asterisk (*).

Months, days, hours, minutes, and seconds: since these values are only ever 2 digits at the most, they are simply appended to the right of the year string, in decreasing order of significance, left-padded with zeroes if necessary to form 2-digit strings.

Additional precision: if additional precision (in the form of milliseconds, microseconds, nanoseconds, etc.) is needed, those values are left-padded with zeroes to 3 digits (because each value is 1/1000 of the previous value, and thus is at most 999) and appended to the end of the timestamp, in decreasing order of significance.

This format has the benefit of lexical sorting being equivalent to numeric sorting of the corresponding timestamp - if time A comes before time B, then the timestamp for A will come before the timestamp for B when lexical sorting is applied.

##The challenge

Given an arbitrarily-long list of numeric values (corresponding to time values in decreasing order of significance, e.g. [year, month, day, hour, minute, second, millisecond]), output the corresponding RFC 2550 timestamp.

##Rules

Solutions must work for any given input. The only limitations should be time and available memory.

Input may be taken in any reasonable, convenient format (such as a list of numerics, a list of strings, a string delimited by a single non-digit character, etc.).

The input will always contain at least one value (the year). Additional values are always in decreasing order of significance (e.g. the input will never contain a day value without a month value, or a second value followed by a month value).

Input will always be a valid time (e.g. there won't be any timestamps for February 30th).

Builtins which compute RFC 2550 timestamps are forbidden.

##Examples

These examples use input as a single string, with the individual values separated by periods (.).

```<code>1000.12.31.13.45.16.8 -> 10001231134516008
12.1.5.1 -> 0012010501
45941 -> A45941
8675309.11.16 -> C86753091116
47883552573911529811831375872990.1.1.2.3.5.8.13 -> ^B478835525739115298118313758729900101020305008013
4052107100422150625478207675901330514555829957419806023121389455865117429470888094459661251.2.3.5.7.11 -> ^^BI40521071004221506254782076759013305145558299574198060231213894558651174294708880944596612510203050711
-696443266.1.3.6.10.15.21.28 -> *V3035567330103061015021028
-5342 -> /4657
-4458159579886412234725624633605648497202 -> !Q5541840420113587765274375366394351502797
</code>```

##Reference implementation

#!/usr/bin/env python

import string

# thanks to Leaky Nun for help with this
def base26(n):
    if n == 0:
        return ''
    digits = []
    while n:
        n -= 1
        n, digit = divmod(n, 26)
        digit += 1
        if digit < 0:
            n += 1
            digit -= 26
        digits.append(digit)
    return ''.join(string.ascii_uppercase[x-1] for x in digits[::-1])

year, *vals = input().split('.')

res = ""
negative = False

if year[0] == '-':
    negative = True
    year = year[1:]

if len(year) < 5:
    y = "{0:0>4}".format(year)
elif len(year) <= 30:
    y = "{0}{1}".format(string.ascii_uppercase[len(year)-5], year)
else:
    b26len = base26(len(year)-30)
    y = "{0}{1}{2}".format('^'*len(b26len), b26len, year)

if negative:
    y = y.translate(str.maketrans(string.ascii_uppercase+string.digits+'^', string.ascii_uppercase[::-1]+string.digits[::-1]+'!'))
    if len(year) == 4:
        y = '/' + y
    if y[0] not in ['/', '!']:
        y = '*' + y

res += y
for val in vals[:5]: #month, day, hour, minute, second
    res += '{0:0>2}'.format(val)

for val in vals[5:]: #fractional seconds
    res += '{0:0>3}'.format(val)

print(res)
```

答:
JavaScript (ES6), 325 bytes

f=
s=>s.split`.`.map((n,i)=>i?`00${n}`.slice(i>5?-3:-2):n<'0'?g(n.slice(1),'!','*','/').replace(/\w/g,c=>c>'9'?(45-parseInt(c,36)).toString(36):9-c):g(n),g=(n,c='^',d='',e='',l=n.length)=>l<5?e+`000${n}`.slice(-4):l<31?d+(l+5).toString(36)+n:h(l-30,c)+n,h=(n,c)=>n?c+h(--n/26|0,c)+(n%26+10).toString(36):'').join``.toUpperCase()
;```
<pre class="snippet-code-html lang-html prettyprint-override"><code><input oninput=o.value=f(this.value);><input id=o></code>```

Shockingly long.

Title: Compute the RFC 2550 timestamp

Body:
JavaScript (ES6), 325 bytes

f=
s=>s.split`.`.map((n,i)=>i?`00${n}`.slice(i>5?-3:-2):n<'0'?g(n.slice(1),'!','*','/').replace(/\w/g,c=>c>'9'?(45-parseInt(c,36)).toString(36):9-c):g(n),g=(n,c='^',d='',e='',l=n.length)=>l<5?e+`000${n}`.slice(-4):l<31?d+(l+5).toString(36)+n:h(l-30,c)+n,h=(n,c)=>n?c+h(--n/26|0,c)+(n%26+10).toString(36):'').join``.toUpperCase()
;

<input oninput=o.value=f(this.value);><input id=o>

Shockingly long.


问:
Output the Current Time

Challenge

You must output the current time continuously (until cancelled by an interrupt), once every second, by any of the following means:

It must be in 24-hour or AM/PM format.

If it is the former, it must be spaced out with colons (i.e. 15:47:36).

If it is the latter, it must be spaced out with colons and have the AM/PM following (i.e. 3:47:36 PM)

It may be pulled from the internet.

It may be the system time.

It must output any naturally accessible form of output which supports text that you choose.

Output may have extra information aside of the time in it, but you must guarantee one, and only one, output of time per second.

The continuous output must be a second apart - if you choose to wait until the second changes between outputs, that is fine. If you wait a second between each output, that is perfectly acceptable, despite the eventual loss of accuracy.

Since this is a catalog, languages created after this challenge are allowed to compete. 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. Other than that, all the standard rules of code-golf must be obeyed. Submissions in most languages will be scored in bytes in an appropriate preexisting encoding (usually UTF-8).

Catalog

The Stack Snippet at the bottom of this post generates the catalog 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>```

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
Batch (Windows), 21 bytes

t.bat

```<code>echo %time%
timeout 1
t
</code>```

Shows the time, delays for 1 second, then recursively calls itself. This is run as t.bat in the same directory.

ContentLicense: CC BY-SA 3.0

Title: Output the Current Time

Body:
Batch (Windows), 21 bytes

t.bat

echo %time%
timeout 1
t

Shows the time, delays for 1 second, then recursively calls itself. This is run as t.bat in the same directory.


问:
Truth Tables: Your great-grandfather's computer
If you remember back to your schooling years, you might remember learning about Truth Tables. They seemed boring, but they are basis for logic and (some would argue) all computing...

Problem

Your mission, should you choose to accept it is to write a program, function, or widget of code that can output a truth table given input.

Input

Input will be a string (like data structure) containing the logic statement to make the Truth Table into. For example:

```<code>p ∧ q
</code>```

This means p and q(logical conjuction) and will output:

```<code> p  q  p ∧ q
 T  T    T
 T  F    F
 F  T    F
 F  F    F
</code>```

Notice the spacing: The item of the column is in the center of the header

Characters

Score via characters, not bytes
The logic comparison characters are special and not always what they look like. Use these characters:

Logical Conjunction (AND): ∧ U+2227

Logical Disjunction (OR): ∨ U+2228

Logical Negation (NOT) ~ or ¬ U+7e and U+ac respectively

Bonuses

All of these bonuses are optional, but will knock points off your score. Pick any.

Logical Negation

Logical Negation is a unary operator in truth tables. It is the equivalent of ! in most C-based languages. It makes false=>true and vise versa. It is notated with a ¬ or ~ (you must support both). Supporting this will knock off 10% of your score. You must, however, add an additional column to show its results:
For example:

```<code>~p ∧ q
</code>```

will output:

```<code>p  ~p  q  ~p ∧ q
T  F   T     F
T  F   F     F
F  T   T     T
F  T   F     F
</code>```

Pretty Print

The normal table notation is boring. Let's make it pretty! Pretty print format is as follows for p ∧ q is as follows:

```<code>+---+---+-------+
| p | q | p ∧ q |
+---+---+-------+
| T | T |   T   |
+---+---+-------+
| T | F |   F   |
+---+---+-------+
| F | T |   F   |
+---+---+-------+
| F | F |   F   |
+---+---+-------+
</code>```

Special details for pretty printing:

There is a 1 space padding in each cell

Cell values are still centered

If you pretty print your tables, from your code and then multiply by 0.6. Use this function for this bonus:

```<code>score = 0.6 * code
</code>```

Examples

p ∧ q:

```<code>p  q  p ∧ q
T  T    T
T  F    F
F  T    F
F  F    F
</code>```

p ∨ q:

```<code>p  q  p ∨ q
T  T    T
T  F    T
F  T    T
F  F    F
</code>```

~p ∧ q:

```<code>p  ~p  q  ~p ∧ q
T   F  T     F
T   F  F     F
F   T  T     T
F   T  F     F
</code>```

~p ∨ q:

```<code>p  ~p  q  ~p ∧ q
T   F  T     T
T   F  F     F
F   T  T     T
F   T  F     T
</code>```

Rules

Standard loopholes apply

No external resources

If you're going to break the rules, be clever ;)

Shortest Code (in characters) wins. Good Luck!

答:
Python3, 145 139 120 119 Bytes

No bonus (with bonus at the end)

```<code> def f(s):
 a,m,b=s.split(" ");print(a,b,s);F,T,c=0,1,"FT"
 for p in c:
  for q in c:print(p,q," ",c[eval(p+"+*"[m=="∧"]+q)>0])
</code>```

Needing Python3 for Unicode support out of the box.

Based on DJgamer98 Python code, figuring out his table is not right.

Edit1: Splitting into distinct variables and ommiting the operator string variable

Edit2: (ab)using F and T as both variables and string characters

Edit3: Saving one space thanks to NoOneIsHere

With Bonus, 215 * 0.6 = 129

```<code>def f(s):
 r="+---"*3+"----+"
 a,m,b=s.split(" ");F,T,c=0,1,"FT"
 print("%s\n| %s | %s | %s |\n%s"%(r,a,b,s,r));
 for p in c:
  for q in c: print("| %s | %s |   %s   |\n%s"%(p,q,c[eval(p+"+*"[m=="∧"]+q)>0],r));
</code>```

Body:
Python3, 145 139 120 119 Bytes

No bonus (with bonus at the end)

 def f(s):
 a,m,b=s.split(" ");print(a,b,s);F,T,c=0,1,"FT"
 for p in c:
  for q in c:print(p,q," ",c[eval(p+"+*"[m=="∧"]+q)>0])

Needing Python3 for Unicode support out of the box.

Based on DJgamer98 Python code, figuring out his table is not right.

Edit1: Splitting into distinct variables and ommiting the operator string variable

Edit2: (ab)using F and T as both variables and string characters

Edit3: Saving one space thanks to NoOneIsHere

With Bonus, 215 * 0.6 = 129

def f(s):
 r="+---"*3+"----+"
 a,m,b=s.split(" ");F,T,c=0,1,"FT"
 print("%s\n| %s | %s | %s |\n%s"%(r,a,b,s,r));
 for p in c:
  for q in c: print("| %s | %s |   %s   |\n%s"%(p,q,c[eval(p+"+*"[m=="∧"]+q)>0],r));


答:
Mathematica, <s>27</s> 21 bytes

With 2 bytes saved thanks to Xavier.

```<code>Dynamic@{Now,Clock[]}
</code>```

Title: Output the Current Time

Body:
Challenge

You must output the current time continuously (until cancelled by an interrupt), once every second, by any of the following means:

It must be in 24-hour or AM/PM format.

If it is the former, it must be spaced out with colons (i.e. 15:47:36).

If it is the latter, it must be spaced out with colons and have the AM/PM following (i.e. 3:47:36 PM)

It may be pulled from the internet.

It may be the system time.

It must output any naturally accessible form of output which supports text that you choose.

Output may have extra information aside of the time in it, but you must guarantee one, and only one, output of time per second.

The continuous output must be a second apart - if you choose to wait until the second changes between outputs, that is fine. If you wait a second between each output, that is perfectly acceptable, despite the eventual loss of accuracy.

Since this is a catalog, languages created after this challenge are allowed to compete. 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. Other than that, all the standard rules of code-golf must be obeyed. Submissions in most languages will be scored in bytes in an appropriate preexisting encoding (usually UTF-8).

Catalog

The Stack Snippet at the bottom of this post generates the catalog 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>```

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
Mathematica, <s>27</s> 21 bytes

With 2 bytes saved thanks to Xavier.

Dynamic@{Now,Clock[]}


问:
Alternating Sign Sequence

Introduction

The sign of a number is either a +, or a - for every non-zero integer. Zero itself is signless (+0 is the same as -0). In the following sequence, we are going to alternate between the positive sign, the zero and the negative sign. The sequence starts with 1, so we write 1 with a positive sign, with zero (this one is weird, but we just multiply the number by 0) and the negative sign:

```<code>1, 0, -1
</code>```

The next number is 2, and we do the same thing again:

```<code>2, 0, -2
</code>```

The sequence eventually is:

```<code>1, 0, -1, 2, 0, -2, 3, 0, -3, 4, 0, -4, 5, 0, -5, 6, 0, -6, 7, 0, -7, ...
</code>```

Or a more readable form:

```<code>a(0) = 1
a(1) = 0
a(2) = -1
a(3) = 2
a(4) = 0
a(5) = -2
a(6) = 3
a(7) = 0
a(8) = -3
a(9) = 4
...
</code>```

The Task

Given a non-negative integer n, output the nth term of the above sequence. You can choose if you use the zero-indexed or one-indexed version.

Test cases:

Zero-indexed:

```<code>a(0) = 1
a(11) = -4
a(76) = 0
a(134) = -45
a(296) = -99
</code>```

Or if you prefer one-indexed:

```<code>a(1) = 1
a(12) = -4
a(77) = 0
a(135) = -45
a(297) = -99
</code>```

This is code-golf, so the submission with the smallest number of bytes wins!

答:
Batch (Windows), 86 bytes

Alternate.bat

```<code>SET /A r=%1%%3
SET /A d=(%1-r)/3+1
IF %r%==0 ECHO %d%
IF %r%==1 ECHO 0
IF %r%==2 ECHO -%d%
</code>```

This program is run as Alternate.bat n where n is the number you wish to call the function on.

Title: Alternating Sign Sequence

Body:
Batch (Windows), 86 bytes

Alternate.bat

SET /A r=%1%%3
SET /A d=(%1-r)/3+1
IF %r%==0 ECHO %d%
IF %r%==1 ECHO 0
IF %r%==2 ECHO -%d%

This program is run as Alternate.bat n where n is the number you wish to call the function on.


答:
JavaScript, 22 bytes

```<code>r=n%3
o=(1-r)/3*(n-r+3)
</code>```

n is the number you wish to call the function on. o is the output number.

Title: Alternating Sign Sequence

Body:
Introduction

The sign of a number is either a +, or a - for every non-zero integer. Zero itself is signless (+0 is the same as -0). In the following sequence, we are going to alternate between the positive sign, the zero and the negative sign. The sequence starts with 1, so we write 1 with a positive sign, with zero (this one is weird, but we just multiply the number by 0) and the negative sign:

```<code>1, 0, -1
</code>```

The next number is 2, and we do the same thing again:

```<code>2, 0, -2
</code>```

The sequence eventually is:

```<code>1, 0, -1, 2, 0, -2, 3, 0, -3, 4, 0, -4, 5, 0, -5, 6, 0, -6, 7, 0, -7, ...
</code>```

Or a more readable form:

```<code>a(0) = 1
a(1) = 0
a(2) = -1
a(3) = 2
a(4) = 0
a(5) = -2
a(6) = 3
a(7) = 0
a(8) = -3
a(9) = 4
...
</code>```

The Task

Given a non-negative integer n, output the nth term of the above sequence. You can choose if you use the zero-indexed or one-indexed version.

Test cases:

Zero-indexed:

```<code>a(0) = 1
a(11) = -4
a(76) = 0
a(134) = -45
a(296) = -99
</code>```

Or if you prefer one-indexed:

```<code>a(1) = 1
a(12) = -4
a(77) = 0
a(135) = -45
a(297) = -99
</code>```

This is code-golf, so the submission with the smallest number of bytes wins!

Body:
JavaScript, 22 bytes

r=n%3
o=(1-r)/3*(n-r+3)

n is the number you wish to call the function on. o is the output number.


问:
24 and 12 Hour Times
Write a program or function with no input that prints or returns this string of 24-hour and 12-hour times:

```<code>00:00 12:00am
01:00  1:00am
02:00  2:00am
03:00  3:00am
04:00  4:00am
05:00  5:00am
06:00  6:00am
07:00  7:00am
08:00  8:00am
09:00  9:00am
10:00 10:00am
11:00 11:00am
12:00 12:00pm
13:00  1:00pm
14:00  2:00pm
15:00  3:00pm
16:00  4:00pm
17:00  5:00pm
18:00  6:00pm
19:00  7:00pm
20:00  8:00pm
21:00  9:00pm
22:00 10:00pm
23:00 11:00pm
</code>```

The string must be output exactly as it appears here. The only exception is that it may optionally have a single trailing newline.

So the MD5 hash of your output should be

```<code>827ae6e2dbb1df494930baedb3ee2653
</code>```

if you do not have a trailing newline and

```<code>cd4c3d18abee9bafb495f390a919a13f
</code>```

if you do. (Your hash could be different if your system uses another type of newline but that's OK.)

The shortest code in bytes wins. Tiebreaker is earlier answer.

Title: 24 and 12 Hour Times

Body:
Python 2, 66 bytes

for i in range(24):print'%02d:00%3d:00%sm'%(i,12+i%-12,'ap'[i>11])


Title: 24 and 12 Hour Times

Body:
Write a program or function with no input that prints or returns this string of 24-hour and 12-hour times:

```<code>00:00 12:00am
01:00  1:00am
02:00  2:00am
03:00  3:00am
04:00  4:00am
05:00  5:00am
06:00  6:00am
07:00  7:00am
08:00  8:00am
09:00  9:00am
10:00 10:00am
11:00 11:00am
12:00 12:00pm
13:00  1:00pm
14:00  2:00pm
15:00  3:00pm
16:00  4:00pm
17:00  5:00pm
18:00  6:00pm
19:00  7:00pm
20:00  8:00pm
21:00  9:00pm
22:00 10:00pm
23:00 11:00pm
</code>```

The string must be output exactly as it appears here. The only exception is that it may optionally have a single trailing newline.

So the MD5 hash of your output should be

```<code>827ae6e2dbb1df494930baedb3ee2653
</code>```

if you do not have a trailing newline and

```<code>cd4c3d18abee9bafb495f390a919a13f
</code>```

if you do. (Your hash could be different if your system uses another type of newline but that's OK.)

The shortest code in bytes wins. Tiebreaker is earlier answer.

Body:
Perl 5, 58

map{printf"%02u:00%3u:00%sm
",$_,$_%12||12,$_>11?p:a}0..23


答:
V, <s>56</s> 53 bytes

```<code>i00:00 23ñYpñH12G$yP13G$pgvó $/am
í/pm
í 0/
í/12
</code>```

Try it online!

Since this can be hard to enter, here is a reversible hexdump:

```<code>00000000: 6930 303a 3030 201b 3233 f159 7001 f148  i00:00 .23.Yp..H
00000010: 1631 3247 2479 5031 3347 2470 6776 f320  .12G$yP13G$pgv.
00000020: 242f 616d 0aed 2f70 6d0a ed20 302f 2020  $/am../pm.. 0/
00000030: 0aed 2f31 320a                           ../12.
</code>```

A noncompeting version is trivially 2 bytes shorter if you replace both occurrences of G$ with L, which was supposed to be the same but had a bug.

Explanation:

```<code>i00:00<esc>                                     #Enter the starting text.
           23ñYp<C-a>ñ                          #Duplicate and increment 23 times
                      H                         #Move back to the beginning
                       <C-v>12G$y               #Select 12 lines horizontally
                                 P              #Horizontally paste
                                  13G$p         #Move to line 13 and Horizontally paste again
                                       gv       #Reselect the top 12 lines
                                         ó $/am #Replace a space at the end of the line with 'am'
</code>```

```<code>í/pm      #Replace the previous search with 'pm'
í 0/      #Replace "Space+0" with 2 spaces
í/12      #Replace the previous search with "12"
</code>```

Title: 24 and 12 Hour Times

Body:
V, <s>56</s> 53 bytes

i00:00 23ñYpñH12G$yP13G$pgvó $/am
í/pm
í 0/
í/12

Try it online!

Since this can be hard to enter, here is a reversible hexdump:

00000000: 6930 303a 3030 201b 3233 f159 7001 f148  i00:00 .23.Yp..H
00000010: 1631 3247 2479 5031 3347 2470 6776 f320  .12G$yP13G$pgv.
00000020: 242f 616d 0aed 2f70 6d0a ed20 302f 2020  $/am../pm.. 0/
00000030: 0aed 2f31 320a                           ../12.

A noncompeting version is trivially 2 bytes shorter if you replace both occurrences of G$ with L, which was supposed to be the same but had a bug.

Explanation:

i00:00<esc>                                     #Enter the starting text.
           23ñYp<C-a>ñ                          #Duplicate and increment 23 times
                      H                         #Move back to the beginning
                       <C-v>12G$y               #Select 12 lines horizontally
                                 P              #Horizontally paste
                                  13G$p         #Move to line 13 and Horizontally paste again
                                       gv       #Reselect the top 12 lines
                                         ó $/am #Replace a space at the end of the line with 'am'

í/pm      #Replace the previous search with 'pm'
í 0/      #Replace "Space+0" with 2 spaces
í/12      #Replace the previous search with "12"


答:
Julia, <s>88</s> <s>71</s> <s>66</s> 64 bytes

[@printf "%02d:00%3d:00%cm
" i-11 i%12+1 i>22?112:97for i=11:34]
```

This is a full program that prints the string with a single trailing newline.

Try it online!

Saved 5 bytes thanks to Sp3000 and 2 thanks to Dennis!

Title: 24 and 12 Hour Times

Body:
Julia, <s>88</s> <s>71</s> <s>66</s> 64 bytes

[@printf "%02d:00%3d:00%cm
" i-11 i%12+1 i>22?112:97for i=11:34]

This is a full program that prints the string with a single trailing newline.

Try it online!

Saved 5 bytes thanks to Sp3000 and 2 thanks to Dennis!


答:
dc, 10

```<code>?2+3~1r-*p
</code>```

Uses 1-based indexing.

```<code>?              # Push input to stack
 2+            # Add 2
   3~          # divmod by 3
     1r-       # subtract remainder from 1
        *      # multiply by quotient
         p     # print
</code>```

Title: Alternating Sign Sequence

Body:
dc, 10

?2+3~1r-*p

Uses 1-based indexing.

?              # Push input to stack
 2+            # Add 2
   3~          # divmod by 3
     1r-       # subtract remainder from 1
        *      # multiply by quotient
         p     # print


答:
Dyalog APL, <s>58</s> 48 characters

Requires ⎕IO←0, which is default on many systems. Takes string as argument.

```<code>{('p q ',⍵)⍪'FT '[p,q,⍪⍎⍵]\⍨324⊤⍨9⍴≢p q←↓2 2⊤⌽⍳4}
</code>```

No bonuses, but on the plus side, any operator works.

⍳4 first four indices (0 1 2 3)

⌽ reverse (3 2 1 0)

2 2⊤ two-bit Boolean table

↓ split into two-element list of lists (high-bits, low-bits)

p q← store as p and q

≢ tally them (2)*

9⍴ cyclically reshape that to length 9 (2 2 2 2 2 2 2 2 2)

324⊤⍨ encode 324 thusly, i.e. as 12-bit binary (1 0 1 0 0 0 1 0 0)

\⍨ use that to expand (insert a space for each 0)...

'FT '[...] the string "FT ", indexed by

 ⍎⍵ the executed argument (valid since p and q now have values)

 ⍪ make that into a column matrix

 q, prepend a column consisting of q (1 1 0 0)

 q, prepend a column consisting of p (1 0 1 0)

(...)⍪ insert a row above, consisting of

 ⍵ the argument

 'p q ', prepended with the string "p q "

* Please star this issue if you see ≢ as ≢ and not as ̸≡.

Title: Truth Tables: Your great-grandfather's computer

Body:
If you remember back to your schooling years, you might remember learning about Truth Tables. They seemed boring, but they are basis for logic and (some would argue) all computing...

Problem

Your mission, should you choose to accept it is to write a program, function, or widget of code that can output a truth table given input.

Input

Input will be a string (like data structure) containing the logic statement to make the Truth Table into. For example:

```<code>p ∧ q
</code>```

This means p and q(logical conjuction) and will output:

```<code> p  q  p ∧ q
 T  T    T
 T  F    F
 F  T    F
 F  F    F
</code>```

Notice the spacing: The item of the column is in the center of the header

Characters

Score via characters, not bytes
The logic comparison characters are special and not always what they look like. Use these characters:

Logical Conjunction (AND): ∧ U+2227

Logical Disjunction (OR): ∨ U+2228

Logical Negation (NOT) ~ or ¬ U+7e and U+ac respectively

Bonuses

All of these bonuses are optional, but will knock points off your score. Pick any.

Logical Negation

Logical Negation is a unary operator in truth tables. It is the equivalent of ! in most C-based languages. It makes false=>true and vise versa. It is notated with a ¬ or ~ (you must support both). Supporting this will knock off 10% of your score. You must, however, add an additional column to show its results:
For example:

```<code>~p ∧ q
</code>```

will output:

```<code>p  ~p  q  ~p ∧ q
T  F   T     F
T  F   F     F
F  T   T     T
F  T   F     F
</code>```

Pretty Print

The normal table notation is boring. Let's make it pretty! Pretty print format is as follows for p ∧ q is as follows:

```<code>+---+---+-------+
| p | q | p ∧ q |
+---+---+-------+
| T | T |   T   |
+---+---+-------+
| T | F |   F   |
+---+---+-------+
| F | T |   F   |
+---+---+-------+
| F | F |   F   |
+---+---+-------+
</code>```

Special details for pretty printing:

There is a 1 space padding in each cell

Cell values are still centered

If you pretty print your tables, from your code and then multiply by 0.6. Use this function for this bonus:

```<code>score = 0.6 * code
</code>```

Examples

p ∧ q:

```<code>p  q  p ∧ q
T  T    T
T  F    F
F  T    F
F  F    F
</code>```

p ∨ q:

```<code>p  q  p ∨ q
T  T    T
T  F    T
F  T    T
F  F    F
</code>```

~p ∧ q:

```<code>p  ~p  q  ~p ∧ q
T   F  T     F
T   F  F     F
F   T  T     T
F   T  F     F
</code>```

~p ∨ q:

```<code>p  ~p  q  ~p ∧ q
T   F  T     T
T   F  F     F
F   T  T     T
F   T  F     T
</code>```

Rules

Standard loopholes apply

No external resources

If you're going to break the rules, be clever ;)

Shortest Code (in characters) wins. Good Luck!

Body:
Dyalog APL, <s>58</s> 48 characters

Requires ⎕IO←0, which is default on many systems. Takes string as argument.

{('p q ',⍵)⍪'FT '[p,q,⍪⍎⍵]\⍨324⊤⍨9⍴≢p q←↓2 2⊤⌽⍳4}

No bonuses, but on the plus side, any operator works.

⍳4 first four indices (0 1 2 3)

⌽ reverse (3 2 1 0)

2 2⊤ two-bit Boolean table

↓ split into two-element list of lists (high-bits, low-bits)

p q← store as p and q

≢ tally them (2)*

9⍴ cyclically reshape that to length 9 (2 2 2 2 2 2 2 2 2)

324⊤⍨ encode 324 thusly, i.e. as 12-bit binary (1 0 1 0 0 0 1 0 0)

\⍨ use that to expand (insert a space for each 0)...

'FT '[...] the string "FT ", indexed by

 ⍎⍵ the executed argument (valid since p and q now have values)

 ⍪ make that into a column matrix

 q, prepend a column consisting of q (1 1 0 0)

 q, prepend a column consisting of p (1 0 1 0)

(...)⍪ insert a row above, consisting of

 ⍵ the argument

 'p q ', prepended with the string "p q "

* Please star this issue if you see ≢ as ≢ and not as ̸≡.


问:
Every Possible Cycle Length
A function (or program) which takes inputs and provides outputs can be said to have a cycle if calling the function on its own output repeatedly eventually reaches the original number. For instance, take the following function:

```<code>Input:  n    1 2 3 4 5 6
Output: f(n) 5 7 1 3 4 9
</code>```

If we start with n=1, f(n)=5, f(f(n))=f(5)=4, f(f(f(n)))=f(4)=3, f(f(f(f(n))))=f(3)=1.

This is written (1 5 4 3). Since there are 4 unique numbers in this loop, this is a cycle of length 4.

Your challenge is to write a program or function which has cycles of every possible length. That is, there must be a cycle of length 1, of length 2, and so on.

In addition, your function/program must be from the positive integers to positive integers, and it must be bijective, meaning that there must be a exactly one input value for every possible output value, over all positive integers. To put it another way, the function/program must compute a permutaion of the positive integers.

Details: Any standard input/output system is allowed, including STDIN, STDOUT, function argument, return, etc. Standard loopholes prohibited.

You do not need to worry about the limitations of your data types - the above properties need only hold under the assumption that an int or float can hold any value, for instance.

There are no restrictions on the behavior of the function on inputs which are not positive integers, and those inputs/outputs will be ignored.

Scoring is code golf in bytes, shortest code wins.

答:
Pyth, 15 bytes

The shortest answer so far that uses numeric operations rather than string operations.

```<code>.|.&Q_=.&_=x/Q2

    Q                input
            /Q2      input div 2
           x   Q     that XOR input
          =          assign that to Q
         _           negate that
       .&       Q    that AND Q
      =              assign that to Q
     _               negate that
  .&                 input AND that
.|               Q   that OR Q
</code>```

The effect of this function on the binary representation is to extend the rightmost block of 1s into the next 0; or if there is no 0, to reset it back to a single 1:

```<code>10010110100000 ↦
10010110110000 ↦
10010110111000 ↦
10010110111100 ↦
10010110111110 ↦
10010110111111 ↦
10010110100000
</code>```

Pyth, 26 bytes, fun variant

```<code>.|.&Q_h.&/Q2+Qy=.&/Q2_h.|y

    Q                           input
         /Q2                    input div 2
             Q                  input
                  /Q2           input div 2
                         yQ     twice input
                       .|  Q    that OR input
                     _h         NOT that
                .&              (input div 2) AND that
               =                assign that to Q
              y                 twice that
            +                   input plus that
       .&                       (input div 2) AND that
     _h                         NOT that
  .&                            input AND that
.|                          Q   that OR Q
</code>```

Performs the above operation simultaneously to all blocks of 1s, not just the rightmost one—still using only bitwise and arithmetic operations.

```<code>1000010001001 ↦
1100011001101 ↦
1110011101001 ↦
1111010001101 ↦
1000011001001 ↦
1100011101101 ↦
1110010001001 ↦
1111011001101 ↦
1000011101001 ↦
1100010001101 ↦
1110011001001 ↦
1111011101101 ↦
1000010001001
</code>```

Title: Every Possible Cycle Length

Body:
Pyth, 15 bytes

The shortest answer so far that uses numeric operations rather than string operations.

.|.&Q_=.&_=x/Q2

    Q                input
            /Q2      input div 2
           x   Q     that XOR input
          =          assign that to Q
         _           negate that
       .&       Q    that AND Q
      =              assign that to Q
     _               negate that
  .&                 input AND that
.|               Q   that OR Q

The effect of this function on the binary representation is to extend the rightmost block of 1s into the next 0; or if there is no 0, to reset it back to a single 1:

10010110100000 ↦
10010110110000 ↦
10010110111000 ↦
10010110111100 ↦
10010110111110 ↦
10010110111111 ↦
10010110100000

Pyth, 26 bytes, fun variant

.|.&Q_h.&/Q2+Qy=.&/Q2_h.|y

    Q                           input
         /Q2                    input div 2
             Q                  input
                  /Q2           input div 2
                         yQ     twice input
                       .|  Q    that OR input
                     _h         NOT that
                .&              (input div 2) AND that
               =                assign that to Q
              y                 twice that
            +                   input plus that
       .&                       (input div 2) AND that
     _h                         NOT that
  .&                            input AND that
.|                          Q   that OR Q

Performs the above operation simultaneously to all blocks of 1s, not just the rightmost one—still using only bitwise and arithmetic operations.

1000010001001 ↦
1100011001101 ↦
1110011101001 ↦
1111010001101 ↦
1000011001001 ↦
1100011101101 ↦
1110010001001 ↦
1111011001101 ↦
1000011101001 ↦
1100010001101 ↦
1110011001001 ↦
1111011101101 ↦
1000010001001


答:
MATL, <s>46</s> <s>42</s> 34 bytes

```<code>12tEt:qy/t15XObZ"!b16XOhhkw14:X~Z)
</code>```

Previously, 42 bytes, 12tEt:q2M/736330+t15XObZ"!b16XOhhkw14:X~Z), and 46 bytes, 736330 24t:qw/+t15XO' '24TX"b16XOhhk14: 12X~Z). Of course the 736330 wasn't needed, that was crazy!

Note: Doesn't work with TryItOnline, I think there is a compatibility issue between Matlab and Octaves implementation of datestr.

datestr takes the number representation of a date and converts it to the string representation of that date. The time of the day is the fractional part of the number, so 0.0 corrsponds to January 0, 0000, at time 00:00:00, and 1.0 corresponds to January 1, 0000, at 00:00:00. 1/24 is 1am, 2/24 2am etc.

Explanation

```<code>12t         % push a 12 onto the stack and duplicate
Et          % double the 12 and duplicate the 24 (stack now has 12, 24, 24, bottom to top)
:q          % make vector 1:24 and decrement by 1, stack has 12, 24, 0:23
y           % duplicate second element on stack (24)
/           % divide, for (0:23)/24
t           % duplicate elements
15XO        % string representation of date, 15 specifies format
b           % bubble up element in stack (gets a 24 on top of the stack)
Z"!         % makes a column of 24 spaces, to put between columns of times
b           % bubble up another (0:23)/24
16XO        % string representation of date, 16 for a different format
hh          % concatenate two time vectors and the column of spaces
k           % convert string to lowercase, because CO gives AM/PM not am/pm
w           % swap elements in stack, that first 12 is now on top
14:         % vector of equally spaced values 1:14
X~          % set exclusive-or, returns [1 2 3 4 5 6 7 8 9 10 11 13 14]
Z)          % get the right columns of the string array to remove extra column of blanks
            % implicit display
</code>```

To show it works in Matlab, here is a screenshot

Title: 24 and 12 Hour Times

Body:
MATL, <s>46</s> <s>42</s> 34 bytes

12tEt:qy/t15XObZ"!b16XOhhkw14:X~Z)

Previously, 42 bytes, 12tEt:q2M/736330+t15XObZ"!b16XOhhkw14:X~Z), and 46 bytes, 736330 24t:qw/+t15XO' '24TX"b16XOhhk14: 12X~Z). Of course the 736330 wasn't needed, that was crazy!

Note: Doesn't work with TryItOnline, I think there is a compatibility issue between Matlab and Octaves implementation of datestr.

datestr takes the number representation of a date and converts it to the string representation of that date. The time of the day is the fractional part of the number, so 0.0 corrsponds to January 0, 0000, at time 00:00:00, and 1.0 corresponds to January 1, 0000, at 00:00:00. 1/24 is 1am, 2/24 2am etc.

Explanation

12t         % push a 12 onto the stack and duplicate
Et          % double the 12 and duplicate the 24 (stack now has 12, 24, 24, bottom to top)
:q          % make vector 1:24 and decrement by 1, stack has 12, 24, 0:23
y           % duplicate second element on stack (24)
/           % divide, for (0:23)/24
t           % duplicate elements
15XO        % string representation of date, 15 specifies format
b           % bubble up element in stack (gets a 24 on top of the stack)
Z"!         % makes a column of 24 spaces, to put between columns of times
b           % bubble up another (0:23)/24
16XO        % string representation of date, 16 for a different format
hh          % concatenate two time vectors and the column of spaces
k           % convert string to lowercase, because CO gives AM/PM not am/pm
w           % swap elements in stack, that first 12 is now on top
14:         % vector of equally spaced values 1:14
X~          % set exclusive-or, returns [1 2 3 4 5 6 7 8 9 10 11 13 14]
Z)          % get the right columns of the string array to remove extra column of blanks
            % implicit display

To show it works in Matlab, here is a screenshot


问:
My "keybore" is key-boring me! Help me find a minimal keystrokes
Credits to @Agawa001 for coming up with this question.

Explanation

My new "keybore" only has 2 buttons, namely + and -.

The number in the memory starts at 0.

Each consecutive press of + or - will increment/decrement the memory for exactly how many times it has been pressed consecutively.

Therefore, if you press + 4 times, first time it adds 1, the second time it adds 2, the third time it adds 3, the fourth time it adds 4, giving you 10 (ten).

Now, if you press - 3 times, the first time it subtracts 1, the second time 2, the third time 3, leaving you with 4 (four).

TL;DR

Given a string of + and -, divide it at each change of character. Then each resulting string of m + symbols adds the m-th triangle number, and each string of n - symbols subtracts the n-th triangle number.

Walk-through

Now, if you still do not understand, I will show you how +++--+-- creates 1.

```<code>Program   | Counter | Memory
----------------------------
          |  0      | 0
+         | +1      | 1
++        | +2      | 3
+++       | +3      | 6
+++-      | -1      | 5
+++--     | -2      | 3
+++--+    | +1      | 4
+++--+-   | -1      | 3
+++--+--  | -2      | 1
</code>```

Task

You will take a positive integer as input, either as functional argument or from STDIN.

Then, you will output/print the minimum number of keystrokes needed to create that number using the method above.

Testcases

Since rearranging the + or - runs gives the same number, for each such group only the lexicographically earliest sequence is listed.

```<code>Input | Output | Possible corresponding sequences
-------------------------------------------------
    4 |      5 | -+++-
    6 |      3 | +++
    9 |      5 | ++++-
   11 |      7 | +++-+++
   12 |      7 | +++++--, ++++-++
   19 |      8 | -++++++-
   39 |     12 | +++++++++---
   40 |     13 | +++++++++---+, ++++++++-+++-
   45 |      9 | +++++++++
   97 |     20 | ++++++++++++++--+---, +++++++++++++-++++--, ++++++++++++-++++++-
  361 |     34 | ++++++++++++++++++++++++++-+++-+++
</code>```

Extra resources

Proof that any number can be made: basically, by repeating ++-, you can obtain any even number. To obtain the odd numbers, just put a + at the end.

Another general way to obtain any number. For example, to generate 50, a way is to press + 50 times, and then press - 49 times.

Solution of the first 50 numbers.

Obligatory JSFiddle.

Scoring

This is code-golf. Shortest solution in bytes wins.

答:
Python, <s>105</s> 100 bytes

Uses an inefficient breadth-first search.

```<code>def k(n):
 m=t=l=0;h=[]
 while m-n:o=1-2*(t>0);(m,t,l),*h=h+[(m+t-o,t-o,l+1),(m+o,o,l+1)]
 return l
</code>```

h is a list used as a queue

m is the value of the sequence at the head of the list

t is the last number added to m

l is the length of the sequence that generated m

o is +/-1, the sign is opposite the sign of t

Edit: Leaky Nun shaved five bytes.

Body:
Python, <s>105</s> 100 bytes

Uses an inefficient breadth-first search.

def k(n):
 m=t=l=0;h=[]
 while m-n:o=1-2*(t>0);(m,t,l),*h=h+[(m+t-o,t-o,l+1),(m+o,o,l+1)]
 return l

h is a list used as a queue

m is the value of the sequence at the head of the list

t is the last number added to m

l is the length of the sequence that generated m

o is +/-1, the sign is opposite the sign of t

Edit: Leaky Nun shaved five bytes.


答:
Batch, 167 bytes

```<code>@echo off
set h=11
set p=a
for /l %%a in (0,1,23)do call:e %%a
exit/b
:e
set a=0%1
set/ah=h%%12+1
set h= %h%
if %1==12 set p=p
echo %a:~-2:00 %h:~-2%:00%p%m
</code>```

Title: 24 and 12 Hour Times

Body:
Batch, 167 bytes

@echo off
set h=11
set p=a
for /l %%a in (0,1,23)do call:e %%a
exit/b
:e
set a=0%1
set/ah=h%%12+1
set h= %h%
if %1==12 set p=p
echo %a:~-2:00 %h:~-2%:00%p%m


答:
TSQL(SQLServer 2012) <s>146</s> <s>124</s> 121

```<code>DECLARE @ DATETIME=0WHILE @<1BEGIN PRINT
CONVERT(char(5),@,108)+' '+LOWER(RIGHT(FORMAT(@,'g'),8))SET @=dateadd(hh,1,@)END
</code>```

Try it online!

First attempt, a bit longer, but a one-liner:

```<code>SELECT CONVERT(char(5),n,108)+' '+LOWER(RIGHT(FORMAT(n,'g'),8))FROM(SELECT
top 24 dateadd(hh,Number,0)n FROM master..spt_values WHERE'P'=type)x
</code>```

Try it online!

Title: 24 and 12 Hour Times

Body:
TSQL(SQLServer 2012) <s>146</s> <s>124</s> 121

DECLARE @ DATETIME=0WHILE @<1BEGIN PRINT
CONVERT(char(5),@,108)+' '+LOWER(RIGHT(FORMAT(@,'g'),8))SET @=dateadd(hh,1,@)END

Try it online!

First attempt, a bit longer, but a one-liner:

SELECT CONVERT(char(5),n,108)+' '+LOWER(RIGHT(FORMAT(n,'g'),8))FROM(SELECT
top 24 dateadd(hh,Number,0)n FROM master..spt_values WHERE'P'=type)x

Try it online!


答:
mIRC 7.49 <s>20</s> 16 Bytes

```<code>/timer 0 1 $time
</code>```

Title: Output the Current Time

Body:
Challenge

You must output the current time continuously (until cancelled by an interrupt), once every second, by any of the following means:

It must be in 24-hour or AM/PM format.

If it is the former, it must be spaced out with colons (i.e. 15:47:36).

If it is the latter, it must be spaced out with colons and have the AM/PM following (i.e. 3:47:36 PM)

It may be pulled from the internet.

It may be the system time.

It must output any naturally accessible form of output which supports text that you choose.

Output may have extra information aside of the time in it, but you must guarantee one, and only one, output of time per second.

The continuous output must be a second apart - if you choose to wait until the second changes between outputs, that is fine. If you wait a second between each output, that is perfectly acceptable, despite the eventual loss of accuracy.

Since this is a catalog, languages created after this challenge are allowed to compete. 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. Other than that, all the standard rules of code-golf must be obeyed. Submissions in most languages will be scored in bytes in an appropriate preexisting encoding (usually UTF-8).

Catalog

The Stack Snippet at the bottom of this post generates the catalog 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>```

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
mIRC 7.49 <s>20</s> 16 Bytes

/timer 0 1 $time


问:
Separate alphabets and numbers
A paragraph of text has numbers and alphabetic letters mixed. Your task is to separate the numbers to the left side and the alphabetic letters to the right side in the same order of each line.

Rules:

Numbers are plain integers; so no decimal point, and no negative/positive signs.

Numbers may or may not be contiguous, but whatever the case may be, they have to be pushed to left side in the same order.

Numbers may occur in between words.

The text contains only ASCII alphabetic letters and numbers, along with spaces, underscores, commas and dots.

The one who does this with minimum keystrokes (like vim macros) or least amount of bytes in case of scripting is the winner.

Example Text:

```<code>A word can have any number of text like 433884,
but all the numb89ers has to be moved left side
but alph6abetical va9lues has to be pas46ted on right side.
The text might con4tain chara29cters s2huffled like hlep or dfeintino or even
meaningless1 words co43mbined togeth81er.
</code>```

Expected output:

```<code>433884A word can have any number of text like ,
89but all the numbers has to be moved left side
6946but alphabetical values has to be pasted on right side.
4292The text might contain characters shuffled like hlep or dfeintino or even
14381meaningless words combined together.
</code>```

答:
Oracle SQL 11.2, 131 bytes

The lines in the input string are separated by '¤'.
That way it is not necessary to create a table to use as the input.

A word can have any number of text like 433884,¤but all the numb89ers has to be moved left side ¤but alph6abetical va9lues has to be pas46ted on right side.¤The text might con4tain chara29cters s2huffled like hlep or dfeintino or even¤meaningless1 words co43mbined togeth81er.
```

<p>Query :</p>

<pre class="lang-sql prettyprint-override"><code>SELECT REGEXP_REPLACE(COLUMN_VALUE,'[^0-9]')||REGEXP_REPLACE(COLUMN_VALUE,'[0-9]')FROM XMLTABLE(('"'||REPLACE(:1,'¤','","')||'"'));
</code>```

Un-golfed

SELECT REGEXP_REPLACE(COLUMN_VALUE,'[^0-9]')||  -- Every number
       REGEXP_REPLACE(COLUMN_VALUE,'[0-9]')     -- Every character not a number
FROM   XMLTABLE(('"'||REPLACE(:1,'¤','","')||'"'))  -- Split on ¤
```

Title: Separate alphabets and numbers

Body:
Oracle SQL 11.2, 131 bytes

The lines in the input string are separated by '¤'.
That way it is not necessary to create a table to use as the input.

A word can have any number of text like 433884,¤but all the numb89ers has to be moved left side ¤but alph6abetical va9lues has to be pas46ted on right side.¤The text might con4tain chara29cters s2huffled like hlep or dfeintino or even¤meaningless1 words co43mbined togeth81er.

Query :

SELECT REGEXP_REPLACE(COLUMN_VALUE,'[^0-9]')||REGEXP_REPLACE(COLUMN_VALUE,'[0-9]')FROM XMLTABLE(('"'||REPLACE(:1,'¤','","')||'"'));

Un-golfed

SELECT REGEXP_REPLACE(COLUMN_VALUE,'[^0-9]')||  -- Every number
       REGEXP_REPLACE(COLUMN_VALUE,'[0-9]')     -- Every character not a number
FROM   XMLTABLE(('"'||REPLACE(:1,'¤','","')||'"'))  -- Split on ¤


答:
JavaScript (ES2015), 147 138 137 134 133 bytes

```<code>((o,x,r)=>{for(i=0;i<24;)b=i%12,c=b||12,o+='0'[r](i<10)+i+++x+' '[r]((c<10)+1)+c+x+(i<13?'a':'p')+"m\n";return o})('',':00','repeat')
</code>```

In this version I took advantage of String.repeat() method to get rid of lengthy .slice() and .join() and moved incrementation inside loop.

Previous version:

```<code>((o,x,i)=>{for(;i<24;i++){b=i%12;o+=[`0${i+x}`.slice(-5),(b||12)+x+(i<12?'a':'p')+'m'].join(' '.repeat((b>0&&b<10)+1))+"\n"}return o})('',':00',0)
</code>```

Gives output with trailing newline. Tested in Firefox Scratchpad. Not sure if passing arguments to IIFE is OK with "no input" rule.

It's my first submission, so hello to everyone! :)

Title: 24 and 12 Hour Times

Body:
JavaScript (ES2015), 147 138 137 134 133 bytes

((o,x,r)=>{for(i=0;i<24;)b=i%12,c=b||12,o+='0'[r](i<10)+i+++x+' '[r]((c<10)+1)+c+x+(i<13?'a':'p')+"m\n";return o})('',':00','repeat')

In this version I took advantage of String.repeat() method to get rid of lengthy .slice() and .join() and moved incrementation inside loop.

Previous version:

((o,x,i)=>{for(;i<24;i++){b=i%12;o+=[`0${i+x}`.slice(-5),(b||12)+x+(i<12?'a':'p')+'m'].join(' '.repeat((b>0&&b<10)+1))+"\n"}return o})('',':00',0)

Gives output with trailing newline. Tested in Firefox Scratchpad. Not sure if passing arguments to IIFE is OK with "no input" rule.

It's my first submission, so hello to everyone! :)


答:
Lua, 51 Bytes

Since the previous owner of this answer in 56 Bytes doesn't update anymore when suggested improvments, here's a 51 Bytes solution heavily based on his:

v=1::a::v=os.date'%c'l=v~=l and print(v)or v goto a
```

Title: Output the Current Time


答:
Mathematica, 129 Bytes

Golfed:

```<code>t=InputString[];s=Append[StringCases[t,LetterCharacter],t];Grid[Prepend[Map[If[#,"T","F"]&,BooleanTable[ToExpression[s]],{2}],s]]
</code>```

Ungolfed:

```<code>(*Take input*)
t=InputString[];
(* Find all occurrences of letters and append the final statement.*)
s=Append[StringCases[t,LetterCharacter],t];
(* Evaluate the list as expressions and create a boolean table of True/False values, then display as a table. *)
(* To satisfy the output conditions, we must convert each True/False to T/F *)
Grid[Prepend[Map[If[#,"T","F"]&,BooleanTable[ToExpression[s]],{2}],s]]
</code>```

Not a Mathematica expert, but I found this rather elegant compared to having to do direct character comparison.

I had a solution that worked for negation, but it was longer than the score reduction would take off.

Depending on what qualifies for pretty printing, I might try for that bonus. I feel like outputting in ASCII in Mathematica would be far too expensive for the score reduction to compensate, but if the two main features are a dotted border and specified padding inside the cells, that's only a couple options in Grid.

With pretty printing, 171 * 0.6 = 102.6 Bytes

```<code>t=InputString[];s=Append[StringCases[t,LetterCharacter],t];Grid[Prepend[Map[If[#,"T","F"]&,BooleanTable[ToExpression[s]],{2}],s],Spacings->1,Frame->All,FrameStyle->Dashed]
</code>```

Body:
Mathematica, 129 Bytes

Golfed:

t=InputString[];s=Append[StringCases[t,LetterCharacter],t];Grid[Prepend[Map[If[#,"T","F"]&,BooleanTable[ToExpression[s]],{2}],s]]

Ungolfed:

(*Take input*)
t=InputString[];
(* Find all occurrences of letters and append the final statement.*)
s=Append[StringCases[t,LetterCharacter],t];
(* Evaluate the list as expressions and create a boolean table of True/False values, then display as a table. *)
(* To satisfy the output conditions, we must convert each True/False to T/F *)
Grid[Prepend[Map[If[#,"T","F"]&,BooleanTable[ToExpression[s]],{2}],s]]

Not a Mathematica expert, but I found this rather elegant compared to having to do direct character comparison.

I had a solution that worked for negation, but it was longer than the score reduction would take off.

Depending on what qualifies for pretty printing, I might try for that bonus. I feel like outputting in ASCII in Mathematica would be far too expensive for the score reduction to compensate, but if the two main features are a dotted border and specified padding inside the cells, that's only a couple options in Grid.

With pretty printing, 171 * 0.6 = 102.6 Bytes

t=InputString[];s=Append[StringCases[t,LetterCharacter],t];Grid[Prepend[Map[If[#,"T","F"]&,BooleanTable[ToExpression[s]],{2}],s],Spacings->1,Frame->All,FrameStyle->Dashed]


Title: 24 and 12 Hour Times

Body:
Write a program or function with no input that prints or returns this string of 24-hour and 12-hour times:

```<code>00:00 12:00am
01:00  1:00am
02:00  2:00am
03:00  3:00am
04:00  4:00am
05:00  5:00am
06:00  6:00am
07:00  7:00am
08:00  8:00am
09:00  9:00am
10:00 10:00am
11:00 11:00am
12:00 12:00pm
13:00  1:00pm
14:00  2:00pm
15:00  3:00pm
16:00  4:00pm
17:00  5:00pm
18:00  6:00pm
19:00  7:00pm
20:00  8:00pm
21:00  9:00pm
22:00 10:00pm
23:00 11:00pm
</code>```

The string must be output exactly as it appears here. The only exception is that it may optionally have a single trailing newline.

So the MD5 hash of your output should be

```<code>827ae6e2dbb1df494930baedb3ee2653
</code>```

if you do not have a trailing newline and

```<code>cd4c3d18abee9bafb495f390a919a13f
</code>```

if you do. (Your hash could be different if your system uses another type of newline but that's OK.)

The shortest code in bytes wins. Tiebreaker is earlier answer.

Body:
MarioLANG, <s>965</s> 834 bytes

<a href="http://mariolang.tryitonline.net/#code=Kys8PikgKysrQCsrKys-ICAgWyEpID4pPigoKCg6OiguKTo6KCguKSkrOis6LS0oLik6OikpLikuKS4pKysrKysrKysrCisrIiIrICsiPT09PT0iIj09PT0jKSAiKyI9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorKyspKyArPj4rKysrKy0gPCs8KS0-KysrICFbLSkuKS4pLikpKDo6KSkuKDooOikpKS4uKCgoOjopKS4oOisoOigoKCg8Cis-KysrICsrIj09PT08KCAiKSIpLSIhKysrIz09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSIKKygrKys-KyshKyspPCsoICsrKystKysrKys-CiAtKSkrKT0oIz09PSIrKCArKysrKSsrKysrIj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSEKIFshISstWyEoKysrISEhICErITwrISsrIT4oKCgoKCs6KC4pKTo6KCgoLgo9PSMjPT09Iz09PT0jIyM9Iz0jIj0jIz0jIj09PT09PT09PT09PT09PT09PAorKysrKSkpKysrKysrKysrKysrKysrKCgoIVstKS4pLikuKTo6KSkuKDopKSAgID4KPj09PT09PT09PT09PT09PT09PT09PT09PSM9PT09PT09PT09PT09PT09PT0gICAiCis-KyA-CisiKyAiPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09WyAgID09PT09PT09PT09PT09PT09PT09PSM9PT09PT09PT09PT09PT1bCishPiAhIC0pLikuKS4pKSg6OikpLikpOisoLi4oKCg6OikpLig6KygoKCgoPCsrIS0pLikuKS4pKSg6OikpLikpOisoLigoKDo6KSkuKDorKCgoKCg8Cj0jPT0jPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ij09Iz09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09&input=" rel="nofollow">Try it online

well this was ridiculously complicated.

Technically the output is valid but in practice the Tio for MarioLANG output "n " instead of "n" when we print a number with ':'

if I find the time i'll guess i'll try to do a (probably much longer) version of the program that output correctly on Tio

++<>) +++@++++>   [!) >)>((((::(.)::((.))+:+:--(.)::)).).).)+++++++++
++""+ +"=====""====#) "+"============================================
+++)+ +>>+++++- <+<)->+++ ![-).).).))(::)).(:(:)))..(((::)).(:+(:((((<
+>+++ ++"====<( ")")-"!+++#=========================================="
+(+++>++!++)<+( ++++-+++++>
 -))+)=(#==="+( ++++)+++++"==========================================!
 [!!+-[!(+++!!! !+!<+!++!>(((((+:(.))::(((.
==##===#====###=#=#"=##=#"=================<
++++)))+++++++++++++++(((![-).).).)::)).(:))   >
>========================#==================   "
+>+ >
+"+ "=======================================[   =====================#===============[
+!> ! -).).).))(::)).)):+(..(((::)).(:+(((((<++!-).).).))(::)).)):+(.(((::)).(:+(((((<
=#==#======================================="==#======================================

Explanation :

our main problem here is the fact that we have 6 NaN char (newLine, Space, :, a, p, m)

in marioLANG, in order to print character, we need their ascii value:

newLine is 10

Space is 32

: is 58

a is 97

p is 112

m is 109

So the first thing to do is to set the memory :

++<>) +++@++++>   [!) >)> !
++""+ +"=====""====#) "+"==
+++)+ +>>+++++- <+<)->+++
+>+++ ++"====<( ")")-"!+++
+(+++>++!++)<+( ++++-+++++
 -))+)=(#==="+( ++++)+++++
 [!!+-[!(+++!!! !+!<+!++!>
==##===#====###=#=#"=##=#"

with this, the memory look like :

                   v
  32 58 0 0 97 109 10 0
  _  :      a   m  \n

we will transform a into p during the rest of the program

then we do the actual output :

++<>) +++@++++>   [!) >)>((((::(.)::((.))+:+:--(.)::)).).).)+++++++++
++""+ +"=====""====#) "+"============================================
+++)+ +>>+++++- <+<)->+++ ![-).).).))(::)).(:(:)))..(((::)).(:+(:((((<
+>+++ ++"====<( ")")-"!+++#=========================================="
+(+++>++!++)<+( ++++-+++++>
 -))+)=(#==="+( ++++)+++++"==========================================!
 [!!+-[!(+++!!! !+!<+!++!>(((((+:(.))::(((.
==##===#====###=#=#"=##=#"=================<
++++)))+++++++++++++++(((![-).).).)::)).(:))   >
>========================#==================   "
+>+ >
+"+ "=======================================[   =====================#===============[
+!> ! -).).).))(::)).)):+(..(((::)).(:+(((((<++!-).).).))(::)).)):+(.(((::)).(:+(((((<
=#==#======================================="==#======================================


问:
Case Permutation
Who needs to compare things case insensitively when you're able to generate every permutation of uppercase and lowercase? No one! That's the answer. No one does. Your task is to achieve this feat; generate all possible permutations of uppercase/lowercase for a given input.

Input

A string of printable standard ascii characters. Input should not be assumed to be all lowercase. Input will always be at least one character.

Output

Every permutation of uppercase and lowercase for the inputted string (no duplicates). This should only change characters with a small and large version (numbers will stay the same). Each permutation must be output as a string or a list of characters; lists of singleton strings are not allowed.

Examples

```<code>a1a
['a1a', 'a1A', 'A1a', 'A1A']

abc
['abc', 'abC', 'aBc', 'aBC', 'Abc', 'AbC', 'ABc', 'ABC']

Hi!
['hi!', 'hI!', 'Hi!', 'HI!']
</code>```

Scoring

This is code-golf, so the shortest answer (in bytes) wins.

As a fun extra see how much additional effort it will take to handle the extended ascii characters, here is an extra test case:

```<code>ž1a -> ['ž1a', 'ž1A', 'Ž1a', 'Ž1A']
</code>```

(your program does not need to support this)

答:
Pyth, 13 12 11

```<code>{msrVQd^U2l
</code>```

1 byte thanks to Leaky Nun!

Another byte thanks to Jakube!

Try it here or run a Test Suite

We create a list of lists True/False values by taking the cartesian product of the list [0, 1] with itself a number of times equal to the length of the input string. So each of the sublists has the same length as the input string. Then we apply the r function as a vector operation over the input and the list, so we get r letter value for each sub element. r with second argument zero is to lowercase and with one it is to upper case. This creates duplicates on non-letters, which means we need to remove duplicates from the result.

Title: Case Permutation

Body:
Pyth, 13 12 11

{msrVQd^U2l

1 byte thanks to Leaky Nun!

Another byte thanks to Jakube!

Try it here or run a Test Suite

We create a list of lists True/False values by taking the cartesian product of the list [0, 1] with itself a number of times equal to the length of the input string. So each of the sublists has the same length as the input string. Then we apply the r function as a vector operation over the input and the list, so we get r letter value for each sub element. r with second argument zero is to lowercase and with one it is to upper case. This creates duplicates on non-letters, which means we need to remove duplicates from the result.


答:
PowerShell v2+, 76 bytes

```<code>0..23|%{"{0:D2}:00{1,3}:00"-f$_,(($_%12),12)[!($_%12)]+('am','pm')[$_-ge12]}
</code>```

Loops from 0..23 and each loop sets a string with the -f operator. The first {0:D2} ensures we have prepended zeros, the second {1,3} ensures we have padded spaces for the middle column. The {0} one corresponds to the $_ of the -f operator, while the {1} corresponds to the pseudo-ternary that chooses between $_%12 or 12 based on whether $_%12 is non-zero or not (i.e., if we're at $_=13, this will choose 1 for 1:00pm). We then concatenate that with another pseudo-ternary that chooses the appropriate am/pm.

As opposed to my answer on List all times in the day at a half hour rate, it's actually shorter here to brute-force the numbers since we get significantly cheaper padding. Here's the answer using date functions, at 78 bytes

```<code>0..23|%{(Date -h $_ -f 'HH:00')+(Date -h $_ -f "h:00tt").ToLower().PadLeft(8)}
</code>```

Title: 24 and 12 Hour Times

Body:
PowerShell v2+, 76 bytes

0..23|%{"{0:D2}:00{1,3}:00"-f$_,(($_%12),12)[!($_%12)]+('am','pm')[$_-ge12]}

Loops from 0..23 and each loop sets a string with the -f operator. The first {0:D2} ensures we have prepended zeros, the second {1,3} ensures we have padded spaces for the middle column. The {0} one corresponds to the $_ of the -f operator, while the {1} corresponds to the pseudo-ternary that chooses between $_%12 or 12 based on whether $_%12 is non-zero or not (i.e., if we're at $_=13, this will choose 1 for 1:00pm). We then concatenate that with another pseudo-ternary that chooses the appropriate am/pm.

As opposed to my answer on List all times in the day at a half hour rate, it's actually shorter here to brute-force the numbers since we get significantly cheaper padding. Here's the answer using date functions, at 78 bytes

0..23|%{(Date -h $_ -f 'HH:00')+(Date -h $_ -f "h:00tt").ToLower().PadLeft(8)}


答:
MATL, 13 bytes

```<code>tYov!Z}N$Z*Xu
</code>```

Try it online!

Explanation

```<code>t       % Implicit input string. Duplicate
Yo      % Change case of string
v       % Concatenate as a 2xN char array, where N is input length
!       % Transpose: Nx2 char array. Each row has different case, if letter
Z}      % Split into rows: gives N strings of 2 chars. Each char has different
        % case if it's a letter, or is repeated otherwise
N$      % Specify N inputs for next function
Z*      % Cartesian product of the N strings. Each combination is a row.
        % Repeated chars (i.e. non-letters) give rise to duplicate rows.
Xu      % Remove duplicate rows. Implicit display
</code>```

Title: Case Permutation

Body:
Who needs to compare things case insensitively when you're able to generate every permutation of uppercase and lowercase? No one! That's the answer. No one does. Your task is to achieve this feat; generate all possible permutations of uppercase/lowercase for a given input.

Input

A string of printable standard ascii characters. Input should not be assumed to be all lowercase. Input will always be at least one character.

Output

Every permutation of uppercase and lowercase for the inputted string (no duplicates). This should only change characters with a small and large version (numbers will stay the same). Each permutation must be output as a string or a list of characters; lists of singleton strings are not allowed.

Examples

```<code>a1a
['a1a', 'a1A', 'A1a', 'A1A']

abc
['abc', 'abC', 'aBc', 'aBC', 'Abc', 'AbC', 'ABc', 'ABC']

Hi!
['hi!', 'hI!', 'Hi!', 'HI!']
</code>```

Scoring

This is code-golf, so the shortest answer (in bytes) wins.

As a fun extra see how much additional effort it will take to handle the extended ascii characters, here is an extra test case:

```<code>ž1a -> ['ž1a', 'ž1A', 'Ž1a', 'Ž1A']
</code>```

(your program does not need to support this)

Body:
MATL, 13 bytes

tYov!Z}N$Z*Xu

Try it online!

Explanation

t       % Implicit input string. Duplicate
Yo      % Change case of string
v       % Concatenate as a 2xN char array, where N is input length
!       % Transpose: Nx2 char array. Each row has different case, if letter
Z}      % Split into rows: gives N strings of 2 chars. Each char has different
        % case if it's a letter, or is repeated otherwise
N$      % Specify N inputs for next function
Z*      % Cartesian product of the N strings. Each combination is a row.
        % Repeated chars (i.e. non-letters) give rise to duplicate rows.
Xu      % Remove duplicate rows. Implicit display


问:
Reimplementing square root
Define a function, s, which takes a number and returns the square root.

No use of library functions, such as Java's Math.sqrt() or PHP's built in sqrt(), allowed.

答:
Python - 41 chars

Takes a while to run for large numbers :)

```<code>n=input()
i=0
while i*i<n:i+=1e-9
print i
</code>```

ContentLicense: CC BY-SA 2.5

Title: Reimplementing square root

Body:
Python - 41 chars

Takes a while to run for large numbers :)

n=input()
i=0
while i*i<n:i+=1e-9
print i


问:
Print NxN spiral of ascending numbers
The numbers should be printed with leading zeroes in a field with length = (number of digits of N^2).

Input (N):

```<code>4
</code>```

Output:

```<code>01 12 11 10
02 13 16 09
03 14 15 08
04 05 06 07
</code>```

I am interested in the algorithm and the cleanliness of the implementation.
So, the white space does not count and the upper limit for N is 42.

Title: Print NxN spiral of ascending numbers

Body:
C

#include<stdio.h>
#include<math.h>

int main() {
    int A[42][42],i,j,N,c=1,k;
    scanf("%d",&N);
    for (i = 0, j = N - 1 ; j >= 0 ; i++, j--) {
            for(k = i ; k < j; k++)A[i][k]=c++;
            for(k = i ; k < j; k++)A[k][j]=c++;
            for(k = j ; k > i; k--)A[j][k]=c++;
            for(k = j ; k > i; k--)A[k][i]=c++;
    }
    if (N%2)
       A[N/2][N/2]=c;
    for (i=0;i<N;i++) {
        for (j=0;j<N;j++)
            printf("%0*d ",((int)log10(N*N)+1),A[j][i]);
        printf("\n");
    }
}


问:
Regex for Finding Radioactive Elements
Find the shortest regex that matches all radioactive elements and nothing else in the Periodic Table of Elements.

Radioactive Elements

```<code>'Technetium','Promethium','Polonium','Astatine','Radon','Francium','Radium','Actinium','Thorium','Protactinium','Uranium','Neptunium','Plutonium','Americium','Curium','Berkelium','Californium','Einsteinium','Fermium','Mendelevium','Nobelium','Lawrencium','Rutherfordium','Dubnium','Seaborgium','Bohrium','Hassium','Meitnerium','Darmstadtium','Roentgenium','Copernicium','Ununtrium','Flerovium','Ununpentium','Livermorium','Ununseptium','Ununoctium'
</code>```

Non-radioactive Elements

```<code>'Hydrogen','Helium','Lithium','Beryllium','Boron','Carbon','Nitrogen','Oxygen','Fluorine','Neon','Sodium','Magnesium','Aluminium','Silicon','Phosphorus','Sulphur','Chlorine','Argon','Potassium','Calcium','Scandium','Titanium','Vanadium','Chromium','Manganese','Iron','Cobalt','Nickel','Copper','Zinc','Gallium','Germanium','Arsenic','Selenium','Bromine','Krypton','Rubidium','Strontium','Yttrium','Zirconium','Niobium','Molybdenum','Ruthenium','Rhodium','Palladium','Silver','Cadmium','Indium','Tin','Antimony','Tellurium','Iodine','Xenon','Caesium','Barium','Lanthanum','Cerium','Praseodymium','Neodymium','Samarium','Europium','Gadolinium','Terbium','Dysprosium','Holmium','Erbium','Thulium','Ytterbium','Lutetium','Hafnium','Tantalum','Tungsten','Rhenium','Osmium','Iridium','Platinum','Gold','Mercury','Thallium','Lead','Bismuth'
</code>```

Scored by character count in the regex.

Use standard Perl regex (just no specialized functions).

Assume all lower case.

You only need to count the characters of the regex itself.

Note if you used a program to get you started and maybe post how well it did. I'll post my best attempt as an answer to get started/show an example.

答:
Char count 59

```<code>e.+[hktv]|oh?r.+m|p...?o|r.*ci|be?.i|^c?u|rad|sta|has|ct|fe
</code>```

Found via a mix of manually selecting good parts and running Peter Norvig's golfer on the remaining items.

Regex101 link

Title: Regex for Finding Radioactive Elements

Body:
Char count 59

e.+[hktv]|oh?r.+m|p...?o|r.*ci|be?.i|^c?u|rad|sta|has|ct|fe

Found via a mix of manually selecting good parts and running Peter Norvig's golfer on the remaining items.

Regex101 link


答:
05AB1E, 17 bytes

Code:

```<code>vyDš‚N0Êiâvy˜J})Ù
</code>```

Explained:

```<code>vy                     # for each character in input
  Dš‚                  # create a pair of different case, eg: ['ž', 'Ž']
     N0Êiâ             # for all pairs but the first, take cartesian product
                         result will be a list of layered lists eg: [['ž', '1'], 'a']
            vy         # for each such list
              ˜J}      # deep flatten and join as a string eg: ž1a
                 )Ù    # wrap in array and remove duplicates
</code>```

Try it online

Title: Case Permutation

Body:
05AB1E, 17 bytes

Code:

vyDš‚N0Êiâvy˜J})Ù

Explained:

vy                     # for each character in input
  Dš‚                  # create a pair of different case, eg: ['ž', 'Ž']
     N0Êiâ             # for all pairs but the first, take cartesian product
                         result will be a list of layered lists eg: [['ž', '1'], 'a']
            vy         # for each such list
              ˜J}      # deep flatten and join as a string eg: ž1a
                 )Ù    # wrap in array and remove duplicates

Try it online


答:
Brachylog, <s>25</s> 22 bytes

```<code>:ef:1fd.
:2ac.
@u.|@l.
</code>```

This works as well as the lowercase/uppercase predicates of Prolog, therefore it works on non-ASCII letters too:

```<code>?- run("ž1a",Z).
Z = ["Ž1A", "Ž1a", "ž1A", "ž1a"] .
</code>```

Explanation

Unlike all other answers as of the moment I'm posting this, this does not use the cartesian product approach at all.

Main Predicate

```<code>:ef       Split the Input string into a list of 1-char strings
   :1f    Find all valid outputs of predicate 1 with the previous list
          of outputs as input
      d.  Unify the Output with that list excluding all duplicates
</code>```

Predicate 1

This is used to apply uppercasing or lowercasing on each char of the input, thus computing one possible permutation. Using findall on this predicate in the main predicate allows to compute all possible permutations (with some duplicates).

```<code>    :2a       Apply predicate 2 on the each element of the Input
       c.     Unify the Output with the concatenation of the elements of
              the previous list
</code>```

Predicate 2

This is used to turn a character of the string into either its uppercase or its lowercase version.

```<code>    @u.       Unify the Output with the uppercase version of the Input
       |      Or
        @l.   Unify the Output with the lowercase version of the input
</code>```

Title: Case Permutation

Body:
Brachylog, <s>25</s> 22 bytes

:ef:1fd.
:2ac.
@u.|@l.

This works as well as the lowercase/uppercase predicates of Prolog, therefore it works on non-ASCII letters too:

?- run("ž1a",Z).
Z = ["Ž1A", "Ž1a", "ž1A", "ž1a"] .

Explanation

Unlike all other answers as of the moment I'm posting this, this does not use the cartesian product approach at all.

Main Predicate

:ef       Split the Input string into a list of 1-char strings
   :1f    Find all valid outputs of predicate 1 with the previous list
          of outputs as input
      d.  Unify the Output with that list excluding all duplicates

Predicate 1

This is used to apply uppercasing or lowercasing on each char of the input, thus computing one possible permutation. Using findall on this predicate in the main predicate allows to compute all possible permutations (with some duplicates).

    :2a       Apply predicate 2 on the each element of the Input
       c.     Unify the Output with the concatenation of the elements of
              the previous list

Predicate 2

This is used to turn a character of the string into either its uppercase or its lowercase version.

    @u.       Unify the Output with the uppercase version of the Input
       |      Or
        @l.   Unify the Output with the lowercase version of the input


答:
Hoon, 242 bytes

```<code>|=
t/tape
=+
l=(reap (pow 2 (lent t)) t)
%+
roll
(gulf 0 (dec (lent l)))
|=
{a/@ b/(set tape)}
=+
%+
turn
(gulf 0 (dec (lent t)))
|=
n/@
=+
t=(snag n t)
=+
k=(trip t)
?:
=(0 (cut 0 n^1 a))
?:
=((cuss k) t)
(cass k)
(cuss k)
t
(~(put in b) -)
</code>```

Ungolfed:

```<code>|=  t/tape
=+  l=(reap (pow 2 (lent t)) t)
%+  roll  (gulf 0 (dec (lent l)))
|=  {a/@ b/(set tape)}
    =+  %+  turn  (gulf 0 (dec (lent t)))
      |=  n/@
      =+  t=(snag n t)
      =+  k=(trip t)
      ?:  =(0 (cut 0 n^1 a))
        ?:  =((cuss k) t)
              (cass k)
        (cuss k)
      t
    (~(put in b) -)
</code>```

I'm not sure how much smaller this could be, unfortunately.

First, we set l equal to a list with 2^(length t) repetitions of t. Hoon doesn't have a fac function in the stdlib, but 2^n is always bigger than n!, so we simply map over the bigger list and use a set (hashmap) to de-duplicate entries.

We then fold over the list [0..(length l)], accumulating into a (set tape). We need to do this instead of mapping over l directly because we also need to know what number repetition it is (a), but can't simply increment an accumulator due to Hoon being a pure language.

We map over [0..(length t)] (again so we have the current index), setting t to the nth character in the string, checking if the nth bye of a and inverting the case (cuss or cass, depending if it changes or not). The return type of this map is a tape.

We then put the string into our hashmap, and return the hashmap of all the strings.

Title: Case Permutation

Body:
Hoon, 242 bytes

|=
t/tape
=+
l=(reap (pow 2 (lent t)) t)
%+
roll
(gulf 0 (dec (lent l)))
|=
{a/@ b/(set tape)}
=+
%+
turn
(gulf 0 (dec (lent t)))
|=
n/@
=+
t=(snag n t)
=+
k=(trip t)
?:
=(0 (cut 0 n^1 a))
?:
=((cuss k) t)
(cass k)
(cuss k)
t
(~(put in b) -)

Ungolfed:

|=  t/tape
=+  l=(reap (pow 2 (lent t)) t)
%+  roll  (gulf 0 (dec (lent l)))
|=  {a/@ b/(set tape)}
    =+  %+  turn  (gulf 0 (dec (lent t)))
      |=  n/@
      =+  t=(snag n t)
      =+  k=(trip t)
      ?:  =(0 (cut 0 n^1 a))
        ?:  =((cuss k) t)
              (cass k)
        (cuss k)
      t
    (~(put in b) -)

I'm not sure how much smaller this could be, unfortunately.

First, we set l equal to a list with 2^(length t) repetitions of t. Hoon doesn't have a fac function in the stdlib, but 2^n is always bigger than n!, so we simply map over the bigger list and use a set (hashmap) to de-duplicate entries.

We then fold over the list [0..(length l)], accumulating into a (set tape). We need to do this instead of mapping over l directly because we also need to know what number repetition it is (a), but can't simply increment an accumulator due to Hoon being a pure language.

We map over [0..(length t)] (again so we have the current index), setting t to the nth character in the string, checking if the nth bye of a and inverting the case (cuss or cass, depending if it changes or not). The return type of this map is a tape.

We then put the string into our hashmap, and return the hashmap of all the strings.


Title: 24 and 12 Hour Times

Body:
///, 160 bytes

/Z/:00 //S/Z //A/:00am
//P/:00pm
/00Z12A01S1A02S2A03S3A04S4A05S5A06S6A07S7A08S8A09S9A10Z10A11Z11A12Z12P13S1P14S2P15S3P16S4P17S5P18S6P19S7P20S8P21S9P22Z10P23Z11P

Try it online!

Ungolfed

00:00 12:00am
01:00  1:00am
02:00  2:00am
03:00  3:00am
04:00  4:00am
05:00  5:00am
06:00  6:00am
07:00  7:00am
08:00  8:00am
09:00  9:00am
10:00 10:00am
11:00 11:00am
12:00 12:00pm
13:00  1:00pm
14:00  2:00pm
15:00  3:00pm
16:00  4:00pm
17:00  5:00pm
18:00  6:00pm
19:00  7:00pm
20:00  8:00pm
21:00  9:00pm
22:00 10:00pm
23:00 11:00pm


答:
Jelly, 6 bytes

```<code>żŒsŒpQ
</code>```

This is a monadic link (function) that expects a string as left argument and returns a list of strings.

Handles non-ASCII characters. Try it online!

How it works

```<code>żŒsŒpQ  Monadic link. Argument: s (string)

 Œs     Swapcase; change the case of all letters in s.
ż       Zipwith; pair each character with itself with changed case.
   Œp   Take the Cartesian product of all pairs.
     Q  Unique; deduplicate the Cartesian product.
</code>```

Title: Case Permutation

Body:
Jelly, 6 bytes

żŒsŒpQ

This is a monadic link (function) that expects a string as left argument and returns a list of strings.

Handles non-ASCII characters. Try it online!

How it works

żŒsŒpQ  Monadic link. Argument: s (string)

 Œs     Swapcase; change the case of all letters in s.
ż       Zipwith; pair each character with itself with changed case.
   Œp   Take the Cartesian product of all pairs.
     Q  Unique; deduplicate the Cartesian product.


Title: 24 and 12 Hour Times

Body:
Javascript, 122 Bytes, 120 Bytes

f=j=>j>12?j-12:j;for(i=0;i<24;i++)console.log('%s:00 %s:00%s',i<10?'0'+i:i,i==0?12:f(i)<10?' '+f(i):f(i),i>11?'pm':'am')

Edit: Small bug fixed + output:

00:00 12:00am
01:00  1:00am
02:00  2:00am
03:00  3:00am
04:00  4:00am
05:00  5:00am
06:00  6:00am
07:00  7:00am
08:00  8:00am
09:00  9:00am
10:00 10:00am
11:00 11:00am
12:00 12:00pm
13:00  1:00pm
14:00  2:00pm
15:00  3:00pm
16:00  4:00pm
17:00  5:00pm
18:00  6:00pm
19:00  7:00pm
20:00  8:00pm
21:00  9:00pm
22:00 10:00pm
23:00 11:00pm


答:
Bash + coreutils, 43 30

Saved 7 bytes thanks to @Yossarian

Saved 3 bytes thanks to @AndersKaseorg

seq 0 23|date -f- +%R\ %l:00%P
```

seq generates integers 0-23, one per line.

date interprets each line as a datetime.  Bare integers appear to be sufficient to be recognised as hours of the day by date.  date then outputs each time with the required formatting using the available time format specifiers.

Assumes LANG=C locale, as per this meta answer.

Ideone.

Title: 24 and 12 Hour Times

Body:
Bash + coreutils, 43 30

Saved 7 bytes thanks to @Yossarian

Saved 3 bytes thanks to @AndersKaseorg

seq 0 23|date -f- +%R\ %l:00%P

seq generates integers 0-23, one per line.

date interprets each line as a datetime.  Bare integers appear to be sufficient to be recognised as hours of the day by date.  date then outputs each time with the required formatting using the available time format specifiers.

Assumes LANG=C locale, as per this meta answer.

Ideone.


Title: 24 and 12 Hour Times

Body:
C Function, 82 bytes

m(i){for(;i<24;printf("%02d:00 %2d:00%cm\n",i,i%12==0?12:i%12,i>11?'p':'a'),i++);}

Usage, 94 Byte

m(i){for(;i<24;printf("%02d:00 %2d:00%cm\n",i,i%12==0?12:i%12,i>11?'p':'a'),i++);}main(){m();}

Ungolfed, 337 Bytes

#include <stdio.h>
void m(){
    int i,a;
    char c;
    for(i=0;i<24;i++){
        if (i%12==0){
            a = 12;
        }
        else{
            a = i%12;
        }
        if (i>11){
            c = 'p';
        } else{
            c = 'a';
        }
        printf("%02d:00 %2d:00%cm\n",i,a,c);
    }
}
int main(){
    m();
}

it works on Windows:

C Program, 85 bytes

main(i){for(;i<24;printf("%02d:00 %2d:00%cm\n",i,i%12==0?12:i%12,i>11?'p':'a'),i++);}


答:
C++, <s>81</s> 79 bytes

```<code>[]{for(time_t t=0,y;t<24;cout<<put_time(gmtime(&y),"%R %l:00%P\n"))y=t++*3600;}
</code>```

This code requires using namespace std somewhere preceding it.

It does a loop on the values 0...23. It multiplies each value by 3600, converts to a tm struct and prints it. The print format %R outputs the 24-hour and minute; the print formats %l and %P output the proper 12-hour parts; they require GNU.

A working online version is here.

Title: 24 and 12 Hour Times

Body:
Write a program or function with no input that prints or returns this string of 24-hour and 12-hour times:

```<code>00:00 12:00am
01:00  1:00am
02:00  2:00am
03:00  3:00am
04:00  4:00am
05:00  5:00am
06:00  6:00am
07:00  7:00am
08:00  8:00am
09:00  9:00am
10:00 10:00am
11:00 11:00am
12:00 12:00pm
13:00  1:00pm
14:00  2:00pm
15:00  3:00pm
16:00  4:00pm
17:00  5:00pm
18:00  6:00pm
19:00  7:00pm
20:00  8:00pm
21:00  9:00pm
22:00 10:00pm
23:00 11:00pm
</code>```

The string must be output exactly as it appears here. The only exception is that it may optionally have a single trailing newline.

So the MD5 hash of your output should be

```<code>827ae6e2dbb1df494930baedb3ee2653
</code>```

if you do not have a trailing newline and

```<code>cd4c3d18abee9bafb495f390a919a13f
</code>```

if you do. (Your hash could be different if your system uses another type of newline but that's OK.)

The shortest code in bytes wins. Tiebreaker is earlier answer.

Body:
C++, <s>81</s> 79 bytes

[]{for(time_t t=0,y;t<24;cout<<put_time(gmtime(&y),"%R %l:00%P\n"))y=t++*3600;}

This code requires using namespace std somewhere preceding it.

It does a loop on the values 0...23. It multiplies each value by 3600, converts to a tm struct and prints it. The print format %R outputs the 24-hour and minute; the print formats %l and %P output the proper 12-hour parts; they require GNU.

A working online version is here.


答:
C, 73 bytes

```<code>m(i){for(i=25;--i;)printf("%02d:00%3d:00%cm\n",24-i,12-i%12,"pa"[i/13]);}
</code>```

mIllIbyte found a particularly neat way to rewrite this answer. Thanks!

Title: 24 and 12 Hour Times

Body:
C, 73 bytes

m(i){for(i=25;--i;)printf("%02d:00%3d:00%cm\n",24-i,12-i%12,"pa"[i/13]);}

mIllIbyte found a particularly neat way to rewrite this answer. Thanks!


问:
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

答:
Haskell, 129 bytes

```<code>import Data.List
import Data.Char
l=length
print.(foldl(const.map concat.groupBy((.l).(==).l).sortOn l)=<<(filter isAlphaNum<$>))
</code>```

Accepts and prints an array of strings. If the result can be returned from the function (in contrast to printed to stdout), you can omit the print. and save 6 bytes.

How it works (note, I use x for the input parameter which of course does not appear in the pointfree version above):

```<code> (    )=<<(     )          -- (f =<< g) x is f (g x) x, so we fold over x with a
                           -- starting value of:
     filter isAlphaNum<$>x -- keep only alphanumeric chars in every line of x

                           -- during folding, I ignore the the elements of x.
                           -- However folding stops the repeatedly applied function
                           -- after (length x) steps, which is enough for combining
                           -- lines of equal length

 const                     -- ignore elements from x, deal only with start value
                sortOn l   -- sort lines from shortest to longest
      groupBy((.l).(==).l) -- group lines of equal length
    map concat             -- concatenate each group

print                      -- print result after (length x) iterations
</code>```

ContentLicense: CC BY-SA 4.0

Title: Let's build a Staircase

Body:
Haskell, 129 bytes

import Data.List
import Data.Char
l=length
print.(foldl(const.map concat.groupBy((.l).(==).l).sortOn l)=<<(filter isAlphaNum<$>))

Accepts and prints an array of strings. If the result can be returned from the function (in contrast to printed to stdout), you can omit the print. and save 6 bytes.

How it works (note, I use x for the input parameter which of course does not appear in the pointfree version above):

 (    )=<<(     )          -- (f =<< g) x is f (g x) x, so we fold over x with a
                           -- starting value of:
     filter isAlphaNum<$>x -- keep only alphanumeric chars in every line of x

                           -- during folding, I ignore the the elements of x.
                           -- However folding stops the repeatedly applied function
                           -- after (length x) steps, which is enough for combining
                           -- lines of equal length

 const                     -- ignore elements from x, deal only with start value
                sortOn l   -- sort lines from shortest to longest
      groupBy((.l).(==).l) -- group lines of equal length
    map concat             -- concatenate each group

print                      -- print result after (length x) iterations