J, 14 13 bytes

,./@($&>~*./)

Try it online!

-1 byte thanks to Bubbler

This answer takes the two lists as its left arg, and the two list lengths as its right arg.

($&>~*./) is a dyadic hook which applies gcd between the two right arg lengths *./ and the reshapes the two left arg lists $ to that length after opening them &>.  At this point they'll be the same length so boxing is no longer needed.
[:,./ so now we can just zip them ,.

original answer taking the lists directly

J, 17 16 bytes

(*.&#$[),.*.&#$]

Try it online!

*.&# is the gcd *. after taking length # of both args

It turns out to be shorter to repeat this phrase than to remain DRY.

,. is zip and and $ is shape.  So we shape the left arg [ by the gcd of the list lengths, do the same to the right arg ], and zip them.


Swift, 76 73 bytes

func P(_ n:Int,_ k:Int)->Int{return n*k>0 ?P(n-k,k)+P(n-1,k-1):n==k ?1:0}

Try it online!

Explanation
How does the code structurally work?
First of all, we define our function P, with two integer parameters n and k, and give it a return type of Int, with this piece of code: func P(_ n:Int,_ k:Int)->Int{...}. The cool trick here is that we tell the compiler to ignore the names of the parameters, with _ followed by a space, which saves us two bytes when we call the function. return is obviously used to return the result of our nested ternary described below.
Another trick I used was n*k>0, which saves us a couple of bytes over n>0&&k>0. If the condition is true (both the integers are still higher than 0), then we recursively call our function with n decremented by k as our new n and k stays the same, and we add the result of P() with n and k decremented by 1. If the condition is not true, we return either 1 or 0 depending on whether n is equal to k.
How does the recursive algorithm work?
We know that the first element of the sequence is p0(0), and so we check that both integers are positive (n*k>0). If they are not higher than 0, we check if they are equal (n==l ?1:0), here being two cases:

There is exactly 1 possible partition, and thus we return 1, if the integers are equal.

There are no partitions if one of them is already 0 and the other is not.

However, if both are positive, we recursively call P twice, adding the results of P(n-k,k) and P(n-1,k-1). And we loop again until n has reached 0.

* Note: The spaces cannot be removed.


Mathematica 144
This may be an invalid attempt. I separated the question from each answer in the input. I also indicated the correct answer by a letter in a separate field, rather than an asterisk before the alternative.
Anyway...
The Data
questions={{{"\n1. Our site is called Programming Puzzles & Code ________.\n","A: Bugging\n","B: Golf\n","C: Hockey\n","D: Programming\n"},"B"},{{"\n2. What is the most popular tag on our site? \n","A: [debug]\n","B: [program]\n","C: [code golf]\n","D: [number]\n"},"C"},{{"\n3. We are part of the _______ Exchange network. \n","A: Stack\n","B: Code\n","C: Programmer\n","D: Hockey\n"},"A"},{{"\n4. Is this the first question? \n","A: Yes\n","B: No\n"},"B"},{{"\n5. Is this the last question? \n","A: Yes\n","B: No\n"},"A"}};

Code
An answer to each question is entered through a dialog box.
Questions, answers, and feedback are printed.
f@x_:=
Print[If[((r=ChoiceDialog[Print[""<>#,"\nanswer: "];""<>#,StringTake[Rest@#,1]])==#2),
r<>"\ncorrect!", r<>"\nincorrect, the answer is "<>#2]&@@x]

Test
f /@ questions


Javascript, 34 bytes
for(r=[b=[i=10]];i--;r[i]=b)b[i]=1

Since it's apparently OK to make the rows equal by reference, I guess it's apparently OK to rely on that fact. This helps us shave off one for-loop by building the table at the same time as its rows. So, here's my new contestant.
Since r[0] and b[0] are overwritten during the loop, they can contain garbage. This gives us another free execution slot to shave off some commas. Sadly, r=b=[] won't do, since then they are equal by-ref.
Also, it scales well (99x99 is still 34 bytes), doesn't require ES5 (the new functions have terribly long names, anyways), and as a bonus, it's unreadable :-)


JavaScript (ES6), 3.143 (81 bytes saved, 664 byte program)

R='replace',S=String.fromCharCode,T=c=>c.charCodeAt(),U='toUpperCase',V='0000000',W=(a,b,c=2)=>a.toString(c).slice(b),X=x=>'0b'+x,Y=a=>[...a].reverse().join``,Z=/[^]/g
C=s=>S(...((Y(q=s[U]()[R](/[^A-Z]/g,m=''))==q?(q=q.slice(0,p=-~q.length/2),p%1&&10):11)+q[R](Z,x=>W(T(x),2))+111+s[R](Z,c=>/[a-z]/.test(c)?W("00",m,m=1):m+(/[A-Z]/.test(c,m='')?"01":W(c<'!'?2:T(c)+384)))+V).match(/(?!0+$).{8}/g).map(X))
D=s=>{s=s[R](Z,c=>W(256+T(c),1))+V;M=r=>(s=s[R](p=s.match(`^${r}|`)[0],''),p);for([,a]=M`1.|0`,t=u=i='';!M`111`;)t+=W(X(M`.{5}`)-~8,0,36);for(t+=W(Y(t),a?a/0:1);p;)u+=M`0(?=00)|00?1`?(c=t[i++])?+p[1]?c[U]():c:'':M`10`?' ':M`11`&&S(X(M`.{7}`));return u+W(t,i)}

Now that I'm fairly satisfied with this program (and the scoring system), I'll write a bit of an explanation.

The basic idea is to compress the input into a string of bits, then compress each set of 8 bits into a byte. For the purposes of explanation, I'll just manipulate the bit string.

The bit string can be separated into several sections:

input  -> Taco Cat.
output -> 0101000000100011011111110100001100100011101011100000000

0      | 10100 00001 00011 01111 111 | 01 00001 10 01 0001 110101110
header | letter data                 | styling data

The header is a very simple mapping:

0  -> odd-length palindrome
10 -> even-length palindrome
11 -> non-palindrome

Letter data is also fairly simple. First, all non-letters are extracted from the string, and all letters are converted to uppercase. If the resulting string is a palindrome, the reversed half is stripped. Then this mapping is applied:

A -> 00001
B -> 00010
C -> 00011
D -> 00100
...
Z -> 11010

This section is terminated with 111. After that comes the styling data, which stores upper/lower-case data and non-letters. This works like so:

01 -> next letter as uppercase
0...01 (n 0s) -> next (n-1) letters as lowercase
10 -> space
11xxxxxxx -> character with code point 0bxxxxxxx

So going through the example shown above, we have

header: 0 -> palindrome
letter data: 10100 00001 00011 01111 111 -> taco
styling data:
  01        -> T
  00001     -> aco
  10        -> <space>
  01        -> C
  0001      -> at
  110101110 -> .

When the end of the bit string is reached, all remaining characters from the letter data are appended to the result. This saves us from having to do one last 000...001 and allows us to truncate these bits from the string.

Going through the test cases:

tacocat -> 3 bytes (-4)
    24 bits: 010100000010001101111111
toohottohoot -> 5 bytes (-7)
    35 bits: 10101000111101111010000111110100111
todderasesareddot -> 7 bytes (-10)
    49 bits: 0101000111100100001000010110010000011001100101111
amanaplanacanalpanama -> 8 bytes (-13)
    59 bits: 00000101101000010111000001100000110000001011100000100011111
wasitacaroracatisaw? -> 11 bytes (-9)
    84 bits: 010111000011001101001101000000100011000011001001111111000000000000000000001110111111
Bob -> 2 bytes (-1)
    16 bits: 0000100111111101
IManAmRegalAGermanAmI -> 13 bytes (-8)
    98 bits: 00100101101000010111000001011011001000101001110000101100111010100010100101000001010100000010100101
DogeeseseeGod -> 7 bytes (-6)
    54 bits: 000100011110011100101001011001100101111010000000000101
A Santa at NASA -> 8 bytes (-7)
    63 bits: 100000110011000010111010100000011110110010000011000011001010101
Go hang a salami! I'm a lasagna hog. -> 20 bytes (-16)
   154 bits: 1000111011110100000001011100011100001100110000101100000010110101001111010011000000110001100000000111010000110011101001110011000110000000001100000111010111


Convert to and from the backwards-factorial number base

ES6, 135 108 bytes

s=>s<"1"?[...s].reduce((t,d,i)=>+d+t*++i):eval("for(i=j=k=1;i<=s;i*=++j);for(r='';k<=j;k++)r+=s%i/(i/=k)|0")

Converting from backwards-factorial is nice and easy. Converting to it... not so nice. I found a 119-byte version that doesn't use eval:

s=>s<"1"?[...s].reduce((t,d,i)=>+d+t*++i):(i=j=k=1,g=_=>s<i||g(i*=++j),g(),[...Array(j)].map(_=>s%i/(i/=k++)|0).join``)


><>, 1 byte per line, 243 161 135 bytes

-26 bytes thanks to Jo King!

2D languages FTW! Although writing loops and branches using goto instructions instead of the 2D structure is not fun.

v
l
:
:
3
%
:
&
0
4
7
*
&
?
.
~
~
"
e
l
p
p
A
"
o
o
o
o
o
$
5
%
:
&
0
a
5
*
&
?
.
~
~
"
e
i
P
"
o
o
o
*
0
@
?
n
?
~
l
{
:
}
=
?
;
a
o
1

Try it online!, or watch it at the fish playground!

The fish swims downward along the code, using conditional gotos to skip things depending on what divides the accumulator.

I believe this meets the spec: whatever newlines are removed, the fish always hits the initial v (the only direction-changing instruction present), so the fish always swims downwards in the first column. Thus deleting a newline has the effect of simply removing the next character from the fish's path, and I don't think you can remove any of the characters without changing the output.


MATLAB, 327 304 296 290 282 276 267 259  255  253 bytes
I think I'm closing in on a limit now. I've managed to remove 51, 60 68 72 74 bytes from an answer I thought was well golfed. =)
Removed 8 bytes by taking the input inside the strsplit, thanks to Luis Mendo. Removed another 6 bytes by taking all the input into one cell array instead of two. Removed another 8 bytes by taking both last statements inside disp(). Removed 6 bytes by removing char and some brackets. This wasn't possible in a previous revision of the answer. Splitting the cell elements into four variables costed 15 bytes, but saved 24, thus 9 bytes saved! 8 additional bytes due to improved disp scheme. 5*~~s saves two bytes compared to (s>0)*5. Thus 4 new bytes saved (for s and t). Taking the opposite of this last expression saves yet another 2 bytes, 83-5*~s is shorter than 78+5*~~s
Golfed code:
x=strsplit([input('','s'),' ',input('','s')]);[a,b,c,d]=x{:};f=@str2num;n=@num2str;i=@sign;s=f(a(1:end-1))*i(a(end)-79)+f(c(1:end-1))*i(c(end)-79);t=f(b(1:end-1))*i(b(end)-79)+f(d(1:end-1))*i(d(end)-79);disp([n(abs(s)),83-5*~s,32,n(abs(t)),87-18*~t,''])

Same code, but with line breaks:
x=strsplit([input('','s'),' ',input('','s')]);
[a,b,c,d]=x{:};
f=@str2num;
n=@num2str;
i=@sign;
s=f(a(1:end-1))*i(a(end)-79)+f(c(1:end-1))*i(c(end)-79);
t=f(b(1:end-1))*i(b(end)-79)+f(d(1:end-1))*i(d(end)-79);
disp([n(abs(s)),78+5*~~s,32,n(abs(t)),69+18*~~t,''])

Test cases:
Save the above as flat_earth.m
flat_earth
0S 0E
0S 0W
0N 0E

flat_earth
0S 9999E
9999N 9999W
9999N 0E

flat_earth
42S 314W
42N 2718W
0N 3032W

flat_earth
5555N 8888W
7777S 0E
2222S 8888W

flat_earth
0001N        4545W
0999N        5454W
1000N 9999W


Jelly, 2 bytes

»Z

Try it online!

How it works

»Z  Main link. Argument: M (integer matrix)

 Z  Zip the rows of M, transposing rows and columns.
»   Take the maxima of all corresponding integers.


Python, 699
This is just a quick pass (ran out of time for now).  It can probably use a lot more golfing.
import sys
m=[list(x)for x in sys.stdin.read().split('\n')]
e=enumerate
S=set
s=lambda x:S([(r,c)for r,i in e(m)for c,j in e(i)if j==x])
q=S()
t=s('T')
b=s('B')
n=s('R')
def d(o,r,c,i,h,q):
 if i<0:return 0
 o[(r,c)]=1
 for p in[(r+1,c),(r-1,c),(r,c+1),(r,c-1)]:
  if p in q or(p in b and not(r,c)in n):continue
  if(r,c)in b and p in t-q:
   x=S([p])
   q|=x
   o[p]=0
   return 1
  if p in h or not p in o:continue
  h|=S([p])
  if not d(o,p[0],p[1],i-1,h,q):return 1
g=1
while g:
 o=dict(zip(b,[0]*len(b))+zip(n,[0]*len(n))+zip(q,[0]*len(q)))
 g=0
 for x,y in t:
  if not(x,y)in q and d(o,x,y,15,S(),q):g=1
for p in o.keys():m[p[0]][p[1]]=o[p]
print"\n".join(map(lambda x:"".join(map(str,x)),m))


The shortest way of getting rid of these numbers


Is the word typeable with keys adjacent to each other?

Pyth, 66
?"Yes".Am>2sm^-.uk2Cm.Dx"qwertyuiopasdfghjkl*zxcvbnm"b9.5dC,ztz"No

Try it here.
I was surprised to learn Pyth doesn't have a hypotenuse function, so this will likely be beat by a different language. I'll propose a hypotenuse function to Pyth, so this atrocity won't happen in the future.
Explanation
I transform the keyboard into this:
┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
| Q | W | E | R | T | Y | U | I | O | P |
└─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┐
  | A | S | D | F | G | H | J | K | L | * |
  └─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┴───┘
    | Z | X | C | V | B | N | M |
    └───┴───┴───┴───┴───┴───┴───┘

Which I then encode as "qwertyuiopasdfghjkl*zxcvbnm". Then I used divmod with modulo 9.5 to figure out the 2D coordinates of every key. Then I compute distances between consecutive keys, and check if the squared distance < 2.


Pip, 38 27 bytes

a@:`(.)\1*`YRR#aa@y@0X:RR3a

This was fun--got to use Pip's regex and mutable string capabilities, which I hadn't pulled out in a while. Takes input via command-line argument.

Explanation:

a@:`(.)\1*`                  Split a into runs of identical chars using regex match
           YRR#a             Yank randrange(len(a)) into y (randomly choosing one such run)
                a@y@0        Take the first character of that run
                     X:RR3   Modify in place, string-multiplying by randrange(3):
                               If RR3 is 0, character is deleted
                               If RR3 is 1, no change
                               If RR3 is 2, character is duplicated
                          a  Output the modified a

Try it online!


Python 2, 217 203 bytes

from random import*
r=[10]+range(33,127)
r=[r[65:91],r[33:59],r[16:26],r[:16]+r[26:33]+r[59:65]+r[91:]]
x=input()
l=x>>4
print''.join(map(chr,sample(sum([k[1]for k in enumerate(r)if x&2**k[0]],[])*l,l)))

Ugh this is horribly long. The part I think could be golfed the most is the part to get the charsets; that part was a pain.

By the way, I am @HyperNeutrino; I'm just getting enough rep to chat. :P

-14 bytes thanks @ValueInk!
Bug fix thanks to @ovs!


JavaScript, one point

for (s='                    ',
    reset=function(){a=s.split(/./).map(function(){return s.split(/(?=.)/)}); x=0; y=0; dx=1; dy=0; pen='#'; down=1;},
    display=function(){console.log(a.map(function(x){return x.join('')}).join('\n'))},
    position=function(){console.log(x, y)},
    draw=function(){a[y][x]=down?pen:a[y][x]},
    forward=function(){draw(); x+=dx; y+=dy; (y<0||y>19||x<0||x>19) && (console.log('Hit wall')||(dx?(x-=dx):(y-=dy))); draw();},
    turn=function(d){nx=-1*(!dx)*d*dy; dy=(!dy)*d*dx; dx=nx;},
    reset();
    ((p=prompt()) != 'STOP') || display();
    (p == "RESET") && reset(),
    (p == "DISPLAY") && display(),
    (p == "POSITION") && position(),
    (p == "DRAW") && (pen='#'),
    (p == "ERASE") && (pen=' '),
    (p == "UP") && (down=0),
    (p == "DOWN") && (down=1),
    (p == "RIGHT") && turn(1),
    (p == "LEFT") && turn(-1),
    (p == "FORWARD") && forward()
);

Sorry, I couldn't resist.


JavaScript (ES6), 219 203 201 bytes

f=
s=>s.split`
`.map((b,i,a)=>b.replace(/./g,(c,j)=>`((a[x+i]||``)[b=y+j]==`*`&&15<<b%3*4)|(y<0?8<<9:g(x,y-2)),(g(0,2)|g(-1,1)|g(1,1)).toString(16).slice(1)}>${c}`)).join`
`
<input type=button value="Colourise!" onclick=i.innerHTML=f(i.textContent)>

 / \ / \
| * | * |
 \ / \ / \
  | * | * |
 / \ / \ / \
| * |   | * |
 \ / \ / \ / \
  | * | * | * |
 / \ / \ / \ /
| * | * |
 \ / \ /

Explanation: Each character is wrapped in a font tag to set its colour, which is calculated by checking each square, plus the squares two to the left and right, plus the four squares one away diagonally, for *s and if so combining the colours of all *s found. The * colours are chosen simply by taking their horizontal coordinate modulo 3 and shifting a bitmask appropriately. Edit: Saved 2 bytes by switching from #RRGGBB to #RGB colours.


Perl, 65 bytes

Includes +2 for -lp

Give input on STDIN. Assumes the empty string is not a valid input

#!/usr/bin/perl -lp
s%.%'+(y/NESW/ESWN/*s/N(.*)W/W$1N/,/N/^/S/)'x4%gere+0or$_=stuck

If you don't mind the absence of a newline after stuck you can drop the l option


Perl, 84 bytes
Thanks @Ton Hospel for guiding me to the right direction to golf out around 30 bytes!
Bytecount includes 82 bytes of code and -0p flags.
/.*/;say y/A/ /r;s/&(.{@{+}})? /A$1&/s||s/ (.{@{+}})?&/&$1A/s||s/ /&/?redo:y;A&;

Note that there are two final spaces, and no final newline (it won't work otherwise).
Takes the maze as input as outputs all the needed frames for Adve to get out of it. Note that Adve is a & rather than a •, since the latter isn't utf8 (and perl doesn't use utf8 by default). Run it with -0pE flags :
perl -0pE '/.*/;say y/A/ /r;s/&(.{@{+}})? /A$1&/s||s/ (.{@{+}})?&/&$1A/s||s/ /&/?redo:y;A&;  ' <<< "### #####
##  #####
## ######
##      #
####### #
#   ### #
# # #   #
# #   ###
# #######
#    ####
#### ####
####  ###
##### ###
##### ###"

Just for the eyes, I also made this animated version, that is a little bit longer, but will clear the terminal between each print and sleep 0.15 sec, so it will look like Adve is actually moving :
perl -0nE 'system(clear);/.*/;say y/A/ /r;select($,,$,,$,,0.15);s/&(.{@{+}})? /A$1&/s||s/ (.{@{+}})?&/&$1A/s||s/ /&/?redo:say"\e[H",y/A&/  /r' <<< "### #####
##  #####
## ######
##      #
####### #
#   ### #
# # #   #
# #   ###
# #######
#    ####
#### ####
####  ###
##### ###
##### ###"


Sᴍᴀʟʟ Cᴀᴘꜱ Cᴏɴᴠᴇʀᴛᴇʀ

Retina, 73 bytes

T`a-z`ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀꜱᴛᴜᴠᴡxʏᴢ

This is exactly what Retina's transliterate mode was made for. It replaces all lowercase letters (a-z) with their corresponding small caps version. Annoyingly, the character codes of the small caps characters are all over the place, so it can't take advantage of ranges for the second part: ideally it would be T`a-z`ᴀ-ᴢ.

Try it online.


CJam (11 bytes)

{_e!_@a#(=}

Online demo showing the full cycle for a four-element list with one duplicate element.

Dissection

{      e# Define a block
  _e!  e#   Find all permutations of the input. Note that if there are duplicate
       e#   elements in the input then only distinct permutations are produced.
       e#   Note also that the permutations are always generated in lexicographic
       e#   order, so the order is independent of the input.
  _@a# e#   Find the index of the input in the list
  (=   e#   Decrement and get the corresponding element of the list
       e#   Incrementing would also have worked, but indexing by -1 feels less
       e#   wrong than indexing by the length, and makes this more portable to
       e#   GolfScript if it ever adds a "permutations" built-in
}


Program that runs when rows and columns are transposed

Here's one I came up with when I originally wrote the challenge a few years back. It's a perl script that can transpose other scripts. You can run it on itself, save the output as a new script, then run that new script on itself to get the original.

#######       p           $f f   ]'
#      ofm    u        $  ho o   -
#      poy    s        w  +r r  p>'
#      er ####h########=##+ #   r[}
    open   'M' , $ARGV[ 0]  ; # i$p
  for(;   <M>  ; ){         #   nxr
      #((@             $  }( (  t]i
      #';r             #   $ $   ?n
      #M<=    @        r   x y   $t
      #'M     m        +   = =   m
      # >     ,        1   0 0   ["
my @r=   $_ =~ /./g;#  >   ; ;   $\
      #  _ /  \                # yn
push @m,     \@r;              # ]"
      # ;=    r            $ $   -}
      #  ~    ;        $   x y   >
$w=($#r   + 1>        $w)      # [
?$#r+1:     $w ;$h++}# ?   < <   $
for (     $x=0 ;$x<$w;         # x
          $x++ ){              # ]
for (     $y=0 ;$y<$h;
          $y++ ){           #$
  print               #$   $ h  d:
defined                #   w ;  e
      #$)/    #        r   ; $  f
      #A{.             +   $ y  i
      #R#/             1   x +  n
      #G g             :   + +  e
      #V ;                 + )  d
     $m[  $y]->[$x]
      #0 #                 ) {  $
 ?$m[$y]->[$x]:' '}          #  m
      #)               $   {    [
      #;               w        $
  print "\n"} #        ;        y


CJam, 58 57 bytes

0WX]2m*qN/{'*f+z}2*f{\~@m<fm<W<}:..+{W<{_'*#'*@'*-,?}/N}/

Input should not end with a linefeed. Output contains 0 for cells without nearby mines.

Try it online in the CJam interpreter.

Idea

We start by padding the input matrix with one row and one column of asterisks.

For input

*4*
**2

this results in

*4**
**2*
****

Now we generate all possible modifications that result of rotating the rows and columns 0, -1 or 1 units up/left:

*4** **** **2* **4* **** ***2 4*** **** *2**
**2* *4** **** ***2 **4* **** *2** 4*** ****
**** **2* *4** **** ***2 **4* **** *2** 4***

We discard the "padding locations" from each rotation, i.e.,

*4* *** **2 **4 *** *** 4** *** *2*
**2 *4* *** *** **4 *** *2* 4** ***

and form a single matrix by concatenating the corresponding characters of each rotation:

******4** 4*******2 **24*****
*******4* *4****2** 2***4****

The first character of each position is its original character.

If it is a non-asterisk, it has to be replaced with an asterisk.
If it is an asterisk, the number of non-asterisks in that string is the number of neighboring mines.

How it works

0WX]2m*   e# Push the array of all vectors of {0,-1,1}^2.
qN/       e# Read all input from STDIN and split at linefeeds.
{'*f+z}2* e# Append a '*' to each row and transpose rows with columns. Repeat.
f{        e# For each vector [A B], push the modified input Q; then:
  \~      e#   Swap Q with [A B] and dump A and B on the stack.
  @m<     e#   Rotate the rows of Q B units up.
  fm<     e#   Rotate each row of the result A units left.
  W<      e#   Discard the last row.
}         e# This pushes all nine rotations with Manhattan distance 1.
:..+      e# Concatenate the corresponding characters for each position.
{         e# For each row:
  W<      e#   Discard the character corresponding to the last column.
  {       e#   For each remaining string:
    _'*#  e#     Find the first index of '*' in a copy.
    '*    e#     Push '*'.
    @'*-, e#     Count the non-asterisks in the string.
    ?     e#     Select '*' if the index is non-zero, the count otherwise.
  }/      e#
  N       e#   Push a linefeed.
}/        e#


Distinguish between Masculine and Feminine Nouns in French within 100 characters

CJam, 0 incorrect, 32 29 bytes

This code uses a few odd characters (some of them unprintable), but they are all well within extended ASCII range. So again, I'm counting each character as a single byte.

"un"'el2b"zPB:  ":i+:%2/*

Due to the unprintable characters, I'm sure Stack Exchange swallows some, so you might want to copy the code from the character counter (it shows bytes with UTF-8 encoding, which is suboptimal for this challenge; also, the link doesn't seem to work in Firefox, but does in Chrome).

Test it here.

After some more discussion in chat, we figured that the regex golfing wouldn't bring us much further. So following an earlier (joking) suggestion of mine we started looking into manipulating the character codes of the words with certain functions, such that all words from one group would yield a number with some property that is easy to check. And we got luckier than we expected! Here is what the code does to the words:

Implicitly convert the characters in the word to their code points.
Interpret those as digits in base 2 (yes, the digits will be much larger than 0 or 1, but CJam can handle that).
Repeatedly take the result modulo... the following numbers: [133, 122, 80, 66, 58, 26, 20, 14, 9, 4]. This sequence of numbers is itself encoded as the code points of a string (this is where the weird and unprintable characters come in).
As if by magic, all 25 masculine nouns yield 0 or 1, and all 25 feminine nouns yield 2 or 3 with this procedure. So if we divide this by 2 (integer division) we get zeroes for masculine nouns and ones for feminine nouns.

To round it off, we push "un" on the stack, the we push a single e. Then we read the input word from STDIN and perform the above computation, and finally multiply the e by the result.

I have never folded modulo onto any list before, and I feel like I never will again...

Many thanks for xnor and Sp3000 for throwing ideas around and helping with the search for divisor chain.


Bash, 43 42 40 bytes

curl -L enwp.org/$@|grep -o Canada|wc -l

Uses curl, grep, and wc to count occurrences of "Canada" in specified webpage. Like the other answers, input is given in the format July_1. This is my first time posting on the Code Golf SE and I'm not quite familiar with all of the rules. Any feedback would be most welcome.

Didn't realize that output to STDERR is traditionally ignored. Thanks for the 3 bytes, Dennis!


Javascript (ES6), 466 456 451 446 bytes

(v,p,w,t)=>(R=g=>g.exec(s),T=r=>s=s.slice(0,-1)+r,Z=s=>s.replace(/\d/g,c=>l=['ıuiü'[(n='aıoueiöü'.search(l))>>1],'ae'[n>>2]][c]),(s=v.slice(k=l=0,-3)).replace(/[aıoueiöü]/g,c=>(L=l,l=c,k++)),(R(/^(gi|ta|di|gü)t$/)||(R(/et$/)&&(k=1)))&&T`d`,((E=R(/[aıoueiöü]$/))&&t==2?(l=L,T``):s)+Z([(E?'':k<2&!R(/^((k?a|bi|bu|ge|o|ö)l)|dur|gör|san|v[aeu]r$/))+'r','0yor',(E?'y1c1':'1c1')+'ğkk'[--w]][t-1])+Z('0m|0z|s0n|s0n0z||l1r'.split`|`[w+w+p],t-2||(l='o')))

Ungofled and commented

// Parameters:
//   - 'v' = verb
//   - 'p' = plural flag
//   - 'w' = person
//   - 't' = tense
(v, p, w, t) => (
  // R() - Helper function to execute a regular expression on the stem.
  R = g => g.exec(s),

  // T() - Helper function to replace the last character of the stem with 'r'.
  T = r => s = s.slice(0, -1) + r,

  // Z() - Function that applies vowel harmony to the string 's', assuming
  //       '0' = 'i' and '1' = 'e' and using the last encountered vowel 'l'.
  Z = s => s.replace(
    /\d/g,
    c => l = [
      'ıuiü' [(n = 'aıoueiöü'.search(l)) >> 1],
      'ae' [n >> 2]
    ][c]
  ),

  // Computes:
  //   - 's' = stem
  //   - 'k' = number of vowels in stem
  //   - 'l' = last vowel in stem
  //   - 'L' = penultimate vowel in stem
  (s = v.slice(k = l = 0, -3)).replace(/[aıoueiöü]/g, c => (L = l, l = c, k++)),

  // Applies ending 't' => 'd' for irregular verbs and those ending in -et(mek).
  (R(/^(gi|ta|di|gü)t$/) || (R(/et$/) && (k = 1))) && T `d`,

  // Computes 'E' = truthy value if the stem ends in a vowel.
  // If 'E' is truthy and the tense is the continuing present, drops this vowel.
  ((E = R(/[aıoueiöü]$/)) && t == 2 ? (l = L, T ``) : s) +

  // Appends sign of tense with vowel harmony.
  Z([
    // t = 1: simple present -> either '-er', '-ir' or '-r'
    (E ? '' : k < 2 & !R(/^((k?a|bi|bu|ge|o|ö)l)|dur|gör|san|v[aeu]r$/) + 'r',

    // t = 2: continuing present -> always '-iyor'
    '0yor',

    // t = 3: future -> either '-yecek', '-ecek', '-yeceğ' or '-eceğ'
    (E ? 'y1c1' : '1c1') + 'ğkk' [--w]
  ][t - 1]) +

  // Appends personal suffix with vowel harmony,
  // forcing last vowel to 'o' for continuing present.
  Z(
    '0m|0z|s0n|s0n0z||l1r'.split `|` [w + w + p],
    t - 2 || (l = 'o')
  )
)

Test cases

let f =
(v,p,w,t)=>(R=g=>g.exec(s),T=r=>s=s.slice(0,-1)+r,Z=s=>s.replace(/\d/g,c=>l=['ıuiü'[(n='aıoueiöü'.search(l))>>1],'ae'[n>>2]][c]),(s=v.slice(k=l=0,-3)).replace(/[aıoueiöü]/g,c=>(L=l,l=c,k++)),(R(/^(gi|ta|di|gü)t$/)||(R(/et$/)&&(k=1)))&&T`d`,((E=R(/[aıoueiöü]$/))&&t==2?(l=L,T``):s)+Z([(E?'':k<2&!R(/^((k?a|bi|bu|ge|o|ö)l)|dur|gör|san|v[aeu]r$/))+'r','0yor',(E?'y1c1':'1c1')+'ğkk'[--w]][t-1])+Z('0m|0z|s0n|s0n0z||l1r'.split`|`[w+w+p],t-2||(l='o')))

console.log(f("gütmek", false, 1, 2));    // -> güdüyorum
console.log(f("almak", true, 3, 3));      // -> alacaklar
console.log(f("boğmak", true, 2, 1));     // -> boğarsınız
console.log(f("ölmek", false, 3, 1));     // -> ölür
console.log(f("boyamak", true, 1, 2));    // -> boyuyoruz
console.log(f("affetmek", false, 2, 1));  // -> affedersin
console.log(f("söylemek", true, 3, 1));   // -> söylerler
console.log(f("söylemek", false, 3, 2));  // -> söylüyor
console.log(f("söylemek", false, 1, 3));  // -> söyleyeceğim


R, 40 30 bytes

function(m,F)Reduce(F,diag(m))

Try it online!

Verify the test cases.

Traverses down the diagonal, so left-to-right in this case. For arithmetic operators, you can use "+" or backticks around the operators (+,*,-,%/%,^,%%)

Pretty straightforward: Reduce is R's equivalent to a fold, and the diagonal of a matrix is those elements a_ij where i==j, i.e., where the row and column indices are the same. diag has the appropriate behavior for non-square matrices.


Pyth (commit b93a874), 11 bytes

.VkI_IJ+zbB

Test suite

This code exploits a bug in the current version of Pyth, commit b93a874. The bug is that _IJ+zb is parsed as if it was q_J+zbJ+zb, which is equivalent to _I+zb+zb, when it should (by the design intention of Pyth) be parsed as q_J+zbJ, which is equivalent to _I+zb. This allows me to save a byte - after the bug is fixed, the correct code will be .VkI_IJ+zbJB. I'll explain that code instead.

Basically, the code brute forces over all possible strings until it finds the shortest string that can be appended to the input to form a palindrome, and outputs the combined string.

.VkI_IJ+zbJB
                z = input()
.Vk             For b in possible strings ordered by length,
       +zb      Add z and b,
      J         Store it in J,
    _I          Check if the result is a palindrome,
   I            If so,
          J     Print J (This line doesn't actually exist, gets added by the bug.
          B     Break.


Consider internal LaTeX macros rather than the documented ones

For example, \roman is a documented LaTeX macro that works on LaTeX counters. To turn 42 into XLIV you'd have to use something like

\newcounter{z}
\setcounter{z}{42}
\roman{z}

Instead, by looking up how \roman is implemented (use \show\roman to get this interactively, instead of reading the source files), one can see that it's implemented in terms of a useful macro called \@roman, and instead use that directly:

\catcode`@11
\@roman{42}

\catcode`@11 is the golfy way of writing \makeatletter (clean way in LaTeX) or \catcode`\@=11 (clean way in plain TeX). It's needed only once at the beginning, after this you can use macro names containing @.


Bash + GNU Utilities, 59

x={0..$[$1-1]}d*
eval echo $x$x+$1%1-0r^56*32+P|dc|fold -$1

Input n given as a command-line parameter.  The y-axis is inverted.
Try it online.


Mask values in a .env file for a screencast

05AB1E, 12 bytes

Uhh, I'd just solve it anyway...

'=¡`g'•иJ'=ý

Try it online!

Explanation

'=¡          Split by equal signs
   `         Put both parts onto the stack
    g        Find the length of the second item
     '•иJ    Repeat that many •'s
         '=ý Join by the equal sign


Node.js
Takes input as (w, l), where w is the width and l is an array of coordinates [x, y]. (This may be changed if the input format really is as strict as described.) Works in O(w²).

f = (w, l) => {
  var x, y,
      W = w * w,
      a = new Uint16Array(W),
      best = 0;

  l.forEach(([x, y]) => a[(y - 1) * w + x - 1] = 1);

  for(y = w; y < W; y += w) {
    for(x = y + 1; x < y + w; x++) {
      if(a[x]) {
        a[x] = 0;
      }
      else {
        best = Math.max(
          best,
          a[x] = Math.min(a[x - 1], a[x - w], a[x - w - 1]) + 1
        );
      }
    }
  }

  return best;
}

Try it online!


Mathematica
This is done in Mathematica, but it may give you some ideas as to how to implement it in R.
hearts = Table[
  With[{v = RotationTransform[\[Theta], {0, 0, 1}][{3, 0, -.2}]},
   ContourPlot3D[(2 (4/3 x)^2 + 2 y^2 + z^2 - 1)^3 - (4/3 x)^2 z^3/
       10 - y^2 z^3, {x, -2, 2}, {y, -2, 2}, {z, -2, 2},
    MaxRecursion -> 6, Mesh -> None,
    BoxRatios -> {.3, 1, 1},
    SphericalRegion -> True,
    Contours -> {0}, Boxed -> False, PlotRange -> All, Axes -> False,
    ViewPoint :> v, ContourStyle -> Red,
    ImageSize -> 300]], {\[Theta], 0, 2 Pi, Pi/24}]


Weirdest way to produce a stack overflow

Python

import sys
sys.setrecursionlimit(1)

This will cause the interpreter to fail immediately:

$ cat test.py
import sys
sys.setrecursionlimit(1)
$ python test.py
Exception RuntimeError: 'maximum recursion depth exceeded' in <function _remove at 0x10e947b18> ignored
Exception RuntimeError: 'maximum recursion depth exceeded' in <function _remove at 0x10e8f6050> ignored
$

Instead of using recursion, it just shrinks the stack so it will overflow immediately.


Partial factorisations of a positive integer

Haskell, 56 bytes

_!1=[[]]
i!n=[j:f|j<-[i..n],mod n j<1,f<-j!div n j]
(2!)

(2!)(1338557220::Int) prints in five minutes on my laptop, when compiled with ghc -O3.

Haskell, 62 bytes, but much faster

i!n|i*i>n=[[n]]|0<1=[i:f|mod n i<1,f<-i!div n i]++(i+1)!n
(2!)

(2!)(1338557220::Int) prints in a quarter of a second on my laptop, when compiled with ghc -O3.


JavaScript (ES6), 14 bytes

f=_=>"f="+f+""

Try it online!

This subsection is also a quine:

f=_=>"f="+f

Try it online!


JavaScript (ES6), 91 88 79 bytes

Saved 8 bytes thanks to @NahuelFouilleul

Takes input in currying syntax (a)(b).

a=>b=>b.filter(([x,y,z])=>(a[x]+=z)<0&a[y]<0?a[y]-=z:0,a.map(([x,y])=>a[x]=~y))

Test cases

let f =

a=>b=>b.filter(([x,y,z])=>(a[x]+=z)<0&a[y]<0?a[y]-=z:0,a.map(([x,y])=>a[x]=~y))

console.log(JSON.stringify(f(
  [["Alice", 5], ["Bob", 2]]
)(
  [["Alice", "Bob", 5], ["Bob", "Alice", 7]]
)))

console.log(JSON.stringify(f(
  [["A", 2], ["B", 3], ["C", 5]]
)(
  [["C", "A", 2], ["B", "C", 4], ["A", "B", 2]]
)))

console.log(JSON.stringify(f(
  [["A", 2], ["B", 3]]
)(
  [["A", "B", 2], ["A", "B", 2]]
)))

console.log(JSON.stringify(f(
  [["A", 4], ["B", 0]]
)(
  [["A", "B", 1], ["A", "B", 5], ["A", "B", 2]]
)))

console.log(JSON.stringify(f(
  [["A", 2], ["B", 3], ["C", 4]]
)(
  [["A", "B", 3], ["C", "B", 4]]
)))

Beautified and commented

a => b =>                 // given the two lists a and b
  b.filter(([x, y, z]) => // for each (x = payer, y = payee, z = amount) in b:
    (a[x] += z) < 0 &     //   update the payer's account; if it's still valid
    a[y] < 0 ?            //   and the payee's account is also valid:
      a[y] -= z           //     update the payee's account
    :                     //   else:
      0,                  //     do nothing
    a.map(([x, y]) =>     //   initialization: for each (x = owner, y = amount) in a:
      a[x] = ~y           //     set up this account (>= 0: closed, -1: $0, -2: $1, etc.)
    )                     //   end of map()
  )                       // end of filter()


I can imagine a scheme better than O(n^2), at least in the common case.

Build a quadtree out of your input points.  For each node in the tree, compute the number and average position of the points within that node.  Then for each point, you can use the quadtree to compute its distance to all other points in less than O(n) time.  If you're computing the distance from a point p to a distant quadtree node v, and v doesn't overlap the 45 degree diagonals from p, then the total distance from p to all the points in v is easy to compute (for v which are more horizontally than vertically separated from p, it is just v.num_points * |p.x - v.average.x|, and similarly using y coordinates if v is predominately vertically seperated).  If v overlaps one of the 45 degree diagonals, recurse on its components.

That should beat O(n^2), at least when you can find a balanced quadtree to represent your points.


Return a word with a prescribed sum of letters

Python 3.8 (pre-release), 262 235 bytes

lambda x:f'JKLmGoPlheAhVegytMtosOdtthfvtWypvttgYsRWspytps    e  eegli ra eehnkPooeoroyyauiuruotoituooup    b   aggd  p ai    mnrwiwpnwsnyotrosturwutr{"":8}d{"":14}gnlz   nht ntkpstmsltty'[(k:=x-10)//46*23+k%23::46].strip()+k//23%2*'er'

Try it online!

Uses words from the list that appear with and without a trailing er, cutting the number of required words almost in half.


Retina, 63 bytes

No,

Mi`\bn(e(ith|v)er|o(|body|ne|r|t|thing|where))\b|n't\b
0|2

Try it online!

Explanation

No,

Remove No, from the input. Due to the capitalisation rules, this can only appear at the beginning of the input, so we don't need an explicit ^.

Mi`\bn(e(ith|v)er|o(|body|ne|r|t|thing|where))\b|n't\b

Count the number of matches of the case-insensitive regex after the `. It just matches all the relevant words, where I've extracted common prefixes/suffixes with the alternatives.

0|2

Count 0 or 2s, so we turn even counts into 1 and odd counts into 0.


Focus on doing as much work as possible in one statement

INTERCAL's statement identifiers are rather verbose; DO is two noise characters on every statement, the statement's name itself also tends to be quite long, and you have to throw in a PLEASE every now and then to keep the parser happy. (The best you can do is a ratio of four DO to one PLEASE, meaning you're using 14 characters in identifiers for every 5 commands.) On the other hand, the expression syntax is fairly terse (ridiculous, but terse). This means that it's often worthwhile fitting part of your program into a single expression even when using multiple statements would be a more "natural" way to do things.

For example, if you want to assign #1 to .1 and #2 to .2, instead of doing it in the obvious INTERCAL-72 way:

DO.1<-#1DO.2<-#2

it's strongly worth considering overloading a random variable to allow you to assign both at once:

DO:1<-#1$#2

(with :1/!1$.2' thrown in somewhere earlier in the program; note that this notation postdates INTERCAL-72 by quite a way, so you'll need to use a modern INTERCAL for this to work). This is only slightly longer even if you take the setup into account, and becomes shorter if you ever need to, or can arrange to, simultaneously assign to .1 and .2 more than once.

It's not just calculate commands where this trick works. If you need to stash a variable twice, don't do it like this:

DOSTASH.1DOSTASH.1

but like this:

DOSTASH.1+.1

(The + notation works for most commands where it could conceptually make sense.)


Maximum summed sub sequences with no two numbers sharing the same digit

05AB1E, 11 bytes

æʒ€ÙJDÙQ}OZ

Try it online!

Explanation

æʒ      }    # filter the powerset of the input, keep only elements
  €Ù         # where each number with duplicate digits removed
    JDÙQ     # have different digits from the other numbers
         O   # sum each
          Z  # take max


Jelly, 10 5 bytes

ẋ"z0Ä

Try it online!

How it works

ẋ"z0Ä  Main link. Argument: A (array)

       e.g. [2, 1, 3, 1]

ẋ"     Repeat each n in A n times.

       e.g. [[2, 2   ]
             [1      ]
             [3, 3, 3]
             [1      ]]

  z0   Zipfill 0; read the result by columns, filling missing elements with 0's.

        e.g. [[2, 1, 3, 1]
              [2, 0, 3, 0]
              [0, 0, 3, 0]]

    Ä  Take the cumulative sum of each row vector.

       e.g. [[2, 3, 6, 7]
             [2, 2, 5, 5]
             [0, 0, 3, 3]]


C (gcc), 40 36 32 29 26 24 bytes

i;f(){--i&&f(sleep(7));}

Try it online!

-3 thanks to @gastropner.

-1 recursive approach thanks to @AZTECCO.

4294967295*7/86400/365.25 ~ 952.69


JavaScript (ES6), 110 bytes

s=>eval((" "+s)[R='replace'](/[^\)](?!\()/g,x=>x+i++%10,i=1)[R](/c| (\ds)+|s\d/g,"")[R](/\d+\/\d+/g,"($&|0)"))

Very simple, but integer division adds 25 bytes. For some reason a regex in JS can't match both the beginning of a string and the first character, so that adds a few bytes as well.

How it works

Prepend a space to the input.
Append the next digit to each character (except )) that isn't immediately before a (.
Remove each c, a digit + s at the beginning (1s2 -> 2), and each s + a digit (3s4 -> 3).
Turn each division operation into int-division (1/2 -> (1/2|0)).
Evaluate and return.


J, 9 bytes - 3 = 6

#~@|.*/#~

Inspired by @NBZ's APL answer, golfed down by @randomra.
This defines a verb that takes in an array of numbers. It's used as follows:

   (#~@|.*/#~) 4 3
12 12 12 12  9  9  9
12 12 12 12  9  9  9
12 12 12 12  9  9  9
16 16 16 16 12 12 12
16 16 16 16 12 12 12
16 16 16 16 12 12 12
16 16 16 16 12 12 12

I also claim the 3-byte bonus, since an input of 0 produces sub-matrices of size zero:

   (#~@|.*/#~) 4 0
16 16 16 16
16 16 16 16
16 16 16 16
16 16 16 16
   (#~@|.*/#~) 0 3
9 9 9
9 9 9
9 9 9

Explanation

J has a definite edge in this challenge.
In addition to eating array manipulation problems for breakfast, it prints 2D matrices in the correct format by default.

       #~  Replicate each number n in input n times
#~@|.      The same for reversed input
     */    Compute their multiplication table


Sisyphus, PHP
Password:
A string golf with 1,000,000 leading whitespaces and 1,000,000 trailing whitespaces
Output: golf
Reason: 1,000,000 is the default backtracking limit of PCRE (which you can get by var_dump(ini_get('pcre.backtrack_limit'));). And preg_match will return FALSE other than 0 or 1 when this limit is breaked.
Try it online!


Count the corners, edges and faces of a cut cube

Perl 6, 59 58 bytes

{6+@_,|((2,3 X*4+@_)X-(@_ X~@_)∩~<<ords "% 286
>C/")}

Try it online!

Uses the numbers 0 to 7 to represent the corners. I probably should have matched them up to the same order as in the question... oops? Outputs a list in the order faces, corners, edges.


Pyth, 49 48 46 44 bytes

_s.b@+kNsYc3mC+913d-.iU25smXm17hT4Cd"KGO"17_

Try it here.

Still working on shortening the function to generate the alphabet... and yes, the generator is longer than hardcoding the alphabet by 4 characters, but not in bytes.

_s.b@+kNsYc3[...]_
                 _  get input (implicit) and reverse
            [...]   generate "ΑΒΓΔΕϜΖΗΘΙΚΛΜΝΞΟΠϘΡΣΤΥΦΧΨΩϠ" (see below)
          c3        split into 3 equal chunks
  .b                map over each input digit (as Y) and chunk (as N)...
     +kN            prepend empty string to N (to support digits of 0)
    @   sY          get the Yth element of the empty-string-plus-digits array
 s                  concatenate all the digits
_                   reverse again to put digits back in the right order

Here's how the alphabet-generating function works. Let's take all the codepoints and subtract 913 (the smallest value):

0 1 2 3 4 75 5 6 7 8 9 10 11 12 13 14 15 71 16 18 19 20 21 22 23 24 79

Now let's pull out the ones that don't fit the pattern:

0 1 2 3 4    5 6 7 8 9 10 11 12 13 14 15    16 18 19 20 21 22 23 24
          75                             71                         79

Okay, so the strategy is forming: generate the range 0 to 24 (we'll deal with the missing 17 later), and then insert 75, 71, and 79 at the correct locations.

How can we insert the outliers? Pyth has an .interleave function that takes ex. [1,2,3] and [4,5,6] and results in [1,4,2,5,3,6]. We're going to have to add some placeholders, though, since obviously the outliers are far apart. Let's represent the placeholder with X:

0 1 2 3  4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24
X X X X 75 X X X X X  X  X  X  X  X 71  X  X  X  X  X  X  X 79

Right, so the bottom outlier array starts with four Xs. Can we group the outliers to each be preceded by four Xs and see what remains?

0 1 2 3  4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24
[four X]75 X X X X X  X [  four X  ]71  X  X  X [  four X  ]79

Now we make another key observation: since 79 comes at the very end, there can be any number of Xs preceding it, and any number of Xs following it as well! This is because interleaving [1,2,3] and [4,5,6,7,8,9] results in [1,4,2,5,3,6,7,8,9]—note that the extra elements in the second array end up at the end, and since they're going to be removed anyway, we can safely allow that.

That means we can normalize this such that every outlier is preceding by four Xs and succeeded by 6:

0 1 2 3  4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24
[four X]75[   six X   ] [  four X  ]71[     six X      ] [four X]79[six X]

Great! Now we can simply take the array [75, 71, 79], insert four placeholder values before each element and six after, and then interleave it with the range 0..24.

But wait, what happened to 17? Remember, the top line in all of these examples has been missing 17. We can simply remove the 17 after interleaving; but this leaves another delightfully evil possibility open. You guessed it—the placeholder value we've been referring to as X will be 17. This allows us to remove both the extraneous 17 and all the placeholder values in one fell swoop.

Finally! Here's the code used to implement this:

mC+913d-.iU25smXm17hT4Cd"KGO"17
              m         "KGO"    for each char in the string "KGO"...
                      Cd         take its ASCII value ("KGO" -> 75,71,79)
                m17hT            generate an 11-element array filled with 17
               X     4           replace the 5th element with the ASCII value ^^
             s                   concatenate all of these together
        .iU25                    interleave with range(25)
       -                     17  remove all the 17s
m     d                          for each value in the resulting array...
  +913                           add 913 (to get the real character value)
 C                               convert to character


Proper army (Canadian Air Cadet) squadron formation

Python 3, 308 314 309 305 269 bytes

Input is the number rows in a squad and a list with a single integer for each squad, indicating the number of persons in the squad.

Could probably be golfed quite a bit.

Edit: +6 bytes, fixed a bug for squads with the same number of persons as rows

Edit: -6 bytes thanks to @Mr.Xcoder

Edit: -36 bytes by combining everything to one function

def z(r,l,v=" ",z="X "):q=[z,v]+[(v*6).join(([z.center((w//r+(w%r>0))*2),v]+[r*[z],[z+[z,v*2][I*w%r and r>=w%r+I]+z*(w//r+(w%r>0)-2)for I in range(r)]][w>r]+[v,z.center((w//r+(w%r>0))*2)])[i]for w in l)for i in range(r+4)];return"\n".join(p.center(len(q[2]))for p in q)

Try it online!


CJam, 266 281 456 bytes * 14 12 7 unique = 3724 3372 3192

Try it online.

14301201124204202034420112034224204431020210101232301021240204310431312122132100240400222324402030223103420431324402222132223233141443401210314023001122320404112224314302132421403301243334313000011124244441400003310332301330220022110121411122100040310110020040121444302100143202204330334033211334242120304123121024200421121232100303121022431044444423243331440434010014400~~10~~100~~1~43c~c~4~~41c~100~~1~43c~c~123~~100~~1~43c~c~44~~14~~43c~c100~~40c~c43c~~

Explanation

The strategy I've used is to treat each character in the string as a base-123 digit and encode that as a decimal number in the program. The program then converts that number back to base 123 and maps each base-123 digit back to a character. Because it's hard to explain why the program is in its current state, I'll explain each version of it.

Here's what the end of the program looked like in the first version:

...2068438725 123b:c

This implements the strategy in the most straightforward way possible. The number, encoded normally in base 10, is converted back to base 123 and each base-123 digit is mapped back to a character. But this uses 4 unique non-digit characters, and being able to get rid of any one of them would likely be worth the size hit due to having to use less straightforward code.

First, I realized that I could get rid of the b and the : operators by creating them at runtime as their ASCII character values converted back to a character (with the already present c operator) and evaluating them with the ~ operator. It turned out to be a little tricky to do this with the : operator, since it has to be parsed together with the following c operator. I solved this by producing the characters : and c and then producing and evaluating the character +, which concatenates the former two characters into the string :c which can then be evaluated properly.

Second, I realized that the ~ operator I just introduced had a handy new overloaded variant: when given a number, it produces the bitwise complement. By using this twice in a row after a number, I could introduce a token break in the source with no resultant computational effect, allowing me to replace the spaces used to separate numbers with ~~.

The final result is 15 more bytes of code at the end, but this cost is greatly outweighed by the benefit of eliminating 2 unique characters out of 14. Here's a comparison of the end of the first version with the end of the second version:

...2068438725  123[ b  ][   :c    ]
...2068438725~~123~~98c~58c99c43c~~

Using any fewer than the 2 operators I was using would be impossible, but I still wanted fewer unique characters. So the next step was to eliminate digits. By changing the number's encoding so that each decimal digit was really a base-5 digit, I could potentially eliminate the digits 6-9. Before eliminating anything from the end of the prgoram, it looked like this:

...4010014400 10b5b123b:c

As mentioned before, eliminating the space is easy. But the b, :, and c would not be so easy, as their character codes are 98, 58, and 99, respectively. These all contained digits marked for elimination, so I had to find ways to derive them all. And the only useful numeric operators with character values not containing 5-9 were decrement, increment, multiply, and add.

For 98, I initially used 100~~40c~40c~, which decrements 100 twice. But then I realized I could make yet another use of the ~ operator, as bitwise complement lets me get negative numbers which, when added, let me emulate subtraction. So I then used 100~~1~43c~, which adds 100 and -2 and is 2 bytes smaller. For 58, I used 44~~14~~43c~, which adds 44 and 14. And for 99, I used 100~~40c~, which decrements 100.

The final result is pretty big and obfuscated, but the cost of the significantly larger number and processing code were slightly outweighed by the big benefit of eliminating 5 unique characters out of 12. Here's a comparison of the final end of the program before eliminations and after eliminations:

...4010014400  10[      b      ][  5  ][     b     ]123[      b      ][            :c            ]
...4010014400~~10~~100~~1~43c~c~4~~41c~100~~1~43c~c~123~~100~~1~43c~c~44~~14~~43c~c100~~40c~c43c~~


AppleScript, 50 bytes

tell app"System Events"to keystroke"Hello, World!"

Thanks to marinus for the suggestion.


V, 3 bytes

"zp

Try it online!

This actually does work in the online interpreter somehow. ¯\_(ツ)_/¯

Explanation:

The 'z' register is predefined to the source file of the program, and p pastes from whatever register you tell it to. P would also work, and not cause any different output.


Python 3.8 (pre-release), 265 250 198 bytes

lambda n,m:sum(not(n>len({*s})or m>len(set(z:=[*zip(*s)]))or any(p*3in"".join(v)or v.count("1")*2-len(v)for p in'01'for v in[*s]+z))for s in P(*[[*P(*['01']*m)]]*n))
from itertools import*;P=product

Try it online! Takes as input 2n and 2m. Thanks to Bubbler for finding a bug in my original answer and for golfing a massive 52 bytes off.

How it works:

The anonymous function we define will be taking 2n and 2m as input, generate all binary boards with the specified dimensions and then count how many of those satisfy the restrictions.

Generating all boards

... for s in P(*[[*P(*['01']*m)]]*n))
from itertools import*;P=product

is generating all the boards. The product function from the library itertools can be used to generate the cartesian product of all the arguments it is given. Breaking the nested Ps down, P(*['01']*m) creates a list of length m with '01': ['01', '01', ..., '01'] and then the splat operator * is used to turn each element of the list into an argument to P, so P(*['01']*m) generates all valid rows of length m. Call it P1.

Then we have P(*[[*P1]]*n) which takes all valid rows and turns it into a list of all valid rows, with [*P1]. We then enclose such a list in another list and multiply by n, so that we get a list of length n where each value is a list of all valid rows. Then the splat operator * is used to provide such a list as a series of arguments to the itertools.product function, thus getting all the correct-sized binary sudoku boards. We iterate over those with s.

Checking restrictions on the board

Now we are left with checking the conditions imposed on the board s with

not(n>len({*s})or m>len(set(z:=[*zip(*s)]))or any(p*3in"".join(v)or v.count("1")*2-len(v)for p in'01'for v in[*s]+z))

Instead of verifying if the board satisfies everything, we check if the board doesn't violate any restriction:

n>len({*s})or m>len(set(z:=[*zip(*s)])) checks if there are n unique rows, by converting the list of rows into a set; similarly we transpose s into z and check if there are m unique columns;
then any(B1 or B2 for v in[*s]+z) goes over all rows and all columns:

B2 = v.count("1")*2-len(v) gives 0 when the amount of 1s is exactly half of the size of the row/column and other non-zero integers when it is not. Regardless of giving a positive or negative result, Python will treat it as a Truthy value.
B1 = p*3in"".join(v) for p in'01' builds the substrings "000" and "111" and checks if those are in the row/column

Wrapping it up

In the end, we just sum all the Truthy values that correspond to all the boards that did not violate any restrictions.


JavaScript (ES7),  136  132 bytes
Takes a single integer as input and returns a string.
s=>(V=g=(d,t=s,k=0)=>k>V?R:[...S=([1e3]+t).slice(-4)].some(p=c=>(p-(p=c))**2-1)?g(d,t=(t-~d)%2400,k+=t%100<60):(V=k,R=S))()&&g(2398)

Try it online!
How?
The only valid hour prefixes are 01, 10, 12, 21 and 23. It means that any invalid minute count starting with a digit greater than 5 will be rejected by the test on the absolute difference between two consecutive digits.
So there's no need to explicitly handle the wrapping of minutes modulo 60. Instead, we can just make sure that the distance k is not incremented on invalid minutes:
k += t % 100 < 60

JavaScript (Node.js),  148  146 bytes
Takes a single integer as input and returns a string.
This version picks the answer from a hardcoded table.
t=>0x60553BCD48A3CE4F56D818FDC473FC726398E907D3A9n.toString(6).substr([22,85,9,423,462,x=98,x,9,9,413,461,9,x,x,9,9].findIndex(d=>(t-=d+2)<0)*4,4)

Try it online!
How?
Once converted to base-6, the integer 0x60553BCD48A3CE4F56D818FDC473FC726398E907D3A9n is turned into the following string, which holds all possible valid answers:
"23450101012101231010101212101212123212342101212121232321232323432345"

The correct answer is selected according to the interval in which the input time falls:
 answer | input interval
--------+----------------
 "2345" | 00:00 - 00:23
 "0101" | 00:24 - 01:10
 "0121" | 01:11 - 01:21
 "0123" | 01:22 - 05:46
 "1010" | 05:47 - 10:10
 "1012" | 10:11 - 11:10
 "1210" | 11:11 - 12:10
 "1212" | 12:11 - 12:21
 "1232" | 12:22 - 12:32
 "1234" | 12:33 - 16:47
 "2101" | 16:48 - 21:10
 "2121" | 21:11 - 21:21
 "2123" | 21:22 - 22:21
 "2321" | 22:22 - 23:21
 "2323" | 23:22 - 23:32
 "2343" | 23:33 - 23:43
 "2345" | 23:44 - 23:59

The lengths of the intervals in minutes (minus 2) are stored in an array.


Taxi, 2399 2391 2370 1783 1773 1706 bytes
-8 bytes for realizing that, instead of leaving a certain passenger at Sunny Side Park forever, it's more worth it to throw them off of Riverview Bridge. Ah, what a lovely town this is.
-21 bytes for taking out a comment I stupidly left in.
-587 bytes by simply changing the entire way I went about this (apparently a shorter way is by arithmetic; integer-dividing [17, 27, 37, 47,...] by 9 yields the sequence, but you gotta skip over the 20's yourself.)
-17 bytes for the realization that any quotes-encased string without a space doesn't need quotes after all (thanks Jo King!).
-67 bytes for the realization that linebreaks are optional.
17 is waiting at Starchild Numerology.Go to Starchild Numerology:w 1 l 2 r 1 l 1 l 2 l.Pickup a passenger going to Cyclone.Go to Cyclone:e 1 l 2 r.[B]Pickup a passenger going to Cyclone.Pickup a passenger going to Divide and Conquer.9 is waiting at Starchild Numerology.Go to Starchild Numerology:s 2 l 2 r.Pickup a passenger going to Divide and Conquer.Go to Divide and Conquer:e 1 l 2 r 3 r 2 r 1 r.Pickup a passenger going to Trunkers.Go to Trunkers:e 1 r 3 r 1 l.Pickup a passenger going to The Babelfishery.Go to The Babelfishery:e 1 r 1 r.Pickup a passenger going to Post Office.\n is waiting at Writer's Depot.Go to Writer's Depot:n 5 l 2 l.Pickup a passenger going to Post Office.Go to Post Office:n 1 r 2 r 1 l.Go to Cyclone:s 1 r 1 l 2 r.Pickup a passenger going to Addition Alley.Pickup a passenger going to Equal's Corner.177 is waiting at Starchild Numerology.Go to Starchild Numerology:s 2 l 2 r.Pickup a passenger going to Equal's Corner.Go to Equal's Corner:w 1 l.Switch to plan C if no one is waiting.Pickup a passenger going to Sunny Skies Park.100 is waiting at Starchild Numerology.Switch to plan D.[C]10 is waiting at Starchild Numerology.[D]Go to Starchild Numerology:n 1 r.Pickup a passenger going to Addition Alley.Go to Sunny Skies Park:w 1 r.Go to Addition Alley:n 1 r 1 r 1 r.Pickup a passenger going to Cyclone.Go to Cyclone:n 1 l 1 l.Pickup a passenger going to Cyclone.Pickup a passenger going to Equal's Corner.917 is waiting at Starchild Numerology.Go to Starchild Numerology:s 2 l 2 r.Pickup a passenger going to Equal's Corner.Go to Equal's Corner:w 1 l.Switch to plan E if no one is waiting.Switch to plan F.[E]Go to Go More:n 1 l.Go to Cyclone:w 1 r.Switch to plan B.[F]

Try it online!
This one isn't winning me any code golf competitions anytime soon, but I decided to try out the esolang Taxi.
Taxi is an esolang in which all programming is done by picking up and dropping off passengers at various stops in the fictional town of Townsburg. Of course, your taxicab will sometimes run out of gas, so you also need to visit gas stations every so often, and pay using the credits you receive as fare (in this case, I only need to stop for gas - at Go More - once per loop iteration!).
I used some tricks that reduce the filesize a bit, such as rephrasing directions like east 1st left, 2nd right as e 1 l 2 r, removing the word the where it is optional, and using the least complicated route towards all of my destinations (not necessarily the shortest path).
I hate this shorter solution more than the one I originally came up with. This solution down here is a more general way of accomplishing the task, which could start and end anywhere you want. Here it is, in its entirety.
2245 bytes (way more general)
1 is waiting at Starchild Numerology.Go to Starchild Numerology:w 1 l 2 r 1 l 1 l 2 l.Pickup a passenger going to Cyclone.Go to Cyclone:e 1 l 2 r.[B]Pickup a passenger going to Addition Alley.Pickup a passenger going to The Babelfishery.Go to The Babelfishery:n 2 r 2 r.Pickup a passenger going to Cyclone.Go to Cyclone:n 5 l 2 l.Pickup a passenger going to Chop Suey.Go to Zoom Zoom:n.0 is waiting at Writer's Depot.Go to Writer's Depot:w.Pickup a passenger going to Narrow Path Park.Go to Narrow Path Park:n 3 r 1 l 1 r.Go to Chop Suey:e 1 r 1 l 1 r.[C]Switch to plan E if no one is waiting.Pickup a passenger going to Crime Lab.2 is waiting at Writer's Depot.Go to Writer's Depot:n 1 l 3 l.Pickup a passenger going to Crime Lab.Go to Crime Lab:n 3 r 2 r.Switch to plan D if no one is waiting.Pickup a passenger going to KonKat's.Go to Narrow Path Park:n 5 l.Pickup a passenger going to KonKat's.Go to KonKat's:e 1 r.Pickup a passenger going to Narrow Path Park.Go to Narrow Path Park:n 2 l.Go to Chop Suey:e 1 r 1 l 1 r.Switch to plan C.[D]Go to Chop Suey:n 5 r 1 l.Switch to plan C.[E]Go to Narrow Path Park:n 1 l 1 r 1 l.Pickup a passenger going to Crime Lab.0 is waiting at Writer's Depot.Go to Writer's Depot:w 1 l 1 r 2 l.1 is waiting at Starchild Numerology.Pickup a passenger going to Crime Lab.Go to Crime Lab:n 3 r 2 r.Switch to plan F if no one is waiting.Pickup a passenger going to Riverview Bridge.Go to Cyclone:n 4 l 2 l.Pickup a passenger going to Post Office.Go to Riverview Bridge:n 2 r.\n is waiting at Writer's Depot.Go to Writer's Depot:w 2 l.Pickup a passenger going to Post Office.Go to Post Office:n 1 r 2 r 1 l.Go to Starchild Numerology:s 1 r 1 l 1 l 2 l.Switch to plan G.[F]Go to Cyclone:s 1 r 1 l 2 r.Pickup a passenger going to Riverview Bridge.Go to Riverview Bridge:n 2 r.Go to Starchild Numerology:w 2 l 3 l 2 r.[G]Pickup a passenger going to Addition Alley.Go to Addition Alley:e 1 l 2 r 3 r 1 r.Pickup a passenger going to Magic Eight.101 is waiting at Starchild Numerology.Go to Starchild Numerology:n 1 l 1 l 3 l 2 r.Pickup a passenger going to Magic Eight.Go to Magic Eight:w 1 r 2 r 1 r.Switch to plan H if no one is waiting.Pickup a passenger going to Cyclone.Go to Cyclone:n 1 l 2 r.Switch to plan B.[H]

Try it online!
And if mega-cheating is allowed, this one is way shorter than either of the last two.
456 bytes (totally cheating)
1\n3\n4\n5\n6\n7\n8\n9\n10\n11\n13\n14\n15\n16\n17\n18\n19\n30\n31\n33\n34\n35\n36\n37\n38\n39\n40\n41\n43\n44\n45\n46\n47\n48\n49\n50\n51\n53\n54\n55\n56\n57\n58\n59\n60\n61\n63\n64\n65\n66\n67\n68\n69\n70\n71\n73\n74\n75\n76\n77\n78\n79\n80\n81\n83\n84\n85\n86\n87\n88\n89\n90\n91\n93\n94\n95\n96\n97\n98\n99\n100 is waiting at Writer's Depot.Go to Writer's Depot:w 1 l 2 r 1 l 2 l.Pickup a passenger going to Post Office.Go to Post Office:n 1 r 2 r 1 l.

Try it online!


Mathematica, 16 bytes

Range@##⋃{#2}&

An unnamed function that takes two integers and a rational number and returns a list of numbers, e.g.:

Range@##⋃{#2}&[-2, 3, 1/2]
(* {-2, -(3/2), -1, -(1/2), 0, 1/2, 1, 3/2, 2, 5/2, 3} *)

Mathematica's Range does exactly what the challenge asks, except that it omits the upper bound if the difference between lower and upper bound isn't exactly a multiple of the step size. Therefore we take the Union (using ⋃) with the list containing only the upper bound which ensures that it appears exactly once. Note that Union will sort the result but we want it sorted anyway, since the step size is always positive. Also since we're working with rationals, they're automatically reduced as much as possible.


Japt, 2 bytes
I feel I must be missing something ...
sC

Try it


Lossless English language text compression challenge

Perl 5, 3651284

Just a simple word-based dictionary scheme. Analyzes the word frequency of
the corpus, and uses that to determine whether to use one or two bytes of
overhead per word. Uses two special symbols for the bytes \0 and \1 since
they do not appear in the corpus. There are plenty of other symbols that
could be used. This was not done. Does not do any huffman encoding or any
of that jazz.

Compression script shakespeare.pl:

use strict;
use warnings;
use bytes;

my $text = join "", <>;
my @words = split/([^a-zA-Z0-9]+)/, $text;

my %charfreq;
for( my $i = 0; $i<length($text); ++$i ) {
    $charfreq{ substr($text, $i, 1) }++
}
for my $i ( 0..255 ) {
    my $c = chr($i);
    my $cnt = $charfreq{$c} // 0;
}

my %word_freq;
foreach my $word ( @words ) {
    $word_freq{ $word }++;
}

my $cnt = 0;
my ( @dict, %rdict );
foreach my $word ( sort { $word_freq{$b} <=> $word_freq{$a} || $b cmp $a } keys %word_freq ) {
    last if $word_freq{ $word } == 1;

    my $repl_length = $cnt < 127 ? 2 : 3;
    if( length( $word ) > $repl_length ) {
        push @dict, $word;
        $rdict{ $word } = $cnt;
        $cnt++;
    }
}

foreach my $index ( 0..$
    print "$dict[$index]\0";
}
print "\1";

foreach my $word ( @words ) {
    my $index = $rdict{ $word };
    if ( defined $index && $index <= 127 ) {
        print "\0" . chr( $index );
    } elsif ( defined $index ) {
        my $byte1 = $index & 127;
        my $byte2 = $index >> 7;
        print "\1" . chr( $byte2 ) . chr( $byte1 );
    } else {
        print $word;
    }
}

Decompression script deshakespeare.pl:

use strict;
use warnings;
use bytes;

local $/;
my $compressed = <>;
my $text = $compressed;
$text =~ s/^.+?\x{1}//ms;
my $dictionary = $compressed;
$dictionary =~ s/\x{1}.*$//ms;

my $cnt = 0;
my @dict;
foreach my $word ( split "\0", $dictionary ) {

    push @dict, $word;
}

my @words = split /(\x{0}.|\x{1}..)/ms, $text;
foreach my $word ( @words ) {
    if( $word =~ /^\x{0}(.)/ms ) {
        print $dict[ ord( $1 ) ];
    } elsif( $word =~ /^\x{1}(.)(.)/ms ) {
        my $byte1 = ord( $1 );
        my $byte2 = ord( $2 );
        my $index = ( $byte1 << 7 ) + $byte2;
        print $dict[ $index ];
    } else {
        print $word;
    }
}

Run using:

perl shakespeare.pl < pg100.txt >pg100.txt.compressed
perl deshakespeare.pl <pg100.txt.compressed >pg100.txt.restored
diff pg100.txt pg100.txt.restored


JavaScript (ES6), 28 25 bytes
Saved 3 bytes thanks to @Shaggy

a=>a.filter(n=>~-a<(a=n))

Try it online!


Python 3, 121 120 108 bytes
Inspired by @Enzo's answer, this works very similarly, except it encodes using a bytestring instead of an integer in base 36. Thanks also to @xnor for shaving 12 bytes off.
Each character in the encoding is equal to chr(' |\\=_¯\n'.index(c) + 7*n + 28) where a symbol c should be repeated n times; the + 28 is just so it's in the printable ASCII range. The last repetition is encoded as ¯ 8 times twice, instead of ¯ 16 times, for the same reason.
for x in b'T,)b,)?%&8,)M%&8,)[%&1,)i%-*,)86M%-)MD)1Q*=)b<)$#t#$)$~$)YY':print(end=' |\=_¯\n'[x%7]*(x//7-4))

Try it online!


Python 2, 76 bytes

c=lambda*a:cmp(*[[(max(i-x,-1),x)for i,x in enumerate(L)]+[(0,)]for L in a])

This replaces each integer in both lists with a 2-tuple to account for the twisted ordering. Python 2's cmp builtin does the rest.

Usage:

>>> c([1,2,1,1,6], [1,2,1,1,7])
-1


Mathematica - 20 30 chars

Just the sorting part

SortBy[%, ArcTan @@ # &]

Whole testing code, that consists of generating 100 random points and plotting the line

RandomReal[{-10, 10}, {100, 2}];
SortBy[%, ArcTan @@ # &];
ListPlot@% /.
 Point[p_] :> {EdgeForm[Dashed], FaceForm[White], Polygon[p],
   PointSize -> Large, Point[p]}

+26 chars

If you demand proper input/ouput, then

"0 0
 4 4
 0 4
 4 0";
Grid@SortBy[%~ImportString~"Table", ArcTan @@ # &]

+2 chars

Just adding N@

Grid@SortBy[%~ImportString~"Table", ArcTan @@ N @ # &]

because above code works only on real numbers and not on integers due to Mathematica's weird behavior when sorting symbolic expressions

N@Sort[{ArcTan[1], ArcTan[-2]}]
Sort[N@{ArcTan[1], ArcTan[-2]}]

{0.785398, -1.10715}
{-1.10715, 0.785398}

EDIT I just realized if the points are not around the origin it won't work, so it also requires shift to the center of points

SortBy[%, ArcTan @@ N[# - Mean@%] &]


Calculate the probability of getting to the target first (exactly)

Wolfram Language (Mathematica), 25 bytes
$$n! \div \left( \sum ^n _{k=0}  k!(n-k)! \right)$$
#!/Sum[k!(#-k)!,{k,0,#}]&

Try it online!
-4 bytes from @ovs


How Many Guineas in a Gross of Threepennies?

Ruby, 345 306 302 288 287 278 273 253 252 242 232 221 202 190 bytes

f=->s{" !#+/7OďǿȗϟЏ'"[%w{fa fp ^pe|co r..p ^gr x|ta sh|^b fl|b f.c ^c f.s .gu d|v ^g .}.index{|k|s[/#{k}/]}].ord-31}
$><<gets.sub(/ (.+ i)n /){" #{r=$1}s %0.4f ".%$`.to_f/f[$']*f[r]}

Takes input from STDIN and prints to STDOUT.

I'm using short regular expressions to match only the desired denominations for each value. There are two arrays, one with regexes and one with values, at corresponding indices. The regex array is a space delimited array literal, and the value array is packed into a string of UTF-8 characters.

I'm selecting the index into the values by searching for a regex that matches each denomination. I'm also defaulting to the tuppence/half-groat case (value 8), because that required the longest regex. Likewise, some of the patterns assume that other values have already been matched by earlier patterns, so each regex only distinguishes the desired value only from the remaining ones. Using this, I could probably shave off another couple of bytes by rearranging the order of the denominations.

Thanks to Ventero for helping me beat Pyth making it shorter!


Write a "Look-and-Say Numbers" generator

Mathematica, 68 bytes

There's no STDIN in Mathematica, so here is a function instead

s=FromDigits/@NestList[Flatten[Reverse@@@Tally/@Split[#]]&,{1},#-1]&

Usage:

s[5]

> {1, 11, 21, 1211, 111221}


Matlab, 120 111 bytes
function f=c(f);c=@(x,i)conv2(x+0,ones(i),'s');a=c(f<34,3);for k=f;a=c(a&f<65,3)|a;a=c(a&f>99,5)|a;end;f(a)='-'

Convolution is the key to success.

The idea is following: Find the active bomb. Enlarge this area to a 3x3 square. Find new affected bombs, enlarge the correspoding areas to the corresponding size and add those to the previously destroyed area. Repeat this enough times (in my case as many times as we have input characters, just because that is the shortest variant) to be sure that we reached a stationary point (=no more exploding bombs). Then set all the destroyed area to - and display the result.
The input is assumed to be a matrix of characters, e.g.
['!XXXXXXXX';
'X@XXXXXXX';
'XX@XXXXXX';
'XXX@XXXXX';
'XXXX@XXXX';
'XXXXX@XXX';
'XXXXXX@XX';
'XXXXXXX@X';
'XXXXXXXX@'];


Probability of something happening at least n out of m times

Mathematica, 29 bytes

BetaRegularized[#3,#,1+#2-#]&

Takes input in the order n,m,p. Mathematica is so good, it even golfs your code for you:

BetaRegularized is the regularised incomplete beta function.


Brachylog, 21 bytes

:1fz:da|,[]
:2a#d
:Am

Try it online!

Try it online!

Predicate 0 (main predicate)

:1fz:da|,[]
:1f            Find all solutions of Predicate 1 using Input as Input.
   z           Transpose
    :da        Deduplicate each.
       |,[]    If there is no solution, return [] instead.

Predicate 1 (auxiliary predicate 1)

:2a#d
:2a     Each element of Output satisfies Predicate 2 with each element of Input as Input
   #d   Each element is different

Predicate 2 (auxiliary predicate 2)

:Am     Output is member of Input


JavaScript (ES7), 31 bytes

A direct formula. Returns 0 if there's no solution.

v=>(r=(1+8*v**.5)**.5)%1?0:r>>1

Try it online!

How?

The sum \$S_n\$ of the first \$n\$ cubes is given by:

$$S_n = \left(\frac{n(n+1)}{2}\right)^2 = \left(\frac{n^2+n}{2}\right)^2$$

(This is A000537. This formula can easily be proved by induction. Here is a nice graphical representation of \$S_5\$.)

Reciprocally, if \$v\$ is the sum of the first \$x\$ cubes, the following equation admits a positive, integer solution:

$$\left(\frac{x^2+x}{2}\right)^2=v$$

Because \$(x^2+x)/2\$ is positive, this leads to:

$$x^2+x-2\sqrt{v}=0$$

Whose positive solution is given by:

$$\Delta=1+8\sqrt{v}\\
x=\frac{-1+\sqrt{\Delta}}{2}
$$

If \$r=\sqrt{\Delta}\$ is an integer, it is guaranteed to be an odd one, because \$\Delta\$ itself is odd. Therefore, the solution can be expressed as:

$$x=\left\lfloor\frac{r}{2}\right\rfloor$$

Commented

v =>                    // v = input
  ( r =                 //
    (1 + 8 * v ** .5)   // delta = 1 + 8.sqrt(v)
    ** .5               // r = sqrt(delta)
  ) % 1 ?               // if r is not an integer:
    0                   //   return 0
  :                     // else:
    r >> 1              //   return floor(r / 2)

Recursive version, 36 35 bytes

Returns NaN if there's no solution.

f=(v,k=1)=>v>0?1+f(v-k**3,k+1):0/!v

Try it online!

Commented

f = (v,                   // v = input
        k = 1) =>         // k = current value to cube
  v > 0 ?                 // if v is still positive:
    1 +                   //   add 1 to the final result
    f(                    //   do a recursive call with:
      v - k ** 3,         //     the current cube subtracted from v
      k + 1               //     the next value to cube
    )                     //   end of recursive call
  :                       // else:
    0 / !v                //   add either 0/1 = 0 if v is zero, or 0/0 = NaN if v is
                          //   non-zero (i.e. negative); NaN will propagate all the
                          //   way to the final output


Pyth, 31 30 29 bytes

e+0f.x!sgM.:iVczdT2ZosN^STlcz

1 byte thanks to @Jakube.

Demonstration. Test Harness.

Input is given on STDIN, space separated. If newline separated input is allowed, I can shorten the program by 2 bytes.

Explanation:

e+0f.x!sgM.:iVczdT2ZosN^STlcz
                                  Implicit: z = input(), T = 10, Z = 0, d = ' '
                        ST        [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
                          lcz     len(z.split())
                       ^          All combinations w/replacement of that length.
                    osN           Order by increasing sum.
   f                              Filter on
              czd                 z.split(' ')
            iV   T                Vectorize the "Convert to base" operation over
                                  the integers as strings and the base sequence.
          .:      2               Take length 2 subsequences.
        gM                        Map the >= operation over them.
      !s                          Sum and logically negate.
    .x             Z              If that throws an error, returns 0 (e.g. reject)
 +0                               Prepend a 0, in case no sequences are found.
e                                 Take the end of the list.

Including 1 in the list of possible bases is safe because i, which uses Python's int builtin, doesn't allow 1 as a base, and therefore always throws an error, which is caught and filtered out.


05AB1E, 31 26 19 bytes
…\/_ŽW ç«ÀIÅP¦4%üeè

-5 bytes by taking inspiration from @HyperNeutrino's Jelly answer.
-7 bytes thanks to @Grimmy.
Outputs as a list of characters.
Try it online (the J in the footer is to join the list together to pretty-print it).
Explanation:

…\/_                 # Push the string "\/_"
    ŽW               # Push compressed integer 8254
       ç             # Convert it to a character with this codepoint: "‾"
        «            # Append it to the earlier string: "\/_‾"
         À           # And rotate it once to the left: "/_‾\"
          IÅP        # Push a list of all primes <= the input-integer
                     #  i.e. 50 → [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47]
             ¦       # Remove the first value
                     #  → [3,5,7,11,13,17,19,23,29,31,37,41,43,47]
              4%     # Take modulo-4 on each value
                     #  → [3,1,3,3,1,1,3,3,1,3,1,1,3,3]
                ü    # For each overlapping pair:
                     #  → [[3,1],[1,3],[3,3],[3,1],[1,1],[1,3],[3,3],[3,1],[1,3],[3,1],[1,1],[1,3],[3,3]]
                 e   #  Get the number of permutations; short for ⌊a!/|a-b|!⌋
                     #   → [3,0,6,3,1,0,6,3,0,3,1,0,6]
                  è  # And index each into the earlier created string
                     # (0-based and with wraparound, so the 6 is index 2 in this case)
                     #  → ["\","/","‾","\","_","/","‾","\","/","\","_","/","‾"]
                     # (after which the result is output implicitly as result)

See this 05AB1E tip of mine (section How to compress large integer?) to understand why ŽW  is 8254.


ASCII topology pt 1: Can I count on you?

SnakeEx - 98 bytes with Javascript, 44 without

This looked like a good problem to try my language from the Fortnightly Challenge on:

m:({e<>PE}\-[|\-]*<T>\+|[|\-]*<T>)+`\+
e:\+

The best place to try this out is my online interpreter.

SnakeEx matches patterns in text by using "snakes" that move around the text matching regexes. The code reads kind of like a regex, except:

The <T> instruction. That is a direction command that branches the snake left and right from its current direction.
{e<>PE} is like a subroutine call. It that spawns a snake with definition e moving forward (<>) and with parameters P (piggyback - the spawning snake follows the new snake) and E (exclusive - don't match anything that's already been matched). This exclusive check is the only thing that stops the snake from looping infinitely.
The prefix ` at the end indicates that what follows should be matched only if it has already been matched, which we can use to force the loop to close.

Because SnakeEx is like regex and doesn't technically output the results as desired by itself, I guess we need to wrap it in some Javascript calling the interpreter:

function e(s){return snakeEx.run('m:({e<>PE}\\-[|\\-]*<T>\\+|[|\\-]*<T>)+`\\+\ne:\\+',s,1).length}

Edit: fixed it up to work with blutorange's additional test cases


Python 3, Score of 5 Tweets (242 spare, counting P0)

-19 bytes thanks to Jonathan Allan!

The spare count does not take into account newlines from between tweets.

Tweet 1 (Declaration, 12 bytes)

python3 t.py

Tweet 2 (70 bytes)

import msvcrt as m,os;f=c=s=0;a=34636833;r=range;p=1<<32;t=30
while 1:

Tweet 3 (129 bytes)

 if m.kbhit()and b"\xe0"==m.getch():p=[p>>(not(a|f<<1)&p),p,p<<(not(a<<4|f>>1)&p),p>>5-5*(bool(f&p>>5)or p<t)][ord(m.getch())-77]

Tweet 4 (113 bytes)

 c+=1;print("\n".join("".join(".#"[1&(f|p)>>i*5+j]for j in r(5))for i in r(6))[::-1]);os.system("cls")
 if c%t<1:

Tweet 5 (134 bytes)

  if f&p>>5or p<t:s=~s;f|=p;p=2-s<<26
  else:p>>=5
 for i in r(0,t,5):
  if f|31<<i==f:b=bin(f)[2:].zfill(t);f=int(b[:-i-5]+b[t-i:],2)

Full Program (449 bytes)

import msvcrt as m,os;f=c=s=0;a=34636833;r=range;p=1<<32;t=30
while 1:
 if m.kbhit()and b"\xe0"==m.getch():p=[p>>(not(a|f<<1)&p),p,p<<(not(a<<4|f>>1)&p),p>>5-5*(bool(f&p>>5)or p<t)][ord(m.getch())-77]
 c+=1;print("\n".join("".join(".#"[1&(f|p)>>i*5+j]for j in r(5))for i in r(6))[::-1]);os.system("cls")
 if c%t<1:
  if f&p>>5or p<t:s=~s;f|=p;p=2-s<<26
  else:p>>=5
 for i in r(0,t,5):
  if f|31<<i==f:b=bin(f)[2:].zfill(t);f=int(b[:-i-5]+b[t-i:],2)

Does some evil bit point hacking and stores the field and piece in two integers. I'll try and post an explanation soon.

Note: This only runs on Windows, but it could be switched to Linux through msvcrt → getch and "cls" → "clear". Additionally, character input doesn't work on Python's IDLE, so I'd recommend running it elsewhere.


Raise integer x to power x, without exponentiation built-ins

Python, 25 bytes

lambda n:eval('1'+'*n'*n)

Try it online!


Whitespace

A rhyming program I	wrote

this poem of whitespace and bloat

because newlines don't count

despite the amount

so deserves your sincerest upvote

Wikipedia: Whitespace (programming language)
Online Interpreter to Test Answer

Output:

Hello World


CJam, 25 23 bytes

{`"_~"+{"#$_+~`"`#}$}_~

Thanks to @MartinBüttner for golfing off 2 bytes!

Try it online!

How it works

{                   }_~  Define, copy and execute a code block.

   `                       Create a string representation of the code block.
  "_~"+                    Append that string.
       {          }$       Sort the characters by the following:
        "#$_+~`"`#           Compute the 0-based index of the character in that
                             string. Returns -1 if not found.
                           Since `$' is stable, all characters with tied index -1
                           will appear at the beginning, in their original order.
                           This places {{}} at the beginning, followed by
                           """"##$$___++~~~```.


Fortran 90

I employ the CORDIC method with a pre-tabulated array of 60 arctan values (see Wiki article for details on why that's necessary).

This code requires a file, trig.in, with all the values on newlines to be stored in the same folder as the Fortran executable. Compiling this is,

gfortran -O3 -o file file.f90

where file is whatever filename you give it (probably SinCosTan.f90 would be easiest, though it's not necessary to match program name and file name). If you have the Intel compiler, I'd recommend using

ifort -O3 -xHost -o file file.f90

as the -xHost (which doesn't exist for gfortran) provides higher level optimizations available to your processor.

My test runs were giving me about 10 microseconds per calculation when testing 1000 random angles using gfortran 4.4 (4.7 or 4.8 is available in the Ubuntu repos) and around 9.5 microseconds using ifort 12.1. Testing only 10 random angles will result in an indeterminable time using Fortran routines, as the timing routine is accurate to the millisecond and simple math says it should take 0.100 milliseconds to run all 10 numbers.

EDIT Apparently I was timing IO which (a) made the timing longer than necessary and (b) is contrary to bullet #6. I've updated the code to reflect this. I've also discovered that using a kind=8 integer with the intrinsic subroutine system_clock gives microsecond accuracy.

With this updated code, I am now computing each set of values of the trigonometric functions in about 0.3 microseconds (the significant digits in the end vary run-to-run, but it's consistently hovering near 0.31 us), a significant reduction from the previous iteration that timed IO.

program SinCosTan
   implicit none
   integer, parameter :: real64 = selected_real_kind(15,307)
   real(real64), parameter :: PI  = 3.1415926535897932384626433832795028842
   real(real64), parameter :: TAU = 6.2831853071795864769252867665590057684
   real(real64), parameter :: half = 0.500000000000000000000_real64
   real(real64), allocatable :: trigs(:,:), angles(:)
   real(real64) :: time(2), times, b
   character(len=12) :: tout
   integer :: i,j,ierr,amax
   integer(kind=8) :: cnt(2)

   open(unit=10,file='trig.out',status='replace')
   open(unit=12,file='CodeGolf/trig.in',status='old')
! check to see how many angles there are
   i=0
   do
      read(12,*,iostat=ierr) b
      if(ierr/=0) exit
      i=i+1
   enddo !-
   print '(a,i0,a)',"There are ",i," angles"
   amax = i

! allocate array
   allocate(trigs(3,amax),angles(amax))

! rewind the file then read the angles into the array
   rewind(12)
   do i=1,amax
      read(12,*) angles(i)
   enddo !- i

! compute trig functions & time it
   times = 0.0_real64
   call system_clock(cnt(1)) ! <-- system_clock with an 8-bit INT can time to us
   do i=1,amax
      call CORDIC(angles(i), trigs(:,i), 40)
   enddo !- i
   call system_clock(cnt(2))
   times = times + (cnt(2) - cnt(1))

! write the angles to the file
   do i=1,amax
      do j=1,3
         if(trigs(j,i) > 1d100) then
            write(tout,'(a1)') 'n'
         elseif(abs(trigs(j,i)) > 1.0) then
            write(tout,'(f10.6)') trigs(j,i)
         elseif(abs(trigs(j,i)) < 0.1) then
            write(tout,'(f10.8)') trigs(j,i)
         else
            write(tout,'(f9.7)') trigs(j,i)
         endif
         write(10,'(a)',advance='no') tout
      enddo !- j
      write(10,*)" "
   enddo !- i

   print *,"computation took",times/real(i,real64),"us per angle"
   close(10); close(12)
 contains
   !> @brief compute sine/cosine/tangent
   subroutine CORDIC(a,t,n)
     real(real64), intent(in) :: a
     real(real64), intent(inout) :: t(3)
     integer, intent(in) :: n
! local variables
     real(real64), parameter :: deg2rad = 1.745329252e-2
     real(real64), parameter :: angles(60) = &
       [ 7.8539816339744830962e-01_real64, 4.6364760900080611621e-01_real64, &
         2.4497866312686415417e-01_real64, 1.2435499454676143503e-01_real64, &
         6.2418809995957348474e-02_real64, 3.1239833430268276254e-02_real64, &
         1.5623728620476830803e-02_real64, 7.8123410601011112965e-03_real64, &
         3.9062301319669718276e-03_real64, 1.9531225164788186851e-03_real64, &
         9.7656218955931943040e-04_real64, 4.8828121119489827547e-04_real64, &
         2.4414062014936176402e-04_real64, 1.2207031189367020424e-04_real64, &
         6.1035156174208775022e-05_real64, 3.0517578115526096862e-05_real64, &
         1.5258789061315762107e-05_real64, 7.6293945311019702634e-06_real64, &
         3.8146972656064962829e-06_real64, 1.9073486328101870354e-06_real64, &
         9.5367431640596087942e-07_real64, 4.7683715820308885993e-07_real64, &
         2.3841857910155798249e-07_real64, 1.1920928955078068531e-07_real64, &
         5.9604644775390554414e-08_real64, 2.9802322387695303677e-08_real64, &
         1.4901161193847655147e-08_real64, 7.4505805969238279871e-09_real64, &
         3.7252902984619140453e-09_real64, 1.8626451492309570291e-09_real64, &
         9.3132257461547851536e-10_real64, 4.6566128730773925778e-10_real64, &
         2.3283064365386962890e-10_real64, 1.1641532182693481445e-10_real64, &
         5.8207660913467407226e-11_real64, 2.9103830456733703613e-11_real64, &
         1.4551915228366851807e-11_real64, 7.2759576141834259033e-12_real64, &
         3.6379788070917129517e-12_real64, 1.8189894035458564758e-12_real64, &
         9.0949470177292823792e-13_real64, 4.5474735088646411896e-13_real64, &
         2.2737367544323205948e-13_real64, 1.1368683772161602974e-13_real64, &
         5.6843418860808014870e-14_real64, 2.8421709430404007435e-14_real64, &
         1.4210854715202003717e-14_real64, 7.1054273576010018587e-15_real64, &
         3.5527136788005009294e-15_real64, 1.7763568394002504647e-15_real64, &
         8.8817841970012523234e-16_real64, 4.4408920985006261617e-16_real64, &
         2.2204460492503130808e-16_real64, 1.1102230246251565404e-16_real64, &
         5.5511151231257827021e-17_real64, 2.7755575615628913511e-17_real64, &
         1.3877787807814456755e-17_real64, 6.9388939039072283776e-18_real64, &
         3.4694469519536141888e-18_real64, 1.7347234759768070944e-18_real64]
     real(real64), parameter :: kvalues(33) = &
       [ 0.70710678118654752440e+00_real64, 0.63245553203367586640e+00_real64, &
         0.61357199107789634961e+00_real64, 0.60883391251775242102e+00_real64, &
         0.60764825625616820093e+00_real64, 0.60735177014129595905e+00_real64, &
         0.60727764409352599905e+00_real64, 0.60725911229889273006e+00_real64, &
         0.60725447933256232972e+00_real64, 0.60725332108987516334e+00_real64, &
         0.60725303152913433540e+00_real64, 0.60725295913894481363e+00_real64, &
         0.60725294104139716351e+00_real64, 0.60725293651701023413e+00_real64, &
         0.60725293538591350073e+00_real64, 0.60725293510313931731e+00_real64, &
         0.60725293503244577146e+00_real64, 0.60725293501477238499e+00_real64, &
         0.60725293501035403837e+00_real64, 0.60725293500924945172e+00_real64, &
         0.60725293500897330506e+00_real64, 0.60725293500890426839e+00_real64, &
         0.60725293500888700922e+00_real64, 0.60725293500888269443e+00_real64, &
         0.60725293500888161574e+00_real64, 0.60725293500888134606e+00_real64, &
         0.60725293500888127864e+00_real64, 0.60725293500888126179e+00_real64, &
         0.60725293500888125757e+00_real64, 0.60725293500888125652e+00_real64, &
         0.60725293500888125626e+00_real64, 0.60725293500888125619e+00_real64, &
         0.60725293500888125617e+00_real64 ]
    real(real64) :: beta, c, c2, factor, poweroftwo, s
    real(real64) :: s2, sigma, sign_factor, theta, angle
    integer :: j

! scale to radians
    beta = a*deg2rad
! ensure angle is shifted to appropriate range
    call angleShift(beta, -PI, theta)
! check for signs
    if( theta < -half*PI) then
       theta = theta + PI
       sign_factor = -1.0_real64
    else if( half*PI < theta) then
       theta = theta - PI
       sign_factor = -1.0_real64
    else
       sign_factor = +1.0_real64
    endif

! set up some initializations...
    c = 1.0_real64
    s = 0.0_real64
    poweroftwo = 1.0_real64
    angle = angles(1)

! run for 30 iterations (should be good enough, need testing)
    do j=1,n
       sigma = merge(-1.0_real64, +1.0_real64, theta <  0.0_real64)
       factor = sigma*poweroftwo

       c2 = c - factor*s
       s2 = factor*c + s
       c = c2
       s = s2
! update remaining angle
       theta = theta - sigma*angle

       poweroftwo = poweroftwo*0.5_real64
       if(j+1 > 60) then
          angle = angle * 0.5_real64
       else
          angle = angles(j+1)
       endif
    enddo !- j

    if(n > 0) then
       c = c*Kvalues(min(n,33))
       s = s*Kvalues(min(n,33))
    endif
    c = c*sign_factor
    s = s*sign_factor

    t = [s, c, s/c]
   end subroutine CORDIC

   subroutine angleShift(alpha, beta, gamma)
     real(real64), intent(in) :: alpha, beta
     real(real64), intent(out) :: gamma
     if(alpha < beta) then
        gamma = beta - mod(beta - alpha, TAU) + TAU
     else
        gamma = beta + mod(alpha - beta, TAU)
     endif
   end subroutine angleShift

end program SinCosTan


K (ngn/k), 8 bytes

|\'2'+!:

Try it online!

this is a composition equivalent to the lambda {|\'2'+!x}. the trailing : forces ! (and therefore the whole composition) to be monadic.

 !2 3         /odometer
(0 0 0 1 1 1
 0 1 2 0 1 2)
 +!2 3        /flip
(0 0
 0 1
 0 2
 1 0
 1 1
 1 2)
 2'+!2 3      /pairs (sliding window size 2)
((0 0;0 1)
 (0 1;0 2)
 (0 2;1 0)
 (1 0;1 1)
 (1 1;1 2))
 |\'2'+!2 3   /cumulative(\) max(|) each(')
((0 0;0 1)
 (0 1;0 2)
 (0 2;1 2)
 (1 0;1 1)
 (1 1;1 2))


Tile the plane with this modified circle

POV-Ray, 199 163
Old version
camera{location -9*z}light_source{-9*z}#declare L=union{#for(X,-9,9,2)#for(Y,-9,9,2)cylinder{X*x+x+Y*y,<.001*pow(-1,(X+Y)/2),0,.1>+X*x+x+Y*y,1}#end#end}object{L pigment{color x}}object{L rotate z*90}

Same output, but golfed down further by using default light/camera, so I dont even need to specify them
#declare L=union{#for(X,-9,9,2)#for(Y,-9,9,2)cylinder{<X+1,Y,9>,<.001*pow(-1,(X+Y)/2),0,.1>+<X+1,Y,9>,1}#end#end}object{L pigment{color rgb x}rotate z*90}object{L}

I am using as many default parameters for camera and lightsource as possible, thats why it is a little dark. Lets ungolf it first
camera{location 9*z look_at 0}
light_source{9*z color 1}
#declare L=union{
    #for(X,-9,9,2)
        #for(Y,-9,9,2)
            cylinder{<1+X,Y,0>,                                 //central axis, start
                     <1+X,Y,0> + <.001*pow(-1,(X+Y)/2), 0, .1>, //central axis, end
                      1}                                        //radius
        #end
    #end
}
object{L pigment{color x}} // x is the <1,0,0> vector, here interpreted as RGB
object{L rotate<0,0,90>}

It is obvious what is happening once we increase the offset of the cylinder axis and change the perspective


Befunge-93 (FBBI) / C (tcc), 93 + 62 = 155 bytes

^"
>#001p#"<>:#,_@#1-8*3:-1*57+55-1*79*57:-1:*77**278\-1:*57$p:1: error: declaration expected

Try it online!: Befunge-93, C

Thanks to randomdude999 for noting that the filename requires matching quotes to work.

Must be saved under the filename ^"\n>#001p#"<>:#,_@#1-8*3:-1*57+55-1*79*57:-1:*77**278\-1:*57$p, where \n is a newline. Because of this, the TIO for C doesn't run exactly as intended. Tested to work on Lubuntu.

Explanation (C):

The program fails to compile, and tcc happily outputs the name of the file as part of its error message. There are multiple compilation errors you can get, based on the beginning of the code. ^ at the start gives us a declaration expected, which is short and doesn't contain any problematic characters like ". On the other hand, the gcc and clang developers are very pessimistic and they chose to output multiple errors at once, which is not very nice, so we aren't using their compilers.

Explanation (Befunge-93):

Befunge is convenient for quines in that its code can also be utilised as character data, thanks to the " command, which toggles string mode. At the beginning, we perform some useless stack operations, then issue a p (put command) which places a NUL character at (0, 1). Then we reflect the instruction pointer to the left and begin reading everything as a string. This has to be done to the left, because of the stack's LIFO nature. After wrapping around and reaching the " character again, the string ends. Note that the NUL character replaced the $ character, creating a delimiter midway through the string. We then push 3 numbers onto the stack and jump over the NUL (because it unfortunately hangs the interpreter when run as an instruction). The static part of the error message has to be executed here. Most of its characters are no-ops, but the p command consumes three arguments (hence why we pushed 3 numbers, otherwise part of the string would be eaten here), and : & 1 characters push a total of 4 values to the stack, which we counteract with a p and a $ (pop and discard) instruction. Then, some arithmetic is performed to push the ASCII codes for ^"\n>#001p#" and finally a loop prints out all the values on the stack as characters until it finds a NUL character and terminates.


Perl, 58 bytes

Added +2 for -lp

Give input on STDIN, run as perl -lp wordcloud.pl

wordcloud.pl:

s/\w+/$l|=$a[pos]|=$"x~-$..$&/eg}for(@a){$_|=$l=~y// /cr


05AB1E, 6 bytes

Σ.L(}¤

Try it online! (note: the trailing newline on the input is necessary for the empty string case.)

How?

Σ.L(}¤ - implicitly push the first input (the dictionary list)
Σ   }  - sort the list by:
       -   implicitly push second input (the misspelled word)
 .L    -   Levenshtein distance
   (   -   negated
     ¤ - tail the sorted list  and place the entry on the top of the stack
       - implicitly print top of stack


Help Mr Jones to enjoy his bicycle round-trip

Haskell, 633 characters

import List
c n=n>>=(++" ").show.(*3)
(x&y)l="<text x='"++c[x]++"' y='"++c[y]++"'>"++l++"</text>"
f%p=[a-1,b+2,(a+b)/2]where n=map(f.fst)p;a=minimum n;b=maximum n
s p=concat["<svg xmlns='http://www.w3.org/2000/svg' viewBox='",c[i,m-1,j,n],"'><polygon fill='none' stroke='#c8c' points='",c$snd=<<(sort$map a p),"'/><g font-size='1' fill='#bbb'>",(\x->(x&m$show x)++(i&x$show x))=<<[floor(i`min`m)..ceiling(j`max`n)],"</g><g font-size='2'>",snd=<<p,"</g></svg>"]where a((x,y),_)=(atan2(x-q)(y-r),[x,y]);[i,j,q,m,n,r]=fst%p++snd%p
w(l,s)=((x,y),(x&y)l)where(x,r)=v s;(y,_)=v r
v=head.reads.tail
main=interact$s.map(w.break(=='(')).lines

Rather longish for code-golf, but produces a lovely SVG map:

Or, if your browser can't handle SVG, a PNG of that image:

Edit: (648 -> 633) in-line coordinate drawing, and possibly draw more than needed, letting them be clipped by the viewBox; also a few golf-tricks here and there.


05AB1E, 16 bytes

05AB1E probably has some sort of slice, but I failed to find it.

∞ʒDSÖß}ʒ0å_}ηs<è

Try it online!

Explanation

∞                [1, 2, 3, ...]
 ʒ               Filter all that satisfies:
  DS                 its DigitS
    Ö                is divisible
     ß}              ßy the original number.
       ʒ         Filter out ^ that satisfies:
        0å_}         0 is å digit of the output.
            ηs<è Trunctuatè by the input.


Write a panic script to remote secure a Mac Pro from an untrustworthy local user

The panic script should be sent to remote machine (Mac Pro) using scp, and then run (no sudo or any input required):

Here is the script: (this assumes that you are John Smith)

#!/bin/bash -m
f() {
 while true
 do
  pmset displaysleepnow
  sleep 0.1
 done
}
f&
while true
do
 osascript -e "set Volume 10"
 say -v Ralph "Stop Shady Sam now. He is trying to do something he is not allowed to."
 for n in {1..10};
 do
  afplay /System/Library/PrivateFrameworks/ScreenReader.framework/Versions/A/Resources/Sounds/Hit.aiff
  sleep 0.05
 done
 sleep 0.1
 say -v Ralph "This is John Smith speaking."
done

For maximum effiency, you should run this on every single machine in room to ensure that everybody will notice the problem and stop him.


bash, vim and dc (343)
I'm sitting at a bash prompt which has been configured by the Evil Genius, and of course he has VISUAL=vim in the default environment. Using the default bash binding for edit-and-execute-command (C-x C-e) bash invokes $VISUAL and will execute its buffer contents on exit (ZZ). I type in the following sequence (Note: kbd-mode are commands issued in normal mode and control sequences):

C-xC-e

acat<<<45C-c4C-aaa
Now the vim buffer contains cat<<<49a. Continuing ...

45C-c3C-aaa

54C-c41C-aaa

55C-c13C-aaa
Now the vim buffer contains cat<<<49a48a95a68a. Continuing ...

51C-c31C-aaa

55C-c24C-aaa

44C-c43C-aaa

42C-c41C-aaa

42C-c41C-aaa

54C-c11C-aaa

55C-c25C-aaa>s
Now the vim buffer contains cat<<<49a48a95a68a82a79a87a83a83a65a80a>s
Get out of insert mode, save and exit

C-cZZ
The s file now contains a dc script that generates the desired string on the stack, now we need to add print commands.

C-xC-eadc<<<55C-c25C-aaa>>sC-cZZ
Repeat the above command 9 times.

C-xC-eadc<<<55C-c25C-aaa>>sC-cZZ

C-xC-eadc<<<55C-c25C-aaa>>sC-cZZ

C-xC-eadc<<<55C-c25C-aaa>>sC-cZZ

C-xC-eadc<<<55C-c25C-aaa>>sC-cZZ

C-xC-eadc<<<55C-c25C-aaa>>sC-cZZ

C-xC-eadc<<<55C-c25C-aaa>>sC-cZZ

C-xC-eadc<<<55C-c25C-aaa>>sC-cZZ

C-xC-eadc<<<55C-c25C-aaa>>sC-cZZ

C-xC-eadc<<<55C-c25C-aaa>>sC-cZZ

C-xC-eacat<<< f >>s
Execute the dc script:

C-xC-eadc sC-cZZ

Output:
PASSWORD_01

Contents of the s file:
49a48a95a68a82a79a87a83a83a65a80a
P
P
P
P
P
P
P
P
P
P
f


Python 3, 67 65 42 bytes

Uses the fact that the sum of an empty array is 0

lambda x,y:[sum(x[i::y])for i in range(y)]

Try it online!


MATL, score 65.30697
tYmhZs

Try it online! Or verify all test cases.
How it works
The built-in function Zs with its default arity (1 input, 1 output) computes the corrected standard deviation:
\$\sqrt{\frac 1 {n-1}\sum (x_i-\bar x)^2}\$
The uncorrected standard deviation can be obtained with the 2-input version of Zs: 1&Zs, where 1 as second input means uncorrected. l or T could be used instead of 1 to reduce the score, but & is very far from the other characters. 2$ or H$ could be used instead of &, but $ is even farther.
So it is better to use the default version of Zs (corrected standard deviation) on the input with its mean appended. This increases the input length by 1 and contributes 0 in the numerator, which causes the corrected standard deviation to become uncorrected.
t     % Implicit input: numeric vector. Duplicate
Ym    % Mean
h     % Concatenate the input vector with its mean
Zs    % Corrected standard deviation


Python code to produce C++14 hex integer literal with ticks

Python 2, 68 65 bytes

-3 bytes for both thanks to tsh

lambda n:"0x"+re.sub("(?!^)(?=(....)+u)","'","%xuLL"%n)
import re

Try it online!

Eligible for both bonuses, 76 73 bytes

lambda x,d:"0x"+re.sub("(?!^)(?=(....)+u)","'","%%0%dxuLL"%d%x)
import re

Try it online!


CJam, 42 41 39 38 bytes

q~,]:T(\-2=),>{IST2/z~\{I<!}#=,',S}fI&

Try it online in the CJam interpreter.


Sledgehammer, 67 66 26 bytes
-40 bytes thanks to @GregMartin and I also no longer have any idea about how my answer works
Completes in less than a few seconds!
⡇⣄⠀⠇⣺⠇⢞⡞⣵⣍⠪⢺⡇⠜⢂⡒⢃⠦⠲⣎⠇⠣⡔⢻⡦⠔

Mathematica code:
Floor[Divide[25194541,184119152] * (NumberFieldFundamentalUnits@Sqrt[4729494])^4658]

(the reason for the Divide is that by default Mathematica represents x/y as x * y^-1, which is half a byte longer in Sledgehammer).