Can you help Tony Stark become an Ironman? Tony Stark is, as we know Ironman (that super awesome guy in metal suit and loads of weapons). However, without the metal suit, he can't claim that title. Tony Stark, having a great ego, wants to finish Norseman, which is considered to be the hardest triathlon in the world (for distances equivalent to those of an Ironman race), to prove that he's a mean machine, even when he leaves the iron at home.

Tony has a predefined schedule / time plan for each part of the competition.
That means for every location in the race (i.e. distance from start), there's an expected time he should arrive there based on the schedule.

He also has a watch that tells the time spent and the total distance covered.

Your task is: Given those two values as input, tell Tony how much he is ahead of, or behind schedule. The input will be a time on the format hh:mm:ss (or (optional) h:mm:ss if it's been less than 10 hours) and a decimal number telling how far he has come (in km).

The distances for each of the three disciplines are:

Swim: 3.8 km
Bike: 180 km
Run: 42 km
Total distance: 225.8 km   // Input will never exceed 225.8

The estimated times for each part (i.e. the schedule):

Swim: 1:20:00
Transition 1: 0:12:00
Bike: 7:10:00
Transition 2: 0:05:00
Run: 4:50:00
Total: 13:37:00

Both distances, and the estimated times are given before the race, and can therefore be hardcoded. The transition zone is just a place where he changes clothes and equipment, so he's not moving during transition.

Input can be comma-separated, a string, two separate arguments or whatever is most convenient in your language. He want the output on the format +/-mm:ss, not hours (assume he's never more than one hour too slow or too fast. If he's in transition, you can assume he just got there.

Examples and explanations (apologies for the length of it):

Input: 04:32:20 93.8
Output: +34:40 / 34:40

At 93.8 km, he has finished the swim, been through transition and has finished half of the bike leg. According to the schedule, this should have taken him: 1:20:00 + 0:12:00 + (0.5 * (07:10:00)) = 5:07:00. If he has used 4:32:20, then he's 34:40 ahead of schedule.

Input: 1:20:00 3.8
Output: +00:00 / +0:00 / 00:00 / 0:00 / -00:00 / -0:00

Assuming the distance is 3.8, you can assume he has just got into the first transition zone. The estimated time here was 1:20:00, so for the input above, he's on time.

If the time is 1:25:00, then he's 5 minutes behind schedule, thus:

Input: 1:25:00 3.8
Output: -05:00 / -5:00

Another example, explained in detail:

Input: 10:33:46 198.14

So, a distance of 198.14 km has been covered. That means he has finished the swim (3.8), the bike leg (180 km) and 14.34 km of the running, and he has been through both transitions. According to the schedule, he should have started the run after: 1:20:00 + 0:12:00 + 07:10:00 + 0:05:00 = 8:47:00. 42 km of running should take 4:50:00, thus 14.34 km should take: 4:50:00 * (14.34 / 42) = 1:39:01. So, according to the plan, 198.14 km should take: 8:47:00 + 1:39:01 = 10:26:01. He has used 10:33:46, which is 07:45 more than planned.

Output: -07:45 / -7:45

The plus sign is optional, but there has to be a minus sign if he's behind schedule.

The output should have exactly the same format as the examples above, but trailing spaces, newlines etc. are OK.

This is code golf, so the shortest code in bytes win.


Display Continued Fractions Your challenge is to convert a fraction into its continued fraction form.

Input: The fraction may be input in any format, including (but not restricted to)

string: "7/16"
list:  {7, 16}, (7, 16), [7, 16]
simple ordered pair: 7 16
function: f[7,16]

Output: A continued fraction, in 2D, with horizontal fraction bars separating numerator from denominator. Only continued fractions with numerators equal to 1 are valid. It is not necessary to make the font size vary according to depth. A leading zero (for proper fractions) is optional.

Depth: Your code must be able to display at least 8 levels of depth.

Winning criterion: Shortest code wins. You must include several test cases showing input and output.

Test Examples (Input followed by output)

5/4

5/3

5/7

9/16

89/150


Plot a hyperbolic plane tessellation Make a plot (Poincare disk) of a tessellation on a hyperbolic plane, such as:

The program takes four inputs:

1) How many edges/polygon (three in this example).

2) How many intersect at each vertex (seven in this example).

3) How many steps away from the center vertex to render (5 in this example, if you look closely). This means that a vertex is included iff it can be reached in 5 or less steps form the center. Edges are rendered iff both their vertexes are included.

4) The resolution of the image (a single number of pixels, the image is square).

The output must be an image. Edges must be rendered as circle-arcs, not lines (the Poincaré disk projection turns lines into circles). Points do not need to be rendered. When the user puts in something that is not hyperbolic (i.e. 5 triangles meeting at each vertex), the program does not have to work properly. This is code-golf, so the shortest answer wins.

Mathematica, 2535 bytes
Taken from here (hence why it's community wiki). Not really that golfed. View the provided link for the author's explanation of his code.
Also, I'm no Mathematica expert, but I bet Martin could do wonders on the code length. I don't even understand the math behind it.
I left it readable, but if the question doesn't get closed, I'll golf it past readability and move the 2 other parameters inside the caller function.
Currently invalid, feel free to help improve it:

I think this uses lines rather than arcs.

Centered on a face, rather than a vertex.

HyperbolicLine[{{Px_, Py_}, {Qx_, Qy_}}] :=
 If[N[Chop[Px Qy - Py Qx]] =!= 0.,
  Circle[OrthoCentre[{{Px, Py}, {Qx, Qy}}],
   OrthoRadius[{{Px, Py}, {Qx, Qy}}],
   OrthoAngles[{{Px, Py}, {Qx, Qy}}]], Line[{{Px, Py}, {Qx, Qy}}]]

OrthoCentre[{{Px_, Py_}, {Qx_, Qy_}}] :=
 With[{d = 2 Px Qy - 2 Py Qx, p = 1 + Px^2, q = 1 + Qx^2 + Qy^2},
  If[N[d] =!= 0., {p Qy + Py^2 Qy - Py q, -p Qx - Py^2 Qx + Px q}/d,
   ComplexInfinity]]

OrthoRadius[{{Px_, Py_}, {Qx_, Qy_}}] :=
 If[N[Chop[Px Qy - Py Qx]] =!= 0.,
  Sqrt[Total[OrthoCentre[{{Px, Py}, {Qx, Qy}}]^2] - 1], Infinity]

OrthoAngles[{{Px_, Py_}, {Qx_, Qy_}}] :=
 Block[{a, b, c = OrthoCentre[{{Px, Py}, {Qx, Qy}}]},
  If[(a = N[Apply[ArcTan, {Px, Py} - c]]) < 0., a = a + 2 \[Pi]];
  If[(b = N[Apply[ArcTan, {Qx, Qy} - c]]) < 0.,
   b = b + 2 \[Pi]]; {a, b} = Sort[{a, b}];
  If[b - a > \[Pi], {b, a + 2 \[Pi]}, {a, b}]]

Inversion[Circle[{Cx_, Cy_}, r_], {Px_, Py_}] := {Cx, Cy} +
  r^2 {Px - Cx, Py - Cy}/((Cx - Px)^2 + (Cy - Py)^2)
Inversion[Circle[{Cx_, Cy_}, r_, {a_, b_}], {Px_, Py_}] := {Cx, Cy} +
  r^2 {Px - Cx, Py - Cy}/((Cx - Px)^2 + (Cy - Py)^2)

Inversion[Circle[{Cx_, Cy_}, r_, {a_, b_}], p_Line] :=
 Map[Inversion[Circle[{Cx, Cy}, r], #] &, p, {2}]

Inversion[Circle[{Cx_, Cy_}, r_, {a_, b_}], p_Polygon] :=
 Map[Inversion[Circle[{Cx, Cy}, r], #] &, p, {2}]

Inversion[Line[{{Px_, Py_}, {Qx_, Qy_}}], {Ux_, Uy_}] :=
 With[{u = Px - Qx,
   v = Qy - Py}, {-Ux (v^2 - u^2) - 2 u v Uy,
    Uy (v^2 - u^2) - 2 u v Ux}/(u^2 + v^2)]
Inversion[Line[{{Px_, Py_}, {Qx_, Qy_}}], p_Polygon] :=
 Map[Inversion[Line[{{Px, Py}, {Qx, Qy}}], #] &, p, {2}]

Inversion[Circle[{Cx_, Cy_}, r_], c_List] :=
 Map[Inversion[Circle[{Cx, Cy}, r], #] &, c]

PolygonInvert[p_Polygon] :=
 Map[Inversion[HyperbolicLine[#], p] &,
  Partition[Join[p[[1]], {p[[1, 1]]}], 2, 1]]
PolygonInvert[p_List] := Flatten[Map[PolygonInvert[#] &, p]]

LineRule = Polygon[x_] :> Line[Join[x, {x[[1]]}]];
HyperbolicLineRule =
  Polygon[x_] :>
   Map[HyperbolicLine, Partition[Join[x, {x[[1]]}], 2, 1]];

CentralPolygon[p_Integer, q_Integer, \[Phi]_: 0] :=
 With[{r = (Cot[\[Pi]/p] Cot[\[Pi]/q] - 1)/
     Sqrt[Cot[\[Pi]/p]^2 Cot[\[Pi]/q]^2 - 1], \[Theta] = \[Pi] Range[
       1, 2 p - 1, 2]/p},
  r Map[{{Cos[\[Phi]], -Sin[\[Phi]]}, {Sin[\[Phi]], Cos[\[Phi]]}}.# &,
     Transpose[{Cos[\[Theta]], Sin[\[Theta]]}]]]

PolygonUnion[p_Polygon, tol_: 10.^-10] := p
PolygonUnion[p_List, tol_: 10.^-10] :=
 With[{q = p /. Polygon[x_] :> N[Polygon[Round[x, 10.^-10]]]},
  DeleteDuplicates[q]]
HyperbolicTessellation[p_Integer, q_Integer, \[Phi]_, k_Integer,
  t_: 10.^-10] :=
 Map[PolygonUnion[#, t] &,
   NestList[PolygonInvert, Polygon[CentralPolygon[p, q, \[Phi]]],
     k][[{-2, -1}]]] /; k > 0

HyperbolicTessellation[p_Integer, q_Integer, \[Phi]_, k_Integer,
  t_: 10.^-10] := Polygon[CentralPolygon[p, q, \[Phi]]] /; k == 0
HyperbolicTessellationGraphics[p_Integer, q_Integer, \[Phi]_,
  k_Integer, rule_RuleDelayed, opts___] :=
 Graphics[{Circle[{0, 0}, 1],
   HyperbolicTessellation[p, q, \[Phi], k, 10.^-10] /. rule}, opts]

Called like:
HyperbolicTessellationGraphics[3, 7, 0., 7, HyperbolicLineRule, ImageSize -> 300, PlotLabel -> "{7,7}"]


Calculate the sum of ILD Input:

An integer

Output:

Sum of the input itself + the length of the input + each individual digit of the input.

nr + nr-length + {sum of digits} = output

Examples:

Input: 99
Output: 99 (nr) + 2 (nr-length) + (9 + 9) (digits) → 119

Input: 123
Output: 123 + 3 + (1 + 2 + 3) → 132

Challenge rules:

The input can also contain negative input, which are resolved special. The -/minus-sign is also +1 for the length, and is part of the first digit.
For example:

Input: -123
Output: -123 + 4 + (-1 + 2 + 3) → -115
You can assume that the input nor output will ever be outside the range of an (32-bit) integer.

General rules:

This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
Default Loopholes are forbidden.
If possible, please add a link with a test for your code.
Also, please add an explanation if necessary.

Test cases:

87901 → 87931
123 → 132
99 → 119
5 → 11
1 → 3
0 → 1
-3 → -4
-123 → -115
-900 → -905
-87901 → -87886

Semi-related: Count Sum of all Digits

Python 2, 39 bytes

lambda x:x+len(`x`)+eval("+".join(`x`))

Test suite
Using the same eval-trick as in my Pyth-answer.


Approximate the proportion of integers with neighboring factors If 1 is not counted as a factor, then

40 has two neighboring factors (4 and 5)
1092 has two neighboring factors (13 and 14)
350 does not have two neighboring factors
(out of its factors 2, 5, 7, 10, 14, 25, 35, 50, 70, and 175,
no two are consecutive)

The proportion of positive integers that have this property
is the proportion divisible by any of
6 (2 × 3), 12 (3 × 4), 20 (4 × 5), 30, 56, ….
If we only calculate the proportion divisible by the first n of these,
we get an approximation that gets more accurate as n increases.

For example,
for n=1,
we find the proportion of integers divisible by 2 × 3 = 6,
which is 1/6.
For n=2,
all integers divisible by 3 × 4 = 12 are also divisible by 6,
so the approximation is still 1/6.
For n=3,
the proportion of integers divisible by 6 or 20 is 1/5,
and so on.

Here are the first few values:

1  1/6                0.16666666666666666
3  1/5                0.20000000000000000
6  22/105             0.20952380952380953
9  491/2310           0.21255411255411255
12 2153/10010         0.21508491508491510
15 36887/170170       0.21676558735382265
21 65563/301070       0.21776663234463747
24 853883/3913910     0.21816623274423785
27 24796879/113503390 0.21846817967287144

For values of n between the provided values,
the output should be the same as the output for the value above
(e.g. n=5 → 1/5).

Your program should take n and output either a fraction or decimal answer.
You may take n at any offset
(e.g. 0-indexing or 2-indexing into this sequence, instead of 1-indexing).

For decimal output,
your program must be accurate to at least 5 digits
for all the test cases given.

Scoring is code-golf, with the shortest code winning.

Inspired by What proportion of positive integers have two factors that differ by 1? by marty cohen -- specifically, by Dan's answer.

Jelly,  14 13  10 bytes
-1 using Erik the Outgolfer's idea to take the mean of a list of zeros and ones.
-3 by using 3-indexing (as allowed in the question) - thanks to Dennis for pointing this out.
ḊPƝḍⱮ!Ẹ€Æm

A monadic Link accepting an integer, n+2, which yields a float.
Try it online! (very inefficient since it tests divisibility over the range \$[2, (n+2)!]\$)
(Started out as +2µḊPƝḍⱮ!§T,$Ẉ, taking n and yielding [numerator, denominator], unreduced)
How?
ḊPƝḍⱮ!Ẹ€Æm - Link: integer, x=n+2
Ḋ          - dequeue (implicit range of) x  - i.e. [2,3,4,...,n+2]
  Ɲ        - apply to neighbours:
 P         -   product                             [2×3,3×4,...,(n+1)×(n+2)]
     !     - factorial of x                        x!
    Ɱ      - map across (implicit range of) x! with:
   ḍ       -   divides?                            [[2×3ḍ1,3×4ḍ1,...,(n+1)×(n+2)ḍ1],[2×3ḍ2,3×4ḍ2,...,(n+1)×(n+2)ḍ2],...,[2×3ḍ(x!),3×4ḍ(x!),...,(n+1)×(n+2)ḍ(x!)]]
       €   - for each:
      Ẹ    -   any?  (1 if divisible by any of the neighbour products else 0)
        Æm - mean


Are there mountain rings? Challenge

Given a matrix of positive integers, determine if there are any "rings" of mountains. The formal definition for this challenge is: given a matrix of positive integers, is there any positive integer n for which there is a closed ring of cells in the matrix that are strictly greater than n such that all cells enclosed in the ring are less than or equal to n.

Let's take a truthy example:

3 4 5 3
3 1 2 3
4 2 1 3
4 3 6 5

If we set n to 2:

1 1 1 1
1 0 0 1
1 0 0 1
1 1 1 1

As we can clearly see, the 1s along the edge form a ring.

We define a ring as an ordered collection of cells where adjacent cells in the collection are also adjacent (edge or corner) on the grid. Additionally, the ring must contain at least 1 cell inside of it; that is, attempting to edge-only BFS-floodfill the entire matrix excluding the cells in the collection and never traversing a cell in the collection must miss at least one cell.

Truthy Test Cases

4 7 6 5 8 -> 1 1 1 1 1
6 2 3 1 5 -> 1 0 0 0 1 (n = 3)
6 3 2 1 5 -> 1 0 0 0 1
7 5 7 8 6 -> 1 1 1 1 1

1 3 2 3 2
1 6 5 7 2
1 7 3 7 4
1 6 8 4 6

1 3 1
3 1 3
1 3 1

7 5 8 7 5 7 8 -> if you have n = 4, you get an interesting ridge shape around the top and right of the grid
8 4 4 2 4 2 7
6 1 8 8 7 2 7
5 4 7 2 5 3 5
5 6 5 1 6 4 5
3 2 3 2 7 4 8
4 4 6 7 7 2 5
3 2 8 2 2 2 8
2 4 8 8 6 8 8

5 7 6 8 6 8 7 -> there is an island in the outer ring (n = 4), but the island is a ring
5 3 2 4 2 4 7
6 3 7 8 5 1 5
8 2 5 2 8 2 7
8 3 8 8 8 4 7
6 1 4 1 1 2 8
5 5 5 5 7 8 7

150 170 150
170 160 170
150 170 150

Falsy Test Cases

1 2 3 2 1 -> this is just a single mountain if you picture it graphcially
2 3 4 3 2
3 4 5 4 3
2 3 4 3 2
1 2 3 2 1

4 5 4 3 2 -> this is an off-centered mountain
5 6 5 4 3
4 5 4 3 2
3 4 3 2 1

1 1 1 1 1 -> this is four mountains, but they don't join together to form a ring
1 2 1 2 1
1 1 1 1 1
1 2 1 2 1
1 1 1 1 1

3 3 3 3 3 -> there is a ring formed by the `3`s, but the `4` in the middle is taller so it doesn't qualify as a mountain ring
3 1 1 1 3
3 1 4 1 3
3 1 1 1 3
3 3 3 3 3

3 4 4 4 3
4 4 3 4 4
3 3 3 3 4
4 4 3 4 4
3 4 4 4 3

1  2  3  4  5
6  7  8  9  10
11 12 13 14 15
16 17 18 19 20
22 23 24 25 26

Rules

Standard Loopholes Apply
This is code-golf, so the shortest answer in bytes in each language is declared the winner of its language. No answers will be accepted.
The input may be taken as any reasonable form for a matrix of positive integers
The output may be given as any two reasonable, consistent, distinct values indicating [true] or [false].

Jelly, 38 bytes

Ẇ€Z$⁺Ẏµ,ZẈ>2ẠµƇµḊṖZƊ⁺FṀ<,Z.ịḊṖ$€Ɗ€ƊȦ)Ṁ

Try it online!

Outputs 1 if the matrix contains mountain ranges, 0 otherwise.

How it works (slightly outdated)

I may be able to shorten the code a bit, so this section will probably undergo heavy editing.

The helper link

,Z.ịḊṖ$€Ɗ€ – Helper link. Let S be the input matrix.
,Z         – Pair S with its transpose.
        Ɗ€ – For each matrix (S and Sᵀ), Apply the previous 3 links as a monad.
  .ị       – Element at index 0.5; In Jelly, the ị atom returns the elements at
             indices floor(x) and ceil(x) for non-integer x, and therefore this
             returns the 0th and 1st elements. As Jelly is 1-indexed, this is the
             same as retrieving the first and last elements in a list.
    ḊṖ$€   – And for each list, remove the first and last elements.

For example, given a matrix in the form:

A(1,1) A(1,2) A(1,3) ... A(1,n)
A(2,1) A(2,2) A(2,3) ... A(2,n)
A(3,1) A(3,2) A(3,3) ... A(3,n)
...
A(m,1) A(m,2) A(m,3) ... A(m,n)

This returns the arrays (the order doesn't matter):

A(1,2), A(1,3), ..., A(1,n-1)
A(m,2), A(m,3), ..., A(m,n-1)
A(2,1), A(3,1), ..., A(m-1,1)
A(2,n), A(3,n), ..., A(m-1,n)

Long story short, this generates the outermost rows and columns, with the corners removed.

The main link

Ẇ€Z$⁺Ẏµ,ZẈ>2ẠµƇµḊṖZƊ⁺FṀ<ÇȦ)Ṁ – Main link. Let M be the input matrix.
Ẇ€                           – For each row of M, get all its sublists.
  Z$                         – Transpose and group into a single link with the above.
    ⁺                        – Do twice. So far, we have all contiguous sub-matrices.
     Ẏ                       – Flatten by 1 level.
      µ      µƇ              – Filter-keep those that are at least 3 by 3:
       ,Z                      – Pair each sub-matrix S with Sᵀ.
         Ẉ                     – Get the length of each (no. rows, no. columns).
          >2                   – Element-wise, check if it's greater than 2.
            Ạ                  – All.
               µ          )  – Map over each sub-matrix S that's at least 3 by 3
                ḊṖ           – Remove the first and last elements.
                  ZƊ         – Zip and group the last 3 atoms as a single monad.
                    ⁺        – Do twice (generates the inner cells).
                     FṀ      – Flatten, and get the maximum.
                       <Ç    – Element-wise, check if the results of the helper
                               link are greater than those in this list.
                         Ȧ   – Any and all. 0 if it is empty, or contains a falsey
                               value when flattened, else 1.
                           Ṁ – Maximum.


Peano arithmetic at compile time Peano numbers represent nonnegative integers as zero or successors of other Peano numbers. For example, 1 would be represented as Succ(Zero) and 3 would be Succ(Succ(Succ(Zero))).
Task
Implement the following operations on Peano numbers, at compile time:

Addition
Subtraction - You will never be required to subtract a greater number from a smaller one.
Multiplication
Division - You will never be required to divide two numbers if the result will not be an integer.

Input/Output
The input and output formats do not have to be the same, but they should be one of these:

A type constructor of kind * -> * to represent S and a type of kind * to represent Z, e.g. S<S<Z>> to represent 2 in Java or int[][] (int for 0, [] for S).
A string with a Z at the middle and 0 or more S(s and )s around it, e.g. "S(S(Z))" to represent 2.
Any other format resembling Peano numbers, where there is a value representing zero at the bottom, and another wrapper that can contain other values.

Rules

You may use type members, implicits, type constructors, whatever you want, as long as a result can be obtained at compile time.
For the purposes of this challenge, any execution phase before runtime counts as compile time.
Since answers must work at compile-time, answers must be in compiled languages. This includes languages like Python, provided you can show that the bytecode contains the result of your computation before you even run the code.
This is code-golf, so shortest code in bytes wins!

Example for just addition in Scala
sealed trait Num {
  //This is like having a method `abstract Num plus(Num n);`
  type Plus[N <: Num] <: Num
}
object Zero extends Num {
  //When we add any n to zero, it's just that n again
  type Plus[N <: Num] = N
}
final class Succ[N <: Num](n: N) extends Num {
  //In Java: `Num plus(Num x) { return new Succ(n.plus(x)) }
  type Plus[X <: Num] = Succ[N#Plus[X]]
}

Usage (Scastie):
//This is just for sugar
type +[A <: Num, B <: Num] = A#Plus[B]

type Zero = Zero.type
type Two = Succ[Succ[Zero]]
type Three = Succ[Two]
type Five = Succ[Succ[Three]]
val five: Five = null
val threePlusTwo: Three + Two = five
val notFivePlusTwo: Five + Two = five //should fail
val zeroPlusFive: Zero + Five = five

Test cases
S is used for successors and Z is used for zero.
S(S(S(Z))) + Z = S(S(S(Z)))                 | 3 + 0 = 3
S(S(Z)) + S(S(S(Z))) = S(S(S(S(S(Z)))))     | 2 + 3 = 5
S(S(S(Z))) - S(S(S(Z))) = Z                 | 3 - 3 = 0
S(S(Z)) * S(S(S(Z))) = S(S(S(S(S(S(Z))))))  | 2 * 3 = 6
S(S(S(S(Z)))) / S(S(Z)) = S(S(Z))           | 4 / 2 = 2
Z / S(S(Z)) = Z                             | 0 / 2 = 0

Some links to help you get started

Type-Level Programming in Scala (a bunch of articles, including ones about Peano arithmetic) (for Scala)
Multiplication at compile time (for Scala)
Peano arithmetic in C++ type system (for C++)
Type arithmetic (for Haskell)

CP-1610 assembly, 37 bytes
This is simply using macro expansion.
Z EQU 0
MACRO S(n)
(%n%+1)
ENDM
 DCW [expression]

Example
With the expression S(S(Z)) * S(S(S(Z))), this gets compiled as:
00000000 Z
0x0                             Z EQU 0
                                MACRO S(n)
                                (%n%+1)
                                ENDM
                                ;DCW S(S(Z)) * S(S(S(Z)))
                                ;DCW (S(Z)+1) * S(S(S(Z)))
                                ;DCW ((Z+1)+1) * S(S(S(Z)))
                                ;DCW ((Z+1)+1) * (S(S(Z))+1)
                                ;DCW ((Z+1)+1) * ((S(Z)+1)+1)
0000   0006                      DCW ((Z+1)+1) * (((Z+1)+1)+1)
 ERROR SUMMARY - ERRORS DETECTED 0
               -  WARNINGS       0

(compiled with as1600 from the SDK included with jzIntv)


How much can you quickly multiply? With the recent Python bashing, here's an attempt to show Python's strengths.
Your challenge is to write a program that calculates the factorial of as high a number n as possible within 10 seconds.

Your score will be (highest n for your program on your machine)/(highest n for my program on your machine)

Rules

You must calculate an exact integer solution. Since the factorial would be much higher than what can fit in a 64 bit unsigned integer, you can use strings if your language does not support large integers
Standard loopholes are forbidden. Particularly, you cannot use any external resources.
Only the calculation part(this includes time for any workarounds using strings) adds to the total time which should be under 10 seconds on average.
Single threaded programs only.
You must store the output in an easily printable form (as printing takes time) (see my program below), string, variable, character array, etc.

EDIT:

Your program must give the correct output for all n: 1 <= n <= (your highest n)

EDIT2:

I hate to say this explicitly but using your language's built-in factorial functions falls under the standard loopholes http://meta.codegolf.stackexchange.com/a/1078/8766
Sorry Mathematica and Sage

My program

from __future__ import print_function
import time

def factorial( n ):
    return reduce( ( lambda x , y : x * y ) , xrange( 1 , n + 1 ) , 1 )

start = time.clock()
answer = factorial( 90000 )
end = time.clock()

print ( answer )
print ( "Time:" , end - start , "sec" )

Highest score wins.
For the record, my code can manage n = 90000 in about 9.89 seconds on a Pentium 4 3.0 GHz

EDIT: Can everyone please add the score rather than just the highest n. Just the highest n has no meaning by itself as it depends on your hardware. It's impossible to have an objective winning criterion otherwise. ali0sha's anwer does this correctly.

We have a winner. I didn't accept the java answer https://codegolf.stackexchange.com/a/26974/8766 as it kind of skirts close to http://meta.codegolf.stackexchange.com/a/1080/8766

Python 2.7
42.575 = ( 6,812,000 / 160,000 ) approx

Code:
import gmpy2

def fac1(n):
    m=lambda(L):([]if len(L)%2==0 else[L.pop()])+map(lambda(l):l[0]*l[1],zip(L[1::2],L[-2::-2]))
    L=map(gmpy2.mpz,xrange(1,n+1))
    Number = (len(L)-1).bit_length()
    while Number:Number-=1;L=m(L)
    return L[0]

def fac2(n):
    global E; E=0
    def f(i):
        global E; E+=i//2
        return[]if i==1 else f(i//2)+range(3,i,2)+[[1,i][i%2]]
    m=lambda(L):([]if len(L)%2==0 else[L.pop()])+map(lambda(l):l[0]*l[1],zip(L[1::2],L[-2::-2]))
    L=map(gmpy2.mpz,f(n))
    N=(len(L)-1).bit_length()
    while N: N-=1;L=m(L)
    return L[0]<<E

Test:
import time

start = time.time()
baseline(160000)
print time.time()-start

start = time.time()
fac1(6811000)
print time.time()-start

start = time.time()
fac2(6812000)
print time.time()-start

start = time.time()
gmpy2.fac(26000000)
print time.time()-start

Output:
10.0069999695
10.0729999542
10.0360000134
9.98699998856

How it works:
Bigger multiplications take more time, thus we want to do as many small multiplications as possible. This is especially true in Python where for numbers less that 2^64 we use hardware arithmetic, and above that we use software. So, in m(L), we start with a list L; if it's odd length we remove one number from consideration to make it even again. Then we multiply element 1 with element -2, element 3 with -4, etc, so that
m([1,2,3,4,5,6,7,8]) = [2*7, 4*5, 6*3, 8*1] = [14, 20, 18, 8]
m([10,12,6]) = [360,112]
m([120,6]) = [40320]

This approach ensures we're using hardware arithmetic for as long as possible, following which we switch onto the efficient gmc arithmetic library.
In fac2, we take a more classic divide and conquer approach as well, where we split out every multiple of 2 and bitshift them at the end for a trivial performance boost. I've included it here because it's usually around 0.5% faster than fac1.
Golfed Version of fac1 (because I can), 220B
import gmpy2
def f(n):
    m=lambda(L):([]if len(L)%2==0 else[L.pop()])+map(lambda(l):l[0]*l[1],zip(L[1::2],L[-2::-2]))
    L=map(gmpy2.mpz,xrange(1,n+1));N=(len(L)-1).bit_length()
    while N:N-=1;L=m(L)
return L[0]


List of paths to nested dictionary Given a list of nested menu items,

items = [
    '3D/Axis',
    '3D/CameraTracker',

    'Color/Invert',
    'Color/Log2Lin',

    'Color/Math/Add',
    'Color/Math/Multiply',

    'Other/Group',
    'Other/NoOp',

    'Views/JoinViews',
    'Views/ShuffleViews',

    'Views/Stereo/Anaglyph',
    'Views/Stereo/ReConverge',
]

..and a dummy function to be triggered by each item:

def msg(path):
    """Dummy function used in menu
    """
    return path.lower()

Programatically create a hierarchal collection of dictionaries, which is equivalent to manually typing this:

menu = {
    '3D': {'Axis':                     lambda: msg('3D/Axis'),
           'CameraTracker':            lambda: msg("3D/CameraTracker")},

    'Color': {'Invert':                lambda: msg('Color/Invert'),
              'Log2Lin':               lambda: msg('Color/Log2Lin'),

              'Math': {'Add':          lambda: msg('Color/Add'),
                       'Multiply':     lambda: msg('Color/Multiply')}},

    'Other': {'Group':                 lambda: msg('Other/Group'),
              'NoOp':                  lambda: msg('Other/NoOp')},

    'Views': {'JoinViews':             lambda: msg('Views/JoinViews'),
              'ShuffleViews':          lambda: msg('Views/ShuffleViews'),
              'Stereo': {'Anaglyph':   lambda: msg('Views/Stereo/Anaglyph'),
                         'ReConverge': lambda: msg('Views/Stereo/ReConverge')}}},

..which could be tested as follows:

assert menu['3D']['Axis']() == '3d/axis'
assert menu['Color']['Invert']() == 'color/invert'
assert menu['Color']['Math']['Add']() == 'color/math/add'
assert menu['Views']['Stereo']['Anaglyph']() == 'views/stereo/anaglyph'

A simple recursion will do the work

def build_nested_helper(path, text, container):
    segs = path.split('/')
    head = segs[0]
    tail = segs[1:]
    if not tail:
        container[head] = lambda: msg(text)
    else:
        if head not in container:
            container[head] = {}
        build_nested_helper('/'.join(tail), text, container[head])

def build_nested(paths):
    container = {}
    for path in paths:
        build_nested_helper(path, path, container)
    return container

menu = build_nested(items)

squashed code: 159 chars

def f(p,t,c):
 s=p.split('/');a=s[0];b=s[1:]
 if b:
  if a not in c:c[a]={}
  f('/'.join(b),t,c[a])
 else:c[a]=lambda:msg(t)
menu={}
for i in items:f(i,i,menu)


The Star-Spangled Code Challenge The flag of the United States of America contains, in its canton, 50 stars, representing the 50 states.

In the past, when there were fewer states, there were of course fewer stars, and they were arranged differently.  For example, from 1912-1959 (after the admission of New Mexico and Arizona but before Alaska), there were 48 stars in a 6×8 rectangular arrangement.

The 37-star flag used from 1867-1877 (after the admission of Nebraska but before Colorado) had an asymmetric star pattern.

In case a 51st state is added in the future, the Army Institute of Heraldry has already developed a preliminary design for a new flag.

But there's no general algorithm for arranging the stars, so let's make one!

The challenge

Write a program that will, for a given number of stars to place in the canton (blue part) of a US flag, output optimal coordinates at which to place those stars.  The coordinate system is defined with the canton [not the flag as a whole] with 0≤x≤W and 0≤y≤H.

For the purpose of this challenge, an “optimal” arrangement is defined as one that minimizes the mean (Euclidean) distance between a point in the canton and the center of the nearest star.

A straightforward (if maybe suboptimal) algorithm to approximate this value is:

def mean_distance_to_nearest_star(stars, width, height, point_density=100):
   """
   Approximate the mean distance between a point in the rectangle
   0 < x < width and 0 < y < height, and the nearest point in stars.

   stars -- list of (x, y) points
   width, height -- dimensions of the canton
   """
   total = 0.0
   nx = round(width * point_density)
   ny = round(height * point_density)
   for ix in range(nx):
       x = (ix + 0.5) * width / nx
       for iy in range(ny):
          y = (iy + 0.5) * width / ny
          min_dist = float('inf')
          for sx, sy in stars:
              min_dist = min(min_dist, math.hypot(x - sx, y - sy))
          total += min_dist
   return total / (nx * ny)

Your program shall take three command-line arguments (not counting the program name itself):

The number of stars to put in the canton.
The width of the canton.  (Must accept floating-point values.)
The height of the canton.  (Must accept floating-point values.)

(If your preferred programming language doesn't support command-line arguments, do something reasonably equivalent, and document it in your answer.)

The output should consist of comma-separated X and Y values, one to a line.  (Order of the points doesn't matter.)

For example:

~$ flagstar 5 1.4 1.0
0.20,0.20
0.20,0.80
0.70,0.50
1.20,0.20
1.20,0.80

Additional rules & notes

I have the right to close loopholes in the rules at any time.
Deadline for answers is Friday, July 4 at 24:00 CDT (UTC-05:00).  Due to lack of answers, the deadline has been extended.  TBA.
Include in your answer:

Your program's code
An explanation of how it works
Its output with the command-line arguments 50 1.4 1.0

Your program must run within a reasonable amount of time: At most 5 min on a typical PC.  I won't be ultra-strict about this, but will disqualify your program if it takes hours.
Your program must be deterministic, i.e., always give exactly the same output for the same arguments.  So, don't depend on time() or rand().  Monte Carlo methods are OK as long as you roll your own PRNG.
Only the center points of the stars matter.  Don't worry about trying to avoid overlap or anything like that.

Scoring

Minimize the mean distance from a point in the canton to the nearest star.  (See above.)
You may be scored based on any historical US flags, between 13 and 50 stars.  The exact algorithm for weighting scores into a single ranking will be posted later.
In case of a tie, the winner will be chosen by number of net upvotes.
I will probably post a program of my own, but will exclude myself from being eligible for the checkmark.

Javascript - move stars towards most isolated point

(with an animation of the process)

The approach is very simple:

choose a large number of random points
find the nearest star to each
choose the point for which the nearest star is most distant
move that star nearer to that point

This process is repeated a large number of times, gradually decreasing the amount by which the stars are moved. This reduces the maximum distance from a point to the nearest star, indirectly reducing the mean distance from a point to the nearest star.

As required by the question, this does not use the built in random function, instead using xorshift.

Much of the code covers set up and animation - the part that applies the algorithm is the function adjustStars.

Code

You can watch the process in progress in the Stack Snippet below.

stars = [];
timeoutId = 0;

resetRandomNumberGenerator();

function resetRandomNumberGenerator() {
  rng_x = 114; // Numbers for the random number generator.
  rng_y = 342;
  rng_z = 982;
  rng_w = 443;
}

$(document).ready(function() {
  c = document.getElementById('canton');
  ctx = c.getContext('2d');
  resizeCanvas();
});

function stop() {
  clearTimeout(timeoutId);
}

function arrange() {
  clearTimeout(timeoutId);
  resetStars();
  resetRandomNumberGenerator();
  maxStepSize = Math.min(cantonWidth, cantonHeight) / 4;
  adjustStars(maxStepSize, 8000, 10000);
}

function resizeCanvas() {
  cantonWidth = parseFloat($('#width').val());
  cantonHeight = parseFloat($('#height').val());
  starRadius = cantonHeight / 20;
  document.getElementById('canton').width = cantonWidth;
  document.getElementById('canton').height = cantonHeight;
  ctx.fillStyle = 'white';
  resetStars();
}

function resetStars() {
  stop();
  stars = [];
  population = parseInt($('#stars').val(), 10);
  shortSide = Math.floor(Math.sqrt(population));
  longSide = Math.ceil(population / shortSide);
  if (cantonWidth < cantonHeight) {
    horizontalStars = shortSide;
    verticalStars = longSide;
  } else {
    horizontalStars = longSide;
    verticalStars = shortSide;
  }
  horizontalSpacing = cantonWidth / horizontalStars;
  verticalSpacing = cantonHeight / verticalStars;
  for (var i = 0; i < population; i++) {
    x = (0.5 + (i % horizontalStars)) * horizontalSpacing;
    y = (0.5 + Math.floor(i / horizontalStars)) * verticalSpacing;
    stars.push([x, y]);
  }
  drawStars();
  updateOutputText();
}

function adjustStars(stepSize, maxSteps, numberOfPoints) {
  $('#stepsRemaining').text(maxSteps + ' steps remaining');
  points = randomPoints(numberOfPoints);
  mostIsolatedPoint = 0;
  distanceToNearestStar = 0;
  for (var i = 0; i < numberOfPoints; i++) {
    point = points[i];
    x = point[0];
    y = point[1];
    star = stars[nearestStar(x, y)];
    d = distance(x, y, star[0], star[1]);
    if (d > distanceToNearestStar) {
      distanceToNearestStar = d;
      mostIsolatedPoint = i;
    }
  }
  point = points[mostIsolatedPoint];
  x = point[0];
  y = point[1];

  starToMove = nearestStar(x, y);

  star = stars[starToMove];
  separationX = x - star[0];
  separationY = y - star[1];
  if (separationX || separationY) {
    hypotenuse = distance(x, y, star[0], star[1]);
    currentStep = Math.min(stepSize, hypotenuse / 2);
    deltaX = currentStep * separationX / hypotenuse;
    deltaY = currentStep * separationY / hypotenuse;
    star[0] += deltaX;
    star[1] += deltaY;
    if (star[0] < 0) star[0] = 0;
    if (star[0] > cantonWidth) star[0] = cantonWidth;
    if (star[1] < 0) star[1] = 0;
    if (star[1] > cantonHeight) star[1] = cantonHeight;

    drawStars();
    updateOutputText();
  }

  if (maxSteps > 0) {
    timeoutId = setTimeout(adjustStars, 10, stepSize * 0.9992, maxSteps - 1, numberOfPoints);
  }
}

function updateOutputText() {
  starText = '';
  for (var i = 0; i < stars.length; i++) {
    starText += stars[i][0] + ', ' + stars[i][1] + '\n';
  }
  $('#coordinateList').text(starText);
}

function randomPoints(n) {
  pointsToReturn = [];
  for (i = 0; i < n; i++) {
    x = xorshift() * cantonWidth;
    y = xorshift() * cantonHeight;
    pointsToReturn.push([x, y]);
  }
  return pointsToReturn;
}

function xorshift() {
  rng_t = rng_x ^ (rng_x << 11);
  rng_x = rng_y;
  rng_y = rng_z;
  rng_z = rng_w;
  rng_w = rng_w ^ (rng_w >> 19) ^ rng_t ^ (rng_t >> 8);
  result = rng_w / 2147483648
  return result
}

function nearestStar(x, y) {
  var distances = [];
  for (var i = 0; i < stars.length; i++) {
    star = stars[i];
    distances.push(distance(x, y, star[0], star[1]));
  }
  minimum = Infinity;
  for (i = 0; i < distances.length; i++) {
    if (distances[i] < minimum) {
      minimum = distances[i];
      nearest = i;
    }
  }
  return nearest;
}

function distance(x1, y1, x2, y2) {
  var x = x2 - x1;
  var y = y2 - y1;
  return Math.sqrt(x * x + y * y);
}

function drawStars() {
  ctx.clearRect(0, 0, cantonWidth, cantonHeight);
  for (i = 0; i < stars.length; i++) {
    star = stars[i];
    x = star[0];
    y = star[1];
    drawStar(x, y);
  }
}

function drawStar(x, y) {
  ctx.beginPath();
  ctx.moveTo(x, y - starRadius);
  ctx.lineTo(x - 0.588 * starRadius, y + 0.809 * starRadius);
  ctx.lineTo(x + 0.951 * starRadius, y - 0.309 * starRadius);
  ctx.lineTo(x - 0.951 * starRadius, y - 0.309 * starRadius);
  ctx.lineTo(x + 0.588 * starRadius, y + 0.809 * starRadius);
  ctx.fill();
}
canvas {
  margin: 0;
  border: medium solid gray;
  background-color: blue;
}

<input id='stars' onchange='resetStars()' type='number' value='13' min='13' max='50' maxlength='2' step='1'>stars

<input id='width' onchange='resizeCanvas()' type='number' value='494' min='1' max='500' maxlength='3' step='any'>width

<input id='height' onchange='resizeCanvas()' type='number' value='350' min='1' max='500' maxlength='3' step='any'>height

<button type='button' onclick='resetStars()'>Reset Stars</button>
<button type='button' onclick='arrange()'>Arrange Stars</button>
<button type='button' onclick='stop()'>Stop</button>
<textarea id='stepsRemaining' rows='1' readonly></textarea>

<canvas id='canton' width='494' height='350'></canvas>

<textarea id='coordinateList' rows='50' cols='40' readonly></textarea>

Output for 50 stars

(width = 1.4, height = 1.0)

Mean distance estimated at 0.0655106697162357.

Coordinates:

0.028377044205135808, 0.2128159150679491
0.10116766857540277, 0.05156676609341312
0.2903566419069437, 0.07216263690037035
0.49154061258041604, 0.004436102736309105
0.6930026352073071, 0.07060477929576484
1.0988644764108417, 0.022979778480838074
1.1735677936511582, 0.18600858289592742
1.3056806950504931, 0.062239869036660435
0.3967626880807638, 0.24483447327177033
0.27004118129346155, 0.40467589936498805
0.4996665039421278, 0.13023282430440133
0.5148978532656602, 0.6161298793146592
0.5907056537744844, 0.2614323599301046
0.8853042432872087, 0.048123917861564044
0.7753680330575412, 0.22938793622044834
1.365432954694329, 0.2355377720528128
0.1985172068244217, 0.23551298706793927
0.4477558465270544, 0.4170264112485973
0.6084424566752479, 0.7764909501169484
0.6099528761580699, 0.4395002434593519
0.9506038166406011, 0.34903243854585914
1.1898331497634231, 0.5756784243472182
1.0933574395540542, 0.46422120794648786
1.1516574254138159, 0.2930213338333888
0.07646053006349718, 0.40665000611360175
0.0634456093015551, 0.5853189455014883
0.3470036636019768, 0.5938838331082922
0.7591083341283029, 0.4005456925638841
0.9745306853981277, 0.184624209972443
1.3552011948311598, 0.549607060691302
1.3334000268566828, 0.7410204535471169
1.2990417572304487, 0.39571229988825735
0.05853941030364222, 0.7734808757471414
0.19396697551982484, 0.5678753467094985
0.7103231124251072, 0.5955041661956884
0.6168410756137566, 0.948561537739087
0.8967624790188228, 0.5368666961690878
0.9751229155529001, 0.8323724819557795
0.9987127931392165, 0.652902038374714
1.3231032600971289, 0.9164326184290812
0.20785221980162555, 0.7566700629874374
0.3987967842137651, 0.7678025218448816
0.44395949605458546, 0.9137553802571048
0.775611700149756, 0.9029717946067138
0.806442448003616, 0.7328147396477286
0.9481952441521928, 0.9872963855418118
1.1528689317425114, 0.9346775634274639
1.1651295140721658, 0.7591158327925681
0.09316709042512515, 0.934205211493484
0.2769325337580081, 0.9341145493466471


Chop up my ASCII art Let's say I've got some ASCII art:

          ___
        ,"---".
        :     ;
         `-.-'
          | |
          | |
          | |
       _.-\_/-._
    _ / |     | \ _
   / /   `---'   \ \
  /  `-----------'  \
 /,-""-.       ,-""-.\
( i-..-i       i-..-i )
|`|    |-------|    |'|
\ `-..-'  ,=.  `-..-'/
 `--------|=|-------'
          | |
          \ \
           ) ) hjw
          / /
         ( (

(Source)

But I want to focus on the cable of this joystick, because I actually want a picture of a garden path, leading up to a door.

 ,=.
-|=|-
 | |
 \ \
  ) )
 / /
( (

I could copy out line after line, I could use a text editor with block selection mode, or... I could write some code!

So, my code needs five arguments:

A piece of ASCII art, a newline separated string.
The X axis of the top-left corner (1-indexed, from left hand column, positive integer)
The Y axis of the top-left corner (1-indexed, from top row, positive integer)
Width of the resultant image (positive integer)
Height of the resultant image (positive integer)

Test Cases

ASCII image:

          ___
        ,"---".
        :     ;
         `-.-'
          | |
          | |
          | |
       _.-\_/-._
    _ / |     | \ _
   / /   `---'   \ \
  /  `-----------'  \
 /,-""-.       ,-""-.\
( i-..-i       i-..-i )
|`|    |-------|    |'|
\ `-..-'  ,=.  `-..-'/
 `--------|=|-------'
          | |
          \ \
           ) ) hjw
          / /
         ( (

Garden path

X: 10
Y: 15
Width: 5
Height: 7

Result:

 ,=.
-|=|-
 | |
 \ \
  ) )
 / /
( (

DB icon

X: 3
Y: 12
Width: 6
Height: 4

Output:

,-""-.
i-..-i
|    |
`-..-'

Alien Elder

X: 9
Y: 1
Width: 7
Height: 10

  ___
,"---".
:     ;
 `-.-'
  | |
  | |
  | |
.-\_/-.
|     |
 `---'

Signature

X: 16
Y: 19
Width: 3
Height: 1

hjw

Rules

Output can be given by any convenient method.
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 (in bytes) wins.

Canvas, 1 byte

＠

Try it here!

It takes height, width, Y, X, and ASCII art as inputs, in that order.

Though almost everything about the ASCII art objects in Canvas is 0-indexed, ＠ is 1-indexed by some reason. ¯\_(ツ)_/¯


Orient the Rubik's Cube Introduction:

I collect twisty puzzles, so I'm quite the fan of rubiks-cube-challenges (even though most are fairly difficult). So, let's try a fairly easy rubiks-cube-challenge for a change.

When an NxNxN Cube gets scrambled during a WCA (World Cubing Association) competition, the cube is always held in the same way before executing the scramble-algorithm:

  Article 4: Scrambling

  4d) Scrambling orientation:

  4d1) NxNxN puzzles and Megaminx are scrambled starting with the white face (if not possible, then the lightest face) on top and the green face (if not possible, then the darkest adjacent face) on the front.

"NxNxN puzzles are scrambled starting with the white face on top and the green face on the front."

Challenge:

For the sake of this challenge we only have to look at the centers, so we'll use a 1x1x1 instead of a 3x3x3. Given a valid 1x1x1 Cube in any orientation, output which rotations of x/x', y/y', and/or z/z' are required to have green at the front and white at the top.

Input:

The input will be a 1x1x1 Cube layout in the following format (where F is the front, and U is the top):

 U
LFRB
 D

For example:

 Y
BRGO
 W

Output:

The output will be the least amount of rotations of x/x', y/y', and/or z/z' required to have the white center at the top and green center at the front.

         x                      y                      z

         x'                     y'                     z'

We basically always want to end up in this orientation:

 W
OGRB
 Y

The example given above would therefore result in either of these outputs: x2y/xxy/x'x'y.

NOTE: In the still image of the gifs above, White is the Upper face and Red is the Front face. So the still image of the gif is:

 W
GRBO
 Y

Challenge rules:

You are allowed to take the input in any reasonable format.

You could use other characters or numbers (i.e. 0-5/1-6) instead of WYROGB
You can take the input as single String, as new-line delimiter single String, as String-array, character-array or -matrix, integer-array or -matrix, etc. Your call. (For example, WOGRBY is a valid input in the format ULFRBD.)
Please specify what input-format you've used!

The output must use xyz, but instead of x' you are also allowed to use x3 or X, or instead of x2 you can also use xx (NOTE: You are NOT allowed to use xxx instead of x'/x3/X).

Always output the least amount of rotations. So although x'x'y'y'y' instead of x2y results in the same orientation of the Cube in the end, it's not a valid output because there is a better alternative. Same applies to
x2y2, because xy'z is one move shorter (x2/xx counts as two moves).
As thumb rule: every possible input results in 0-2 x, 0-2 y and/or 0-2 z rotations, and you'll never need more than three rotations in total (i.e. x2z2 → y2)

You can assume all inputs are valid 1x1x1 Cubes.
If the input is already in the correct position (green front, white top), output nothing (or something indicating nothing, like null, false, 0, an error, etc.)

General rules:

This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
Default Loopholes are forbidden.
If possible, please add a link with a test for your code.
Also, please add an explanation if necessary.

Test cases:

Input:   Output (multiple valid answers are possible for some):

 Y
BRGO     x2y   y'x2   z2y'   yz2   zy'x   zxz   xzx   xyz
 W

 W
OGRB     nothing
 Y

 G
RWOY     y2x'   z2x   yzy   xy2   x'z2   yx'z   zxy   zyz
 B

 W
RBOG     y2
 Y

 R
BWGY     yz   zx   xy
 O

 G
WOYR     x'z   zy   yx'
 B


Positioning a fake mirror for best effect Challenge

Premise

Consider a mosaic of \$m\times n\$ tiles, in \$k\$ unique colours designated by integers. Example (\$3\times6\$, four colours):

4 1 3 2 4 2
1 2 4 2 1 3
4 3 2 1 4 4

My poor man's mirror is a pane of glass of width \$\sqrt{2}\cdot\min(m,n)\$. I stand it diagonally on the mosaic, like so:

4 1 3 M 4 2
1 2 M 2 1 3
4 M 2 1 4 4

For this example I can pretend it reflects exactly two full tiles:

x 1 x M x x
x 2 M x x x
x M 2 1 x x

No matter what diagonal I choose, this is the greatest number of full tiles I can fake-reflect. Yay.

Task

Input: an integer matrix of \$m\$ rows and \$n\$ columns where \$2\leq m\leq1000,2\leq n\leq1000\$. The number of unique values is \$k\$ where \$3\leq k\ll mn\$.

Output: three integers, in any format. The first and second respectively represent the row coordinate and column coordinate of the matrix element ('mosaic tile') at the left end of the 45-degree diagonal where the fake mirror should be placed for 'best effect', effectiveness being defined as shown above. The third integer is 0 or 1, respectively meaning a rising (bottom left to top right) or falling (top left to bottom right) diagonal.

For clarity's sake, here are some simple test cases.

Example 1

Input:

4 1 3 2 4 2
1 2 4 2 1 3
4 3 2 1 4 4

Output: 3 2 0

Example 2

Input:

3 6
4 7
5 8
1 2
2 1

Output: 4 1 1 or 5 1 0 (not both)

As you can see, a unique solution isn't guaranteed.

Example 3

Input:

2  7  4  10 7  8  9  5  6  4  2  4  10 2  1  7  10 7  2  4  10 10 8  7
6  5  6  2  2  3  6  1  6  9  7  2  10 3  4  7  8  8  3  7  1  8  4  2
3  3  7  6  10 1  7  9  10 10 2  6  4  7  5  6  9  1  1  5  7  6  2  7
7  10 3  9  8  10 9  3  6  1  6  10 3  8  9  6  3  6  2  10 1  2  8  1
7  7  8  1  1  6  4  8  10 3  10 4  9  3  1  9  5  9  10 4  6  7  10 4
1  10 9  7  7  10 3  3  7  8  2  2  4  2  4  7  1  7  7  1  9  9  8  7
5  9  5  3  8  6  5  7  6  7  2  7  9  9  7  10 8  8  7  3  5  9  9  10
9  3  8  2  9  2  1  3  6  3  8  5  7  10 10 9  1  1  10 2  5  1  6  9
8  7  6  2  3  2  9  9  9  7  9  5  8  3  8  2  2  5  2  2  10 10 3  5
7  1  1  2  3  2  10 1  2  10 3  3  2  1  4  2  5  6  10 9  6  5  3  8
8  9  5  2  1  4  10 6  8  6  9  10 10 8  1  6  10 6  4  8  7  9  3  5
8  1  5  7  1  8  7  5  8  6  4  5  10 1  6  1  4  4  10 7  6  3  3  6

Output: 1 10 1

Edit - indexing

The example outputs are 1-indexed, but 0-indexing is allowed.

Remarks

This is code-golf, so fewest bytes wins.
Standard rules, I/O rules and loophole rules apply.
If possible, link an online demo of your code.
Please explain your code.

Charcoal, 91 bytes

≔⟦⟧θＷＳ⊞θＩ⪪ι ≔Ｌ§θ⁰η≔⊖⌊⟦Ｌθη⟧ζＦ⁻ＬθζＦ⁻ηζＦ²⊞υ⟦Σ⭆⊕ζ⭆⊕ζ⁼§§θ⁺ι⎇λμ⁻ζμ⁺κξ§§θ⁺ι⎇λξ⁻ζξ⁺κμ⎇λι⁺ιζκλ⟧Ｉ✂⌈υ¹

Try it online! Link is to verbose version of code. 0-indexed. Explanation:

≔⟦⟧θＷＳ⊞θＩ⪪ι

Input the mosaic. (These 12 bytes could be avoided by requiring the input to be in JSON format, but I was too lazy to punctuate the example.)

≔Ｌ§θ⁰η

Get the width of the mosaic.

≔⊖⌊⟦Ｌθη⟧ζ

Get the inner size of the mirror, i.e. the distance from the first to the last character of the mirror in terms of diagonal steps.

Ｆ⁻Ｌθζ

Loop over the possible row(s) of the top left corner of the mirror's enclosing square.

Ｆ⁻ηζ

Loop over the possible column(s) of the top left corner of the mirror's square.

Ｆ²

Loop over the possible rotations of the mirror.

⊞υ⟦Σ⭆⊕ζ⭆⊕ζ⁼§§θ⁺ι⎇λμ⁻ζμ⁺κξ§§θ⁺ι⎇λξ⁻ζξ⁺κμ⎇λι⁺ιζκλ⟧

Calculate the number of tiles it reflects exactly. Exact matches are counted twice and the diagonal is also counted but this doesn't affect the relative score. Push this number along with the potential solution to the predefined empty list.

Ｉ✂⌈υ¹

Output the solution with the highest number of exactly reflected tiles.


Print the current time… taking leap seconds into account (Note: although related, this challenge is not a duplicate of this one because it requires determining leap seconds automatically rather than hardcoding their times, and is not a duplicate of this one because most of the difficulty comes from determining the time without leap second skewing, something that most time APIs don't do by default. As such, a solution is likely to look different from a solution to either of those challenges.)

We're coming to the end of 2016, but it's going to take slightly longer than most people expect. So here's a challenge celebrating our extra second this year.

Output the current time in UTC, as hours, minutes, seconds. (For example, legitimate output formats for midday would include 12:00:00 and [12,0,0]; the formatting isn't massively important here.)

However, there's a twist: your program must handle leap seconds appropriately, both past and future. This means that your program will have to obtain a list of leap seconds from some online or automatically updated/updatable source. You may connect to the Internet to obtain this if you wish. However, you may only connect to a URL that predates this challenge (i.e. no downloading parts of your program from elsewhere), and you may not use the connection to determine the current time (specifically: your program must function even if any attempt to access the Internet returns a page that's up to 24 hours stale).

Most operating systems' default APIs for the current time will skew time around leap seconds in order to hide them from programs that might otherwise be confused. As such, the main difficulty of this challenge is to find a method or an API to undo that, and work out the true unmodified current time in UTC.

In theory, your program should be perfectly accurate if it ran on an infinitely fast computer, and must not intentionally take more than zero time to run. (Of course, in practice, your program will run on an imperfect computer, and so will probably not run instantaneously. You don't have to worry about this invalidating the results, but must not depend on it for the correctness of your program.)

Your program must function regardless of which timezone the system clock is set to. (However, it may request information from the operating system or environment as to what timezone is being used, and may assume that the reply is accurate.)

As a code-golf, the shortest program wins. Good luck!

PowerShell, 161 bytes

(('{0:H:m:s}','23:59:60')[(($d=[datetime]::UtcNow).Ticks-6114960*98e9)/1e8-in((irm ietf.org/timezones/data/leap-seconds.list)-split'[^@]	|
'-match'^\d{9}')])-f$d

Try it online! (doesn't work here, it seems that TIO doesn't recognize irm and iwr, maybe it's a security feature?)

Logic Test (Hardcoded Date):

(('{0:H:m:s}','23:59:60')[(($d=[datetime]'1/1/2017 00:00:00').Ticks-6114960*98e9)/1e8-in((irm ietf.org/timezones/data/leap-seconds.list)-split'[^@]	|
'-match'^\d{9}')])-f$d

Notes

There is a literal TAB and a literal linebreak (0xA) in the regex string, so that I didn't have to escape them (saved 1 byte each).

Explanation

The times given (of the leap seconds) in the ietf file are in seconds since NTP epoch which is 1/1/1900 00:00:00. On Windows, a "tick" is simply one ten-millionth of a second (10,000,000 ticks/sec).

If you add an integer to a [datetime] it counts the integer value as ticks, so I'm using the hardcoded tick value of NTP epoch, then subtracting it from the tick value of the current UTC time (the original value of which is simultaneously being assigned to $d).

To make that hardcoded tick value smaller, I took away some zeros (9 of them) and divided by 98, then multiply by 98e9 (98*109).

The result of that subtraction is the value in ticks since NTP epoch. That gets divided by 1e8 (not 1e9, for reasons that will be clear in a moment) to get the value in seconds (sort of) since NTP epoch. It will be smaller by a factor of 10, actually.

Retrieving the document from the IETF, rather than split it into lines first, then process the lines with the timestamps, I decided to split on both line breaks and on TAB characters, since that's what comes after the timestamp. Because of a single errant line in the file, that alone would include an additional timestamp we don't want. The line looks like this:

#@	3707596800

So I changed the regex to split on [^@]\t (any character that's not @ followed by a TAB) which works to exclude that line, but also ends up consuming the last 0 in each of the timestamps.

That's why I divide by 1e8 and not 1e9, to account for the missing 0.

The current timestamp is checked to see it exists inside the list of neutered leap second timestamps. This whole process I described is inside the array accessor [], so the resulting [bool] value gets coalesced to a 0 ($false) or 1 ($true). The array we're indexing into contains two elements: a format string for displaying the time, and a hardcoded 23:59:60. The truthiness of the aforementioned comparison determines which one will be chosen, and that is fed into the format operator -f with the previously assigned current date $d as its parameter.


Write lines in detention Introduction
Bad news guys - you got detention. Your English teacher doesn't understand this site and wants you to "stop doing math on your digital dohickeys, this is English class!"
She sentenced you to write her favorite saying on the blackboard 25 times, which will give a total of 100 lines on the blackboard.
The eighteen-hundreds were a time for rum.
The nineteen-hundreds were a time for fun.
The two-thousands are a time to run
a civilized classroom.

Lucky for you, you are an avid reader (not to mention an expert code-golfer)! You have a read about a trick that might possibly get you off easy.

(Foxtrot by Bill Amend)
Unfortunately for Jason, it didn't work out. But you have a better idea! Since your English teacher thinks you're doing math, if you leave all the numbers out of your program it just might work! You also want to keep your program as short as possible because you are a lazy student and don't want to write a lot on the board.
Write a program that complies with the following rules:

Your program must print the 4 above lines 25 times. The lines must be outputted in that order, repeating. Total exactly 100 lines of output (a trailing newline at the very end or a leading newline at the very beginning is okay).
You cannot use the characters 0123456789. Your teacher gets confused by math and will call you out!
You can use any imports and external libraries without counting the imports. Your English teacher doesn't know about programming. Jason could have saved a lot of work by not writing #include <stdio.h> and you don't want to make his same mistakes!
Score your program by byte count. Lowest score wins!

JavaScript (ES6) 164
B='teen-hundreds were a time',alert(B.replace(/./g,
"The eigh"+B+" for rum.\nThe nine"+B+" for fun.\nThe two-thousands are a time to run\na civilized classroom.\n"))

Test In FireFox/FireBug console.


Deranged !Combinatorics: Compute the Subfactorial The subfactorial or rencontres numbers (A000166) are a sequence of numbers similar to the factorial numbers which show up in the combinatorics of permutations. In particular the nth subfactorial !n gives the number of derangements of a set of n elements. A derangement is a permutation in which no element remains in the same position. The subfactorial can be defined via the following recurrence relation:
!n = (n-1) (!(n-1) + !(n-2))

In fact, the same recurrence relation holds for the factorial, but for the subfactorial we start from:
!0 = 1
!1 = 0

(For the factorial we'd have, of course, 1! = 1.)
Your task is to compute !n, given n.
Rules
Like the factorial, the subfactorial grows very quickly. It is fine if your program can only handle inputs n such that !n can be represented by your language's native number type. However, your algorithm must in theory work for arbitrary n. That means, you may assume that integral results and intermediate value can be represented exactly by your language. Note that this excludes the constant e if it is stored or computed with finite precision.
The result needs to be an exact integer (in particular, you cannot approximate the result with scientific notation).
You may write a program or a function and use any of the standard methods of receiving input and providing output.
You may use any programming language, but note that these loopholes are forbidden by default.
This is code-golf, so the shortest valid answer – measured in bytes – wins.
Test Cases
n     !n
0     1
1     0
2     1
3     2
4     9
5     44
6     265
10    1334961
12    176214841
13    2290792932
14    32071101049
20    895014631192902121
21    18795307255050944540
100   34332795984163804765195977526776142032365783805375784983543400282685180793327632432791396429850988990237345920155783984828001486412574060553756854137069878601

Funciton, 336 bytes

Byte count assumes UTF-16 encoding with BOM.

┌─╖┌─╖  ┌─╖
│f╟┤♭╟┐┌┤♭╟┐
╘╤╝╘═╝├┘╘═╝├────┐
 │┌─╖ │ ┌┐┌┘╔═╗╓┴╖
 ││f╟─┴┐└┴┼─╢0║║f║
 │╘╤╝  │  │ ╚═╝╙─╜
 │┌┴╖ ┌┴╖┌┴╖ ╔═╗
 ││+╟┐│×╟┤?╟┐║1║
 │╘╤╝│╘╤╝╘╤╝┘╚╤╝
 └─┘ └─┘  └───┘

This defines a function f which takes one integer and outputs another integer at a 90 degree turn to the left. It works for arbitrarily large inputs.

Try it online!

Considering this is Funciton it's even reasonably fast (n = 20 takes about 14 seconds on TIO). The main slowdown comes from the double-recursion, as I don't think the Funciton interpreter automatically memoises functions.

Unfortunately, some monospaced fonts don't correctly monospace the ♭ and/or insert small gaps between the lines. Here's a screenshot of the code from TIO in all its beauty:

I think it might be possible to golf this some more, e.g. by changing the condition from >0 to <1 and swapping the branches of the conditional, so that I could reuse the number literal, or maybe by using a completely different formula, but I'm quite happy with how compact it is already.

Explanation

This basically implements the recursion given in the challenge, although it uses the base case !(-1) = !0 = 1. n-1 and n-2 are computed with the predecessor function ♭, and the intermediate result n-1 is reused in three places. There isn't much more to it, so I'll just quickly go through the control flow:

               ─┐
               ╓┴╖
               ║f║
               ╙─╜

This is the function header which emits the function's input n long the attached line. This immediately reaches T-junction, which simply duplicates the value.

        ┌┐┌┘╔═╗
        └┴┼─╢0║
          │ ╚═╝

The 0 box is just a numeric literal. A 4-way junction computes two functions: the path that leads off the bottom computes 0 < n, which we'll use to determine the base case. The path that goes left separately computes 0 << n (a left-shift), but we discard this value with the Starkov construct.

         ┌┴╖ ╔═╗
         ┤?╟┐║1║
         ╘╤╝┘╚╤╝
          └───┘

We lead this into the three-way conditional ?. If the value is false, we return the constant result 1. The loose end right of the ? is the function output. I'm twisting it around by 180 degrees here, so that the relative orientation of input and output of f is more convenient in the rest of the program.

If the condition was true, then the other value will be used. Let's look at the path that leads to this branch. (Note that Funciton's evaluation is actually lazy so that this branch will never be evaluated if it's not needed, which makes the recursion possible in the first place.)

        ┌─╖
      ┐┌┤♭╟┐
      ├┘╘═╝
      │
     ─┴┐

In the other branch we first compute n-1 and then split the path twice so we get three copies of the value (one for the coefficient of the recurrence, one for the first subfactorial, the last for n-2).

┌─╖┌─╖
│f╟┤♭╟
╘╤╝╘═╝
 │┌─╖
 ││f╟
 │╘╤╝
 │┌┴╖
 ││+╟
 │╘╤╝
 └─┘

Like I said, we decrement one copy again with another ♭, then we feed both n-1 and n-2 recursively to f and finally add the two results together in the +.

       ┐
       │
      ┌┴╖
     ┐│×╟
     │╘╤╝
     └─┘

All that's left is to multiply n-1 by !(n-1) + !(n-2).


Triangular Grids: Simply Connected Polyiamonds While we're on a triangular grids kick, I'd like to point out that there is an equivalent to polyominoes on a triangular grid. They are called polyiamonds, and they are shapes formed by gluing equilateral triangles together along their edges. In this challenge you are going to be deciding which subsets of a triangular grid are polyiamonds, and whether they have holes in them. Because it only takes 9 triangles to make a polyiamond with a hole in it, your code needs to be as short as possible.

The grid

We'll use Martin's triangular grid layout for the input:

Pay attention to the fact that the centers of the triangles form a roughly rectangular grid and that the top left triangle "points" upward. We can describe a subset of this grid, then, by giving a rectangular "star map" indicating which triangles are included and which are not included. For instance, this map:

** **
*****

corresponds to the smallest polyiamond which contains a hole:

Holes

A polyiamond which contains a hole like the example above (a region not a part of the polyiamond, which is surrounded on all sides by regions which are) is not, topologically speaking, simply connected.

The Challenge

Write a function or program which takes as input a "star map" as described above and output a truthy if and only if the indicated subset of the triangular grid is a simply connected polyiamond.

More Examples

*** ***
*******

corresponds to the polyiamond

which is simply connected.

*   *
** **
 ***

corresponds to the polyiamond

which is simply connected.

**  **
*** **
 ****

corresponds to the non-polyiamond

which would not be simply connected even if it were a polyiamond.

Input Spec

The input will consist only of asterisks, spaces, and line feeds.
The first character of input will always be a space or asterisk (corresponding to the upward pointing triangle in the top left corner of the grid).
There will always be at least one asterisk on the first and last lines.
There is NO guarantee that lines after the first line won't be empty. Two linefeeds in a row may appear in a legitimate input.
Line lengths need not all be the same.

Winning Condition

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

Test Cases

Truthy maps:

1) *

2) *
   *

3) **

4) *** ***
   *******

5) *   *
   ** **
    ***

6) *
   **
    *

7)    **
     ***
   ****

8) ****
   **   *
    *****

9) ***********
   **    **  **
    ****  **  **
              **
   ************

Falsy maps:

1) *
   *
   *

2) * *

3) *
    *

4)  **
   **

5) ***

   ***

6) ** **
   *****

7) **  **
   *** **
    ****

8)  *
    *

9) *****
   **   *
    *****

Snails, 95 bytes
F&
lr|=((ul.)2 ,l~a~)d|!((ul.)2 ,l~a~)u}\*}+l\ ,~a~|{\ (lr|=((ul.)2 ,l~a~)d|!((ul.)2 ,l~a~)u}+~

This really suffered from duplication, as I haven't implemented macros or any kind of back-reference. What it does is to check that for each star, there exists a path to the leftmost star on the top line; and for each space, there is a path to an edge of the grid.
F&                         ,, option F: pad lines with spaces to the length of the longest
                           ,, option &: print 1 iff match succeeds from every cell
lr                         ,, direction left or right, or
      | =((ul.)2 ,l~a~) d  ,, direction down, if we are an even number of orthogonal moves from the top left
      | !((ul.)2 ,l~a~) u  ,, or, direction up if we are odd number of moves from the top left
    }  \*                  ,, literal '*'
}+                         ,, 1 or more times
l\ ,~a~                    ,, check that we are on the leftmost * in the top line

|                          ,, the part before this is for starting on '*'; part after for starting on ' '

{ \                        ,, literal ' '
    (   lr                 ,, direction left or right, or
      | =((ul.)2 ,l~a~) d  ,, same drill as before...
      | !((ul.)2 ,l~a~) u
}+                         ,, 1 or more times
~                          ,, end on an out of bounds cell


Build a Faulty XKCD Browser Challenge

Given the number of an XKCD comic, output the title text of that comic (the mouseover text).

However, the program must throw an error when given the numbers 859 or 404.

Rules

The number given will always be an existing comic (except 404).

Your program must not throw an error for any other numbers than 859 or 404.

For reference, comic 404 does not exist and 859 is:

Brains aside, I wonder how many poorly-written xkcd.com-parsing scripts will break on this title (or ;;"''{<<[' this mouseover text."

Url shorteners are disallowed. You may use the internet to get the title text.

Examples

Input > Output
1642 > "That last LinkedIn request set a new record for the most energetic physical event ever observed. Maybe we should respond." "Nah."
1385 > ::PLOOOOSH:: Looks like you won't be making it to Vinland today, Leaf Erikson.
1275 > If replacing all the '3's doesn't fix your code, remove the 4s, too, with 'ceiling(pi) / floor(pi) * pi * r^floor(pi)'. Mmm, floor pie.
1706 > Plus, now I know that I have risk factors for elbow dysplasia, heartworm, parvo, and mange.

Bounty

I will award a bounty to the shortest answer which fails on comic 859 because it's poorly written instead of checking for the number.

Your program may break on other alt texts (such as 744) providing they have unmatched parentheses, quotation marks etc.

Winning

Shortest code in bytes wins.

Python 2.7 + xkcd,  55 bytes

xkcd is a third-party Python package. In Python, there is a package for everything!

lambda n:[xkcd.getComic(n).altText][n==859]
import xkcd

  For 404: urllib2.HTTPError: HTTP Error 404: Not Found

  For 859: IndexError: list index out of range


Find the shortest pangrams from a word list A pangram is a string that contains every letter a-z of the English alphabet, case-insensitive. (It's OK if the pangram contains more than one copy of a letter, or if it contains non-letter characters in addition to the letters.)

Write a program or function whose input is a list of strings, and which outputs one or more strings which have the following properties:

Each output string must be a pangram.
Each output string must be formed by concatenating one or more strings from the input list, separated by spaces.
Each output string must be the shortest, or tied for the shortest, among all strings with these properties.

Many programs will choose to output only one string; you'd only want to output more than one string if you'd otherwise have to write extra code to limit the output.

You may assume that the input contains no unprintable characters or spaces, and that no word in it is more than (26 times the natural logarithm of the length of the list) characters long. (You may not assume, however, that the input contains nothing but letters, or only lowercase letters; punctuation marks and uppercase letters are entirely possible.)

Input and output can be given in any reasonable format. For testing your program, I recommend using two test cases: a dictionary of English words (most computers have one), and the following case (for which a perfect (26-letter) pangram is impossible, so you'd have to find one containing duplicate letters):

abcdefghi
defghijkl
ijklmnop
lmnopqrs
opqrstuvw
rstuvwxyz

You should include a sample of your program's output along with your submission. (This may well be different for different people as a result of using different word lists.)

Victory condition

This is a restricted-complexity code-golf challenge. The winner is the shortest program (in bytes) that runs in polynomial time. (A summary for people who don't know what that means: if you double the size of the word list, the program should become slower by no more than a constant factor. However, the constant factor in question can be as large as you like. For example, it's valid for it to become four times slower, or eight times slower, but not for it to become smaller by a factor of the length of the word list; the factor via which it becomes slower must be bounded.)

Ruby 159 (iterative)

Ruby 227 220 229 227 221 (recursive)

New iterative solution (based on the algorithm described by @Niel):

c={('A'..'Z').to_a=>""}
while l=gets
d=c.clone
c.map{|k,v|j=k-l.upcase.chars
w=v+" "+l.strip
d[j]=w if !c[j]||c[j].size<w.size}
c=d
end
x=c[[]]
p x[1..-1] if x

Old recursive solution:

W=[]
while l=gets
W<<l.strip
end
I=W.join(" ")+"!!"
C={[]=>""}
def o(r)if C[r]
C[r]
else
b=I
W.map{|x|s=r-x.upcase.chars
if s!=r
c=x+" "+o(s)
b=c if c.size<b.size
end}
C[r]=b
end
end
r=o ('A'..'Z').to_a
p r[0..-2] if r!=I

The byte measurement is based on leaving off the final newline in the file, which does not matter to ruby 2.3.1p112. The byte count went back up after fixing a small bug (adding .downcase .upcase for case-insensitivity as required by the problem statement).

Here is an earlier version from before shortening identifiers and such:

#!/usr/bin/env ruby

$words = [];

while (line=gets)
  $words << line[0..-2];
end

$impossible = $words.join(" ")+"!!";

$cache = {};

def optimize(remaining)
  return $cache[remaining] if ($cache[remaining]);
  return "" if (remaining == []);

  best = $impossible;

  $words.each{|word|
    remaining2 = remaining - word.chars;
    if (remaining2 != remaining)
      curr = word + " " + optimize(remaining2);
      best = curr if (curr.length < best.length);
    end
  };

  $stderr.puts("optimize(#{remaining.inspect})=#{best.inspect}");

  return $cache[remaining] = best;
end

result = optimize(('a'..'z').to_a);

puts(result[0..-1]);

How does it work? It basically maintains a set of characters still to cover and only recurses on a word if it would reduce the uncovered set. Additionally, the results of recursion are memoized. Each subset of 2^26 corresponds to a memoization table entry. Each such entry is calculated in time proportional to the size of the input file. So the whole thing is O(N) (where N is the size of the input file), albeit with a huge constant.


Find how many alphanumeric characters can be made up of a single number The alphanumeric characters have ASCII-values:

0-9  ->  48-57
A-Z  ->  65-90
a-z  ->  97-122

Your challenge is to take an integer as input, and output how many characters can be made using consecutive digits of that number. The character codes may be overlapping. 666 should result in 2, since you have 66 twice.

Test cases:

Input: 5698
Possible characters: '8' (56), 'E' (69), 'b' (98)
Output: 3

Input: 564693
Possible characters: '8' (56), 'E' (69)
Output: 2

Input: 530923864209124521
Possible characters: '5' (53), 'V' (86), '4' (52)
Output: 3

Input: 1111111
Possible characters: 'ooooo' (5*111)
Output: 5

Input: 5115643141276343
Possible characters: '3' (51), '8' (56), 'L' (76), 's' (115)
Output: 4

Input: 56789
Possible characters: '8' (56), 'C' (67), 'N' (78), 'Y' (89)
Output: 4

Input: 94
Possible characters: ''
Output: 0

Input: 1
Output: 0

Input and output formats are optional (yes, you may take the integer as a string).

05AB1E, 8 7 bytes

žKÇIŒÃg

Try it online!

Explanation

žK       # push [a-zA-Z0-9]
  Ç      # convert to list of ascii codes
   IŒ    # push all substrings of input
     Ã   # keep only the subtrings which exist in the list of acsii codes
      g  # push length of resulting list


A Programming Puzzle of Mode Golf Your task is to print the text Good morning, Green orb!, with every character repeated in place as many times as the most frequent byte in your source (the mode).  A trailing newline is permitted and need not be repeated.

For example if your source was

print p

Since p appears twice and every other byte appears once you would need to print

GGoooodd  mmoorrnniinngg,,  GGrreeeenn  oorrbb!!

Answers will be scored by the product of their byte count and the number of times the output is repeated.  For example the above code (if it worked) would score 7*2 = 14.  The goal should be to minimize one's score.

Your code must contain at least 1 byte.

Use this program to verify that your code and output match


Split string on first occurrence of each character Related.

Given a printable ASCII string, split it into a list of non-empty strings with a new sub-string beginning every time a character, which has not previously been seen in the same case, occurs.

Examples

"mississippi" → ["m","i","ssissi","ppi"]

"P P & C G" → ["P"," P ","& ","C ","G"]

"AAA" → ["AAA"]

"Adam" → ["A","d","a","m"]

"" → []

Anecdote: The result will have between 0 and 95 elements. The 95th sub-string will necessarily continue until the end because at that point, all printable ASCII characters have begun a sub-string, so every additional character will have occurred before and thus cannot cause a new sub-string to begin.

Jelly, 4 bytes

QƤĠị

Try it online!

Explanation

QƤĠị  Input is a string, say s = "adam"
 Ƥ    For each prefix of s: ["a","ad","ada","adam"]
Q     remove duplicates: ["a","ad","ad","adm"]
  Ġ   Group indices by equal values: [[1],[2,3],[4]]
   ị  Index into s: ["a","da","m"]

The internal representation of the strings, which the TIO link displays, is slightly different.


Get delta of days by current hour and added delta of days Inputs:

current hour: from 0 to 23 (inclusive)
delta of hours: [current hour] + [delta of hours] = withing the range of Integer

Output:

delta of days: the value which shows difference in days between day of current hour and day of sum [current hour] + [delta of hours]

Scoring

Answers will be scored in bytes with fewer bytes being better.

Examples:

[current hour] = 23; [delta of hours] = -23; delta of days = 0
[current hour] = 23; [delta of hours] = 1; delta of days = 1
[current hour] = 23; [delta of hours] = 24; delta of days = 1
[current hour] = 23; [delta of hours] = 25; delta of days = 2
[current hour] = 23; [delta of hours] = -24; delta of days = -1
[current hour] = 23; [delta of hours] = -47; delta of days = -1

JavaScript (ES6),  26  25 bytes
Takes input as (current)(delta).

a=>b=>(a+b-(a<-b)*2)/3>>3

Try it online!
Commented
a =>                // a = current hour
b =>                // b = delta of hours
  (                 //
    a + b           // 1) we compute the sum
    - (a < -b) * 2  //    and we subtract 2 if this sum is negative
                    //    examples:
                    //      51 remains 51
                    //      23 remains 23
                    //      -1 is turned into -3
  ) / 3             // 2) float division by 3
                    //    examples:
                    //      51 is turned into 17
                    //      23 is turned into 7.666…
                    //      -3 is turned back into -1
  >> 3              // 3) right arithmetic shift by 3 on the integer part
                    //    examples:
                    //      17 becomes 2
                    //      7.666… becomes 0
                    //      -1 is unchanged

JavaScript (ES6), 26 bytes
More straightforward, but less fun and 1 byte longer anyway.
Takes input as (current)(delta).

a=>b=>Math.floor((a+b)/24)

Try it online!


Sum the First n Even Fibonacci Numbers There seems not to be a contest for this one yet.

The task is simple. Add the first n numbers of the Fibonacci sequence that are even and output the result.

This is given by OEIS A099919, except that sequence is shifted by one, starting with fib(1) = 0 instead of fib(1) = 1.

This is code golf. Lowest byte count wins.

Examples

n sum
1 0
2 2
3 10
4 44
5 188
6 798
7 3382
8 14328
9 60696

Related

Python, 33 bytes

c=2+5**.5
lambda n:(7-c)*c**n//20

Try it online

Magic formula!


Write a program that converts unary input to binary, decimal, and hexadecimal equivalents Write a program that accepts input (through stdin) as a string of unary numbers delimited by spaces, and prints the equivalent string of numbers in binary, decimal, and hexadecimal. These unary symbols are allowed:

stroke, '/' or '\'
Decimal 1
ASCII 'I'
ASCII '-'

Your program does not have to support all symbols, but it must use at least one. Zero should be represented as simply two spaces (the lack of unary symbols)

e.g. if the input is

Test Cases:

Input:

1 11 111 1111111111

Example Output:

1 2 3 10

1 2 3 A

1 10 11 1010

Output must be to standard output. If no standard output is available, use whatever output logging stream is available.

It does not have to print the converted strings in any particular order; it must print the binary, hexadecimal, and decimal string equivalents, but it does not have to print in that specific order.

This is code-golf, so shortest program wins!

Python 3, 68 bytes

i=input().split(" ")
for f in[bin,str,hex]:print(*map(f,map(len,i)))

Outputs like such:

0b1 0b10 0b11
1 2 3
0x1 0x2 0x3

If the 0b and 0x are not allowed then that can be solved at the cost of 17 extra bytes by changing the second line to:

for f in[bin,str,hex]:print(*(f(len(n))[2*(f!=str):]for n in i))

Or using this version (minified version of My Ham DJ's answer):

i=input().split(" ")
for b in"dxb":print(*("{:{}}".format(len(x),b)for x in i))


Retrograde morse (d)e(n)coder This question is inspired by retrograde music. Retrograde music is a piece of music that can both be played normally (from the beginning to the end) as reversed (from the end the beginning). A similar thing exists in literature, this is called a semi-palindrome, e.g. "roma" and "amor".
Your task is to write a retrograde program. If executed normally it has to encode a string with the morse code, decode it when executed reversed.

Task

You're to write a program or function that accepts a string and outputs it's morse code encoding (STDIN and STDOUT are used in case of a program, a function receives it's input as a function argument and returns a string). However, when you run the reverse of the program, it works the same except it decodes the input. Note that you don't have to use the same programming language. The reversing of the program is done manually.

Details

Comments are not allowed in your program, as they would make this task very easy.
You have to use the international morse code. This includes letters, numbers and some punctuation. See the link for a complete list. No prosigns or special characters have to be supported. There's one exception mentioned in the edit.
You have to represent dots and dashes with . and -.
Letters are separated with  (spaces), words are separated with / (slashes).
You can choose to use either use lower or uppercase. However, you have to be consistent (if your program only uses uppercase, the reversed program must do so too).
You can assume the program will only receive valid input.

Example

Input of the normal program or output of the reversed program:

MORSE CODE?

Output of the normal program or input of the reversed program:

-- --- .-. ... . / -.-. --- -.. . ..--..

Score

Because I want to reward both clever (short) algorithms and creativity, Your score will be based upon your votes and the program length. Concretely, it will be 100 * amount of votes / program length (in bytes)

EDIT: The morse code site I mentioned uses the same code for opening and closing parentheses, however it's not my intention to let you implement a feature for recognizing this. So you have to use these more modern morse codes for the parentheses:

( = -.--.
) = -.--.-


Compute the Fibonomial Coefficient Background
The Fibonacci sequence is defined as
$$f(1) = 1 \\ f(2) = 1 \\ f(n) = f(n-1) + f(n-2)$$
The Fibonorial, similar to the factorial, is the product of the first \$n\$ Fibonacci numbers.
$$g(n) = f(1) \times f(2) \times ... \times f(n-1) \times f(n)$$
The Fibonomial coefficient, similar to the binomial coefficient is defined as
$$\begin{align}a(n, 0) & = 1 \\
a(n, k) & = \frac {g(n)} {g(n-k) \times g(k)} \\
& = \frac {f(n) \times f(n-1) \times ... \times f(n-k+1)} {f(1) \times f(2) \times ... \times f(k)}
\end{align}$$
Task
Your goal is to create a function or program to compute the Fibonomial coefficient given two non-negative integers \$n\$ and \$k\$ with \$l \le n\$.
Test Cases
a(0, 0) = 1
a(1, 1) = 1
a(2, 0) = 1
a(3, 2) = 2
a(8, 3) = 1092
a(11, 5) = 1514513
a(22, 7) = 7158243695757340957617
a(25, 3) = 49845401197200
a(50, 2) = 97905340104793732225
a(100, 1) = 354224848179261915075

Rules

This is code-golf so the shortest code wins.
Builtins are allowed.

Related

A000045 - Challenge - Fibonacci Sequence
A003266 - Challenge - Fibonorial
A010048 - Fibonomial coefficient

Python 67 bytes
f=lambda n,a=1,b=1:n<1or a*f(n-1,b,a+b)
lambda n,k:f(n)/f(k)/f(n-k)

Call using a(n,k). Uses @Dennis fibonorial answer (is that allowed?), and a straightforward implementation of the question otherwise.


Make a colorful table For this challenge, you must accept input as a comma-separated list (columns) of a run (rows) of the first letters of any of the colors red, orange, yellow, green, blue, or purple, and output (to stdout) the HTML for a table of those colors.

This is fairly hard to understand, so I'll just give a simple example.

Input:

rgb,gbr,grb

Output (with example screenshot):

Note that the HTML you output need not be valid; it just has to work. By "work", I mean that your output will be pasted into a .html file and viewed in the latest (currently, 9/28/13) Chrome (v 29.0.1547.76). The squares must be 50 pixels width and height. You may have whatever padding between them as you want (Chrome automatically uses 1 pixel of padding, even when you specify padding: 0px, so I can't control that).

Input will always be valid (letters will be one of roygbp), but the rows are not guaranteed to have equal amounts of squares in them. For example, roygbp,ooo is valid and should output

This is code-golf, shortest code wins.

Perl: 153 126 124 116 114 characters
s!\w!''!ge;s!,!
!g;$_="
$_"

Sample run:
bash-4.1$ perl -p table.pl <<< 'rgb,oyp'

Sample output:
bash-4.1$ perl -p table.pl <<< 'yrryyryyryyyrrr,ryyyryryryyyryy,ryryryryryyyrry,yrryyryyrrryryy'


XOR two monochrome images Challenge:

Take input of two black and white (monochrome) images and xor each pixel of the first, with each pixel of the second, add them to a new image and output the new image.

Some clarifications:

Size of pictures does not matter. Extension/Image format doesn't matter. You can make it take input any extension and output any extension, as long as the extension is used to store digital images. You can also use graphics to draw the output in eg: a picturebox if you wish. Otherwise, save the output as a file. Input can be taken  as a path to the image, or url.

One thing you can't do however, is I/O arrays, eg. of triplets(R,G,B).

Do NOT tamper with alpha. It should not be xored, it should be 255 (max value) for every pixel.

What do you mean xor each pixel?

You don't have to do it this way, but one way to xor two pixels is to take their RGB values and xor R1 with R2, G1 with G2, B1 with B2, and take the result, which is your new color

Since we have only two colors, obviously when the colors are the same the result would be (0,0,0) and when they are different (white is 255,255,255 and black is 0,0,0) in this case, the result would be 255,255,255.

Thus when two pixels are different, the result is a white pixel, else a black pixel

Example I/O:

Input 1:     Input 2:

Output:

This is code-golf so shortest code wins.

The Fx Expression Language (ImageMagick), 8 4 bytes
EDITS

Simplified to u!=v, -4 bytes

As "Fx Expression Language" is apparently Turing complete, I've re-profiled my answer to it (was Unix Shell + Image Magick).
Golfed
u!=v

Fx does not support bitwise XOR nor bitwise NOT, so I've used != instead (which works just fine for the pure BW images).
u=> stands for "first image in list"
v=> "second image in list"

Input and output are implicit (controlled by the interpreter).
Usage
ImageMagick convert utility, serves as the "Fx Expression Language" interpreter, when invoked with -fx, as illustrated below:
convert $1 $2 -fx u!=v $3

The arguments are:

Input image A
Input image B
Output image O (A^B).

Sample output
convert a.png b.png -fx u!=v o.png


How can I shorten this multiple assignment in Lua? Is there any better way to golf this (other than removing newlines/indentation)?

function(a,b,...)
  local c=s(a,b)
  local d=c
  for i,v in ipairs{...} do d=d:push(v) end
  return c
end

I'm particularly bothered by the double local usage, but as Lua does not have multiple assignment, and I cannot use function parameters to declare the locals, I can't see a way to remove them.

For those who care, this is the implementation of the __call metamethod in my quick hack of a linked-list ~class used in this answer.

As requested in the comments, here it is as an answer.

local c,d=s(a,b)  -- d is nil
d=c

This saves you one local declaration, should give you -5 bytes.


What's my TIO uniqueness? Try it online! currently has 680 listed languages, all of which are searchable. For most of those languages, when searching for it, you don't have to enter the entire string. For example, entering lega results in just 05AB1E (legacy) appearing, and entering d+ results in only Add++. However, for some languages, there is no such string that results in only that languages, e.g. Jelly returns both Jelly and Jellyfish
We will call the length of the shortest string required to return only a specific language on TIO the TIO uniqueness of that language. The TIO uniqueness of a language for which this is impossible is undefined. Note that TIO ignores case when searching, so bri results in Brian & Chuck and SOM results in Somme.
You are to take the name of a programming language on Try it online!, exactly as spelt in the search function, and return that language's TIO uniqueness. If the language's TIO uniqueness is undefined, you may instead return any value which is not a positive integer (or could reasonably be interpreted as a positive integer). This value need not be consistent between such languages. Your program should handle all 680 languages currently on TIO.
This is code-golf, so the shortest code wins. Standard loopholes are forbidden, especially internet access. You may also not access the file system of TIO. Essentially, your program should work whether it's run on TIO or locally.
Test cases
All test cases include the TIO uniqueness string in lowercase, as TIO is case insensitive in its search, and use 0 for undefined TIO uniquenesses
"Arcyóu" -> 1 ("ó")
"Befunge-98 (PyFunge)" -> 13 ("befunge-98 (p")
"Cauliflower" -> 3 ("cau")
"Shove" -> 3 ("hov")
"Funky" -> 0
",,," -> 2 (",,")
"Agony" -> 0
"Starry" -> 4 ("tarr")
"Add++" -> 2 ("d+")
"ATS2" -> 3 ("ts2")
"F# (.NET Core)" -> 5 ("f# (.")
"Dyvil" -> 2 ("yv")
"Python 3.8 (pre-release)" -> 2 ("3.")

The full list of names and the full list of test cases

JavaScript (Node.js),  819  779 bytes
Returns 0 for undefined TIO uniqueness.
s=>(B=Buffer)('J .!> . 8 " .  . 0 L"0"c$E"~~~="8"~1 Y$^"~~~j S$x"P S$;"7 @ Z G"/$8$A :%X!T%A G M$c*h"d"L!Q$8"~F$.$>"s$@"`"E 3 1$r"U">"8 F&~Y"="z"~Q"F"E"g |"R%m!c$"~N"~?$Q  1 ~W B$k"F ="d$> U"7%"""F"X%Y%s"S$E"<-O$b _"]"?$3 <$B i"0"~A"W">$6 L `"I%2"1"?$6"M "A _$2"A ="; T"t @$:"q"N i"["V&~= z"5"1 I!N"8"Z ` ~~B 4"1 }"#"2$."e P F ;!A"W$K G">$9$K"T M*W #"8 < 0"A ]""~~J Z""m"0"V!; ~~[ h+$2$~^"1"3$1"3 A$}"D"~i"9 H%N"~3 9 K"~4"; C%C"Q"3"/ X ^"D"9$4 4 /"7 J":$$0*o"~<"Z 9"T"I"~D$5"@ 1"j ". ~c"O$4"3 O ~X 6$K"I ~8 F  d$T } 6"#"V"W";$I$0 H$R"x$"[$6 j i"U"~M L"K$~~h W$L O"0%="Z 4"F$X"6!?$;"4"M"~0$~1%r"k"6"K"^"2 5$V v"4"J"z 1"1 H$;$W"#">!i"."V"V$e"6$~~<*~C!~/"7 8!/ q$3"U /"."? t"Y"J!<$4 i"~P K"Y'.replace(/[.-~]/g,c=>'#'.repeat(B(c)[p=0]-44))[B(s).map(c=>p=(p*79^c)>>>0)|p%12635])[0]-32

Try it online! (test cases)
Try it online! (all languages)
How?
There are only \$10\$ distinct TIO uniqueness values, ranging from \$0\$ to \$13\$. Besides, more than 50% of the languages have a TIO uniqueness of \$3\$.
 uniq. | count | ratio
-------+-------+--------
   0   |   97  | 14.24%
   1   |   12  |  1.76%
   2   |  140  | 20.56%
   3   |  357  | 52.42%
   4   |   56  |  8.22%
   5   |   11  |  1.62%
   6   |    2  |  0.29%
  10   |    4  |  0.59%
  11   |    1  |  0.15%
  13   |    1  |  0.15%
We need:

a function \$H_0\$ that turns the language name \$s\$ into an integer \$H_0(s)\$
a function \$H_1\$ and a corresponding lookup table \$T\$ so that the TIO uniqueness of the language is \$T[H_1(H_0(s))]\$

It seems unlikely to find some simple functions \$H_0\$ and \$H_1\$ that would directly lead to a small lookup table. But if we use \$3\$ (the most common uniqueness) as the padding value for unused slots, the table is going to contain a lot of \$3\$'s.
So our strategy is to use:

the first 14 printable ASCII characters (32 to 45, i.e.   to -) to encode the actual uniqueness values other than \$3\$
all other printable characters (46 to 126, i.e. . to ~) to encode runs of 2 to 82 consecutive \$3\$'s

Conveniently, the single quote ' (ASCII code 39) will never appear in the table because no language has a uniqueness of 7. So we can use it as our string delimiter and safely use " and ` in the table without having to escape them.
We now need to find \$H_0\$ and \$H_1\$ so that the distribution of actual uniqueness values among the \$3\$'s leads to the smallest table with this simple compression scheme.
After some brute-forcing, it turns out that the following functions work reasonably well:

Buffer(s).reduce((p, c) => p * 79 ^ c) >>> 0 (actually implemented with a .map())
% 12635


Fit a word into an alphabet grid Inspired by a meme I saw earlier today.

Challenge description

Consider an infinite alphabet grid:

ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
...

Take a word (CODEGOLF in this example) and make it a subsequence of the grid, replacing unused letters by a space and removing letters at the end of the infinite grid altogether:

  C           O
   DE G       O
           L
     F

Examples

STACKEXCHANGE

                  ST
A C       K
    E                  X
  C    H
A            N
      G
    E

ZYXWVUTSRQPONMLKJIHGFEDCBA

                         Z
                        Y
                       X
                      W
                     V
                    U
                   T
                  S
                 R
                Q
               P
              O
             N
            M
           L
          K
         J
        I
       H
      G
     F
    E
   D
  C
 B
A

F

     F

ANTIDISESTABLISHMENTARIANISM

A            N     T
        I
   D    I         S
    E             ST
AB         L
        I         S
       H    M
    E        N     T
A                R
        I
A            N
        I         S
            M

Notes

Trailing whitespaces are allowed.
You don't need to pad the last any line with spaces. For example, if the input is ABC, you may output just ABC without 23 trailing spaces.
You may assume input will match [A-Z]+ regex.
Alternatively, you may use lower-case alphabet, in which case output will match [a-z]+.
You must use a newline (\n, \r\n or equivalent) to separate lines, that is a list of strings is not a proper output format.
This is a code-golf challenge, so make your code as short as possible!

Husk, 15 bytes

TṪS`?' €…"AZ"ġ>

Try it online!

Explanation

TṪS`?' €…"AZ"ġ>  Implicit input, e.g. "HELLO"
             ġ>  Split into strictly increasing substrings: x = ["H","EL","LO"]
        …"AZ"    The uppercase alphabet (technically, the string "AZ" rangified).
 Ṫ               Outer product of the alphabet and x
  S`?' €         using this function:
                   Arguments: character, say c = 'L', and string, say s = "EL".
       €           1-based index of c in s, or 0 if not found: 2
  S`?'             If this is truthy, then c, else a space: 'L'
                 This gives, for each letter c of the alphabet,
                 a string of the same length as x,
                 containing c for those substrings that contain c,
                 and a space for others.
T                Transpose, implicitly print separated by newlines.


Make big rocks into small rocks Welcome to the grinder.

Your task is to make big rocks into small rocks by grinding them.

Take an input of a big rock of size n > 3  and grind it.

Continue to grind the rocks by dumping them into the grinder until the size of all the rocks are 2.

rocks are always grinded into equal even halves. If the result of a grinding is odd take result - 1.

Print the output of each grinding as you proceed.

Examples

input: 5

output: 22

The result are two rocks of size 2

input: 50

output:

2424 //two rocks of size 24
12121212 //four rocks of size 12
66666666 //8 rocks of size 6
2222222222222222

the result is 16 rocks of size 2

input: 30

output:

1414
6666
22222222

the result is 8 rocks of size 2

This is code-golf so the shortest code wins! Have fun and good luck!

TSQL, 61 59 bytes
DECLARE @ int=50

,@x int=1WHILE @>2SELECT @=@/4*2,@x*=2PRINT replicate(@,@x)

Try it out


J - 52 characters

wd,.10|(^12+12&|)/"1(".@{:`".;._2@,&'x ');._2(1!:1)3

Passes all tests given, though only if the trailing spaces on the third input are removed (I'm guessing this was unintentional).

Solution will work in j602 in console mode (e.g. in terminal, emacs j-shell, etc.). It will not work in j701 (no wd).

Explanation & Mathiness:

The 'magic number' 12 is the LCM of the lengths of the "last digit" tables found in the other answers. All digits repeat with periods 1,2,3 or 4 so they will also repeat with period 12. Adding twelve to that fixes cases where b mod 12 = 0. My solution computes (Last digit of A)^(12+(B mod 12)), giving a number with the same last digit. (I considered a sneaky broken solution eliminating the three characters '12+' by using e.g. B mod 96 where no examples were likely to collide...)