text:
Falsify brief truths
Find the longest run of true in a list of booleans. Return the same list, with all other trues falsified.
Input, output
A list; any usual format (e.g., a delimited list as a string).
Details
True and false can be anything your language typically uses for those values, or the integers 1 and 0. If you use single characters, the list can be a concatenation (e.g., 10001).
If there's a tie for longest run, keep all tying runs true, and falsify all shorter runs.
Examples
input ↦ output
1,0,1,0,1 ↦ 1,0,1,0,1
1,1,0,1,1,0,1 ↦ 1,1,0,1,1,0,0
1,1,0,1,1,1,0,1,1 ↦ 0,0,0,1,1,1,0,0,0
1,1,1 ↦ 1,1,1
0,0,1 ↦ 0,0,1
0,0 ↦ 0,0
1,1,1,0,0,0,1,1,1,1,0,1,0,0,1,1,0,1,1,1,1,0,0,1,0 ↦ 0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0

(directly from https://stackoverflow.com/q/37447114)

Jelly, 8 bytes
ṣ0¬¬M¦j0

Try it online! or verify all test cases.
How it works
ṣ0¬¬M¦j0  Main link. Argument: A (list of Booleans)

ṣ0        Split at zeroes. This leaves a 2D list of ones.
  ¬       Negate each 1, replacing it with 0.
     ¦    Conditional application:
    M       Yield all maximal indices.
            In lexicographical list comparison, a shorter list of zeroes is less
            than a longer one, so this identifies the longest runs.
   ¬        Negate the items in those lists, changing zeroes back to ones.
      j0  Join, separating by single zeroes.

Jeez ... this language ...

Haskell, 59, 58, 55, 64 bytes
import Data.List
((=<<)=<<(=<<)(<$).(==).maximum.([1<2]:)).group

Fun note, this works on any list of values where falsy < truthy. So False/True, 0/1, 'f'/'t', etc.
Note:
As several people have pointed out (including @proud haskeller and @nimi), the previous version failed on a list of all falsy values. The addition of .([1<2]:) has fixed this, as suggested by @proud haskeller. I'm leaving the explanation the same for now, because I think it still makes sense. If anyone comments, asking for an explanation of the edit, I'll edit.
Explanation:
I'll first desugar without the group, and then add it back.
First, I find that words are often easier on the eyes than symbols, so I'll make a few substitutions. (Note that =<< is 'classy' so it applies differently for lists and functions. I'm calling bind the version of =<< for functions.)
bind :: (a -> b -> c) -> (b -> a) -> b -> c
bind k f = k =<< f
bind k f = \ r -> k (f r) r

f = ((=<<)=<<(=<<)(<$).(==).maximum)
f = ((bind) concatMap (bind)(<$).equals.maximum)
f = (bind concatMap (bind (<$) . equals . maximum))
f = bind concatMap ((bind (<$)) . equals . maximum))
f = bind concatMap ((\f r -> (<$) (f r) r) . equals . maximum))
f = bind concatMap ((\f r -> (f r) <$ r) . equals . maximum)
f = bind concatMap ((\g r -> (g r) <$ r) . equals . maximum)
f = (\h r -> concatMap (h r) r) ((\g r -> (g r) <$ r) . equals . maximum)
f = \r -> concatMap (((\g r -> (g r) <$ r) . equals . maximum) r) r
f = \r -> concatMap (((\g r -> (g r) <$ r) . equals) (maximum r)) r
f = \r -> concatMap (((\g s -> (g s) <$ s)) (equals (maximum r))) r
f = \r -> concatMap (((\s -> ((equals (maximum r)) s) <$ s))) r
f = \r -> concatMap (\s -> (s == (maximum r)) <$ s) r

f . group = ((=<<)=<<(=<<)(<$).(==).maximum).group
f . group = \r -> concatMap (\s -> (s == (maximum (group r))) <$ s) (group r)

The last details are that x <$ list replaces every element of the list with x and group list splits the list up into chunks of equal elements. So group [1, 1, 2, 3, 3, 3] == [[1, 1], [2], [3, 3, 3]].
To sum it all up, the function splits the list of values into groups of only true and groups of only false. Then for each group, replace each element with the result of the statement this is the biggest group (the largest group of true's will be the biggest) and concatenate the groups.
Four bytes saved by @Zgarb

I think you can replace (\y->(maximum g==y)<$y) with ((<$)=<<(==maximum g)). I haven't tested it though.

@Zgarb I just worked it out from the instance declaration and it works. Thanks.

Even better: replace the entire definition of f by the point-free function ((=<<)=<<(=<<)(<$).(==).maximum).group. Saves three bytes and is utterly unreadable!

@Zgarb: Cool! At that point, b=(=<<);b b(b(<$).(==).maximum).group is one byte shorter still. I’ve never seen anything like this before in Haskell golf :)

@Lynn I tried that too, but unfortunately it threw a type error. It seems that the monomorphism restriction doesn't allow b to be used in two different monadic contexts, since it can't have a polymorphic type... But yeah, it's not usual for Haskell to resemble J. :P

@Lynn That typechecks/works for me, but only in GHCI (doing let b=.., b b(b(<$).(==).maximum).group$[stuff]). Is that acceptable for an answer?

(Apparently, GHCI has the monomorphism restriction off by default)

@MichaelKlein By consensus on Meta, it's only acceptable as a "GHCI" answer, not pure Haskell. In any case, the let would be necessary, which makes the code longer...

@Zgarb That's unfortunate.

I opened a Meta post inspired by this case.

Would you include an explanation of how your code works, please?

Nice, but unfortunately it fails for all False values, e.g. [False,False].

Wait, doesn't it fail if there aren't any truth values in the list?

If I'm not mistaken, you can fix it by inserting (:[t]) before the maximum or something similar

Retina, 47 43 36
0
!
T`p`0`\b(1+)\b(?<=(?=.*1\1).*)|!

Try it online! or try all the test cases
Thanks to msh210 for golfing 4 bytes!
Also big thanks to Martin for 7 bytes!
Explanation:
0
!

Replace all 0s with !s. This is done to make matching groups of 1s shorter, as now 1! and !1 will have a word boundary (\b) between them, which also matches either the start or the end of the string.
T`p`0`

This is a configuration option saying that after applying the regex after the backtick to the input, in every match translate every printable ascii character into a 0 character.
\b(1+)\b(?<=(?=.*1\1).*)|!

This regex matches groups of 1s that are surrounded by zeroes, but do cannot match a 1 followed by itself anywhere in the string. These are the non-maximal groups that will be falsified. In addition, this also matches the ! characters we added to convert them back into 0s.

MATL, 14 bytes
Y'yy*X>y=b*wY"

Try it Online!
Modified version with all test cases
Explanation
        % Implicitly grab the input as an array
Y'      % Perform run-length encoding of the input. Yields an array of values and an array
        % of run-lengths
yy      % Copy these outputs
*       % Multiply the values (booleans) by the run-lengths. This will zero-out all
        % zero-valued runs so we don't consider them when computing the longest run.
X>      % Compute the longest run of 1's
y       % Copy the run lengths vector
=       % Determine which runs are the same length as the longest run of ones
b*      % Bubble-up the values from the run-length encoding and multiply element-wise
        % With this boolean. This substitutes all 1's that are not in the longest run
        % of ones with 0's
w       % Flip the run-lengths and values on the stack
Y"      % Perform run-length decoding using these substituted values
        % Implicitly display the resulting boolean

Python 2, 62 bytes
lambda s:'0'.join(`1-(t+'1'in s)`*len(t)for t in s.split('0'))

Test it on Ideone.
How it works
s.split('0') splits the input string s into runs of zero or more 1's
For each run t, we check whether t+'1' is a substring of s.

If it is, the run isn't maximal, t+'1'in s return True, 1-(t+'1'in s) return 1 - True = 0 and the run is replaced with a run of 0's of the same length.
If it isn't, the run is maximal, t+'1'in s return False, 1-(t+'1'in s) return 1 - False = 1 and the run is replaced with a run of 1's of the same length, i.e., by itself.

Finally, '0'.join restores all removed 0's.

Pyth, 26 24 23 21 bytes
M,G&HGJrgMrQ8 9qReSJJ

Test suite.

Uses 1/0 or true/false in input.
Uses true/false in output.

Explanation
M,G&HGJrgMrQ8 9qReSJJ

           Q      input
          r 8     run-length encode
        gM        convert each run of 1 to their length
                  for example: [1,1,1,0,1,1] will be
                  converted to [3,3,3,0,2,2]
                  in the run-length encoded version
                  [1,1,1,0,1,1] will be [[3,1],[1,0],[2,1]]
                  [3,3,3,0,2,2] will be [[3,3],[1,0],[2,2]]
                  therefore basically [G,H] becomes [G,H and G]
                  which is what the code below does:
M,G&HG            def g(G,H): return [G,H and G]
       r      9   run-length decode
      J           store to J

               qReSJJ

                R   J   in each element of J
               q eSJ    check if equal to maximum of J

Previous 23-byte
M,G&HGJrgMrQ8 9msqdeSJJ

Test suite.

Uses 1/0 or true/false in input.
Uses 1/0 in output.

Previous 24-byte
Jrm,hd&edhdrQ8 9msqdeSJJ

Test suite.

Uses 1/0 or true/false in input.
Uses 1/0 in output.

Previous 26-byte
rm?nhdeS.u&YhNQ0,hd0drQ8 9

Test suite.

Uses 1/0 or true/false in input.
Uses 1/0 in output.

Creating a function that is only called at a single location is almost always a mistake. You could for instance replace it with: Jr.b,N&YNrQ8)9qReSJJ or Jrm,hd*FdrQ8 9qReSJJ. Both versions save one byte. Or go even crazier with JrXR1*FdrQ8 9qReSJJ and save two. ;-)

J, 25 bytes
[:(}.=>./)@;0<@(*#);.1@,]

This is a monadic verb that takes and returns a 0-1 array. Use it like this:
   f =: [:(}.=>./)@;0<@(*#);.1@,]
   f 1 1 0 1 1 1 0 1 1
0 0 0 1 1 1 0 0 0

Explanation
[:(}.=>./)@;0<@(*#);.1@,]  Input is y.
            0          ,]  Prepend 0 to y, and
                   ;.1@    cut the result along occurrences of 0,
                           so that each piece begins with a 0.
               (*#)        Multiply each piece element-wise by its length,
             <@            and put it in a box.
                           Without the boxing, the pieces would go in a 0-padded array.
           ;               Join the pieces back together.
                           Now all runs of 1 have been replaced by runs of (1+length of run).
[:(      )@                Apply verb in parentheses:
   }.                        remove the prepended 0,
     =                       form the 0-1 array of equality with
      >./                    the maximum value.

Nice use of cut ;..

C, 135 129 bytes
Try Online
m,c,i,d,j;f(int*l,int s){while(i<s)c=l[i++]?c+1:0,m=c>m?c:m;while(j<s)if(l[j++])d=d+1;else if(d<m)while(d)l[j-1-d--]=0;else d=0;}

Ungolfed
m,c,i;
f(int*l,int s)
{
    // obtain max
    while(i<s)
        c = l[i++] ? c+1 : 0,
        m = c>m ? c : m;

    c=0,i=0;

    // remove smaller segments
    while(i<s)
        if(l[i++]) c=c+1;
        else if(c<m) while(c) l[(i-1)-c--]=0;
        else c=0;
}

Mathematica, 46 41
1-Join@@Sign[1~Max~#-#]&[#*Tr/@#]&@*Split

Works on lists of 0 and 1.  I thought I had done pretty well until I looked at the other answers!

Explanation for 46 character version; I shall update when I cannot improve it further.
An explanation of this code was requested.
A non-code-golf equivalent (using version 10 operator forms) is:
RightComposition[
  Split,
  Map[# Tr@# &],
  # - Max[1, #] &,
  UnitStep,
  Apply[Join]
]

This means a function made up of five steps (sub-functions) applied in order from top to bottom.

Split: break up into runs of identical elements:  {1,1,0,1,1,0,1} ↦ {{1,1}, {0}, {1,1}, {0,0}}
Map[# Tr@# &]: For each sub-list (Map) multiply it (#) by its sum (vector trace, Tr): {1,1} ↦ {2, 2}
# - Max[1, #] & subtract from every element the maximum value appearing anywhere in the list of lists, or one, whichever is higher.  (The one handles the case of all zeros.)
UnitStep: equal to 0 for x < 0 and 1 for x >= 0, applied to every element.
Apply[Join]: join the sub-lists into a single list.  Could also be done with Flatten or Catenate, but in short form Join@@ is more terse.

Oracle SQL 12.1, 137 135 bytes
SELECT REPLACE(REPLACE(REPLACE(:1,m,2),1,0),2,m)FROM(SELECT MAX(TRIM(COLUMN_VALUE))m FROM XMLTABLE(('"'||REPLACE(:1,0,'",0,"')||'"')));

Un-golfed
-- Replace the max value with 2
-- Then replace every 1 with 0
-- Then replace 2 with the max value
SELECT REPLACE(REPLACE(REPLACE(:1,m,2),1,0),2,m)
FROM   ( -- Split on 0 and keep the max value
         SELECT MAX(TRIM(COLUMN_VALUE))m
         FROM XMLTABLE(('"'||REPLACE(:1,'0','",0,"')||'"'))
       );

Input use single characters. Ex: '1100111'

JavaScript (ES6), 56 bytes
s=>s.replace(/1+/g,t=>t.replace(/1/g,+!~s.indexOf(t+1)))

Works by checking all runs of 1s and replacing the characters with 0s unless the run is (equally) longest, as measured by searching the string for a longer run of 1s.
Previous 72-byte recursive solution:
f=s=>/11/.test(s)?f(s.replace(/1(1*)/g,"0$1")).replace(/0(1+)/g,"1$1"):s

Does nothing if there are no runs of 1s (i.e. single 1s at most). Otherwise, subtracts one 1 from each 1 or run thereof, then calls itself recursively on the shorter runs, then adds one 1 back on the (now equally longest) runs. The number of recursive calls is one less than the length of the longest run.

"In all runs of 1s, replace each 1 with 0 if there exists a run of 1s one longer than the current run, else replace with 0." Brilliant!

Julia, 51 bytes
s->replace(s,r"1+",t->map(c->c-contains(s,"1"t),t))

Try it online!
How it works
replace finds all all runs of one or more 1's in the input string s via the regex r"1+" and calls the lambda t->map(c->c-contains(s,"1"t),t) to determine the replacement string.
The lambda maps c->c-contains(s,"1"t) over all characters in the run of ones t.

If "1"t (concatenation) is a substring of s, the run isn't maximal, contains returns true and c-contains(s,"1"t) returns '1' - true = '0', replacing all 1's in that run with 0's.
If "1"t (concatenation) is not a substring of s, the run is maximal, contains returns false and c-contains(s,"1"t) returns '1' - false = '1', leaving the run unmodified.

Java 8, 205 bytes
This is a lambda expression for a Function<String,String>:
s->{int x=s.length();for(String t="1",f="0";s.indexOf(t+1)>=0;t+=1){s=s.replaceAll(0+t+0,0+f+0);if(s.indexOf(t+0)==0)s=s.replaceFirst(t,f);if(s.lastIndexOf(0+t)==--x-1)s=s.substring(0,x)+f;f+=0;}return s;}

input/output is a String where true is represented by 1 and false is represented by 0. There are no delimiter characters separating the values.
code with explanation:
inputString -> {
  int x = inputString.length();
  //starting with the truth combination "1",
  //loop until the input string does not contain the combination appended with another "1"
  //with each consecutive loop appending a "1" to the combination
  for( String truthCombo = "1", falseCombo = "0"; inputString.indexOf( truthCombo + 1 ) >= 0; truthCombo += 1 ) {
    //all instances in the input string
    //where the combination has a "0" on either side of it
    //are replaced by "0"'s
    inputString = inputString.replaceAll( 0 + truthCombo + 0, 0 + falseCombo + 0 );
    //if the combination followed by a "0"
    //is found at the beginning of the input string
    //replace it with "0"'s
    if( inputString.indexOf( truthCombo + 0 ) == 0 )
      inputString = inputString.replaceFirst( truthCombo , falseCombo );
    //if the combination preceeded by a "0"
    //is found at the end of the input string
    //replace it with "0"'s
    if( inputString.lastIndexOf( 0 + truthCombo ) == --x - 1 )
      inputString = inputString.substring( 0, x ) + falseCombo;
    falseCombo += 0;
  }
  return inputString;
}

see ideone for the test cases

APL, 22 chars
(⊣=⌈/)∊(⊣×+/¨)(~⊂⊣)0,⎕

In English (from right to left in blocks):

prepend 0 to the input
box starting with each 0
multiply each box by its sum
flatten
1 if number equal to the max, 0 otherwise

Clojure, 137 bytes
#(let[v(map(juxt first count)(partition-by #{1}%))](mapcat(fn[t](repeat(t 1)(if(=[1(apply max(map(fn[[f c]](if(= 1 f)c 0))v))]t)1 0)))v))

First partitions the input into consecutive zeros and ones and maps these into "tuples" of partitions' first element and the count of elements. It then repeats the needed number of zeros or ones, depending if this is the max-length sequence of ones or not.
Less golfed:
(def f #(let [v(map(juxt first count)(partition-by #{1}%))
              m(apply max(map(fn[[f c]](if(= 1 f)c 0))v))]
           (mapcat (fn[[f c]](repeat c(if(=[1 m][f c])1 0))) v)))

Vyxal, 99 bitsv2, 12.375 bytes
0€‹:ÞG£ƛ¥⁼ß›;0j

Try it Online!
Bitstring:
001111010110101010011111011100100110010001011001110011110001101100100100110001000010011101000000010

port of jelly

Perl 5, 68 bytes
67, plus 1 for -pe instead of -e
y/0/ /;$_<${[sort@a]}[-1]&&y/1/0/for@a=split/\b/;$_=join"",@a;y; ;0

Expects and prints a string (concatenation) of 0s and 1s.


text:
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.
Each submission must be a full program able to compile and run, so not just a method/function. 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:
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

Output 1:
Okthatwilldo
Thisisasampletext
Blablablasomemoretext
Thewoodmaybeofexcellentquality
thatyouwillhavetousetobuildstairs
orprettycrappyalmostfallingapartandfilledwithtermites

Input 2:
A
small
one
that
contains
equal
length
strings
for
the
special
rule

Output 2:
A                   Or alternatively:       A
length                                      length
oneforthe                                   theforone
smallequal                                  equalsmall
stringsspecial                              specialstrings
thatrulecontains                            containsrulethat

Steps explained of 2:
First order on length:
A
one
for
the
that
rule
small
equal
length
strings
special
contains

First merge:
A
oneforthe
thatrule
smallequal
length
stringsspecial
contains

Second order on length:
A
length
thatrule
contains
oneforthe
smallequal
stringsspecial

Second merge:
A
length
thatrulecontains
oneforthe
smallequal
stringsspecial

Third order on length:
A
length
oneforthe
smallequal
stringsspecial
thatrulecontains

Input 3:
Test,
test.
This
is
a
test.

Output 3:
a                   Or alternatively:       a
is                                          is
TesttestThistest                            testThistestTest

Input 4:
a
bc
d!
123

Output 4:
123     Or alternatively:    123
adbc                         dabc

contains isn't supposed to be in output 2. It gets merged with thatrule

You pretty much got the exact opposite of what you wanted, it's pretty hard to do this.

"Feel free to use newer languages than this question" - So, if I create a language, just to solve this challenge in 0 bytes, that's technically legal, isn't it?

Was this challenge in the sandbox?

@Bálint Yeah, I noticed it was a bit harder than I original thought when I tried it myself, which is a bit unfortunate. And yes, it has been in the sandbox for ~ 70 hours. And if you want to make a language to solve this challenge in 0 bytes then go ahead. It seems a bit overkill to me, but if you want then go for it.

@nimi I personally indeed prefer a full program, but if you really insist I can remove it now and everyone can use the default.. I'm rather new, so perhaps it's indeed better to use the default from now on. Sorry for everyone that has already posted a full program. Feel free to edit, and I'll try to not chance the rules mid-challenge next time.

Are leading or trailing newlines permitted?

@Shaggy Although I would have said no when I posted this challenge back in 2016, right now I guess it's all right. Probably saves bytes for items not containing any A-Za-z0-9?

Husk, 11 bytes
ωȯmΣġLÖLmf□

Try it online!
Husk is younger than this challenge (which makes no difference officially, but still).
Explanation
ωȯmΣġLÖLmf□  Implicit input (list of strings), say ["a","bc","d!","123"]
        mf□  Keep only alphanumeric chars of each: ["a","bc","d","123"]
ωȯ           Repeat until fixed point is reached:
      ÖL       Sort by length: ["a","d","bc","123"]
    ġL         Group by length: [["a","d"],["bc"],["123"]]
  mΣ           Concatenate each group: ["ad","bc","123"]
             Final result ["123","adbc"], print implicitly separated by newlines.

When "keep only alphanumeric chars of each" is mf□, you ought to be jealous. When "group by length" is ġL, you ought to be amazed.

I've accepted your answer now. The new meta is that languages newer than the challenge can be used (and I've also already mentioned that in my challenge when I posted it). As I said before, nice answer!

Python 3, 264 Bytes
I'm not good at code golf so I'm confident this won't be the best Python 3 answer. This uses recursion and an ordered dict with all the words for each length.
from collections import*
def f(i):
 d = defaultdict(list)
 for l in i: x = "".join(c for c in l if c.isalnum());d[len(x)].append(x)
 n = (sorted(["".join(d[z]) for z in d.keys()], key=len))
 if n == i:return "\n".join(n)
 return f(n)
print(f(eval(input())))

Takes input from stdin as a list, for example, test it with this list:
['A', 'small', 'one', 'that', 'contains', 'equal', 'length', 'strings', 'for', 'the', 'special', 'rule']

Will output:
A
length
oneforthe
smallequal
stringsspecial
thatrulecontains

Great answer! A couple tips on golfing: 1) You don't need spaces around = signs, or == signs. 2) Python can detect keywords if it knows it can't be another variable name, like what you did with "import*" (ex. ")for", "return"\n""). 3) I'm pretty sure (not positive) that you don't need the parentheses around sorted(). Happy coding!

you can use filter(str.isalnum, l) instead of the "".join part

Retina, 69 63 bytes

[^\w¶]|_

{`\b((.)+)¶((?.)+)\b(?(2)(?!))
$1$3
O$`(.)+
$#1$*

Try it online!

I think you can change the first line to [^\w¶]|_. Although I'm still not sure it is optimal.

Oracle SQL 11.2, 346 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.
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
A¤small¤one¤that¤contains¤equal¤length¤strings¤for¤the¤special¤rule
Test,¤test.¤This¤is¤a¤test.¤

Query :
WITH v AS(SELECT REGEXP_REPLACE(COLUMN_VALUE,'[^a-zA-Z0-9]')s FROM XMLTABLE(('"'||REPLACE(:1,'¤','","')||'"'))),r(s,i,l)AS(SELECT s,1,1 FROM v UNION ALL SELECT LISTAGG(s)WITHIN GROUP(ORDER BY s)OVER(PARTITION BY LENGTH(s)),ROW_NUMBER()OVER(PARTITION BY LENGTH(s)ORDER BY s),l+1 FROM r WHERE l<LENGTH(:1)AND i=1)SELECT s FROM r WHERE l=LENGTH(:1);

Un-golfed
WITH v AS
(
  -- Splits on ¤ and keeps only alphanum characters
  SELECT REGEXP_REPLACE(COLUMN_VALUE,'[^a-zA-Z0-9]')s FROM XMLTABLE(('"'||REPLACE(:1,'¤','","')||'"'))
)
-- Recursive view
-- s : string
-- i : index of the string in case of duplicates
-- l : exit condition
,r(s,i,l)AS
(
  -- Start with every element of the input
  SELECT s,1,1 FROM v
  UNION ALL
  SELECT -- Concatenate elements of the same lengths
         LISTAGG(s)WITHIN GROUP(ORDER BY s)OVER(PARTITION BY LENGTH(s))
         -- Index of elements of the same length (listagg with over generates duplicates)
        ,ROW_NUMBER()OVER(PARTITION BY LENGTH(s) ORDER BY s)
        -- exit condition
        ,l+1 FROM r WHERE l<LENGTH(:1) AND i=1
)
-- Keep only the elements from the last iteration (automaticaly sorted on my system)
SELECT s FROM r WHERE l=LENGTH(:1)

You can replace your regex with [\W_]

@FliiFe it does not remove the ',' and '.' in the last test case

Weird... But you could still replace 0-9 with \d. Maybe the regex rules are different in sql than in python/php/javascript ? (js is still a special case because of lookbehinds)

J, 48 bytes
[:(/:#&>)[:(#&>,&.>//.])^:_(#~e.&AlphaNum_j_)&.>

Try it online!
ungolfed
[: (/: #&>) [: (#&> ,&.>//. ])^:_ (#~e.&AlphaNum_j_)&.>

explanation

(#~e.&AlphaNum_j_)&.> remove non alphanum
(#&> ,&.>//. ]) combine same length items
^:_ keep combining until it stops changing
(/: #&>) sort by length

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

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

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

Try it on Ideone

jq, 78 bytes
Expects "an array with multiple strings."
def g:group_by(length);map(scan("\\w+"))|g|until(all(length<2);map(add)|g)[][]

Try it online!

Javascript 198 188 186 179 bytes
This is my second longest golfed javascript program
s=>s.replace(/[^\w]|_/g,``,l=0).split(/\s/g).sort(g=(a,b)=>a[m=`length`]-b[m]).reduce((a,b,c)=>a+(a.split(/\s/g)[c-1][m]<b[m]?`
`:` `)+b).replace(/ /g,``).split`
`.sort(g).join`
`

Probably can be golfed further

What do you use the t variable for?

Ok so you can golf it by declaring y="split" and then instead of using .split() you can use [y]()

@gcampbell That was just a leftover from testing

@BaldBantha I don't think that would make it shorter

@BaldBantha I did that with length though

@Bálint 2 questions while trying to figure out how this works. What input is expected and where is the tree printed?

@Kwebble The input should be a string with back ticks, and it doesn't print anything, it just returns the value

@Kwebble tt's not that hard actually, first I make sure, that there are only alphanumerical characters in it with the repalce, then I split it where there are withespace characters, then I sort the array based on length, then I reduce it while I put a new line in the output string, and lastly, I join the result

Pyth, 39 bytes
Back to golfing !
There is the program :
=Qm:d"[\W_]"kQKYLmsd.glkolNb;WnKQ=KQ=yQ;jQ

=Qm:d"[\W_]"kQLmsd.glkolNb;WnYQ=YQ=yQ;j

Test it here !
Explanations
=Qm:d"[\W_]"kQLmsd.glkolNb;WnYQ=YQ=yQ;j       (Implicit) Assign evaluated imput to Q (In this case, an array)
=Q                                            Reassign a value to Q
  m          Q                                map a function over Q
   :d"[\W_]"k                                 Replace any special character with an empty string
              L           ;                   Declare a function y(b)
                      olNb                      Sort b by length
                  .glk                          Group strings of same length in arrays
               msd                              Concat each inner array
                           WnYQ      ;        While Y != Q (previous array is not equal to current array)
                               =YQ              Assign the current array to Y (Y=Q)
                                  =yQ           Assign y(Q) to Q (Q=yQ). Here, the assigned variable name is implicit
                                      j       Display the resulting array

Try to use R and L instead of m

Pyth, 22 bytes
jlDusM.glkG@Ls++GrG1UT

Try it here.
Explanation:
jlDusM.glkG@Ls++GrG1UT
j                      join on newlines
 lD                     sort by length
   u                     run until duplicate result, return result (argument G, iteration number H)
    sM                    map concatenate elements
      .g                   group elements by function (argument k)
        l                   length
         k                   k
          G                 G
           @L             left map filter on presence (extra argument first)
             s             concatenate elements
              +             concatenate two items
               +             concatenate two items
                G             G (default = lowercase alphabet)
                 r 1          to uppercase
                  G            G
                    U        unary range [0..n)
                     T        T (default = 10)

Java 8, 268 bytes
A void lambda accepting a mutable List<String> (i.e. implements add and remove; e.g. ArrayList). Output is printed to standard out, delimited by newline, with a trailing newline. Cast to Consumer<List<String>>.
l->{int i=0,z;while(i<l.size())l.set(i,l.get(i++).replaceAll("\\W| ",""));while(l.size()>0){l.sort((s,t)->s.length()-t.length());String s=l.remove(0);for(i=0,z=s.length();l.size()>0&&l.get(0).length()==z;i++)s+=l.remove(0);if(i<1)System.out.println(s);else l.add(s);}}

Try It Online
This ended up being much longer than I expected. As Kevin observed, it's more complicated than it seems at first glance.
Ungolfed lambda
l -> {
    int i = 0, z;
    while (i < l.size())
        l.set(i, l.get(i++).replaceAll("\\W| ", ""));
    while (l.size() > 0) {
        l.sort((s, t) -> s.length() - t.length());
        String s = l.remove(0);
        for (
            i = 0, z = s.length();
            l.size() > 0 && l.get(0).length() == z;
            i++
        )
            s += l.remove(0);
        if (i < 1)
            System.out.println(s);
        else
            l.add(s);
    }
}

First, I reduce the input in place to letters and numbers. I then process the inputs in groups by length. I append items to the first in the list until the next length is reached, removing them as I go. If only the first element was used, that will be the only string of that length, so it's printed. Otherwise, the joined string is added to the list for another iteration. I sort the list by length each iteration before use.
I started off with a lovely solution that used a priority queue to keep track of the intermediate strings. Unfortunately, java.util.PriorityQueue<String> is quite long (and using the raw type was longer), so it had to go.

Jelly, 17 bytes
f€ØWṖ¤L€Ġị⁸Ẏ€µÐLY

Try it online!
Not sure why Ẏf¥€ØWṖ¤L€ĠịµÐLY doesn't work...
Explanation:
f€ØWṖ¤L€Ġị⁸Ẏ€µÐLY Full program
             µÐL  Execute the following until we get a result a second time
     ¤              The following as a nilad
  ØW                  [A-Za-z0-9_]
    Ṗ                 Remove last element (_)
f€                  Filter the left argument (current result) with the above nilad
       €            Left map
      L               Length
        Ġ           Group indices of same values, sort values
          ⁸         Left argument
         ị          Index on ^^ and ^
            €       Left map
           Ẏ          Concatenate elements
                Y Join on newlines (full program will display correctly)

Perl 5, 112 bytes
@F=<>;while($n-@F){$n=@F;%k=();s/[^a-z0-9]//gi,$k{y///c}.=$_ for@F;@F=values%k}say $k{$_}for sort{$a<=>$b}keys%k

Try it online!

JavaScript, 119 bytes
I feel like this should be much shorter ...
Includes 2 leading newlines in the output.
f=s=>s==(s.replace(/[^\w\n]|_/g,t=``).split`
`.sort((x,y)=>x[l=`length`]-y[l]).map(x=>t+=s==(s=x[l])?x:`
`+x),t)?t:f(t)

Try it online

A negative character range seems to assume a global flag, so you can drop the g for 118

@Jan, see here

Then it must be the recursion, still you can drop the global flag

@Jan, that would fail, e.g., https://tio.run/##TY3NDoIwEITvfQtuuxHqnWTxQQDdikUxtSV0ozXx3fEn/s3pm0lm5mjOJnbTMErhw87Oc0@RqkgEUU92dKazsKzXzaXx7W2zzIWYUcfRDcKKdQyTAKT8ilSl2hE76/dy4La41q5FfTIjJKpkQa9JSs90lcpHd5EwF1xJ2YPg3AUfg7PahT3USrHZqo7zN2Q/@seMlWo/Fz0k1DINJ0DUxzB4bnzji6@ejnG@Aw

Perl 6, 85 bytes
{.&([o] {my@a;@a[+.comb]~=$_ for $_;@a.grep(~*)}xx$_).sort(+*.comb)}o*.map:{S:g/\W//}

Try it online!
Input and outputs as lists of strings.

Pyth, 21 bytes
jusM.glkG:R"[^\w\d]"k

Input is a list of strings. Try it online here, or verify all the test cases here.
jusM.glkG:R"[^\w\d]"kQ   Implicit: Q=eval(input()), k=""
                         Trailing Q inferred
          R          Q   For each string in Q...
         : "[^\w\d]"     ... replace non-alphanumerics...
                    k    ... with k (empty string)
 u                       Repeat the following until a fixed point occurs, current as G:
    .g  G                  Group the elements of G...
      lk                   ... by length
                             Groups ordered by the result of the inner function, i.e. length
                             This means that, in the final iteration, this acts as a sort by length
  sM                       Concatenate each group back into a string
j                        Join the resulting list on newlines, implicit print

Japt v2.0a1 -h, 11 bytes
Input & output as arrays of strings.
£=mk\W üÊmq

Try it
£=mk\L üÊmq
                :Implicit input of string array U
£               :Map
  m             :  Map U
   k            :    Remove
    \W          :    /[^A-Z0-9]/gi
       ü        :  Sort & partition by
        Ê       :    Length
         m      :  Map
          q     :    Join
 =              :  Reassign to U for next iteration
                :Implicit output of last element

Although I forgot to add test cases for it at the time (will add one now), digits should also be kept in the strings (so [a-zA-Z0-9] instead of [a-zA-Z]).

@KevinCruijssen, fixed

Ruby, 95 93 bytes
f=->a{b=a.map{_1.gsub /\W|_/,""}.group_by(&s=:size).map{_2*""}.sort_by &s
b[a.size-1]?a:f[b]}

Attempt This Online!

Vyxal, 12 bytes
krv↔⁽LġṠÞṡ)Ẋ

Try it Online!
I/O as lists of lines
          )Ẋ # Repeat until no change...
  v          # To each...
   ↔         # Keep only characters from...
kr           # Alphanumeric chars
      ġ      # Group by...
    ⁽L       # Length
       Ṡ     # Concatenate each
        Þṡ   # Sort by length

@KevinCruijssen Done

05AB1E, 16 bytes
εžKÃ}»Δ¶¡é.γg}J»

Input as a list of strings.
Try it online or verify all test cases.
Could have been 14 bytes with εžKÃ}Δé.γg}J}» if Δ would work with a list of strings as well..
Explanation:
ε   }            # Map the (implicit) input-list of strings:
 žjÃ             #  Leave only the letters and digits of each string
                 #   i.e. ["a","bc","d!","123"] → ["a","bc","d","123"]
     »           # Join the list by newlines to a single string
                 #  i.e. ["a","bc","d","123"] → "a\nbc\nd\n123"
      Δ          # Loop until the string no longer changes:
       ¶¡        #  Split by newlines
                 #   i.e. "a\nbc\nd\n123" → ["a","bc","d","123"]
         .γ }    #  Group the strings by:
           g     #   Their length
                 #    i.e. ["a","bc","d","123"] → [["a,"d"],["bc"],["123"]]
             J   #  Join each group-list to a single string
                 #   i.e. [["a,"d"],["bc"],["123"]] → ["ad","bc","123"]
              »  #  Join this list by newlines again
                 #   i.e. ["ad","bc","123"] → "ad\nbc\n123"
                 # (and the result is output implicitly after the loop)
                 #  i.e. "123\nadbc"

Powershell, Windows 10, 63 bytes
So input...
$n = @"
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
"@

and code...
((($n -Split '\n').Replace(" ","")) -Replace '[\W]','')|Sort *h

That covers input/output 1, working on 2 and 3...

Welcome to PPCG! We usually don't allow input by setting a variable. You'd either have to create function that takes an argument, or take input from STDIN, a command line arg, or similar.

Welcome to PPCG! In addition to what @StepHen said, you current answer fails for the special case. It only puts everything together and sorts once, but it doesn't merge equal-sized lines together and sort again. (See test case 2.)

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Create a 3d-like ASCII art
Your challenge is to convert a string to an ASCII art version of it.
Input
Your input is a single string, wich you should convert into the ASCII art version of it.
Output
Your output should be formatted in the following ASCII art type:
    _/_/_/_/  _/_/_/_/  _/_/_/_/  _/_/_/    _/_/_/_/  _/_/_/_/  _/_/_/_/  _/    _/  _/_/_/_/  _/_/_/_/  _/    _/  _/        _/    _/  _/    _/  _/_/_/_/  _/_/_/_/  _/_/_/_/  _/_/_/_/  _/_/_/_/  _/_/_/_/  _/    _/  _/    _/  _/  _/  _/  _/    _/  _/    _/  _/_/_/_/
   _/    _/  _/    _/  _/        _/    _/  _/        _/        _/        _/    _/    _/_/          _/  _/  _/    _/        _/_/_/_/  _/_/  _/  _/    _/  _/    _/  _/    _/  _/    _/  _/          _/_/    _/    _/  _/    _/  _/  _/  _/  _/    _/  _/    _/        _/
  _/_/_/_/  _/_/_/_/  _/        _/    _/  _/_/_/    _/_/_/    _/  _/_/  _/_/_/_/    _/_/          _/  _/_/      _/        _/    _/  _/  _/_/  _/    _/  _/_/_/_/  _/    _/  _/_/_/_/  _/_/_/_/    _/_/    _/    _/  _/    _/  _/  _/  _/    _/_/    _/_/_/_/      _/
 _/    _/  _/    _/  _/        _/    _/  _/        _/        _/    _/  _/    _/    _/_/    _/    _/  _/  _/    _/        _/    _/  _/    _/  _/    _/  _/        _/_/_/_/  _/  _/          _/    _/_/    _/    _/  _/    _/  _/  _/  _/  _/    _/    _/_/      _/
_/    _/  _/_/_/_/  _/_/_/_/  _/_/_/    _/_/_/_/  _/        _/_/_/_/  _/    _/  _/_/_/_/    _/_/    _/    _/  _/_/_/_/  _/    _/  _/    _/  _/_/_/_/  _/            _/    _/    _/  _/_/_/_/    _/_/    _/_/_/_/    _/_/      _/  _/    _/    _/    _/_/    _/_/_/_/

(This font is called "Lenny")
Each letter is 4 "blocks" wide and 5 "blocks" tall, except for the W, wich is 5 blocks wide. Every letter is a bit skewed.
A blocks consist of an underscore (_) and a slash(/), together: _/
A space should be skewed, like the letters, and should consist of 8*5 spaces (marked here as full stops/dots):
    ........
   ........
  ........
 ........
........

Test cases
> codegolf

    _/_/_/_/  _/_/_/_/  _/_/_/    _/_/_/_/  _/_/_/_/  _/_/_/_/  _/        _/_/_/_/
   _/        _/    _/  _/    _/  _/        _/        _/    _/  _/        _/
  _/        _/    _/  _/    _/  _/_/_/    _/  _/_/  _/    _/  _/        _/_/_/
 _/        _/    _/  _/    _/  _/        _/    _/  _/    _/  _/        _/
_/_/_/_/  _/_/_/_/  _/_/_/    _/_/_/_/  _/_/_/_/  _/_/_/_/  _/_/_/_/  _/

> dennis

    _/_/_/    _/_/_/_/  _/    _/  _/    _/  _/_/_/_/  _/_/_/_/
   _/    _/  _/        _/_/  _/  _/_/  _/    _/_/    _/
  _/    _/  _/_/_/    _/  _/_/  _/  _/_/    _/_/    _/_/_/_/
 _/    _/  _/        _/    _/  _/    _/    _/_/          _/
_/_/_/    _/_/_/_/  _/    _/  _/    _/  _/_/_/_/  _/_/_/_/

> doorknob

    _/_/_/    _/_/_/_/  _/_/_/_/  _/_/_/_/  _/    _/  _/    _/  _/_/_/_/  _/_/_/_/
   _/    _/  _/    _/  _/    _/  _/    _/  _/  _/    _/_/  _/  _/    _/  _/    _/
  _/    _/  _/    _/  _/    _/  _/_/_/_/  _/_/      _/  _/_/  _/    _/  _/_/_/_/
 _/    _/  _/    _/  _/    _/  _/  _/    _/  _/    _/    _/  _/    _/  _/    _/
_/_/_/    _/_/_/_/  _/_/_/_/  _/    _/  _/    _/  _/    _/  _/_/_/_/  _/_/_/_/

> martin ender

    _/    _/  _/_/_/_/  _/_/_/_/  _/_/_/_/  _/_/_/_/  _/    _/            _/_/_/_/  _/    _/  _/_/_/    _/_/_/_/  _/_/_/_/
   _/_/_/_/  _/    _/  _/    _/    _/_/      _/_/    _/_/  _/            _/        _/_/  _/  _/    _/  _/        _/    _/
  _/    _/  _/_/_/_/  _/_/_/_/    _/_/      _/_/    _/  _/_/            _/_/_/    _/  _/_/  _/    _/  _/_/_/    _/_/_/_/
 _/    _/  _/    _/  _/  _/      _/_/      _/_/    _/    _/            _/        _/    _/  _/    _/  _/        _/  _/
_/    _/  _/    _/  _/    _/    _/_/    _/_/_/_/  _/    _/            _/_/_/_/  _/    _/  _/_/_/    _/_/_/_/  _/    _/

> alex a

    _/_/_/_/  _/        _/_/_/_/  _/    _/            _/_/_/_/
   _/    _/  _/        _/        _/    _/            _/    _/
  _/_/_/_/  _/        _/_/_/      _/_/              _/_/_/_/
 _/    _/  _/        _/        _/    _/            _/    _/
_/    _/  _/_/_/_/  _/_/_/_/  _/    _/            _/    _/

Rules

Standard ppcg rules apply
Loopholes are forbidden
No trailing whitespace is allowed, except to fill out the gaps in the letters

Scoring
This is a code-golf, so the shortest answer in bytes wins!

Related

Related too

This also related challenge has just been closed as duplicate. I'm unsure about this post but something tells me this will be closed as well.

@BassdropCumberwubwubwub That's different

The only real difference I spot between this and the other challenge is the kerning between characters. The answers from the other posts can mostly be re-used, and that's what we're trying to avoid when writing a challenge. Just my 2 cents though

Answer in Unix shell script + FIGlet: figlet -f lenny $1. :P

You should have explicitly disallowed builtins like these. :P

The slant/kerning isn’t enough of a difference, IMO: all you have to do is add (5–k) spaces to the k-th line of output. Other than that, this feels like a duplicate of the ASCII-art-text-printing challenge’s we’ve had before, as others have pointed out.

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Stack Exchanging
Problem
Say you have N stacks named S1 through SN, where each Sk (k = 1 to N) contains N copies of the number k.
For example, when N = 3 the stacks looks like this:
1  2  3  <- top of stack
1  2  3
1  2  3  <- bottom of stack
=======
1  2  3  <- stack index

Here there are 3 stacks indexed as 1, 2, and 3, and each one contains N instances of its own index.
The goal is to rearrange the N stacks such that each of them identically contains the numbers 1 through N in order from top to bottom.
e.g. for N = 3 the goal is to rearrange the stacks into:
1  1  1
2  2  2
3  3  3
=======
1  2  3

The only action you can perform with the stacks is taking the top number from one of the stacks (popping) then immediately placing it on top of a different stack (pushing). This is subject to these stipulations:

A number can only be pushed onto a stack if it is less than or equal to the top number on that stack.

e.g. a 1 can be pushed onto a stack with a 1, 2, or 3 at the top, but a 2 can only be pushed onto a stack with a 2 or 3 (or higher) at the top.
This has the effect that stacks are always monotonically increasing from top to bottom.

Any nonempty stack may be popped from, and, assuming the previous bullet is satisfied, any stack may be pushed to.
Any number may be pushed onto an empty stack.
Stacks have no maximum height limit.
Stacks cannot be created or destroyed, there are always N of them.

This challenge is about deciding which pops and pushes to do in order to complete the stack exchange, not necessarily in the fewest moves, but in a surefire way.
(Practicing with a deck of cards is a good way to get a feel for the problem.)
Challenge
Write a program or function that takes in a positive integer N, guaranteed to be 3 or above. Print or return a string that denotes all the pop-push actions required to rearrange the stacks from the initial state:
1  2  3  4  5
1  2  3  4  5
1  2  3  4  5
1  2  3  4  5
1  2  3  4  5
=============
1  2  3  4  5

(N = 5 case)
To the final state:
1  1  1  1  1
2  2  2  2  2
3  3  3  3  3
4  4  4  4  4
5  5  5  5  5
=============
1  2  3  4  5

Every line in your output must contain two numbers separated by a space. The first number is the index of the stack to pop from and the second number is the index of the stack to push to. Performing the actions of all the lines in order should arrange the stacks correctly without breaking any rules.
For example, here is a potential valid output for the N = 3 case:
1 2  [move the top number on stack 1 to the top of stack 2]
1 2  [repeat]
1 2  [repeat]
3 1  [move the top number on stack 3 to the top of stack 1]
2 3  [etc.]
2 3
2 3
2 1
2 1
2 1
3 1
3 1
3 1
3 2
1 2
1 2
1 2
1 3
2 3
2 3
2 3
1 2
3 2
3 1

Notes

Your output does not need to be optimal, only correct. i.e. you do not need to minimize the number of pops and pushes.

So it would be alright if, say, some move were repeatedly made and immediately reversed.
Popping and pushing to the same stack in one move, e.g. 2 2, is allowed as well (though of course pointless).

Your output does need to be deterministic and finite.
Remember that stacks have 1-based indexing. 0-based indexing is not allowed.
N greater than 9 should of course work just as well as single digit N.
If desired you may use any two distinct, non-digit printable ASCII characters in place of spaces and newlines. A trailing newline (or newline substitute) in the output is fine.

Scoring
The shortest code in bytes wins. Tiebreaker is higher voted answer.
Valueless brownie points if you can show your algorithm is optimal.

Stop with the "extra points for small things" nonsense >_>

@zyabin101 You just lost any chance at brownies.

You always come up with such wonderful titles!

@HelkaHomba -._(._.)_.-

Is the possible output you include for the case of N=3 optimal?

Pyth 96 94 bytes
Mt*Q+++bGdHM|%+y_GHQQg1 2++Qd1g2 3g2 1g3 1++Qd2Vr3QgNtN++QdN;g1QVStQVStQI<NHgnNHnNtH)++nN0dnNH

Try it here
How does it work?
This explanation will be using N=5.
Part 1: Create the bottom layer on every stack
The reason why this is needs a separate piece of code is because every stack needs to be used: the first 4 need a 5 to be put beneath them, and the last stack must provide the 5s. This means that we can't just move all the 4s somewhere, put a 5 there, and move the 4s back.
Visualization: (parentheses mean what will be moved)
     _
11111 |
22222 |_ Can't move 4s here, not monotonically increasing
33333_|
(44444)------------??? Where to put the 4s?
55555 <- Must supply the 5 that will be moved

Instead, to do this first exchange, we will first move all the 1s over to to the second stack, move a 5 to the first stack (which is now empty), move the 1s to the third stack, move the 2s to the first stack, move the 1s back to the first stack, and finally move a 5 to the second stack.
(11111)-----.
2222211111<-'
===============================
5<---------.
2222211111 : (from stack 5)
===============================
5
22222(11111)-.
3333311111<--'
===============================
522222<-.
(22222)-'
3333311111
===============================
52222211111<-.
             |
33333(11111)-'
===============================
52222211111
5<-----.
33333  |
44444  |
555(5)-'

Now that we have a free space to move stacks into (stack 2, which only contains a 5 that is placed in the right spot), we can move all the 3s to stack 2 and place a 5 in stack 3. We can then repeat the same thing for stack 4, and now we get all the 5s in the right place! And just one more thing: we will move all the 1s to stack 5 so that we get a nice setup for the next stack exchange.
522222(11111)-.
533333        |
544444        |
5             |
511111<-------'

Part 2: Do everything else :)
This is much easier now, because now we will always have a free stack to move other numbers we need to juggle around into. So, first we figure out where the 4 is. A bit of examination will show that it will always be 1 up from where it started, or 2 above the last stack. Now, we just keep going down the stacks, placing a 4 in the stack if it's free, or moving the other numbers up 1 stack if it's not. Now we have all the 4s in place.
522222<------.
533333<----. |
544444-.-.-'-'
5<-----' |
511111<--'
===============================
5433333
54
54
5411111
5422222

Now, we realize that the 3s are 2 stacks above where the 4s where. This means that we can do the exact same thing we did with the 4s! And as it turns out, we can keep doing this as long as we wrap the stack index around to the other side.
5433333-'wrap around 543
54                   543
54                   54311111
5411111 .----------->54322222
5422222 |2 stacks up 543

And so, we can keep doing this until we have exchanged all the stacks.
Code explanation:
First of all: The (important) predefined variables.
Q: Evaluated input.
b: The newline character, '\n'
d: A space, ' '

There are 2 lambda definitions.
M           | g(G)(H), used for moving Q numbers at a time.
            | We will call these Q numbers a "(number) block"
 t          | Tail, used to remove beginning newline
  *Q        | Repeat the following Q times
    +++bGdH | '\n' + G + ' ' + H. Just a whole bunch of concatenating.
            |
M           | n(G)(H), used for figuring out which stacks to move from
 |       Q  | If the following code is 0 (false), then use Q instead
  %     Q   | Mod Q
   +   H    | Add H
    y       | Multiply by 2
     _G     | Negate (remember in the explanation part 2? Always 2 stacks above?)

The stack exchanging: part 1
g1 2                       | Move the 1 block to stack 2
    ++Qd1                  | Move a Q to stack 1
         g2 3              | Move the 1 block to stack 3
             g2 1          | Move the 2 block to stack 1
                 g3 1      | Move the 1 block back to stack 1
                     ++Qd2 | Move a Q to stack 2
 v---Code-continuation---' |I don't have enough room!!!
Vr3Q                       | For N in range(3, Q)
    gNtN                   | Move the number block in stack N up 1
        ++QdN              | Move a Q to stack N
             ;g1Q          | End for loop; move the 1 block to the last stack

The stack exchanging: part 2
VStQ                           | For N in [1, 2, ..., Q - 1]
    VStQ                       | For H in [1, 2, ..., Q - 1]
        I<NH                   | If N < H
            g                  | Number block move
             nNH               |  (find number block)
                nNtH           |  (find the previous stack)
                    )          | End "For H"
                     ++nN0dnNH | Find start, move number to next location down

I already know I'm not getting brownie points, cuz I can see many more efficient and more complicated methods :(


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

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
827ae6e2dbb1df494930baedb3ee2653

if you do not have a trailing newline and
cd4c3d18abee9bafb495f390a919a13f

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.

Similar: http://codegolf.stackexchange.com/questions/49728/list-all-times-in-the-day-at-a-half-hour-rate/49788#49788

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.

You can even just do seq 0 23 and save 7 bytes

And %H:00 → %R saves another 3.

@AndersKaseorg, nop, %R inserts a leading zero, not wanted by the OP.

@rexkogitans A leading zero is wanted (in the first column, which is the one I’m talking about).

@AndersKaseorg, oh, you were talking about the first one... then you are right, of course. Corrected my comment above.

For me, %P does not output anything (German locale), so seq 0 23|LANG=C date -f- +%R\ %l:00%P is correct, 37 Bytes

@Yossarian Excellent - thanks!

@AndersKaseorg Very good - thanks!

@rexkogitans I think LANG=C may be used as a default, though there is no harm in explicitly stating this - see my edit.

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

modulo -12 is clever!

Just in case anyone is wondering: i=0;exec"print'%02d:00%3d:00%cm'%(i,~-i%12+1,97+i/12*15);i+=1;"*24 changes the code in three different ways, but each change is the same length.

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!

Cool - I never knew about ?:

I didn’t know! Interesting. I fixed it :)

Ahh, well, ?: is actually the closest equivalent to Perl’s ||, I believe. C’s || is more like (a || b) ? 1 : 0.

i++,i%12?:12,"ap"[i/12]) lacks a sequence point.  Can't be certain when i++ occurs.  Perhaps for(i=0;i<24;i++) ...i,i%12?:12,"ap"[i/12]...

i++<24 is better - doesn't add more bytes to the source code

(i+11)%12+1 is equivalent to (i-1)%12+1 (saved 1 byte)

@anatolyg for(i=0;i++<24;) does not print 00:00 12:00am

@chux for(i=-1;i++<24;) is one way to solve it

It seems you cannot get rid of the reliance on the specifics of undefined behavior without increasing code size. This is so 1337!

How about m(i){for(i=25;--i;)printf("%02d:00%3d:00%cm\n",24-i,12-i%12,"pa"[i/13]);} . Although, I am a fan of the Elvis operator. ?:)

@mIllIbyte I love it!!

MATL, 46 42 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

MarioLANG, 965 834 bytes
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 :
++<>) +++@++++>   [!) >)>((((::(.)::((.))+:+:--(.)::)).).).)+++++++++
++""+ +"=====""====#) "+"============================================
+++)+ +>>+++++- <+<)->+++ ![-).).).))(::)).(:(:)))..(((::)).(:+(:((((<
+>+++ ++"====<( ")")-"!+++#=========================================="
+(+++>++!++)<+( ++++-+++++>
 -))+)=(#==="+( ++++)+++++"==========================================!
 [!!+-[!(+++!!! !+!<+!++!>(((((+:(.))::(((.
==##===#====###=#=#"=##=#"=================<
++++)))+++++++++++++++(((![-).).).)::)).(:))   >
>========================#==================   "
+>+ >
+"+ "=======================================[   =====================#===============[
+!> ! -).).).))(::)).)):+(..(((::)).(:+(((((<++!-).).).))(::)).)):+(.(((::)).(:+(((((<
=#==#======================================="==#======================================

///, 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

Fun fact: making the :00 into a replacement is one byte longer... TIO

@steenbergh That's because :00 is a 3-byte string that appears 3 times. 3 × 3 = 9, making a replacement in your case costs 3+1+3=7 since it uses a 1-byte alias, and you use it 3 times, so 7+3=10. 9 < 10, so I won't replace it.

Julia, 88 71 66 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!

C# function, 100 bytes
void F(){for(int i=0;i<24;i++){Console.Write($"{i:00}:00 {(i+11)%12+1,2}:00 {(i>11?"p":"a")}m\n");}}

Ungolfed version:
void F()
{
    for (int i = 0; i < 24; i++)
    {
        Console.Write($"{i:00}:00 {(i + 11)%12 + 1,2}:00 {(i > 11 ? "p" : "a")}m\n");
    }
}

Console.Write() takes too many characters!

Hello, and welcome to PPCG! I use C# a bit, but what is the leading $ doing to the string?

@NoOneIsHere - That's called "string interpolation" and it's a new feature in C# 6.0.  You can read more about it here https://msdn.microsoft.com/en-us/library/dn961160.aspx.

TSQL(SQLServer 2012) 146 124 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!

Reduced to 121 chars: try it online

@RossPresser once again you helped me, learning alot here

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! :)

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

V, 56 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"

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

In case you're wondering about the downvote.

05AB1E, 51 50 48 44 42 bytes
Saved two bytes thanks to carusocomputing
Code:
24FNgi0}N…:00©ðN12(%12+Dgiðs}®„paN12‹è'mJ,

Try it online!
Explanation
24F                                         # for N in [0...23]
   Ngi0}                                    # if len(N)=1, push 0
        N                                   # push N
         …:00©                              # push ":00" and store a copy in register
             ð                              # push " "
              N12(%12+D                     # push 2 copies of N%(-12)+12
                       giðs}                # if the length of that number is 1,
                                            # push " " and swap with the number
                            ®               # push ":00" again
                             „pa            # push "pa"
                                N12‹è       # index into that with N<12
                                     'm     # push "m"
                                       J,   # join everything and print with newline

http://codegolf.stackexchange.com/questions/103242/bridges-are-metaphors-for-everything-in-ascii-art/103264#103264 ;). Now whether or not that could be optimized below 50 is up for question haha.

23Ý instead of 24L< for 1 byte.  And how long has ë existed? I feel so dumb not knowing about else statements in 05AB1E until now.

@carusocomputing: Thanks! else has existed for a while, but it's been buggy at times. Especially when nesting ifs.

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

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

C++, 81 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.

Kotlin, 95 bytes
It can be improved for sure.
fun p(){for(i in 0..23)println("%02d:00 ${(i+11)%12+1}:00${if(i>12)"p" else "a"}m".format(i))}

Ruby, 66 62 bytes
0.upto(23){|i| puts "%02d:00%3d:00#{'ap'[i/12]}m"%[i,(i-1)%12+1]}

New version
24.times{|i|puts"%02d:00%3d:00#{'ap'[i/12]}m"%[i,(i-1)%12+1]}

24.times is shorter. No need for the spaces around puts.

You can replace (i-1) with ~-i for 2 bytes.

JavaScript (ES6), 119 116 bytes
_=>Array(24).fill().map((_,i)=>`${`0${i}`.slice(-2)}:00 ${` ${(i+11)%12+1}`.slice(-2)}:00${'ap'[+(i>11)]}m`).join`
`

JavaScript, 97 95 bytes
This is based off of starcorder’s answer. Thanks to George Reith for a 2 byte improvement.
for(i=0,k=12;i<24;k=i++%12+1)console.log('%s:00 %s:00%sm',i>9?i:'0'+i,k>9?k:' '+k,i>11?'p':'a')

Ungolfed:
for (i=0, k=12; i < 24; k = (i++) % 12 + 1)
    console.log('%s:00 %s:00%sm',
        i > 9 ? i : '0' + i,
        k > 9 ? k : ' ' + k,
        i > 11 ? 'p' : 'a')

You can save 2 bytes by rewriting n < 10 as 9 < n and swapping the ternary cases

Sclipting, 76 bytes
The program assumes that the input is empty (or '0' or anything that converts to the integer 0).
The byte count assumes UTF-16 encoding.
군上❶겠小꼀虛嗎❷꾣갰글❷결加곀剩增❶겠小글虛嗎댆밁⓷꾣갰⓷⓼곀小掘닐밊終
Ungolfed:
군 // 23
上 // for loop (goes from 0 to 23 if input is 0)
    ❶겠小꼀虛嗎 // n < 10 ? "0" : ""
    ❷          // n
    꾣갰글      // ":00 "
    ❷결加곀剩增 // k = (n+11) % 12 + 1
    ❶겠小글虛嗎 // k < 10 ? " " : ""
    댆밁       // "pa"
    ⓷         // Pull n to top of stack
    꾣갰       // ":00"
    ⓷         // Pull "pa" to top of stack
    ⓼         // Pull k to top of stack
    곀小掘     // "pa"[k < 10 ? 1 : 0]
    닐밊       // "m\n"
終 // end of for loop

Each iteration of the loop leaves lots of small strings on the stack; at the end they are all automatically concatenated.

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

You might need initialization i=0 for the function version. And for the program version, you can stuff the code directly into main - no need to define a function there!

Thanks! edited!! FYI: In the funcion version if you use it without params it's self initialized to 0!

i%12==0?12:i%12 --> i%12?i%12:12

"In the funcion version if you use it without params it's self initialized to 0!" This does not appear to be standard C.  Any reference to support this?

i have noticed it works only on the gcc i have installed on my windows system.. a friend of mine with linux told me it doesn't work on his pc but i don't know how to fix it for linux...

the command gcc --version output this : gcc (GCC) 4.8.1 Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions.  There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

PHP, 110 107 bytes
for($h=0;$h<24;){$m=($h+11)%12+1;echo($h<10?0:"")."$h:00 ".($m<10?" ":"")."$m:00".($h++<12?"a":"p")."m\n";}

exploded view
for ($h=0; $h<24; ) {
  $m = ($h+11) % 12 + 1;
  echo ($h < 10 ?  0  : "") . "$h:00 " .
       ($m < 10 ? " " : "") . "$m:00"  . ($h++ < 12 ? "a" : "p") . "m\n";
}

Somewhat surprised, tried to turn the ($i < 10 ? $s : "") . "$i:00" bit into a function, but it wound up adding ~25 characters.  No go there.

Swift, 85 bytes
for x in 0...23{print(String(format:"%02d:00 %2d:00\(x<12 ?"a":"p")m",x,12+x % -12))}

This doesn't work, at least not for me on Swift 2.2.  Output

I had to change your format string: String(format: "%02d:00 %2d:00\(x<12 ?"a":"p")m", x, x%12 != 0 ? x%12 : 12)

PHP, 67 65 64 bytes
This uses IBM-850 encoding.
for(;$i<24;)printf(~┌¤═ø┼¤¤┌╠ø┼¤¤┌îÆ§,$i,$i%12?:12,$i++>11?p:a);

With the unencoded string (66 bytes):
for(;$i<24;)printf("%02d:00%3d:00%sm\n",$i,$i%12?:12,$i++>11?p:a);

Run like this:
php -n -r 'for(;$i<24;)printf(~┌¤═ø┼¤¤┌╠ø┼¤¤┌îÆ§,$i,$i%12?:12,$i++>11?p:a);'

Tweaks

Saved 2 bytes by improving sprintf format
Saved a byte by getting rid of unnecessary space (thx @Titus)

You can use -n instead of -d error_reporting=30709. There should be no space before am/pm. Save one byte on the unencoded version with a physical linebreak.

Foo, 163 bytes
Pretty brute-force approach; nothing clever here (I tried in a couple spots but it ended up being shorter not to), just wanted to give Foo a shot. Foo automatically prints anything within quotes. $c10 prints a line break. (## ... ) loops until the current cell equals ##.
"00:00 12:00am"$c10+1(10"0"$i":00  "$i":00am"$c10+1)(12$i":00 "$i":00am"$c10+1)"12:00 12:00pm"$c10+1(22$i":00  ">+1$i<":00pm"$c10+1)(24$i":00 ">+1$i<":00pm"$c10+1)

Ungolfed a bit:
"00:00 12:00am"$c10+1
(10"0"$i":00  "$i":00am"$c10+1)
(12$i":00 "$i":00am"$c10+1)
"12:00 12:00pm"$c10+1
(22$i":00  ">+1$i<":00pm"$c10+1)
(24$i":00 ">+1$i<":00pm"$c10+1)

Try it online

Javascript (using external library - Enumerable) (107 bytes)
_.Range(0,24).WriteLine(x=>((x<10?"0"+x:x)+":00 "+(((h=((x+11)%12)+1))<10?" "+h:h)+":00"+(x<12?"am":"pm")))

Link to library: https://github.com/mvegh1/Enumerable/
Code explanation: Create array of integers from 0 to 23, for each write a line according to the predicate. That predicate checks if current val is less than 10, and pads it with 0, else uses the current val as is. Then adds the minutes string to it. Then basically does a little trickery to convert military to am/pm time, and handles padding for am/pm times less than 10.

tcl, 93
set i 0;time {puts [format %02d:00%3d:00[expr $i<12?"a":"p"]m $i [expr $i%-12+12]];incr i} 24

demo

SmileBASIC, 73 bytes
FOR H=0TO 23?FORMAT$(%02D:00 %2D:00%Sm",H,(H+11)MOD 12+1,"ap"[H>11])NEXT

Someone found a better 24->12 hour formula than my old one, which saves 3 bytes, and 5 bytes in another program

VBA, 91 Bytes
Anonymous VBE immediate window function that outputs to the VBE immediate window.
For i=0To 23:t=TimeSerial(i,0,0):?Format(t,"hh:mm")Right("  "+Format(t,"h:mmam/pm"),8):Next

Hi Sir, you can save 8 bytes by replacing Right("  "+Format(t,"h:mmam/pm"),8)  with &" "&format(t,"h:mmam/pm") :)

@remoel - unfortunately the correction you have purposed is not valid as it does not account for the double spacing on hours that have a single digit hour value - and thus does not produce the correct MD5 hash

ah Yes. I'm sorry. I forgot about the md5. my bad. Just one more thing, your code output 12am-12am not 12am-11pm. :3

@remoel, ahh - you are correct; and I have fixed this

LOLCODE, 365 bytes
I'll golf down...
HAI 1.3
VISIBLE "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 1:00pm"
KTHXBYE

Try it online!

Groovy, 90/94 bytes
90 byte version (only works in a script):
24.times{a->s=' ';m=a%12?:12;println"${a<10?0:''}$a:00 ${m<10?s:''}$m:00${a<12?'a':'p'}m"}

94 byte version:
24.times{a->def s=' ',m=a%12?:12;println"${a<10?0:''}$a:00 ${m<10?s:''}$m:00${a<12?'a':'p'}m"}

C#, 91 bytes
for(var i=0;i<24;i++){Console.Write($"{i:00}:00 {(i+11)%12+1,2}:00 {(i>11?"p":"a")}m\n");};

hmmm...  for values of I less than 10, this doesn't print a leading 0 for the hour of the military time.

good call, should display it properly now


text:
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
a1a
['a1a', 'a1A', 'A1a', 'A1A']

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

Hi!
['hi!', 'hI!', 'Hi!', 'HI!']

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:
ž1a -> ['ž1a', 'ž1A', 'Ž1a', 'Ž1A']

(your program does not need to support this)

Interesting Unicode test case: Σ → ['Σ', 'σ', 'ς']

Can we use a list of characters instead of a string? For example, if Hi! gave {('H', 'i', '!'), ('h', 'I', '!'), ('h', 'i', '!'), ('H', 'I', '!')} would that be acceptable?

@DrGreenEggsandHamDJ List of characters are allowed by default. In Python, those are singleton strings though, which is different.

@DrGreenEggsandHamDJ I would tend to agree with Dennis here. I didn't want to be too specific in the spec in order to not inadvertently exclude languages based on their output and wanted to make sure something like a list of characters was allowed. However I don't think singleton strings fit the bill in this case.

@n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳  even more interesting is that Σ is the uppercase version at the beginning of a word, σ is the lowercase version at the beginning or in the middle but not the end of a word, and ς is the lowercase version at only the end of a word.

I know this is pretty old but when outputting strings, is it acceptable to output a trailing space at the end of the line?

@DomHastings As in you have a list and you're just space-delimiting the output? That seems reasonable to me.

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.

http://pyth.herokuapp.com/?code=%7Bms.nd%2aFrRR2&input=%22ab1c%22&debug=0

@LeakyNun Ah, I had tried that but for some reason I thought using M on both s and .n was the same length. I seem to be good at counting. Anyway, editing now, thanks!

Yes they are the same length, I just changed the last part

{msrVQd^U2l is a little bit shorter.

@Jakube Thanks! Using V is pretty sneaky, I don't think I would have ever thought of that here.

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.

Get rekt other languages :p

Even after looking at the code-page, the fact that I consistently see Jelly with the lowest byte count on code-golf challenges amazes me.

Python, 74 71 bytes
f=lambda s:s and{r[0]+t for r in{s,s.swapcase()}for t in f(s[1:])}or{s}

Handles non-ASCII characters. Test it on Ideone.

Oracle SQL 11.2, 276 bytes
WITH v AS(SELECT SUBSTR(:1,LEVEL,1)c,ROWNUM p FROM DUAL CONNECT BY LEVEL<=LENGTH(:1))SELECT w FROM(SELECT REPLACE(SYS_CONNECT_BY_PATH(c,','),',','')w FROM(SELECT UPPER(c)c,p FROM v UNION SELECT LOWER(c),p FROM v)START WITH p=1CONNECT BY PRIOR p=p-1)WHERE LENGTH(:1)=LENGTH(w);

Un-golfed
WITH v AS
( -- Split input into an array of characters
  SELECT SUBSTR(:1,LEVEL,1)c,ROWNUM p FROM DUAL CONNECT BY LEVEL<=LENGTH(:1)
)
SELECT w
FROM   ( -- Build every string combination
         SELECT REPLACE(SYS_CONNECT_BY_PATH(c,','),',','')w
         FROM   ( -- Merge upper and lower arrays, keep same position for each character, it allows to mix cases
                  SELECT UPPER(c)c,p FROM v UNION SELECT LOWER(c),p FROM v
                )
         START WITH p=1          -- Start with first character (either lowercase or uppercase)
         CONNECT BY PRIOR p=p-1  -- Add the next character (either lowercase or uppercase)
       )
WHERE LENGTH(:1)=LENGTH(w); -- Keep only full strings

Ugly as hell, must be more golfable.

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, 25 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

Haskell, 69 58 bytes
import Data.Char
mapM(\x->toLower x:[toUpper x|isAlpha x])

Try it online!
Edit: @Angs saved 11 bytes. Thanks!

mapM(\x->toLower x:[toUpper x|isAlpha x]) should get rid of the other import?

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

JavaScript (Firefox 30-57), 92 90 bytes
f=([c,...s])=>c?[for(t of f(s))for(d of new Set(c.toUpperCase()+c.toLowerCase()))d+t]:['']

Edit: Saved 2 bytes because new Set will happily extract the unique characters from a string.

When !c s is also [] so you can return [s] instead

f=([c,...s])=>c?[for(t of f(s))for(d of new Set(c.toUpperCase()+c.toLowerCase()))d+t]:[s]

Perl 6, 37 bytes
{[X~] '',|.comb.map:{unique .lc,.uc}}

Try it
Explanation:
{
  [X[~]]                     # cross combine using &infix:<~> operator
    '',                      # empty string so that 1 character strings work
    |                        # flatten the following into outer list
      .comb                  # get every character from input string
      .map:                  # and map it with:
        { unique .lc, .uc }
}

Test:
#! /usr/bin/env perl6

use v6.c;
use Test;

my &case-permutation = {[X~] '',|.comb.map: {unique .lc,.uc}}

my @tests = (
  'a1a' => <a1a a1A A1a A1A>,
  'abc' => <abc abC aBc aBC Abc AbC ABc ABC>,
  'Hi!' => <hi! hI! Hi! HI!>,
  'ž1a' => <ž1a ž1A Ž1a Ž1A>,
);

plan +@tests;

for @tests -> $_ (:key($input),:value($expected)) {
  is case-permutation($input).sort, $expected.sort, .gist
}

1..4
ok 1 - a1a => (a1a a1A A1a A1A)
ok 2 - abc => (abc abC aBc aBC Abc AbC ABc ABC)
ok 3 - Hi! => (hi! hI! Hi! HI!)
ok 4 - ž1a => (ž1a ž1A Ž1a Ž1A)

You can save a byte I think: {[X~] '',|.comb.map:{unique .lc,.uc}} (remove space after map:)

Julia, 66 60 bytes
!s=s>""?[~s[1:1]t for~=(ucfirst,lcfirst),t=!s[2:end]]∪[]:[s]

Try it online!

Python, 69 bytes
import itertools as i;f=lambda s:set(i.product(*zip(s,s.swapcase())))

That returns tuples of singleton strings instead of strings. I'm not sure if that's allowed.

Save 1 byte by using from itertools import*; and omitting the i.

OP has said that singleton strings are not allowed. You should update this answer.

The output requirement is ambiguous (still is).  After I posted this, the OP clarified in the comments.  Should I just delete this answer?  What is the proper protocol?

Actually, 28 bytes
;╗l2r∙`"'Ö*£"£M╜@Z"iƒ"£MΣ`M╔

Try it online!
This program can handle non-ASCII characters, thanks to the magic of Python 3.
Explanation:
;╗l2r∙`"'Ö*£"£M╜@Z"iƒ"£MΣ`M╔
;╗                            save a copy of input to reg0
  l                           length of input
   2r                         [0,1]
     ∙                        Cartesian product with self (length of input) times
      `                  `M   map:
       "'Ö*£"£M                 push `Ö` (swapcase) if 1 else `` for each value in list
               ╜@Z              zip with input
                  "iƒ"£M        swap the case of those values
                        Σ       join string
                           ╔  unique elements

C 229 252 bytes
i,n,j,k,l;f(char *s){l=strlen(s);for(i=0;i<l;i++)s[i]=tolower(s[i]);int v[l];for(i=0;i<l;i++)v[i]=0;for(i=0;i<pow(2,l);i++){n=i,k=0;for(;n;k++){v[k]=n;n/=2;}for(j=0;j<l;j++){v[j]%=2;if(v[j])s[j]=toupper(s[j]);else s[j]=tolower(s[j]);}printf("%s ",s);}}

Ungolfed version:
void f(char *s)
{
  int i,num,k,l=strlen(s);
  for(i=0;i<l;i++)
     s[i]=tolower(s[i]);

   int v[l];
   for(i=0;i<l;i++)
     v[i]=0;

   for(i=0;i<pow(2,l);i++)
   {
      num=i,k=0;
      for(;num;k++)
      {
         v[k]=num;
         num/=2;
      }

      for(int j=0;j<l;j++)
      {
        v[j]%=2;

        if(v[j])
         s[j]=toupper(s[j]);
        else
         s[j]=tolower(s[j]);

      }
      printf("%s \n",s);

   }
}

Explanation:

Accept the character string, convert the string to lowercase.
Declare integer array of length equal to that of the string. Fill it with zeroes.
Store the numbers from 0 to 2^strlen(s)in binary form in an int array.( For a 3 byte string: 000,001,010...111)
Depending on if a bit at a position is set or, toggle the case.
Output the string for every possible combination.

Try it online!

When I originally did this in vb6 like 10 years ago I believe my solution was similar to this one. You brought back some memories ;)

@Poke Glad that i could! :)

Some things to golf: Remove the i++ in the for-loops and use ++ directly, as well as placing some parts inside the for-loop to remove brackets and semi-columns where possible. Also, you can remove the space in the parameter and use a ternary-if assignment at the end. In total: i,n,j,k,l;f(char*s){l=strlen(s);for(i=0;i<l;)s[i]=tolower(s[i++]);int v[l];for(i=0;i<l;)v[i++]=0;for(i=0;i<pow(2,l);){for(n=i++,k=0;n;n/=2)v[k++]=n;for(j=0;j<l;j++){v[j]%=2;s[j]=v[j]>0?toupper(s[j]):tolower(s[j]);}printf("%s ",s);}} (-20 bytes / 232 bytes)

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.

"2^n is always bigger than n!".  Actually n! > 2^n, provided that n is at least 4.  (Prove by induction, with base case n=4.) https://en.wikipedia.org/wiki/Factorial#Rate_of_growth_and_approximations_for_large_n

Tcl, 165 181 bytes
set n -1
while {[incr n]<1<<[llength [set s [split $argv {}]]]} {puts [join [lmap c $s b [split [format %0[llength $s]b $n] {}] {string to[expr $b?{u}:{l}] $c}] ""]}

Improvements thanks to sergiol.
Previous answer:
set s [split $argv {}]
set n -1
while {[incr n]<1<<[llength $s]} {set r ""
foreach c $s b [split [format %0[llength $s]b $n] {}] {set r $r[string [expr $b?{tou}:{tol}] $c]}
puts $r}

Uses a binary number to choose between upper/lower case when creating the output text.

165

@sergiol That's different enough from mine that you ought to post it as your own answer and get good cred for being awesome.

No. I only changed minor parts of your answer, I did not change the approach nor the essential algorithmics, so, in my point of view I thought I did not deserve to create a new answer out form yours!
And I doubt I could get an algorithm short as your original for the same purpose!

Python3, 96 bytes
i=input().lower()
for l in{*__import__('itertools').product(*zip(i,i.upper()))}:print(*l,sep='')

Late to the party but still had a go.
Thanks to DLosc for reminding me of the stuff I missed, giving me golfing tips and saving me a bunch of bytes. :)

@DLosc Thanks for the tips! I'll add those features in. :)

Thanks for the tips. It really helped. Although if I use {} instead of set(), the loop goes through the set instead of the products (I hope that makes sense). At least on my implementation (I'm using QPython on Android), {} just puts the list inside a set instead of converting the list to a set.

I've tried both ways and doing {*expr} gives me a SyntaxError.

Ahhhh. That's why. Latest version of QPython is on 3.3 or something.

Here you go: Try it online! (Also fixed a bug and golfed a space.)

C, 216 bytes
k,i,j,p,n,m;z(char *c){n=-1;m=0;while(c[++n])if(c[n]>64&c[n]<90)c[n]+=32;else if(c[n]<'a'|c[n]>'z')m++;k=1<<(n-m);for(j=0;j<k;j++){for(i=0;i<n;i++){p=1<='a'&c[n]<='z')c[n]-=32; // If we are lower case, then convert
        else if(c[n]<'A'|c[n]>'Z')m++;   // If we are neigther lower case
                                         // nor upper, then make a note
    }

    // get 2 ^ ("length" - "number of invonvertibles")
    k=1<<(n-m);
    for(j=0;j<k;j++) {      // go through the combinations
        for(i=0;i<n;i++) {  // for each combination go though the characters
            p=1<<i;         // for each character get it's bit position
            putc(
                // if the bit position is set (==1)
                (j&p)==p ?
                   tolower(c[i]) // convert
                   : c[i], // else: don't
                stdout);
        }
        putc(0xa, stdout);  // print a newline
    }
}

Wolfram Language (Mathematica), 55 bytes
""<>#&/@Union@Tuples[{#,ToUpperCase@#}]&@*Characters

Try it online!
 is the transpose operator (and displays as a superscript T in Mathematica).

Perl 5, 52 + 1 (-n) = 53 bytes
@k{glob s/./lc("{$&,").uc"$&}"/ger}++;say for keys%k

Try it online!

Perl 5, 30 bytes
s/\pl/{\l$&,\u$&}/g;say<"$_ ">

Try it online!
Outputs an additional space at the end of the output.

Attache, 39 bytes
&Cross[Sum@V]##Unique@V#SwapCase=>Chars

Try it online!
Similar to the perl answer. (I've lost my more interesting alternative, I should be posting those in the next few hours.)

JavaScript (ES6), 103
Handles non-ASCII characters
(a,r=new Set)=>a?f(a.slice(1)).map(v=>(C=o=>r.add(a[0][`to${o}erCase`]()+v),C`Upp`,C`Low`))&&[...r]:[a]

Test

f=(a,r=new Set)=>a?f(a.slice(1)).map(v=>(C=o=>r.add(a[0][`to${o}erCase`]()+v),C`Upp`,C`Low`))&&[...r]:[a]

function test() { O.textContent = f(I.value).join('\n') }

test()
<input id=I oninput='test()' value='ž1a'>

Ruby, 52 bytes
->s{a,*b=s.map{[_1,_1.swapcase]}
a.product(*b).uniq}

Attempt This Online!

authors: n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/