Where does the laser go? Take a 2-dimensional grid and draw a number of line segments on it to represent mirrors. Now pick a point to place a theoretical laser and an angle to define the direction it's pointing. The question is: if your follow the laser beam path for some specified distance, what coordinate point are you at?
Example:

In this image, L is the location of the laser, t is it's angle (measured from the positive X axis), M1, M2, and M3 are all line segment mirrors, and E is the point on the laser beam path after D = d1 + d2 + d3 + d4 units, starting from L.
Goal
Write the shortest program (in bytes) that outputs E given L, t, D, and a list of mirrors.
(Use http://mothereff.in/byte-counter to count bytes.)
Input Format
Input will come from stdin in the format:
Lx Ly t D M1x1 M1y1 M1x2 M1y2 M2x1 M2y1 M2x2 M2y2 ...

All the values will be floating points matching this regex: [-+]?[0-9]*\.?[0-9]+.
There is always exactly one space between each number.
Requiring quotes around the input is allowed.
t is in degrees, but not necessarily in the [0, 360) range. (If you prefer you may use radians instead, just say so in your answer.)
D may be negative, effectively rotating the laser 180 degrees. D may also be 0.
There may be arbitrarily many mirrors (including none at all).
The order of the mirrors should not matter.
You may assume the input will come in multiples of 4 numbers. e.g. Lx Ly t or Lx Ly t D M1x1 are invalid and will not be tested. No input at all is also invalid.

The layout above might be input as:
1 1 430 17 4.8 6.3 6.2 5.3 1.5 4.8 3.5 6 6.3 1.8 7.1 3

(Note that the image was drawn freehand and these values are only approximations. Martin Büttner's input values of
1 1 430 17 4.8 5.3 6.2 4.3 1.5 4.8 3.5 6 6.3 1.8 7.1 3

will give more collisions though they do not match the sketch.)
Output Format
Output should go to stdout in the format:
Ex Ey

These are also floats and may be in exponential form.
Notes

Mirrors may intersect each other.
Both sides of mirrors are reflective.
The beam may hit the same mirror many times.
The beam goes on forever.

Undefined Cases
You may assume that the cases where

the laser starts on a mirror line segment
the laser beam hits the endpoint of a mirror
the laser beam hits the intersection between two mirrors

are undefined and will not be tested. Your program may do anything if these occur, including throw an error.
Bonus
Just for fun, I will award 200 bounty points to the highest voted submission that outputs a graphical representation of the problem (you could even write an interactive script). These bonus submission do not need to be golfed and can be lenient with how input and output are handled. They are distinct from the actual golfed submissions but both should be submitted in the same answer.
Note: Only submitting a bonus answer is fine, you just wont be the accepted answer. To be accepted you must exactly follow the input/output spec (e.g. output only involves Ex Ey, not images), and be the shortest.

Ruby, 327 bytes

(scroll to the bottom)

Mathematica, bonus answer

I'm only going for the graphical submission right now. I might port this to Ruby later and golf it if I feel like it.

(* This function tests for an intersection between the laser beam
   and a mirror. r contains the end-points of the laser, s contains
   the end-points of the mirror. *)
intersect[r_, s_] := Module[
   {lr, dr, nr, ds, ns, \[Lambda]},
   (* Get a unit vector in the direction of the beam *)
   dr = r[[2]] - r[[1]];
   lr = Norm@dr;
   dr /= lr;
   (* Get a normal to that vector *)
   nr = {dr[[2]], -dr[[1]]};

   (* The sign of dot product in here depends on whether that end-point
      of the mirror is to the left or to the right of the array. Return
      infinity if both ends of s are on the same side of the beam. *)
   If[Apply[Times, (s - {r[[1]], r[[1]]}).nr] > 0,
    Return[\[Infinity]]];

   (* Get a unit vector along the mirror. *)
   ds = s[[2]] - s[[1]];
   ds /= Norm@ds;
   (* And a normal to that. *)
   ns = {ds[[2]], -ds[[1]]};
   (* We can write the beam as p + λ*dr and mirror as q + μ*ds,
      where λ and μ are real parameters. If we set those equal and
      solve for λ we get the following equation. Since dr is a unit
      vector, λ is also the distance to the intersection. *)
   \[Lambda] = ns.(r[[1]] - s[[1]])/nr.ds;
   (* Make sure that the intersection is before the end of the beam.
      This check could actually be slightly simpler (see Ruby version). *)
   If[\[Lambda] != 0 && lr/\[Lambda] < 1, Infinity, \[Lambda]]
   ];

(* This function actually does the simulation and generates the plot. *)
plotLaser[L_, t_, distance_, M_] := Module[
   {coords, plotRange, points, e, lastSegment, dLeft, \[Lambda], m, p,
     d, md, mn, segments, frames, durations},

   (* This will contain all the intersections along the way, as well
      as the starting point. *)
   points = {L};
   (* The tentative end point. *)
   e = L + distance {Cos@t, Sin@t};
   (* This will always be the currently last segment for which we need
      to check for intersections. *)
   lastSegment = {L, e};
   (* Keep track of the remaining beam length. *)
   dLeft = distance;

   While[True,
    (* Use the above function to find intersections with all mirrors
       and pick the first one (we add a small tolerance to avoid
       intersections with the most recent mirror). *)
    {\[Lambda], m} =
     DeleteCases[
       SortBy[{intersect[lastSegment, #], #} & /@ M, #[[1]] &],
       i_ /; i[[1]] < 1*^-10][[1]];
    (* If no intersection was found, we're done. *)
    If[\[Lambda] == \[Infinity], Break[]];
    (* Reduce remaining beam length. *)
    dLeft -= \[Lambda];
    (* The following lines reflect the beam at the mirror and add
       the intersection to our list of points. We also update the
       end-point and the last segment. *)
    p = lastSegment[[1]];
    d = -Subtract @@ lastSegment;
    d /= Norm@d;
    md = -Subtract @@ m;
    md /= Norm@md;
    mn = {md[[2]], -md[[1]]};
    AppendTo[points, p + \[Lambda]*d];
    d = -d + 2*(d - d.mn*mn);
    e = Last@points + dLeft*d;
    lastSegment = {Last@points, e};
    ];
   (* Get a list of all points in the set up so we can determine
      the plot range. *)
   coords = Transpose@Join[Flatten[M, 1], {L, e}];
   (* Turn the list of points into a list of segments. *)
   segments = Partition[points, 2, 1];
   (* For each prefix of that list, generate a frame. *)
   frames = Map[
     Graphics[
       {Line /@ M,
        Red,
        Point@L,
        Line /@ segments[[1 ;; #]]},
       PlotRange -> {
         {Min@coords[[1]] - 1, Max@coords[[1]] + 1},
         {Min@coords[[2]] - 1, Max@coords[[2]] + 1}
         }
       ] &,
     Range@Length@segments];
   (* Generate the initial frame, without any segments. *)
   PrependTo[frames,
    Graphics[
     {Line /@ M,
      Red,
      Point@L},
     PlotRange -> {
       {Min@coords[[1]] - 1, Max@coords[[1]] + 1},
       {Min@coords[[2]] - 1, Max@coords[[2]] + 1}
       }
     ]
    ];
   (* Generate the final frame including lastSegment. *)
   AppendTo[frames,
    Graphics[
     {Line /@ M,
      Red,
      Point@L,
      Line /@ segments,
      Line[lastSegment],
      Point@e},
     PlotRange -> {
       {Min@coords[[1]] - 1, Max@coords[[1]] + 1},
       {Min@coords[[2]] - 1, Max@coords[[2]] + 1}
       }
     ]];

   (*Uncomment to only view the final state *)
   (*Last@frames*)

   (* Export the frames as a GIF. *)
   durations = ConstantArray[0.1, Length@frames];
   durations[[-1]] = 1;
   Export["hardcoded/path/to/laser.gif", frames,
    "GIF", {"DisplayDurations" -> durations, ImageSize -> 600}];

   (* Generate a Mathematica animation form the frame. *)
   ListAnimate@frames
   ];

You can call it like

plotLaser[{1, 1}, 7.50492, 95, {
  {{4.8, 5.3}, {6.2, 4.3}}, {{1.5, 4.8}, {3.5, 6}}, {{6.3, 1.8}, {7.1, 3}},
  {{5, 1}, {4, 3}}, {{7, 6}, {5, 6.1}}, {{8.5, 2.965}, {8.4, 2}},
  {{8.5, 3.035}, {8.6, 4}}, {{8.4, 2}, {10.5, 3}}, {{8.6, 4}, {10.5, 3}}
}]

That will give you an animation in Mathematica and also export a GIF (the one at the top for this input). I've slightly extended the OPs example for this, to make it a bit more interesting.

More examples

A tube with slightly diverging walls but a closed end:

plotLaser[{0, 0}, 1.51, 200, {
  {{0, 1}, {20, 1.1}},
  {{0, -1}, {20, -1.1}},
  {{20, 1.1}, {20, -1.1}}
}]

An equilateral triangle and an initial direction that is almost parallel to one of the sides.

plotLaser[{-1, 0}, Pi/3 + .01, 200, {
  {{-2.5, 5 Sqrt[3]/6}, {2.5, 5 Sqrt[3]/6}},
  {{0, -5 Sqrt[3]/3}, {-2.5, 5 Sqrt[3]/6}},
  {{0, -5 Sqrt[3]/3}, {2.5, 5 Sqrt[3]/6}}
}]

One more:

plotLaser[
 {0, 10}, -Pi/2, 145,
 {
   {{-1, 1}, {1, -1}}, {{4.5, -1}, {7.5, Sqrt[3] - 1}},
   {{11, 10}, {13, 10}}, {{16.5, Sqrt[3] - 1}, {19.5, -1}},
   {{23, -1}, {25, 1}}, {{23, 6}, {25, 4}}, {{18, 6}, {20, 4}}, {{18, 9}, {20, 11}},
   {{31, 9}, {31.01, 11}}, {{24.5, 10.01}, {25.52, 11.01}}, {{31, 4}, {31, 6}}, {{25, 4.6}, {26, 5.6}}, {{24.5, 0.5}, {25.5, -0.5}},
   {{31, -1}, {33, 1}}, {{31, 9}, {33, 11}}, {{38, 10.5}, {38.45, 9}}
 }
]

Ruby, golfed answer

x,y,t,p,*m=gets.split.map &:to_f
u=q=Math.cos t
v=r=Math.sin t
loop{k=i=p
u=x+q*p
v=y+r*p
m.each_slice(4){|a,b,c,d|((a-u)*r-(b-v)*q)*((c-u)*r-(d-v)*q)>0?next: g=c-a
h=d-b
l=(h*(x-a)-g*(y-b))/(r*g-q*h)
f=(g*g+h*h)**0.5
t,k,i=g/f,h/f,l if l.abs>1e-9&&l/i<1}
i==p ?abort([u,v]*' '): p-=i
x+=q*i
y+=r*i
n=q*k-r*t
q-=2*n*k
r+=2*n*t}

This is basically a direct translation of the Mathematica solution to Ruby, plus some golfing and making sure it meets the I/O criteria.


Ex-Increasing Set Sequence Background

An ex-increasing set sequence of order \$N\$ is defined as a sequence of integer sets \$S_1,S_2,\cdots,S_n\$ which satisfies the following:

Each \$S_i\$ is a non-empty subset of \$\{1,2,\cdots,N\}\$.
For \$1\le i<n\$, \$S_i \cap S_{i+1} = \varnothing\$, i.e. any two consecutive sets have no elements in common.
For \$1\le i<n\$, the mean (average value) of \$S_i\$ is strictly less than that of \$S_{i+1}\$.

Challenge

Given a positive integer N, output the length of the longest ex-increasing set sequence of order N.

Test cases

These are based on the results by Project Euler user thundre.

1 => 1 // {1}
2 => 2 // {1} {2}
3 => 3 // {1} {2} {3}
4 => 5 // {1} {2} {1,4} {3} {4}
5 => 7 // {1} {2} {1,4} {3} {2,5} {4} {5}
6 => 10 // {1} {2} {1,4} {3} {1,4,5} {2,3,6} {4} {3,6} {5} {6}
7 => 15 // {1} {2} {1,4} {3} {1,2,7} {3,4} {1,2,5,7} {4} {1,3,6,7} {4,5} {1,6,7} {5} {4,7} {6} {7}
8 => 21
9 => 29
10 => 39
11 => 49
12 => 63
13 => 79
14 => 99
15 => 121
16 => 145
17 => 171
18 => 203
19 => 237
20 => 277
21 => 321
22 => 369
23 => 419
24 => 477
25 => 537

Rules

Standard code-golf rules apply. The shortest valid submission in bytes wins.

Bounty

This problem has been discussed here on Project Euler forum about 4 years ago, but we failed to come up with a provable polynomial-time algorithm (in terms of N). Therefore, I will award +200 bounty to the first submission that achieves this, or prove its impossibility.

Brachylog, 28 bytes

⟦₁⊇ᶠk⊇pSs₂ᶠ{c≠&⟨+/l⟩ᵐ<ᵈ}ᵐ∧Sl

Try it online!

This is really damn slow. Takes about 30 seconds for N = 3, and it didn't complete after 12 minutes for N = 4.

Explanation

⟦₁                             Take the range [1, …, Input]
  ⊇ᶠk                          Find all ordered subsets of that range, minus the empty set
     ⊇                         Take an ordered subset of these subsets
      pS                       Take a permutation of that subset and call it S
       Ss₂ᶠ                    Find all substrings of 2 consecutive elements in S
           {           }ᵐ      Map for each of these substrings:
            c≠                   All elements from both sets must be different
              &⟨+/l⟩ᵐ            And the average of both sets (⟨xyz⟩ is a fork like in APL)
                     <ᵈ          Must be in strictly increasing order
                         ∧Sl   If all of this succeeds, the output is the length of L.

Faster version, 39 bytes

⟦₁⊇ᶠk⊇{⟨+/l⟩/₁/₁}ᵒSs₂ᶠ{c≠&⟨+/l⟩ᵐ<₁}ᵐ∧Sl

This takes about 50 seconds on my computer for N = 4.

This is the same program except we sort the subset of subsets by average instead of taking a random permutation. So we use {⟨+/l⟩/₁/₁}ᵒ instead of p.

{         }ᵒ     Order by:
 ⟨+/l⟩             Average (fork of sum-divide-length)
      /₁/₁         Invert the average twice; this is used to get a float average

We need to get a float average because I just discovered a ridiculous bug in which floats and integers don't compare by value but by type with ordering predicates (this is also why I use <ᵈ and not <₁ to compare both averages; the latter would require that double inversion trick to work).


Solve the New York Times Spelling Bee The New York Times periodically runs a puzzle they call the "Spelling Bee" in which they list six "allowed" letters plus one "mandatory" letter and challenge the reader to form as many five-letter-or-longer dictionary words as possible out of those letters. Each "allowed" letter can appear 0 or more times. The mandatory letter must appear at least once in each word. No other letters are allowed. Proper nouns are not acceptable answers.

For example, in last week's puzzle, the allowed letters were {"A", "C", "D", "H", "I", and "R"}, while the mandatory letter was "N".

Allowed answers for this set of letters range from 5-letter words "ranch", "naiad", and "nadir", up to 9-letter words "cnidarian" and "circadian".

The more words you find, the higher the Times rates your intelligence. Your challenge: write a solver in the language of your choice.

Additional rules and tips:

If your programming environment or operating system provides a list of words, you may use it. If not, you must include code for loading a word list from disk or the internet; you can not assume it has been magically loaded into a variable outside your code.
The word list should be generic, not limited to only those words that contain the mandatory letter, and not limited to words that meet the length or other requirements here. In other words, all dictionary searches should be done by your code, not some pre-processor.
If a word is capitalized in the dictionary, treat it as a proper noun. If your dictionary does not distinguish proper nouns, find a different dictionary.
Different dictionaries will deliver different sets of answers, but given the test case above, you must return at least 20 qualifying answers, and the words "harridan", "niacin", and "circadian" must be on it. The words "Diana", "Adrian", and "India", as proper nouns, must not be.
Your code should take the form of a function or program that accepts two variables: a string or list of characters representing the allowed letters, and a character representing the required letter. It should return a list of allowed answers in any order.
Except to the extent my rules here dictate otherwise, standard loopholes are forbidden.
In the event my rule summary here deviates from the rules at the New York Times, follow the rules here.
Shortest byte count wins, though I plan to call out excellent solutions using novel algorithms or that are otherwise interesting to me, assuming any such are submitted.

PowerShell, 50 44 41 39 43 bytes

param($a,$m)gc z|sls $m|sls "^[$a$m]{5,9}$"

Notes

Using a scriptblock (unnamed function) because there's still a requirement for a function full program.
Takes the "allowed" letters as a single string.
Using The English Open Word List which is provided as a series of lists (one for each letter). I've combined them all into a single file named z, but I only included words that are between 5 and 9 letters, inclusive due to the new rule, the wordlist and my gist have been updated to not exclude any of the original words (of any size). Here's the list, for anyone else to use.

Explanation

Reads the wordlist file z as lines and does two regular expression matches (by way of Select-String with the sls alias). The first sls matches the mandatory letter, so the result is all the words that contain the letter, then that gets piped into the second sls which uses an expression that, in the case of the example input, looks like this: ^[acdhirn]{5,9}$ (so it matches only words that consist of those letters and no others, between 5 and 9 characters in length, inclusive).

Invocation and Output

&{param($a,$m)gc z|sls $m|sls ^[$a$m]+$} 'acdhir' 'n'

Output (57 words):

acarian
acaridan
acini
ahind
anana
anarch
anarchic
arachnid
arcana
arnica
cairn
canard
cancan
candid
candida
canid
canna
cannach
caranna
carina
chain
characin
chicana
china
chinar
chinch
cinch
circadian        #
cnida
cnidarian
cranch
crania
dharna
diarian
dinar
dinic
drain
handcar
harridan         #
inarch
indican
indicia
indri
iridian
nadir
naiad
naira
nanna
niacin           #
nicad
rachidian
radian
ranarian
ranch
rancid
randan
ricin


RNA to Protein Translation RNA, like DNA, is a molecule found in cells encoding genetic information. It consists of nucleotides, which are represented by the bases adenine (A), cytosine (C), guanine (G) and uracil (U).* A codon is a sequence of three nucleotides.

Proteins are large molecules which perform a vast array of functions, such as keratin which is found in hair and nails and hemoglobin which carries oxygen in blood cells.  They are made up of amino acids, which are encoded as codons in RNA molecules. Sometimes different codons may encode for the same amino acid. Each amino acid is commonly represented by a single letter, for example H stands for histidine.

Given a sequence of ACGU, can you translate it into the corresponding protein string?

* DNA consists of ACGT, where the T is thymine. During DNA to RNA transcription, thymine is replaced by uracil.

Input

Input will be a single string consisting of only the characters ACGU in upper case. You may write either a function or a full program for this challenge.

Output

You may choose to output via either printing or returning a string (the latter choice is only available in the case of a function).

Translation should begin at a start codon (AUG, represented as M) and end at a stop codon (one of UAA, UAG or UGA, represented as *). There are four cases where input may be invalid:

The input does not begin with a start codon
The input does not end with a stop codon
The input's length isn't a multiple of 3
The input contains a stop codon somewhere other than at the end

In all of these cases, Error should be outputted. Note that, unlike stop codons, start codons may appear after the start of the string.

Otherwise, you should convert each codon into its respective amino acid via the following RNA codon table:

* UAA UAG UGA
A GCU GCC GCA GCG
C UGU UGC
D GAU GAC
E GAA GAG
F UUU UUC
G GGU GGC GGA GGG
H CAU CAC
I AUU AUC AUA
K AAA AAG
L UUA UUG CUU CUC CUA CUG
M AUG
N AAU AAC
P CCU CCC CCA CCG
Q CAA CAG
R CGU CGC CGA CGG AGA AGG
S UCU UCC UCA UCG AGU AGC
T ACU ACC ACA ACG
V GUU GUC GUA GUG
W UGG
Y UAU UAC

...and output the translated string.

Examples

Invalid cases:

<empty string> -> Error
AUG -> Error
UAA -> Error
AUGCUAG -> Error
AAAAAAA -> Error
GGGCACUAG -> Error
AUGAACGGA -> Error
AUGUAGUGA -> Error
AUGUUUGUUCCGUCGAAAUACCUAUGAACACGCUAA -> Error

Valid cases:

AUGUGA -> M*
AUGAGGUGUAGCUGA -> MRCS*
AUGGGUGAGAAUGAAACGAUUUGCAGUUAA -> MGENETICS*
AUGCCAGUCGCACGAUUAGUUCACACGCUCUUGUAA -> MPVARLVHTLL*
AUGCUGCGGUCCUCGCAUCUAGCGUUGUGGUUAGGGUGUGUAACUUCGAGAACAGUGAGUCCCGUACCAGGUAGCAUAAUGCGAGCAAUGUCGUACGAUUCAUAG -> MLRSSHLALWLGCVTSRTVSPVPGSIMRAMSYDS*
AUGAAAAACAAGAAUACAACCACGACUAGAAGCAGGAGUAUAAUCAUGAUUCAACACCAGCAUCCACCCCCGCCUCGACGCCGGCGUCUACUCCUGCUUGAAGACGAGGAUGCAGCCGCGGCUGGAGGCGGGGGUGUAGUCGUGGUUUACUAUUCAUCCUCGUCUUGCUGGUGUUUAUUCUUGUUUUAA -> MKNKNTTTTRSRSIIMIQHQHPPPPRRRRLLLLEDEDAAAAGGGGVVVVYYSSSSCWCLFLF*

Edit: Added more test cases

Scoring

This is code golf, so the code in the fewest bytes wins.

Note: I'm no expert in molecular biology, so feel free to correct me if I've misstated anything :)

JavaScript (ES6) 167 177 chars encoded in UTF8 as 167 177 bytes

... so I hope everyone is happy.

Edit In fact, no need for a special case for last block too short. If the last 2 (or 1) chars are not mapped, the result string does not end with '*' and that gives error anyway.

F=s=>/^M[^*]*\*$/.test(s=s.replace(/.../g,x=>
"KNKNTTTTRSRSIIMIQHQHPPPPRRRRLLLLEDEDAAAAGGGGVVVV*Y*YSSSS*CWCLFLF"
[[for(c of(r=0,x))r=r*4+"ACGU".search(c)]|r]))?s:'Error'

Explained

Each char in a triplet can have 4 values, so there are exactly 4^3 == 64 triplets. The C function map each triplet to a number between 0 and 63. No error check needed as input chars are only ACGU.

C=s=>[for(c of(r=0,s))r=r*4+"ACGU".search(c)]|r

Each triplet maps to an aminoacid identified by a single char. We can encode this in a 64 character string. To obtain the string, start with the Codon Map:

zz=["* UAA UAG UGA","A GCU GCC GCA GCG","C UGU UGC","D GAU GAC","E GAA GAG"
,"F UUU UUC","G GGU GGC GGA GGG","H CAU CAC","I AUU AUC AUA","K AAA AAG"
,"L UUA UUG CUU CUC CUA CUG","M AUG","N AAU AAC","P CCU CCC CCA CCG","Q CAA CAG"
,"R CGU CGC CGA CGG AGA AGG","S UCU UCC UCA UCG AGU AGC","T ACU ACC ACA ACG"
,"V GUU GUC GUA GUG","W UGG","Y UAU UAC"]
a=[],zz.map(v=>v.slice(2).split(' ').map(x=>a[C(x)]=v[0])),a.join('')

...obtaining "KNKNTTTTRSRSIIMIQHQHPPPPRRRRLLLLEDEDAAAAGGGGVVVV*Y*YSSSS*CWCLFLF"

So we can scan the input string and use the same logic of the C function to obtain the code 0..63, and from the code the aminoacid char. The replace function wil split the input string in 3 chars blocks, eventually leaving 1 or 2 chars not managed (that will give an  invalid result string, not ending in '*').

At last, check if the encoded string is valid using a regexp: it must start with 'M', must not contain '*' and must end with '*'

Test In FireBug/FireFox console

;['AUGCUAG','GGGCACUAG','AUGAACGGA','AUGUAGUGA','AAAAAAA',
'AUGUUUGUUCCGUCGAAAUACCUAUGAACACGCUAA',
'AUGAGGUGUAGCUGA','AUGCCAGUCGCACGAUUAGUUCACACGCUCUUGUAA',
'AUGCUGCGGUCCUCGCAUCUAGCGUUGUGGUUAGGGUGUGUAACUUCGAGAACAGUGAGUCCCGUACCAGGUAGCAUAAUGCGAGCAAUGUCGUACGAUUCAUAG']
.forEach(c=>console.log(c,'->',F(c)))

Output

AUGCUAG -> Error
GGGCACUAG -> Error
AUGAACGGA -> Error
AUGUAGUGA -> Error
AAAAAAA -> Error
AUGUUUGUUCCGUCGAAAUACCUAUGAACACGCUAA -> Error
AUGAGGUGUAGCUGA -> MRCS*
AUGCCAGUCGCACGAUUAGUUCACACGCUCUUGUAA -> MPVARLVHTLL*
AUGCUGCGGUCCUCGCAUCUAGCGUUGUGGUUAGGGUGUGUAACUUCGAGAACAGUGAGUCCCGUACCAGGUAGCAUAAUGCGAGCAAUGUCGUACGAUUCAUAG -> MLRSSHLALWLGCVTSRTVSPVPGSIMRAMSYDS*


Closest 7-Distinct-Prime Product (via chat)

The OEIS entry A123321 lists the sequence of numbers that are the product of seven distinct primes. For brevity, we'll call this a 7DP number. The first few numbers and their corresponding divisors are below:

510510 = 2 * 3 * 5 * 7 * 11 * 13 * 17
570570 = 2 * 3 * 5 * 7 * 11 * 13 * 19
690690 = 2 * 3 * 5 * 7 * 11 * 13 * 23
746130 = 2 * 3 * 5 * 7 * 11 * 17 * 19

The challenge here will be to find the closest 7DP number, in terms of absolute distance, from a given input.

Input

A single positive integer n in any convenient format.

Output

The closest 7DP number to n, again in any convenient format. If two 7DP numbers are tied for closest, you can output either or both.

Rules

Numbers can be assumed to fit in your language's default [int] datatype (or equivalent).
Either a full program or a function are acceptable.
Standard loopholes are forbidden.
This is code-golf, so all usual golfing rules apply, and the shortest code wins.

Examples

5 -> 510510
860782 -> 870870
1425060 -> 1438710 (or 1411410, or both)

Python, 89 86 85 bytes

f=lambda n,k=0:126^sum(1>>n%i<<7*(n/i%i<1)for i in range(2,n))and f(n+k,k%2*2+~k)or n

The algorithm is O(scary) to begin with and the recursion doesn't really help, but it works well as long as n is sufficiently close to a 7DP number.

Thanks to @xnor for golfing off 3 bytes!

Test it on repl.it.

How it works

Python has no primality or factorization built-ins, but we can identify 7DP numbers by the amount and nature of their divisors.

By the multiplication principle, the number of divisors of an integer can be computed as the product of the incremented exponents of its prime factorization. Thus, σ0(n) (divisor function) is 2m whenever n is a mDP number.

σ0(n) = 128 is thus a necessary condition, but it is not sufficient; for example, σ0(2127) = 128, but 2127 is clearly not a 7DP number. However, if both σ0(n) = 128 and no perfect square divides n evenly, then n is a 7DP number.

For the input n, the algorithm consists in inspecting the integers n, n - 1, n + 1, n - 2, n + 2, etc. and returning the first one that is a 7DP number.

When f is called with argument n, the following happens:

The code

126^sum(1>>n%i<<7*(n/i%i<1)for i in range(2,n))

tests if n is not a 7DP number as follows.

For all integers i such that 1 < i < n, 1>>n%i<<7*(n/i%i<1) gets evaluated.

If n is divisible by i but not by i2, 1>>n%i yields 1 and (n/i%i<1) yields 0, resulting in
1 · 27 · 0 = 1.
If n is divisible by i2, 1>>n%i and (n/i%i<1) both yield 1, resulting in 1 · 27 · 1 = 128.
If n not not divisible by i, 1>>n%i yields 0, resulting in 0 · 27 · x = 0.

The sum of the resulting integers will be 2m - 2 if n is a mDP number (its 2m divisors, excluding 1 and n) and a number greater than 127 if n has a perfect square factor. Thus, the sum will be 126 if and only if n is a 7DP number.
For 7DP numbers, the sum is 126, so XORing it with 126 yields 0, which is falsy. Thus, the or part of the lambda is executed and f returns the current value of n.
If n is not a 7DP number, XOR will return a non-zero, truthy value. Thus, the and part of the lambda is executed.

f(n+k,k%2*2+~k)

recursively calls f with updated values of n (the next potential 7DP number) and k (the difference between the the new candidate and the one after that).

If k is an even, non-negative integer, k%2*2 yields 0 and ~k yields -(k + 1). The sum of both results is -(k + 1), which is an odd, negative integer that is 1 greater in absolute value than k.

If k is an odd, negative integer, k%2*2 yields 2 and ~k yields -(k + 1). The sum of both results is 2 - (k + 1) = -(k - 1), which is an even, non-negative integer that is 1 unit greater in absolute value than k.

This means that k takes the values 0, -1, 2, -3, 4, ⋯.

When added cumulatively to n0 (the initial value of n), the resulting integers are

n0 + 0
(n0 + 0) - 1 = n0 - 1
(n0 - 1) + 2 = n0 + 1
(n0 + 1) - 3 = n0 - 2
(n0 - 2) + 4 = n0 + 2
etc.

making sure the first 7DP number we encounter is as close to n0 as possible.


Unfold musical jumps The Dal Segno and Da Capo are two very commonly used musical terms. They mean "from the sign" () and "from the beginning" respectively.

There is also the idea of the coda (), which is the very end of a piece of music. It's what's played after the "main section" of the piece.

A D.S. al coda (Dal Segno al coda), for example, means "go to the segno, play until you're told to go to the coda, and then jump there."

Description

Your job in this challenge is to take input composed of any number of notes which may or may not contain Dal Segnos and Da Capos and output the same music with the aforementioned jumps "unfolded" so that the repetitions are expanded out verbatim.

Input

Your code should take as input a sequence of either notes or signals (here defined as anything but a note), separated by spaces in one string.

Notes are any of a, b, c, d, e, f, or g, with an optional # or b appended (for the purposes of this challenge, there is no rhythm).
A C (capital c) represents a coda marking. There will always be either zero or two coda markings; the first coda marking represents where to jump from, and the second represents where to jump to.
An S (capital s) represents a signo marking. There will always be either zero or one signo marking(s).
An F (capital f) represents a fine marking. This "overrides" the end of the piece—more on that below. There will always be either zero or one fine marking(s).
Any of the following exact strings of text represent:

D.S. al fine: go to the signo and play until either the end of the piece or the fine marking (if it exists).
D.S. al coda: go to the signo, play until the coda, then jump to the second coda marking and play until the end of the piece.
D.C. al fine: go to the beginning, play until the end or the fine marking.
D.C. al coda: go to the beginning, play until the coda, then jump to the second coda marking and play until the end of the piece.

There will always be a minimum of zero and a maximum of one of each string per piece. There will never be multiple al fines or multiple al codas in a piece.

Output

Your code should output in a similar string format: a list of notes, separated by spaces.

You may always assume that the output will end up being one or more characters long.

Test cases

In: a# bb c b a
Out: a# bb c b a

In: a S b D.S. al fine c
Out: a b b c

In: a S b C c D.S. al coda d C e
Out: a b c b e

In: a b F c d D.C. al fine e f
Out: a b c d a b

In: a b D.C. al fine c d F e f
Out: a b a b c d

In: a b C c d D.C. al coda e f C g g#
Out: a b c d a b g g#

In: a b D.C. al coda c d C e f C g g#
Out: a b a b c d g g#

In: a b S c d C D.C. al coda C D.S. al fine e f F g
Out: a b c d a b c d c d e f

In: a S b C c D.S. al coda C d D.S. al fine e F f
Out: a b c b d b c d e

In: a b C c d D.C. al coda e f F g g# C gb a# D.C. al fine
Out: a b c d a b gb a# a b c d e f

In: a F b C D.C. al coda C D.C. al fine
Out: a b a b a

In: C a S b D.C. al coda C c D.S. al fine d
Out: a b c b c d

In: a S b D.S. al coda C C c D.C. al fine
Out: a b b c a b c

In: a F C b C D.C. al coda D.C. al fine
Out: a b a a

Rules

The markings will always appear in a logical order. That is, there will never be an S after a D.S. and there will always be one before, etc.
This is code-golf, so the shortest code in bytes will win.

JavaScript (ES6), 253 bytes

x=>eval('n=(" "+x).replace(/D.{11}|[CSF]/g,d=>({C:4,S:5,F:6}[d]|(d[2]<"S")*2+(d[8]<"f"))).split` `;for(i=c=f=o="";v=n[++i];v<9?v<4?(n[i]=7,i=0,s=n.indexOf`5`,v==0?f=i=s:v==1?c=i=s:v==2?f=1:c=1):v==4&c?c=!(i=n.indexOf("4",i+1)):v==6&f?i=n:0:o+=v+" ");o')

Explanation

Could be golfed better but I'm done for now.

x=>
  eval(`                                  // use eval to enable for loop without return
    n=(" "+x)                             // n = array of [ "", ...notes/commands ]
                                          // empty first element means f and c can be set
                                          //     to i (always true) in the cases below
      // DS fine => 0, DS coda => 1, DC fine => 2, DC coda => 3, C => 4, S => 5, F => 6
      .replace(/D.{11}|[CSF]/g,d=>({C:4,S:5,F:6}[d]|(d[2]<"S")*2+(d[8]<"f")))
      .split\` \`;
    for(
      i=                                  // i = position in note array
      c=                                  // c = look out for coda if true
      f=                                  // f = look out for fine if true
      o="";                               // o = output string
      v=n[++i];                           // v = note/command
      v<9?                                // if not a note
        v<4?(                             // if DS/DC
          n[i]=7,                         // change it to NOP
          i=0,                            // reset i here to save doing it in DC cases
          s=n.indexOf\`5\`,
          v==0?f=i=s:                     // case: D.S. al fine
          v==1?c=i=s:                     // case: D.S. al coda
          v==2?f=1:                       // case: D.C. al fine
          c=1                             // case: D.C. al coda
        ):
        v==4&c?c=!(i=n.indexOf("4",i+1)): // case: C
        v==6&f?i=n:                       // case: F
        0                                 // case: S
      :o+=v+" "                           // add the note
    );o                                   // return the output
  `)

Test

var solution = x=>eval('n=(" "+x).replace(/D.{11}|[CSF]/g,d=>({C:4,S:5,F:6}[d]|(d[2]<"S")*2+(d[8]<"f"))).split` `;for(i=c=f=o="";v=n[++i];v<9?v<4?(n[i]=7,i=0,s=n.indexOf`5`,v==0?f=i=s:v==1?c=i=s:v==2?f=1:c=1):v==4&c?c=!(i=n.indexOf("4",i+1)):v==6&f?i=n:0:o+=v+" ");o')
<input type="text" id="input" value="a b C c d D.C. al coda e f F g g# C gb a# D.C. al fine" />
<button onclick="result.textContent=solution(input.value)">Go</button>


Reorder a matrix, twice You are given a square \$n \times n\$ matrix \$A\$, and a list (or vector) \$u\$ of length \$n\$ containing the numbers \$1\$ through \$n\$ (or \$0\$ through \$n-1\$). Your task is to reorder the columns and rows of the matrix \$A\$ according to the order specified in \$u\$.

That is, you will construct  a matrix \$B\$ where the \$(i,j)\$-th element is the \$(u(i),u(j))\$-th element of \$A\$. You should also output the inverse of this action; that is, the (i,j)-th element of \$A\$ will end up at position \$(u(i),u(j))\$ in a new matrix \$C\$.

For example, given $$A = \begin{bmatrix} 11 &12& 13 \\ 21& 22& 23 \\ 31& 32& 33 \end{bmatrix},\quad u=\begin{bmatrix}3 & 1 & 2\end{bmatrix}$$

the output should be $$B = \begin{bmatrix}33 & 31 & 32 \\ 13 & 11 & 12 \\ 23 & 21 & 22 \end{bmatrix},\quad C= \begin{bmatrix}22 & 23 & 21 \\32 & 33 & 31 \\ 12 & 13 & 11 \end{bmatrix}$$

You may take input and output through any of the default I/O methods. You do not have to specify which matrix is \$B\$ or \$C\$, as long as you output both. You may assume \$A\$ only contains positive integers, and you may use 1- or 0-based indexing for \$u\$. You must support matrices up to at least size \$64 \times 64\$.

Example

===== Input =====
A =
 35     1     6    26    19    24
  3    32     7    21    23    25
 31     9     2    22    27    20
  8    28    33    17    10    15
 30     5    34    12    14    16
  4    36    29    13    18    11
u=
  3 5 6 1 4 2

==== Output =====
B =
  2    27    20    31    22     9
 34    14    16    30    12     5
 29    18    11     4    13    36
  6    19    24    35    26     1
 33    10    15     8    17    28
  7    23    25     3    21    32
C =
 17    15     8    10    28    33
 13    11     4    18    36    29
 26    24    35    19     1     6
 12    16    30    14     5    34
 21    25     3    23    32     7
 22    20    31    27     9     2

MATL, 15 13 bytes

t3$)&Gw&St3$)

Inputs u,  then A.

Outputs B, then C without a separator, as there is no ambiguity.

Try it online!

Explanation

t     % Take input u implicitly. Duplicate u
3$)   % Take input A implicitly. Index A with u as row and column indices
&G    % Push the two inputs again: u, A
w     % Swap
&S    % Push indices that would make u sorted. Call that v
t     % Duplicate v
3$)   % Index A with v as row as column indices. Display implcitly


How many days in a month? Given a textual representation (case-insensitive full name or 3 character abbreviation) of a month return the number of days in the month.

For example, december, DEC, and dec should all return 31.

February can have either 28 or 29 days.

Assume the input is a month in one of the correct forms.

JavaScript (ES6),  48 47 44 43  42 bytes

m=>31^'311'[parseInt(m[1]+m[2],34)*3%49%8]

Demo

let f =

m=>31^'311'[parseInt(m[1]+m[2],34)*3%49%8]

;(
  'JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC,' +
  'JANUARY,FEBRUARY,MARCH,APRIL,MAY,JUNE,JULY,AUGUST,SEPTEMBER,OCTOBER,NOVEMBER,DECEMBER'
).split`,`
.forEach(m => console.log(m, '->', f(m)))

How?

These operations lead to a lookup table of 8 entries, which would not be very interesting if the values were randomly distributed. But any result greater than 2 is mapped to 31 days. Therefore, only the first 3 entries need to be stored explicitly.

Month | [1:2] | Base 34 -> dec. | * 3  | % 49 | % 8 | Days
------+-------+-----------------+------+------+-----+-----
  JAN |    AN |             363 | 1089 |   11 |   3 |  31
  FEB |    EB |             487 | 1461 |   40 |   0 |  28
  MAR |    AR |             367 | 1101 |   23 |   7 |  31
  APR |    PR |             877 | 2631 |   34 |   2 |  30
  MAY |    AY |              10 |   30 |   30 |   6 |  31
  JUN |    UN |            1043 | 3129 |   42 |   2 |  30
  JUL |    UL |            1041 | 3123 |   36 |   4 |  31
  AUG |    UG |            1036 | 3108 |   21 |   5 |  31
  SEP |    EP |             501 | 1503 |   33 |   1 |  30
  OCT |    CT |             437 | 1311 |   37 |   5 |  31
  NOV |    OV |             847 | 2541 |   42 |   2 |  30
  DEC |    EC |             488 | 1464 |   43 |   3 |  31


Is it simple or is it hard? For your hard thing to do, you must make a thing for a computer to do that finds out if some words are explained in a simple way. Something is explained in a simple way if it only uses the ten hundred most used words. If not, it is explained in a hard way. This can be a full computer thing or part of a computer thing. (full program or function)

There is a thing for a computer to read that has all of the ten hundred words in it with a space between each word. The name of the thing for the computer to read is called 'most used.txt'. You can take this thing from this computer place.

The person who uses the computer thing will enter some words. (This can be from STDIN, function arguments or command line arguments) The computer must say something like a true if the words are simple and something like a not true if it is hard. (truthy-falsy) The person who makes the shortest thing for the computer to do is the best. The things that every person knows are bad are bad. (standard loopholes apply)

More stuff to know about how the computer thing works:

It doesn't matter if the words are BIG or little.
The pictures that make what the word meaning easier to know (punctuation) don't matter. So if the person who uses the computer thing says "dont" it isn't a different word than the word "don't". Numbers and other pictures also don't matter. So if the person says "HE$$ll9o" the computer should read it like "hello"
The little lines between words (dashes) work the same way as spaces. So the word "up-goer-five" is the same as the words "up goer five".

More stuff to know about making words like this:

https://xkcd.com/1133/

http://splasho.com/upgoer5/#

R, 106 bytes

Is not sure if is understand challenge because is has hard time reading.

function(s){u=toupper;all(strsplit(gsub("[^A-Z -']","",u(s)),"[ -]")[[1]]%in%u(scan("most used.txt","")))}

This creates an unnamed part of a computer thing that accepts a string and returns something like a true or like a not true.

Ungolfed + explanation:

partOfAComputerThing <- function(s) {
    # Remove everything but letters, spaces, dashes, and single quotes
    s <- gsub("[^A-Z -']", "", toupper(s))

    # Split s into a vector on spaces/dashes
    v <- strsplit(s, "[ -]")[[1]]

    # Read the file of words (assumed to reside in the current directory)
    m <- scan("most used.txt", "")

    # Determine if all words in the input are in the file
    all(v %in% toupper(m))
}

Thanks to Dennis for inspiration thing.


Show the input RGB color Write a program that takes R, G, and B values as command arguments and then displays that color some way. It doesn't matter how, as long as at least 100 pixels have the color. Shortest code wins.

JavaScript, 25

document.bgColor=prompt()

You'll have to specify the three components in hexadecimal. This is code golf, so no commas or whitespace.


Output Pi without math In as few bytes as possible, your job is to write a program that outputs:

3.14

In celebration of a late Pi day of course! :)

Rules

You can do it anyway you like, but there are some restrictions.

You may not use arithmetic operations anywhere in your program. This includes +, -, *, /, %, ^ (exponentiation), etc... This also includes incrementing (usually ++), decrementing (--), bitwise operations, and any built in functions that can be used as a replacement such as sum(), prod(), mod(), double(), pow(), sqrt(), inc(), dec(), etc... (Author's discretion)
The digits 3, 1, and 4 may not appear anywhere in your code.
You may not use any predefined variables/constants that your language may have as a replacement for 3, 1, and 4. (Author's discretion)
You may also not use any trigonometric functions such as sin(), cos(), tan(), arcsin(), arccos(), arctan(), sinh(), cosh(), tanh(), etc... (Author's discretion)
You may not use built-in or predefined values of Pi (or 3.14). No web requests.
Your program cannot require input of any kind (besides running it).
3.14 is the only thing that you may output, it cannot be part of some longer/larger output..

Winner

The answer with the least amount of bytes on April 18th wins. Good luck!

Looking forward to clever answers from clever minds! Malbolge anyone? :P

PHP - 22 bytes

<?=date('n.j',8899e5);

Pi Day in year 1998 was really cool!


Visualize a Recursive Acronym Background

Famously, the acronym GNU stands for GNU's Not Unix. 1

It's recursive because, after expanding it once, it still contains the acronym GNU, and so must be exanded again:

(GNU's Not Unix)'s Not Unix

And so on, ad infinitum.  Visualizing this, we get a kind of Droste effect:

┌────────────────────────────────────────────┬───────────┐
│┌──────────────────────────────┬───────────┐│'s Not Unix│
││┌────────────────┬───────────┐│'s Not Unix││           │
│││┌──────────────┐│'s Not Unix││           ││           │
││││GNU's Not Unix││           ││           ││           │
│││└──────────────┘│           ││           ││           │
││└────────────────┴───────────┘│           ││           │
│└──────────────────────────────┴───────────┘│           │
└────────────────────────────────────────────┴───────────┘

Recursive acronyms need not recurse on the first word, or only once.  For example:

YOPY: Your Own Personal YOPY
PIPER: PIPER Is PIPER Expanded Recursively

Visualized:

Challenge

Input

You will be given two inputs:

A string whose space-delimited words form a recursive acronym.  That is, if you form a string from the first letter of each word, that string is guaranteed to be either:

One of the words of the input string (it may occur more than once).
A prefix of one or more of those words (e.g. GNU is a prefix of GNU's)
The casing will match exactly

A non-negative integer -- the number of times to recursively expand.  Given 0, you'll return the input unaltered (or "framed" once, in its entirety).  Given 1, you'll expand once.  Etc.

Output

The output is the input string with all instances of the acronym visually expanded, recursively, the specified number of times.

You must use some visual effect to "frame" the nesting -- at minimum, distinct start and end delimiters like parentheses.  Ascii boxing of some sort, as in the examples above, is also fine.  As would be outputting an actual image that showed the nesting.

I'm flexible as long as the nesting is in fact visualized.

For clarity, parenthesized output would like this:

(((GNU's Not Unix)'s Not Unix)'s Not Unix)'s Not Unix

You are guaranteed that parentheses will never be part of acronym.  Other than alphanumeric characters, the acronym will only contain apostrophes, commas, quotes, question marks and exclamation points, and those will only occur as valid punctuation (e.g., a question mark will not appear at the beginning of a word).

This is code golf, fewest bytes wins, no loopholes.

Test Cases

This assumes you're using a parentheses visualization.

Format for test cases:

Input string (the acronym)
Input integer (recursion)
Expected Output

GNU's Not Unix
0
GNU's Not Unix

GNU's Not Unix
2
((GNU's Not Unix)'s Not Unix)'s Not Unix

YOPY Own Personal YOPY
1
(YOPY Own Personal YOPY) Own Personal (YOPY Own Personal YOPY)

YOPY Own Personal YOPY
2
((YOPY Own Personal YOPY) Own Personal (YOPY Own Personal YOPY)) Own Personal ((YOPY Own Personal YOPY) Own Personal (YOPY Own Personal YOPY))

YourYOPY Own Personal YOPY
2
YourYOPY Own Personal (YourYOPY Own Personal (YourYOPY Own Personal YOPY))

APL (Dyalog Extended), 33 32 bytes

-1 byte thanks to Bubbler.

Anonymous infix lambda. Takes count as left argument and string as right argument.

{('\b',⊃¨⍵⊆⍨≠⍵)⎕R(1⌽')(',⍵)⍣⍺⊢⍵}

Try it online!

{…} "dfn"; number is ⍺ and text is ⍵:

 ⊢⍵ on the text:

 ⍣⍺ repeat given number of times

 (…)⎕R(…) PCRE Replace:

  ')(',⍵ the text prefixed by ")("

  1⌽ cyclically rotated one step left (puts ")" at end)

  … with:

  ≠⍵ The mask of non-spaces in the text

  ⍵⊆⍨ characters runs in the text corresponding to runs of 1s in that

  ⊃¨ first character of each

 '\b', prepend PCRE for word boundary


Find all possible dates You get a string which contains an integer between 1000 and 99999999 as input. The input string might contain leading zeroes but cannot be longer than 8 characters.

Your goal is to output all dates between 6th of December 1919 and 5th of December 2019 which fit the input in these formats:

day - month - year (dmy)
month - day -year (mdy)
year - month - day (ymd)

Days and months can be either one or two digits. Years can be either two or four digits. Also don't forget the leap years!

Your output dates must be all in the same format (choose one). Its days, months and years must be clearly distinguishable (choose a separator or encode them like YYYYMMDD).

You are free to leave any duplicate dates in your output (you're a good boy if you remove them though). If there are no dates to return, return nothing.

Examples:

Input:  "1234"
Output: 1934-02-01, 2012-03-04, 1934-01-02

Input:  "01234"
Output: 1934-01-02, 1934-02-01

Input:  "01211"
Output: 2001-11-01, 2011-01-01, 2001-01-11

Input:  "30288"
Output: 1988-02-03, 1988-02-30, 1988-03-02

Input:  "999999"
Output:

Shortest code in bytes wins. Have fun!

Ruby, 234 bytes

require'date'
a,b,g=%w(%Y%-m%d %Y%m%d %Y%-m%-d %Y%m%-d %-m%d%Y %m%d%Y %-m%-d%Y %m%-d%Y %d%-m%Y %d%m%Y %-d%-m%Y %-d%m%Y),Date.new(1920)-26,gets
(b..b+36524).map{|d|puts d.to_s if(a+a.map{|x|x.tr(?Y,?y)}).map{|x|d.strftime(x)}.member?g}

Try it online!

I'm willing to bet that this can be shortened this significantly (with regex maybe), but I'm not clever or knowledgable enough to figure that out.

If we are allowed to print the date object itself instead of a string, change puts d.to_s to p d.


Primes in the prime factorisation I saw another prime challenge coming by in PPCG, and I do love me some primes. Then I misread the introductory text, and wondered what the creative brains here had come up with.
It turns out the question posed was trivial, but I wonder if the same is true of the question I (mis)read:

\$6\$ can be represented by \$2^1\times3^1\$, and \$50\$ can be represented by \$2^1\times5^2\$.
Your task:
Write a program or function to determine how many distinct primes there are in this representation of a number.
Input:
An integer \$n\$ such that \$1 < n < 10^{12}\$, taken by any normal method.
Output:
The number of distinct primes that are required to represent the unique prime factors of \$n\$.
Test cases:
Input      Factorisation      Unique primes in factorisation representation
24         2^3*3^1            2 (2, 3)
126        2^1*3^2*7^1        3 (2, 3, 7)
8          2^3                2 (2, 3)
64         2^6                1 (2) (6 doesn't get factorised further)
72         2^3*3^2            2 (2, 3)
8640       2^6*3^3*5^1        3 (2, 3, 5)
317011968  2^11*3^5*7^2*13^1  6 (2, 3, 5, 7, 11, 13)
27         3^3                1 (3)

This is not an OEIS sequence.
Scoring:
This is code-golf, lowest score in bytes wins!

Mathematica, 39 bytes
Count[Union@@FactorInteger@#,_?PrimeQ]&

Try it online!
thanks to Martin Ender (-11 bytes)


We love our weird puzzles, us Brits In a few British newspapers there is a game known as Hidato. It is somewhat similar to Sudoku, albeit instead of having 1-9 in a line and block, it's about placing numbers such that they connect in order from 01 all the way up to the highest one, so they are all touching horizontally, diagonally or vertically.
Inputs will contain multiple lines separated by \n, containing blocks separated by a space, which you can assume to be two characters wide. Each block will be a number, a blank space to be filled (indicated by --), or a wall that cannot have numbers in (XX).
Your output should match the provided one albeit with empty blocks provided with numbers. Note that there may not be a unique, or even the existence of, a solution – some may yield multiple due to their ambiguity, much like Sudoku, and some may be literally unsolvable, in which case you should give a falsey output, but you can assume inputs are formatted as below.
Use a standard header Language: XX bytes. Happy golfing!
Examples
Inputs 01 XX 03, 01 -- 04, 01 --, etc should all return something falsey.
Input:
01 -- --
-- XX 05

Output:
01 03 04
02 XX 05

Input:
-- 33 35 -- -- XX XX XX
-- -- 24 22 -- XX XX XX
-- -- -- 21 -- -- XX XX
-- 26 -- 13 40 11 XX XX
27 -- -- -- 09 -- 01 XX
XX XX -- -- 18 -- -- XX
XX XX XX XX -- 07 -- --
XX XX XX XX XX XX 05 --

Output:
32 33 35 36 37 XX XX XX
31 34 24 22 38 XX XX XX
30 25 23 21 12 39 XX XX
29 26 20 13 40 11 XX XX
27 28 14 19 09 10 01 XX
XX XX 15 16 18 08 02 XX
XX XX XX XX 17 07 06 03
XX XX XX XX XX XX 05 04

Input:
XX XX XX XX -- 53 XX XX XX XX
XX XX XX XX -- -- XX XX XX XX
XX XX 56 -- -- -- 30 -- XX XX
XX XX -- -- -- -- -- -- XX XX
XX -- -- 20 22 -- -- -- -- XX
XX 13 -- 23 47 -- 41 -- 34 XX
-- -- 11 18 -- -- -- 42 35 37
-- -- -- -- 05 03 01 -- -- --
XX XX XX XX -- -- XX XX XX XX
XX XX XX XX 07 -- XX XX XX XX

Output:
XX XX XX XX 52 53 XX XX XX XX
XX XX XX XX 54 51 XX XX XX XX
XX XX 56 55 28 50 30 31 XX XX
XX XX 26 27 21 29 49 32 XX XX
XX 25 24 20 22 48 45 44 33 XX
XX 13 19 23 47 46 41 43 34 XX
14 12 11 18 04 02 40 42 35 37
15 16 17 10 05 03 01 39 38 36
XX XX XX XX 09 06 XX XX XX XX
XX XX XX XX 07 08 XX XX XX XX

JavaScript (Node.js), 482 bytes

This is a brute-force solution, it starts at 01 and checks every neighbouring cell checking for empty cells (--) or the desired number and following the path to completion or impossibility. If the desired number exists and isn't a neighbour it shortcuts this solution. Takes a few seconds for the largest grid.

This probably isn't particularly interesting, but I thought I'd try my hand at making a solution before looking at the answers linked on Rosetta Code and I enjoyed tackling a slightly more difficult challenge!

Finds all solutions when many exist. The body is a function that accepts a two dimensional array and the footer processes the input to the desired format, and returns the result to the desired format too. Happy to provide more information (and a less golfed implementation if there's interest).

f=a=>{F=(D,n,j)=>[Z=[].concat(...D),z=Z.indexOf(j),z>-1&&[x=z%w,y=z/w|0],z>-1&&[[x-1,y-1],[x,y-1],[x+1,y-1],[x-1,y],[x+1,y],[x-1,y+1],[x,y+1],[x+1,y+1]]][n];C=q=>q.map(Q=>Q.slice());w=a[0][L='length'];l=F(a,0).filter(c=>c!='XX')[L];R=[];r=(s,d)=>{let n=`0${+s+1}`.slice(-2);N=F(d,2,n);n>l?R.push(C(d)):~F(d,1,s)?(p=F(d,3,s),p.filter(P=>P==N+'')[L]?r(n,C(d)):!~F(d,1,n)?p.map(I=>{[x,y]=I,(x<0||x>w-1||y<0||y>d[L]-1)||d[y][x]=='--'&&(D=C(d),r(D[y][x]=n,D))}):0):0};r('01',a);return R}

Try it online!


Combination lock counter The scene is:
Peter is at the gym with his buddy Brian when Brian suddenly is in dire need of his inhaler. Brian manages to tell Peter the code to his combination lock before he collapses on the floor.
The moment Peter gets to Brian's locker and sees what the indicator is pointing at, Stewie ambushes him and sprays a full can of pepper spray in his face, thus blinding Peter.
Peter must now try to open the lock without looking at it. He starts turning the dial to the right, counting the numbers while he passes them. He then, at the correct number starts turning the dial to the left, still counting, and finally turns it to the right until the lock opens.

The challenge:
Write a function/program that takes two inputs, the combination from Brian, and the indicator position. Output the numbers Peter has to count.
Rules:

The combination and the indicator position must be separate arguments.
The input can be either from command prompt or as function arguments.
The output must be printed to the screen / otherwise displayed (not to file)
Assume that the starting position is not the same as the first number, and that all three numbers in the combination are unique
It's the lock shown in the picture below, with possible numbers: 0-39.

Instructions:
To open the lock below, you need to follow a set of instructions:

You must know your code. Assume it's (38, 16, 22) for now.
Turn the dial 3 times to the right (passing the starting number three times), then stop when the first number (38) aligns with the indicator
Turn the dial 1 full turn to the left, passing
the first number, and stop when the second number (16) lines
up with the indicator.
Turn the dial to the right and stop when the
third number (22) lines up with the indicator
Pull the lock down

Example:
Input
38 16 22
33

Output
33  32  31  30  29  28  27  26  25  24  23  22  21  20  19  18  17  16  15  14  13  12  11  10   9   8   7   6   5   4   3   2   1   0  39  38  37  36  35  34  33  32  31  30  29  28  27  26  25  24  23  22  21  20  19  18  17  16  15  14  13  12  11  10   9   8   7   6   5   4   3   2   1   0  39  38  37  36  35  34  33  32  31  30  29  28  27  26  25  24  23  22  21  20  19  18  17  16  15  14  13  12  11  10   9   8   7   6   5   4   3   2   1   0  39  38  37  36  35  34  33  32  31  30  29  28  27  26  25  24  23  22  21  20  19  18  17  16  15  14  13  12  11  10   9   8   7   6   5   4   3   2   1   0  39  38  39   0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39   0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  15  14  13  12  11  10   9   8   7   6   5   4   3   2   1   0  39  38  37  36  35  34  33  32  31  30  29  28  27  26  25  24  23  22

Standard code golf rules apply.
Solutions that are posted later can still win if they're shorter than Dennis' answer.

CJam, 52 39 bytes

q~[3X0].{@40,m<1$({(+W%}&:T*T@#)T<)}e_p

Try it online in the CJam interpreter.

How it works

q~      e# Read and evaluate all input. This pushes the initial position
        e# as an integer and the combination as an array.
[3X0]   e# Push [3 1 0]. This encodes the respective numbers of full turns
.{      e# For each number in the combination (N) and the corresponding
        e# number of full turns (F):
  @     e#   Rotate the initial position on top of the stack.
  40,m< e#   Push [0 ... 39] and rotate it that many units to the left.
        e#   For position P, this pushes [P P+1 ... 39 0 ... P-2 P-1].
  1$(   e#   Copy F and subtract 1.
  {     e#   If the result is non-zero:
    (+  e#     Rotate the array of length 40 one unit to the left.
    W%  e#     Reverse it.
  }&    e#   For position P, this pushes [P P-1 ... 0 39 ... P+2 P+1].
  :T*   e#   Save in T and repeat the array F.
  T@    e#   Push T. Rotate N on top of the stack.
  #)    e#   Find the index of N in T and add 1 to it.
  T<    e#   Keep that many elements from the beginning of T.
  )     e#   Pop the last element of the result (N).
}       e# N is the new initial position.
e_p     e# Flatten the resulting array and print it.


Roman Numeral Line Segments Write a program or function that accepts an integer in the range 1..3999 as input and returns the number of line segments required to express that integer in standard Roman numerals (so you would use XL but not VM). Examples:

   1 -> 1
   4 -> 3
   5 -> 2
   9 -> 3
  10 -> 2
  40 -> 4
  50 -> 2
  90 -> 3
 100 -> 1
 400 -> 3
 500 -> 2
 900 -> 5
1000 -> 4

Roman number conversion builtins are permitted, but you can solve the problem without them by repeatedly subtracting the largest remaining number from the above list. Example: 1234 = 4 + 1 + 1 + 2 + 2 + 2 + 3 = 15.

This is code-golf, so the shortest program wins.


Let us play the ocarina As we all know, the Zelda series are one of the best game series ever made. In honor of that, let us play some songs on the ocarina.

Challenge:

Write a program which, given a song, outputs the score to stdout for that particular song.

Input:

The song which you will have to output the score of will be given by a unique three character combination as seen below:

zel - Zelda's Lullaby
sas - Saria's Song
eps - Epona's Song
sos - Sun's Song
sot - Song of Time
sst - Song of Storms

Bonus songs, -7 % each:

mof - Minuet of Forest
bof - Bolero of Fire
sow - Serenade of Water
nos - Nocturne of Shadow
ros - Requiem of Spirit
pol - Prelude of Light

Bonus song 2, -8 %:

scs - Scarecrow's song

As we all know, the Scarecrow's song is a song you compose yourself.
This song needs to have eight notes. Output a score you compose yourself which is different from all the other scores.

If you decide to include all songs, it will total to a -50 % bonus to your byte score.

Output:

The notes in the output are symbolized by the following characters:

^
<
>
V
A

Output a score on the following format:

-^-^-^-^-^-^-^-^-
-<-<-<-<-<-<-<-<-
->->->->->->->->-
-V-V-V-V-V-V-V-V-
-A-A-A-A-A-A-A-A-

Only one note per column is allowed.
For simplicity's sake I've added another row to the original four rows.

Each note correspond to a different row:

^: ----------------
<: ----------------
>: ----------------
V: ----------------
A: ----------------

Output shall be written to stdout. Trailing newlines are allowed.

Examples:

Input (Zelda's Lullaby):

zel

Output:

---^-----^-------
-<-----<---------
----->----->-----
-----------------
-----------------

Input (Bolero of Fire):

bof

Output:

-----------------
-----------------
--------->--->---
-V---V-----V---V-
---A---A---------

Note cheat sheet:

zel
<^><^>
sas
V><V><
eps
^<>^<>
sos
>V^>V^
sot
>AV>AV
sst
AV^AV^
mof
A^<><>
bof
VAVA>V>V
sow
AV>><
nos
<>>A<>V
ros
AVA>VA
pol
^>^><^

Since we play the ocarina code golf, the shortest program in bytes wins!

Song references:

http://www.thonky.com/ocarina-of-time/ocarina-songs

http://www.zeldadungeon.net/Zelda05-ocarina-of-time-ocarina-songs.php

Funciton, 4322 − 50% = 2161

Not really trying to golf here. Going more for the beauty angle. I think the main program looks really neat, a perfect rectangular box tucked away on the right.

As always, you can get a better rendering by executing $('pre').css('line-height',1) in your browser console.

                 ┌─────────────────────────┐
               ┌─┴─╖                     ┌─┴─╖
      ┌────────┤ · ╟─────────────────────┤ · ╟─────────────┐    ╔═════════╗   ╔════╗  ╔════╗
      │        ╘═╤═╝     ╔═════════╗     ╘═╤═╝ ╓───╖       │    ║ 1257283 ║ ┌─╢ 40 ║  ║ 25 ║
      │          │       ║ 2097151 ║       ├───╢ ʫ ╟───┐   │    ║ 6456094 ║ │ ╚════╝  ╚══╤═╝
    ┌─┴─╖        │       ╚════╤════╝     ┌─┴─╖ ╙─┬─╜ ┌─┴─╖ │    ║ 8219021 ║ │  ┌───╖   ┌─┴─╖
┌───┤ · ╟────────┴────┐       └─────┬────┤ · ╟───┴───┤ · ╟─┤    ║ 4660190 ║ └──┤ × ╟───┤ % ║
│   ╘═╤═╝             │            ┌┴┐   ╘═╤═╝       ╘═╤═╝ │    ╚════════╤╝    ╘═╤═╝   ╘═╤═╝
│     │               │            └┬┘     │           │   │    ╔═══╗  ┌─┴─╖  ┌──┴─╖   ╔═╧═╗
│     │  ╔═══╗ ┌────╖ │           ┌─┴─╖ ┌┐ │           │   │    ║ 8 ╟──┤ ʫ ╟──┤ >> ║   ║   ║
│     │  ║ 1 ╟─┤ >> ╟─┘       ┌───┤ ? ╟─┤├─┤           │   │    ╚═══╝  ╘═╤═╝  ╘══╤═╝   ╚═══╝
│     │  ╚═══╝ ╘══╤═╝         │   ╘═╤═╝ └┘ │           │   │    ╔════════════════╧═════════╗
│     │         ┌─┴─╖ ┌───╖ ┌─┴─╖ ┌─┴─╖  ╔═╧═╗         │   │    ║ 609678112368778425678534 ║
│   ┌─┴─────────┤ ʫ ╟─┤ ‼ ╟─┤ · ╟─┤ ‼ ║  ║ 1 ║         │   │    ║ 616189712722605554111376 ║
│   │           ╘═╤═╝ ╘═╤═╝ ╘═╤═╝ ╘═╤═╝  ╚═══╝         │   │    ║ 461573643915077926310571 ║
│   │             │     │     │   ╔═╧══╗               │   │    ║ 355541007599150245813976 ║
│   │   ╔══════╗  │     │     └───╢ 45 ║               │   │    ║ 426564826002362964111793 ║
│   │   ║ 2097 ║  │   ┌─┴─╖ ┌───╖ ╚════╝               │   │    ║ 714054902293682079346275 ║
│   │   ║ 1565 ║  └───┤ · ╟─┤ ♭ ╟─┐                    │   │    ║ 663973372550500581508544 ║
│   │   ╚═╤════╝      ╘═╤═╝ ╘═══╝ ├────────────────────┘   │    ║ 874263187322344354338195 ║
│   │   ┌─┴─╖         ┌─┴─╖       │                        │    ║ 642609790172899326178321 ║
│   │   │ ‼ ╟─────────┤ ? ╟───────┘                        │    ║ 071643306454414932126243 ║
│   │   ╘═╤═╝         ╘═╤═╝                                │    ║ 308860823981077902637848 ║
│ ┌─┴─╖ ┌─┴─╖ ╔═══╗   ┌─┴─╖                                │    ║ 322657399386789617074176 ║
└─┤ · ╟─┤ ʫ ╟─╢ 8 ║ ┌─┤ ? ╟────────────────────────────────┘    ╚══════════════════════════╝
  ╘═╤═╝ ╘═╤═╝ ╚═══╝ │ ╘═╤═╝
    │ ┌───┴╖ ╔════╗ │ ╔═══╗
    └─┤ >> ╟─╢ 21 ║ └─╢ 0 ║
      ╘════╝ ╚════╝   ╚═══╝

Continuing in the tradition of giving Funciton functions names consisting of a single, strange, rarely-used Unicode character, I thought about what could best represent this challenge, and it occurred to me that Link and Zelda (or, if you want, Legend of Zelda) give you LZ, so the lower-case digraph ʫ (U+02AB, ʟᴀᴛɪɴ sᴍᴀʟʟ ʟᴇᴛᴛᴇʀ ʟᴢ ᴅɪɢʀᴀᴘʜ) seems appropriate.

Explanation

As explained in the esolangs article, the Funciton program receives the input encoded as what I would call “UTF-21”, but as a single humongous integer. If I wanted to use this number as a key to a hashmap (dictionary, associative array), I’d need a hash function that satisfies two criteria: one, it’s simple enough to implement in Funciton, and two, all of the 13 expected input strings give a different hash value. The simplest hash function I could think of was input % m for some value of m. Therefore, I tried m = 13, 14, 15, etc. until I got to the smallest integer for which all the hash values are unique. Turns out this number is 25.

The hash values are:

zel =  6
sas = 19
eps = 10
sos = 22
sot =  1
sst =  9
mof = 14
bof =  3
sow = 13
nos = 17
ros = 21
pol = 16
scs = 23

We encode each song by having one bit represent the presence or absence of a note. For example, Zelda's Lullaby would be encoded as follows:

---^-----^------- = 01001000
-<-----<--------- = 10010000
----->----->----- = 00100100
----------------- = 00000000
----------------- = 00000000

except that the bits are in the opposite order; the top left cell is in the least significant bit. This means every song is 40 bits long.

We thus create a (moderately sparse) hash table by taking a 40×25 = 1000-bit number and placing the bit pattern for each song in the right place according to its hash value. The monstrous number in the program is exactly this hash table.

Here’s what each of the remaining numbers mean:

45 = 0x2D is the Unicode for -.
1257283645609482190214660190: This is the string ^<>VA in UTF-21. In hindsight I could have used 7 bits per character here, making the number shorter, but UTF-21 is so deeply traditional in Funciton that it simply didn’t occur to me.
2097151 = 0x1FFFFF = (1 << 21) − 1. Used to get the first character from the above string.
20971565: This is the string -\n, which is appended to the end of each line.

It may seem curious that this number and the previous look so similar, but if you think about it, it’s because we’re using decimal and the Unicode for \n happens to be 10. That last number is (10 << 21) + 45.

The program now proceeds as follows:

The main program calls ʫ with the following 3 parameters:

B: The hash table, shifted right by 40 bits times the hash value of the input. The song we want to output is now in the 40 least significant bits.
c: The string ^<>VA.
a: The number 8.

In each iteration of ʫ,

if c is not empty,

if a is not zero, look at the bottom bit of B. Output -, followed by another - if it is zero or the first character of c otherwise. Shift right B by one to remove one bit and decrement a.
if a is zero, output -\n, then chop off the first character from c and start another loop with a = 8.

if c is empty, we are done.


How much water is left? Here in California, we're in a drought so we need to know how much water we have left so we can conserve as much water as possible.

Because water is limited supply, your code will need to be as short as possible.

Examples

|   |
|   |
|~~~|
|___|

Output: 0.5

|~~~~~|
|     |
|     |
|_____|

Output: 1

|  |
|__|

Output: 0 (or bonus)

Specification

The input will consist solely of all of: |_ ~ and newlines. All above the ~'s are considered air; _, spaces below ~, and ~ itself are considered water. The percent of water left is computer by water / (air + water). Your output needs to be accurate to 4 decimal places (unless you go for the percent bonus). The input will always be rectangular. The ~ will only be on one line, if on any. The input may optionally also have a trailing line feed if you'd like.

Bonus

If you go for both bonuses the -15% bonus is applied before the -35 bonus

-35 byte Bonus: If your code prints "This drought goat out of hand", instead of 0 when the Output is 0

-15% Bonus: If you output a percent.

To do this, you would shift the decimal place two places to the left, trim leading zeros, and add a % to the end. Trailing zeros (max 2) are allows as long as they don't affect the value. 0.5 -> any of: 50.00% 50% 50.0%

Pyth - 17 46 45 52 * .85 - 35 = 9.2 bytes
Filters the input (With the new # filter meta-op!) for a line with ~ in it, then indexes that to the input, and then divides that by the length of the input. If there are none with ~, it errors, and triggers the except clause of .x and prints the string.
.x+*100-1cxK.zh@#\~KlK\%." u(C$éáPãbÉãç*îÂe[W

Try it online here.


There can be only 1! Your task is, given a positive integer n, to generate an expression that equals the number n.
The catch is: you're only allowed the number 1 in the output.
The operators at your disposal are:

+, -, * and /

/ is floating-point division (so 5/2 = 2.5).

sqrt (as s)
ceil and floor (as c and f respectively)
! (factorial)

The factorial, in this case, only works for positive integers.

You are also allowed to stack 1's together, so something like 11 is acceptable in the output. However, they count as the same number of 1's that's in the number (so 11 counts as 2 1's).
You must also include brackets in the output, so that the expression in the output, when executed through the order of operations, will result in the input.
They do not count as operations, though.
Examples:

Input = 24, one possible output = (1+1+1+1)!
Input = 11, one possible output = 11
Input = 5, one possible output = c(s((1+1+1+1)!))

The ceiling of the square root of 24 is 5.

Rules:

You are guaranteed that the input is a positive integer from 1 to 2^31-1.
Your program must work for any positive integer up to 2^31-1, even if they are not tested.
Your program must finish processing all outputs for all numbers in the set in 1 hour.
The results for every run of the program must be exactly the same - also, no seeds.
You are only allowed to hardcode the expressions for a maximum of 10 numerical values.
You are not allowed to have imaginary numbers anywhere in the output (so no s(some negative number)).
You are also not allowed to have numbers larger than 2^31-1 or smaller than -2^31+1 anywhere in the output, even when they are sqrted or /ed (so no (((1+1+1)!)!)! or ((1+1+1+1)!)!).

Set of Numbers:
945536, 16878234, 32608778, 42017515, 48950830, 51483452, 52970263, 54278649, 63636656, 78817406, 89918907, 90757642, 95364861, 102706605, 113965374, 122448605, 126594161, 148064959, 150735075, 154382918, 172057472, 192280850, 194713795, 207721209, 220946392, 225230299, 227043979, 241011012, 248906099, 249796314, 250546528, 258452706, 276862988, 277140688, 280158490, 286074562, 308946627, 310972897, 322612091, 324445400, 336060042, 346729632, 349428326, 352769482, 363039453, 363851029, 392168304, 401975104, 407890409, 407971913, 425780757, 459441559, 465592122, 475898732, 482826596, 484263150, 506235403, 548951531, 554295842, 580536366, 587051904, 588265985, 588298051, 590968352, 601194306, 607771869, 618578932, 626776380, 667919873, 681786366, 689854904, 692055400, 697665495, 711608194, 734027104, 750869335, 757710567, 759967747, 777616154, 830071127, 833809927, 835873060, 836438554, 836945593, 863728236, 864158514, 871273503, 881615667, 891619600, 897181691, 918159061, 920521050, 924502226, 929983535, 943162304, 950210939, 950214176, 962610357, 974842859, 988572832

(These are 100 random numbers from 1 to 1 billion.)
Scoring System:
Your score is determined like so:

Your program will be tested against the random numbers in the set.

You must provide the output generated using the random numbers in the set (either inside your answer or as a pastebin link).

Your then have two "scores": A primary score and a secondary score.

Your primary score is (no. of 1's in output)*(no. of operators in output). If your primary score is the lowest, you win.
Your secondary score is the time of your upload, in GMT, and in 24-hour time. So, if you upload your program on September 12th, 00:00 GMT, then your score is 12/09/2016, 00:00 (use DD/MM/YYYY HH:MM for your formatting).

Display your score like so:
(language name)
Primary Score = (primary score)
Secondary Score = (secondary score)
(no. of 1's) `1`'s, (no. of operators) operators

Replace all the things in the brackets with your language name, primary score and secondary score respectively.
Current Winner:
The current winner is @ChrisJefferson, who has a primary score of 3,810,660.

C++11
Further small update: Do much less adding, and try all numbers of form A*B+C. I believe that, within the time limit, this is fairly close to optimal, assuming you only use +, * and !. I leave other operators to people with more time than me!
Small update: Try harder to make use of factorials and numbers like 11....111. Also fixed bug that I wasn't counting ! in my costing
New result:
Primary Score = 3,810,660
Secondary Score = 12/09/2016 20:00
2532 1s, 1505 operators.
Various tricks put together. My program starts by setting the shortest program for all factorials and numbers of the form 111..111 (I don't think this falls foul of the hard-wiring rule, as these are the shortest ways to make these numbers. I could rearrange my code so I check these patterns in my dynamic programming if you want). Then do a partial dynamic programming approach, trying various forms:

A + B
A*B + C
A! + B
11....11 + B

Unfortunately I can't try all the ways of decomposing a number, so I choose for factorial and 11...11 to only try the nearest number, for A+B to try things near A/2, and for A*B+C to try only quite small As.
It would be easy to extend this to try some '-'s, by trying to overshoot slightly sometimes (particular in A*B - C), but I quite like only trying to grow.
Also, it is very hard to optimise the optimisation condition (I don't like it!) because in principle you can't come up with a 'best' value for each number in isolation, you have to consider your set of answers globally (which I don't intend to do).
Warning: This program needs a 64-bit machine, and around 10GB of memory (as I inefficiently make a giant array for all partially-computed results).
Program:
#include <algorithm>
#include <vector>
#include <string>
#include <assert.h>
#include <iostream>
#include <cmath>

std::vector<int> numints;
std::vector<int> numops;
std::vector<std::string> strings;

void fill_all_ones(long maxval)
{
    int val = 1;
    int len = 1;
    std::string name = "1";
    while(val < maxval) {
        val = val * 10 + 1;
        len++;
        name = name + "1";
        numints[val] = len;
        strings[val] = name;
    }
}

void get_best_for_next_full(long i);
// let's just assume this is the best way to make factorials
void fill_all_factorials(long maxval)
{
    // skip 1 and 2
    long result = 6;
    long val = 3;
    while(result < maxval) {
        get_best_for_next_full(val);
        strings[result] = "(" + strings[val] + ")!";
        numints[result] = numints[val];
        numops[result] = numops[val] + 1;
        val++;
        result = result * val;
    }
}

long get_nearest_all_ones(long i)
{
    int val = 11;
    int prevval = 1;
    while(val < i) {
        prevval = val;
        val = val * 10 + 1;
    }
    return prevval;
}

long get_nearest_factorial(long i)
{
    int val = 6;
    int prevval = 2;
    int step = 3;
    while(val < i) {
        prevval = val;
        step++;
        val = val * step;
    }
    return prevval;
}

int getlen(long i);

void get_best_for_next_full(long i)
{
    if(numints[i] > 0)
        return;

    int best = INT_MAX; // we'll do better than this
    std::string beststring = "invalid2";
    int ones = -1;
    int ops = -1;
    for(long loop = 1; loop <= i/2; loop++)
    {
        int new_val = getlen(loop) + getlen(i - loop);
        if(new_val < best) {
            best = new_val;
            ones = numints[loop] + numints[i - loop];
            beststring = "(" + strings[loop] + "+" + strings[i - loop] + ")";
            ops = numops[loop] + numops[i - loop] + 1;
        }
    }

    for(long loop = 2; loop * loop <= i; loop++)
    {
        long divisor = i / loop;
        long rem = i - loop*divisor;
        assert(rem >= 0);
        int new_val;
        if(rem == 0)
        {
            new_val = getlen(divisor) + getlen(loop);
        }
        else
        {
            new_val = getlen(divisor) + getlen(rem) + getlen(loop);
        }

        if(new_val < best) {
            best = new_val;
            if(rem == 0) {
                ones = numints[divisor] + numints[loop];
                beststring = "(" + strings[divisor] + "*" + strings[loop] + ")";
                ops = numops[divisor] + numops[loop] + 1;
            } else {
                ones = numints[divisor] + numints[loop] + numints[rem];
                beststring = "(" + strings[divisor] + "*" + strings[loop] + "+" + strings[rem] + ")";
                ops = numops[divisor] + numops[loop] + numops[rem] + 2;
            }
        }
    }

    numints[i] = ones;
    strings[i] = beststring;
    numops[i] = ops;
}

void check_divising(const long i, const long loop, long& best, long& ones, std::string& beststring, long& ops);
void check_adding(const long i, const long loop, long& best, long& ones, std::string& beststring, long& ops);

void get_best_for_next_partial(long i)
{
    if(numints[i] > 0)
        return;

    long best = INT_MAX; // we'll do better than this
    long ones = 1;
    std::string beststring = "invalid";
    long ops = 1;

    // Special: Try a nearby all ones
    {
        long loop = get_nearest_all_ones(i);
        check_adding(i, loop, best, ones, beststring, ops);
    }

    // Special: Try nearest factorial
    {
        long loop = get_nearest_factorial(i);
        check_adding(i, loop, best, ones, beststring, ops);
    }

    for(long loop = 2; loop * loop <= i; loop++)
    {
       check_divising(i, loop, best, ones, beststring, ops);
    }

    numints[i] = ones;
    strings[i] = beststring;
    numops[i] = ops;
}

void check_adding(const long i, const long loop, long& best, long& ones, std::string& beststring, long& ops)
{
    int new_val = getlen(loop) + getlen(i - loop);
    if(new_val < best) {
        best = new_val;
        ones = numints[loop] + numints[i - loop];
        beststring = "(" + strings[loop] + "+" + strings[i - loop] + ")";
            ops = numops[loop] + numops[i - loop] + 1;
    }
}

void check_divising(const long i, const long loop, long& best, long& ones, std::string& beststring, long& ops)
{
    long divisor = i / loop;
    long rem = i - loop*divisor;
    assert(rem >= 0);
    int new_val;
    if(rem == 0)
    {
        new_val = getlen(divisor) + getlen(loop);
    }
    else
    {
        new_val = getlen(divisor) + getlen(rem) + getlen(loop);
    }

    if(new_val < best) {
        best = new_val;
        if(rem == 0) {
            ones = numints[divisor] + numints[loop];
            beststring = "(" + strings[divisor] + "*" + strings[loop] + ")";
            ops = numops[divisor] + numops[loop] + 1;
        }
        else {
            ones = numints[divisor] + numints[loop] + numints[rem];
            beststring = "(" + strings[divisor] + "*" + strings[loop] + "+" + strings[rem] + ")";
            ops = numops[divisor] + numops[loop] + numops[rem] + 2;
        }
    }
}

long count = 0;
long countops = 0;

const int little_cutoff = 200000;

int getlen(long i)
{
    if(numints[i] == 0) {
        if(i < little_cutoff)
            get_best_for_next_full(i);
        else
            get_best_for_next_partial(i);
    }
    if(numints[i] == 0) {
        std::cout << i << " failure!" << numops[i] << ":" << strings[i] << std::endl;
        exit(1);
    }

    return numints[i] + numops[i];
}

const std::vector<long> vals = {945536, 16878234, 32608778, 42017515, 48950830, 51483452, 52970263, 54278649, 63636656, 78817406, 89918907, 90757642, 95364861, 102706605, 113965374, 122448605, 126594161, 148064959, 150735075, 154382918, 172057472, 192280850, 194713795, 207721209, 220946392, 225230299, 227043979, 241011012, 248906099, 249796314, 250546528, 258452706, 276862988, 277140688, 280158490, 286074562, 308946627, 310972897, 322612091, 324445400, 336060042, 346729632, 349428326, 352769482, 363039453, 363851029, 392168304, 401975104, 407890409, 407971913, 425780757, 459441559, 465592122, 475898732, 482826596, 484263150, 506235403, 548951531, 554295842, 580536366, 587051904, 588265985, 588298051, 590968352, 601194306, 607771869, 618578932, 626776380, 667919873, 681786366, 689854904, 692055400, 697665495, 711608194, 734027104, 750869335, 757710567, 759967747, 777616154, 830071127, 833809927, 835873060, 836438554, 836945593, 863728236, 864158514, 871273503, 881615667, 891619600, 897181691, 918159061, 920521050, 924502226, 929983535, 943162304, 950210939, 950214176, 962610357, 974842859, 988572832};

const long biggest = 988572832;

int main(void)
{
    numints.push_back(2);
    strings.push_back("(1-1)");
    numops.push_back(1);

    numints.push_back(1);
    strings.push_back("1");
    numops.push_back(0);

    numints.push_back(2);
    strings.push_back("(1+1)");
    numops.push_back(1);

    numints.resize(biggest + 1);
    strings.resize(biggest + 1);
    numops.resize(biggest + 1);

    fill_all_ones(biggest);
    fill_all_factorials(biggest);

    for(long i = 0; i < little_cutoff; ++i)
        get_best_for_next_full(i);

    for(long v : vals) {
        get_best_for_next_partial(v);
        std::cout << v << ":" << strings[v] << "\n";
        count += numints[v];
        countops += numops[v];

    }

    std::cout << count << ":" << countops << ":" << count * countops << "\n";

}

Results:
945536:((1111*(1+(11+11))+(1+1))*((1+11)*(1+(1+1))+1)+1)
16878234:(((1+(1+1111))*(1+(1+(1+111)))+(11+11))*((1+11)*11+1)+(1+1))
32608778:((((((1+(1+1)))!+(111+11111))*(11*11)+111)*(1+11)+1)*(1+1))
42017515:((11)!+((((1+111)*11)*11+1)*((1+11)*(1+11)+11)))
48950830:((((11+11)*(1+11))+(11111*(1+(1+1))))*((1+111)*(1+(1+11))+1)+1)
51483452:(((1+(1+1111))*(1+111)+1)*(11+(((1+11)*11+(1+1))*(1+(1+1))))+111)
52970263:((11+((1111*11+(1+(1+1)))*(1+(1+1))))*(111*(1+(1+11))+1)+11)
54278649:((11)!+(((1+(11+(11+(11+1111))))*111+1)*(1+(1+111))+1))
63636656:((((11+111)*(1+(1+1)))*(1+111)+11)*(1+(111+((((1+(1+1)))!)!*(1+1)))))
78817406:(((((111*(11+11)+1)*(1+1))*(1+111)+111)*(1+11)+1)*(1+11)+(1+1))
89918907:(((111+((1+(1+((1+(1+1)))!)))!)*(1+1))*(1+1111)+((11*11)*(1+(1+1))))
90757642:((1111+((11+11111)*(1+1)))*(111*(11+((1+(1+(1+1))))!)+1)+(1+111))
95364861:((11)!+(((((((11+11)*11)+11111)*111)*11+(1+1))*(1+1))*(1+1)+1))
102706605:(((11)!+(((111+((11*11)*11))*(1+(((1+(1+1)))!)!))*11))*(1+1)+1)
113965374:((((111*(1+(1+(1+11))))*1111+((1+(11+11))*11+1))*11+1)*((1+(1+1)))!)
122448605:(((((1+(1+1)))!)!+((111*11)*11))*((1+(((1+(1+1)))!)!)*(1+11)+1)+(1+1))
126594161:(((((11*11)+(((1+(1+1)))!)!)*(1+111))*(1+11)+1)*(1+111)+1)
148064959:((11)!+(((111*111+(1+11))*111+1)*((1+(1+11))*((1+(1+1)))!+1)+(1+(1+1))))
150735075:(((111*111+(1+1))*(1+1111)+(1+11))*11+(1+((1+(1+1)))!))
154382918:((1111*(1+11)+1)*(((1+(11+(111+111)))*(1+1))+11111)+111)
172057472:((((((1+11)*11)*11+1)*(1+(1+1)))+11111)*(11+11111)+((1+11)*11))
192280850:(((11111*(1+11)+11)*(1+(((1+(1+1)))!)!)+(11+111))*(1+1))
194713795:((11)!+((((111+11111)*(1+(1+(1+111)))+((1+(1+1)))!)*11)*11+1))
207721209:(((111*111)*(1+(11+11))+(1+1))*(1+(1+(11+(((1+(1+1)))!)!)))+(1+(1+(1+1))))
220946392:((11)!+((((1+(1+(1+1111)))*(11+111))*111+11)*(1+11)+(1+(1+(1+1)))))
225230299:((111111111+((111*111+(1+((1+(1+1)))!))*(11+111)+(11+11)))*(1+1)+1)
227043979:((((((11+11)*11)+11111)*(1+(1+1))+1)*1111+(1+(1+1)))*((1+(1+1)))!+1)
241011012:(((11)!+((11)!+((11)!+((11+1111)*((1+111)*((1+(1+1)))!+1)))))*(1+1))
248906099:(((11111+(((((1+(1+1)))!)!*111)*(1+1)))*(1+111)+111)*(1+(1+11)))
249796314:(((11)!+(((((1+(1+1)))!)!+((1+1111)*(1+11)))*(11+111)+111))*((1+(1+1)))!)
250546528:((11)!+(((111*111)*(1+(1+(1+11)))+11)*(111*11)+(1+(11+1111))))
258452706:(((11)!+(((((1+(1+1)))!)!*((1+(1+1)))!+1)*(11+(((1+(1+1)))!)!)))*((1+(1+1)))!)
276862988:(((11+(1111*(1+1)))*(((1+(1+1)))!+1111))*111+(((1+(1+1)))!+11))
277140688:(((111*111+(1+(1+(1+(1+11)))))*(1+1))*(11+(111+11111))+(1+111))
280158490:((11)!+(((1+(111+111111))*(((1+(1+1)))!)!+(1+(1+1)))*(1+(1+1))+1))
286074562:(((11)!+((((11+1111)*(11+11))*(1+1)+1)*(1+(11+1111))))*(1+(1+1))+1)
308946627:((11)!+((((1+1111)*(((1+(1+1)))!)!+((11+11)*(1+1)))*(1+111)+1)*(1+(1+1))))
310972897:((11111*(1+(1+1))+1)*(((1111+(111*11))*(1+1))*(1+1)+1)+11)
322612091:((((((1+11)*(1+11))*(1+11)+(1+1))*111+1)*(1+111))*(1+(1+(1+(1+11))))+11)
324445400:(((1111111+(1+(1+1)))*(1+1))*((1+11)*(1+11)+(1+1))+(1+111))
336060042:(((1+1111)*(1+(11+111))+(1+111))*(11+((111*11+1)*(1+1)))+(1+1))
346729632:(((1+(1+(11111+(111*111))))*((1+111)*11+1)+(1+(1+(1+11))))*(1+11))
349428326:(((((11+11)*11)*11+1)*(1+1111)+1)*(1+(((1+(1+1)))!+111)))
352769482:(((1+11111)*(111*(11+11))+((11+111)*((1+1)*(1+1)+1)))*(1+(1+11)))
363039453:(((((1+111)*(1+111)+1)*(1+1))*(1+(1+11))+11)*(1+(1+1111)))
363851029:((((111*11+1)*1111+11)*((1+11)*11+(1+1))+(1+11))*(1+1)+1)
392168304:(((((1+(1+1111))*(1+111))*11+1)*(1+(1+11))+11)*(11+11))
401975104:(((((1+11)*(1+11)+1)*111)*111+11)*((1+111)*(1+1)+1)+(1+(1+(1+1))))
407890409:(((1+11111)*11)*((1+1111)*(1+(1+1))+1)+((1+1111)*(1+1)+1))
407971913:((11)!+((11)!+(((1+(1+11111))*(1+1)+1)*(((11+111)*11)*11+1)+(1+1111))))
425780757:(((1111+((((1+11)*11)+11111)*(1+(1+1))))*11+1)*1111+((1+(1+1)))!)
459441559:(((11111+(((1+(1+111))*(1+1)+1)*111))*111+1)*(1+(1+(1+111)))+(1+(1+11)))
465592122:(((11)!+((((1111*(11*(1+(1+1))+1)+1)*(1+(11+11)))*(1+1)+1)*111))*(1+1))
475898732:(((11)!+(((((1+111)*11+(1+1))*(1+11))*(1+1)+1)*(1+(1+111))))*11+1)
482826596:(((1+(((111*11)*11)+(11111*(1+1))))*111+1)*(11+111)+((1+(1+1)))!)
484263150:(((111*111+(1+(1+1)))*111+11)*(1+(111+((11+11)*11))))
506235403:(((1+11))!+((((1+(1+1111))*(1+1111)+((11+111)*(1+1)))*11+1)*(1+1)+1))
548951531:((((111+111)*(1+1)+1)*111+11)*11111+((11+111)*(1+11)+1))
554295842:(((1+11))!+((((1+1111)*111+1)*((1+1)*(1+1)+1))*(11+111)+(1+111)))
580536366:(((1+(111+((111*111+11)*(1+11))))*(1+111)+1)*(11+((1+(1+(1+1))))!)+11)
587051904:(((((1+1111)*(1+11))*(1+(1+1))+1)*(111*11+1)+(111*((1+(1+1)))!))*(1+11))
588265985:(((1+11))!+((1+(111+(1111*(1+(1+11)))))*((1+111)*(11*((1+(1+1)))!+1)+(1+(1+1)))))
588298051:((((((11+111)*11)*11)+(11111*(1+(1+1))))*(1+1111)+1)*11)
590968352:(((((((1+(1+1)))!)!+11111)*111+(11+11))*((1+111)*(1+1)+1)+1)*(1+1))
601194306:((((1111*(1+(1+(1+(11+111))))+1)*111+(1+1))*(1+(1+1))+1)*(1+(1+11))+11)
607771869:(((1+11))!+(((11)!+(((1111*11+1)*(1+1))*(1+(11+111))+11))*(1+(1+1))))
618578932:(((((1111*111)*11+1)*(1+1)+1)*(1+1))*(1+(1+(1+111)))+(1+111))
626776380:((((1+(1+(1+1))))!+((((1+(1+1)))!)!+(1111*111)))*(1+(11+((1+((1+(1+1)))!))!)))
667919873:((((((1+(11+111))*11+1)*111+(1+(1+1)))*1111+1)*(1+1))*(1+1)+1)
681786366:(((1+11))!+((11)!+(((11)!+((11)!+((1+(1+11111))*((1+11)*(1+11))+111)))*(1+1))))
689854904:(((11+((11111+((1+1111)*11))*(1+1)))*((11+111)*11+1)+11)*11+(1+1))
692055400:(((1+11))!+(((((1+(1+111))*(1+(1+(1+11))))*11)*11+1)*(1+(1+1111))+1))
697665495:(((1+11))!+(((((((1+(1+1)))!)!*(1+(1+(1+111)))+1)*(1+11))*(1+1)+1)*111))
711608194:(((11)!+(((1+(1+(1+(1+1111))))*(11+((11+111)*(1+1)))+(1+1))*1111))*(1+1))
734027104:(((111*(11+((1+(1+(1+1))))!)+1)*(((1+(1+1)))!+11)+1)*11111+1111)
750869335:((11111111+((1+(((1+(1+1)))!)!)*((1+11)*11+1)+1))*(11*((1+(1+1)))!+1))
757710567:((((((11+111)*11)+111111)*(1+(1+1))+1)*(1+(11+1111))+(1+(1+1)))*(1+1)+1)
759967747:(((11)!+(((1+(1+(111+11111)))*(1+(1+111)))*(1+(11+11))+1))*11)
777616154:((11111*(111+(((111*11+1)*(1+1))*(1+1)))+(11+111))*(1+(1+(1+11))))
830071127:((((1+111)*111)*((1+(1+1)))!+1)*(((1+(1+1)))!+(11+11111))+(111*(1+1)+1))
833809927:((((11+1111)*(1+1)+1)*111+1)*(1+(1+(11+(1111*(1+(1+1))))))+111)
835873060:(((((11+(111+111))*111+1)*(1+(1+111))+1)*(1+(1+11))+1)*(11+11))
836438554:(((1+11))!+(((11111*(1+1)+1)*((11+(((1+(1+1)))!)!)*11+1)+1111)*(1+1)))
836945593:(((1111*1111+(1+111))*(1+(1+111))+(1+(1+1)))*((1+(1+1)))!+1)
863728236:(((1+(1111+((11+11111)*(1+1))))*(111*111+((1+(1+1)))!))*(1+(1+1)))
864158514:(((1+11))!+(((1111*(1+(1+(1+11)))+((1+(1+1)))!)*111+1)*(111*(1+1)+1)+11))
871273503:((((1+11111)*(11+11)+1)*((1+(1+11))*(1+1)+1)+1)*((1+11)*11)+111)
881615667:((11111+((111*111+11)*(1+1)))*((111*111)*(1+1)+1)+((11+1111)*11))
891619600:(((11)!+((11)!+((((1+(11+11))*(1+1))+111111)*11)))*11+(1+(1+1)))
897181691:((11+(11+(11+((1+(1+((1+(1+1)))!)))!)))*(11+(11111*(1+1)))+((111*11+1)*11))
918159061:(((11)!+(((11+11)*11+1)*(1+(1+11))))*(1+(11+11))+(1+(1+(1+1))))
920521050:(((11)!+((((1+(11+1111))*(1+(1+(1+1111))))*(1+111)+111)*(1+(1+1))))*(1+1))
924502226:((((1111*(1+11))*(1+1)+1)*((111*(1+11)+1)*(1+1)+1))*(1+(1+11))+11)
929983535:(((11)!+((((11+111)*111+1)*111)*((1+11)*(1+1)+1)+(1+1)))*(1+11)+11)
943162304:(((11)!+((((((1+((1+(1+1)))!))!+(111*111))*111+(1+1))*(1+111))*(1+1)))*(1+1))
950210939:(((11+(111+11111))*(1+(1+(1+(((1+(1+1)))!)!)))+(1+1))*(((1+(1+1)))!+111)+(1+1))
950214176:(((11)!+((((111*111)*(1+(1+11)))*11+1)*((1+(11+111))*(1+1)+1)))*(1+1))
962610357:((((1+11))!+((1+((((1+(1+1)))!)!+(111*(1+11))))*(11+1111)+(1+111)))*(1+1)+1)
974842859:((((((11*(1+((1+(1+1)))!))+1111)*11+1)*(1+111))*((1+(1+1)))!)*111+11)
988572832:(((111111111+((11111*(1+(1+1111))+11)*11+(1+(1+1))))*(1+1))*(1+1))


Generate the longest error message in C++ Write a short program, that would generate the longest possible error message, in a standard C++ compiler (gcc, cl.exe, icc, or clang).

The score of each entry is the number of characters in the longest error message the compiler emitted. Types included in your source code and quoted by the compiler are counted as a single character.

Cheating

You can always redefine a template in template in template with long names, but I expect something creative. I tried to prevent some of that by the last rule, but of course the rules can be better, and I'll be glad for improvements.

19 characters

Create a file a.cpp with this content :

#include __FILE__
p;

Compile as :

g++ a.cpp

and get amazing 21300 lines error messages  :

In file included from a.cpp:1:0,
                 from a.cpp:1,
                 from a.cpp:1,
                 from a.cpp:1,

...

... 21280 error lines ...
...

In file included from a.cpp:1:0,
                 from a.cpp:1,
                 from a.cpp:1,
                 from a.cpp:1,
                 from a.cpp:1:
a.cpp:2:1: error: ‘p’ does not name a type
In file included from a.cpp:1:0,
                 from a.cpp:1,
                 from a.cpp:1,
                 from a.cpp:1:
a.cpp:2:1: error: ‘p’ does not name a type
In file included from a.cpp:1:0,
                 from a.cpp:1,
                 from a.cpp:1:
a.cpp:2:1: error: ‘p’ does not name a type
In file included from a.cpp:1:0,
                 from a.cpp:1:
a.cpp:2:1: error: ‘p’ does not name a type
In file included from a.cpp:1:0:
a.cpp:2:1: error: ‘p’ does not name a type
a.cpp:2:1: error: ‘p’ does not name a type


Code Golf: Forwards sdrawkcaB sdrawkcaB Forwards Forwards sdrawkcaB Task

The user inputs a sentence - words only. Any input other than letters or spaces, including integers and punctuation, should throw an exception: "Sentence must only use letters".
The output has a pattern, where some
words are reversed and others words are normal.
The pattern starts as
a normal word, the next two words are reversed, then the next two
words are normal and the pattern continues.
An example of where the words should be normal and where words reversed is below:

Normal - Reversed - Reversed - Normal - Normal - Reversed - Reversed - Normal ...

Input Example

She sells Sea shells on the Sea shore

Output Example

She slles aeS shells on eht aeS shore

Additional Rules

If capital letters are used, they should remain on the letter they were originally posted on.
Any multiple spaces initially posted on input should be reduced to one space. For example Programming   Puzzles and   Code Golf becomes Programming selzzuP dna Code Golf

Shortest Code Wins!!

Happy coding...

TeaScript, 55 bytes 58 60 69 76 78 80 87 89

xO`a-z `?xl(#~-i&2?l:lv(),/ +/):Ld`SÀZn Û § «e Ò5s`

This is extremely short, I'm very happy with it.

The last ~20 characters may seem like gibberish but that's "Sentence must only use letters" encoded. All the characters have char codes below 256 so each are one byte

Explanation

xO`a-z `?  // If input contains only a-z and space...

   xl(#       // Loop through input
      ~-i&2?  // If (index - 1 "unary and"ed with 2) isn't 0...
          :l,     // Leave alone
          lv()    // Otherwise, reverse string
       / +/ // Loops on spaces
   )

:Ld`SÀZn Û § «e Ò5s` // Otherwise... decompress and print  the error string

Try it online
Pastebin


Make a bottom up poem Based on the "Pretty Ugly" poem.
Input consists of a number of stanzas (positive integer), and four arrays/lists of strings, called the "negatives", "negations", "positives", and "filler" sentences.
You must output a "pretty ugly" poem with the specified number of stanzas. A stanza consists of a negative, negation, positive and filler sentence, in that order. Finally, the poem must end with the string (Now read bottom up).
In other words, the output must be a list of strings of the form [negative, negation, positive, filler, negative, negation, positive, filler, negative, ..., "(Now read bottom up)"], with the negative, negation, positive , filler part repeated once per stanza.
Rules:

The lines should be chosen at random from the lists
Output can be in any format, as long as it's a comprehensible poem. Printing to STDOUT, returning a list of strings, returning a string with lines separated by commas, and so on are all allowed
You may assume that the 4 lists are all non-empty, but not that they have the same length
The number of stanzas can be zero. If so, the output is (Now read bottom up)
Shortest program (in bytes) wins

Sample input:
n = 4

negatives = [
  "I am a terrible person",
  "Everything I do is useless",
  "I don't deserve to be loved",
  "I will never succeed at anything"
]

negations = [
  "It's foolish to believe that",
  "I don't think it's reasonable to say that",
  "I will never believe that",
  "No one can convince me into thinking that"
]

positives = [
  "I am beautiful inside and out",
  "The people around me love me",
  "I will succeed at my career",
  "I can be successful"
]

fillers = [
  "I just have to accept that",
  "After all, it's pretty clear",
  "So I think it's pretty obvious",
  "It will be clear if you think about it"
]

Sample output:
I don't deserve to be loved
I don't think it's reasonable to say that
I will succeed at my career
After all, it's pretty clear
I don't deserve to be loved
I don't think it's reasonable to say that
I can be successful
I just have to accept that
Everything I do is useless
No one can convince me into thinking that
I can be successful
So I think it's pretty obvious
I don't deserve to be loved
It's foolish to believe that
I am beautiful inside and out
I just have to accept that
(Now read bottom up)

Perl 5, 62 61 bytes
@randomdude999 pointed out a space I could remove to save a byte.

sub f{(map{map$$_[rand@$_],@_}1..pop),"(Now read bottom up)"}

Try it online!
A function which takes in the sets of statements as a reference to an array for each type of statement and the number of stanzas.  Returns an array of strings, one element for each line of the poem.


Output the n-th Bell Number A Bell number (OEIS A000110) is  the number of ways to partition a set of n labeled (distinct) elements. The 0th Bell number is defined as 1.

Let's look at some examples (I use brackets to denote the subsets and braces for the partitions):

1: {1}
2: {[1,2]}, {[1],[2]}
3: {[1,2,3]}, {[1,2],[3]}, {[1,3],[2]}, {[2,3],[1]}, {[1],[2],[3]}

There are many ways to compute Bell numbers, and you are free to use any of them. One way will be described here:

The easiest way to compute Bell numbers is to use a number triangle resembling Pascal's triangle for the binomial coefficients. The Bell numbers appear on the edges of the triangle. Starting with 1, each new row in the triangle is constructed by taking the last entry in the previous row as the first entry, and then setting each new entry to its left neighbor plus its upper left neighbor:

1
1    2
2    3    5
5    7   10   15
15  20   27   37   52

You may use 0-indexing or 1-indexing. If you use 0-indexing, an input of 3 should output 5, but should output 2 if you use 1-indexing.

Your program must work up to the 15th Bell number, outputting 1382958545. In theory, your program should be able to handle larger numbers (in other words, don't hardcode the solutions).
EDIT: You are not required to handle an input of 0 (for 0-indexing) or 1(for 1-indexing) because it is not computed by the triangle method.

Test cases (assuming 0-indexing):

0 ->  1 (OPTIONAL)
1 ->  1
2 ->  2
3 ->  5
4 ->  15
5 ->  52
6 ->  203
7 ->  877
8 ->  4140
9 ->  21147
10 -> 115975
11 -> 678570
12 -> 4213597
13 -> 27644437
14 -> 190899322
15 -> 1382958545

Answers using a built-in method (such as BellB[n] in the Wolfram Language) that directly produces Bell numbers will be noncompetitive.

Shortest code (in bytes) wins.

JavaScript (ES6), 47 bytes

f=(n,a=[b=1])=>n--?f(n,[b,...a.map(e=>b+=e)]):b
f=(n,a=[b=1])=>--n?f(n,[b,...a.map(e=>b+=e)]):b

First one is 0-indexed, second is 1-indexed.


Output a Dance Dance Revolution arrow chart If you're not familiar, Dance Dance Revolution is a rhythm game where you hit four receptors (left, down, up, right) with your feet as arrows scroll up the screen. One of the file formats used to lay out the arrow patterns looks something like this:

1000
0100
0000
0011
,

A 1 represents a tap note. This chart has a left tap, a down tap, an empty line, and an up-right jump, respectively. The comma at the end indicates the end of a measure, and there can be any number of measures in a song.

Now here's an example of a more complicated chart:

1000
0010
0100
0001
0010
0100
2000
0000
,
0010
0001
3100
1001
,

The first measure has eight lines, so each line represents an eighth note, but the second measure only has four lines, all of which are quarter notes. All measures are the same duration; measures containing more lines are simply denser. You can assume that all measures will have lengths that are powers of two greater than or equal to 4. So measures can have 4 lines, 8 lines, 16 lines, and so on.

A 2 indicates the start of a hold arrow and a 3 represents its end. You can assume that each 2 will have a corresponding 3 in the same column, without anything between them other than zeroes and/or measure boundaries.

Your task is to print the stepchart in a more human-readable format. It's probably best if I just give you an example. Here's the expected output for the chart given above:

<
  ^
 v
   >
  ^
 v
<
|
| ^
|
|  >
|
|v

<  >

(If this is confusing to you, perhaps looking at this will help.)

Left, down, up, and right taps are indicated by <, v, ^, and >, respectively. Hold arrows are indicated by pipes that trail beneath the starting taps.

Additionally, the chart needs to be stretched so that each measure is the same length: in the above example, the measures have lengths of 8 and 4, so the output shows all measures as if they contained eighths. If you have a chart where all measures are 4 lines long except for one that's 64 lines, the output needs to render all measures as 64 lines long!

I/O: Assume the chart exists in a file whose name is given as the first argument to the program (e.g. python arrows.py input.txt). Write to standard output. If (and only if) your language of choice doesn't have filesystem access for whatever reason, it's acceptable to load it as a string at the beginning of the program.

Goal: The program with the fewest characters will be accepted a week from now, the 17th of August, around 8:00 EST.


Generate a Stack Exchange Favicon Do you recognize the PPCG logo?
it looks like this, when you do an ascii art of it.

+---+
|PCG|
+---+
   v

Now, In this Code Golf, You will make a code, that makes logos for other sites, similar to the PPCG logo.

What You should do

The "Shortened" string will be the string, with all upper case letters and numbers in the input string.(Which would be PPCG when the input string is Programming Puzzles & Code Golf)

The "Box" (

+---+
|   |
+---+
   v

)
should fit the Shortened string perfectly.(No bigger or smaller)

Also the v part should be exactly 1 down and 1 left to the down right +.

Then output the box which has the shortened string in it.

Example

Stack Overflow:

+--+
|SO|
+--+
  v

Area 51:

+---+
|A51|
+---+
   v

Rules

You may assume that the input contains at least one digit or upper case letter.

Standard code-golf rules apply.

Vim, 42 strokes

:s/[^A-Z0-9]//g
YPVr-i+<DOWN><LEFT>|<ESC><C-V>ky$pYjppVr $xrv

Replace <DOWN> with ↓, <LEFT> with ←, <ESC> with esc and <C-V> with CTRL+V.

Here's an animation of this script running (old version which uses a V instead of a v):

Explanation of the script:

:s/[^A-Z0-9]//g                               # Remove all the characters that are not uppercase or numbers using a Regex.
YPVr-                                         # Duplicate the current, and replace all the characters of the upper one with dashes.
     i+<DOWN><LEFT>|<ESC>                     # Insert a + on the upper line, and a | on the second line.
                         <C-V>ky$p            # Copy the + and | to the end of both lines.
                                  Yjpp        # Copy the upper line to the bottom two times.
                                      Vr $    # Replace the bottom most line with spaces and put the cursor on the last character.
                                          xrv # Remove the last character and replace the second last character with a v.