Surjection from one string to two strings This is the inverse of negative seven's question.

Write a program or function which, given any single, possibly-empty string of printable ASCII (codes \$[32,126]\$) outputs or returns two strings of printable ASCII.

For any two ordered, possibly empty strings \$s_1\$ and \$s_2\$, there must be third string \$s_0\$, which input to your program, outputs \$s_1\$ and \$s_2\$.

In other words, if \$\mathbb S\$ is the set of all ASCII strings (including the empty string):

\$f\$ is well-defined on \$\mathbb S\$: \$(\forall s\in\mathbb S)(f(s)\in\mathbb S\times\mathbb S)\$

\$f\$ is a surjection to \$\mathbb S\times\mathbb S\$: \$(\forall s_1,s_2\in\mathbb S)(\exists s_0\in\mathbb S)(f(s_0)=(s_1,s_2))\$

Test cases:

For each of these strings (surrounding «quotes» excluded), your output should be two strings:

«»
«hello world»
«'one' 'two' 'three' 'four'»
«"one" "two" "three" "four"»
«["one", "two", "three"]»
«; exit()»

For each of these pairs of strings, there must be at least one string you can provide to your program such that that pair is output (surrounding «quotes» excluded):

 s_1     |  s_2
---------|----------
«hello » | «world»
«hell»   | «o world»
«hello»  | « world»
« »      | «»
«»       | « »
«»       | « !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~»
«\r\n»   | «\r\n»

As always, you are encouraged to add test cases pertinent to your method.

Rules:

Input must be a single string/character array/byte array consisting of only ASCII characters.
Output is  ordered; \$(a,b)\neq(b,a)\$. Output can be any ordered structure in your language, or printed with a newline (LF or CR LF) separator and optional trailing newline.
I/O must be consistent. If one case handles input as an argument and outputs to stdout with a trailing newline, all cases must handle input as an argument and output to stdout with a trailing newline.
Standard loopholes are forbidden.
This is code-golf, so shorter programs are better!

As a reminder, this is only a surjection, not a bijection: Your program/function will likely map many different strings to the same output.

Python 2, 42 bytes

lambda s:(s.split("1"+len(s)/2*"0")*2)[:2]

Try it online!

The inverse is:

def F(a,b):
    return a+"1"+len(a+b)*"0"+b

A tempting idea for the inverse is to encode the pair of input strings by putting some separator string in between them. That way, we can extract the pair by splitting on this separator. The issue is that the separator may appear in the inputs string.

We get around this by making the separator longer than the total length of both strings. We use 1 followed by a number of 0's equal to the number of characters in both strings. For example,

abc, defgh -> abc100000000defgh

Note that no matter how many 0's and 1's are in the two inputs, there's no way to get another copy of the separator to appear.

We can recover the separator from the combined string by using a number of zeroes equal to half its length rounded down. I had wanted to compute this as 10**_, but Python's repr appends an annoying L to large numbers, which messes it up.

We need to the submission function still give two outputs when the input string doesn't contain the required separator. In this case, splitting just gives the original string, but we copy it twice to be compliant.

Python 2, 35 bytes (not working)

lambda s:s.split(s[:len(s)/3])[-2:]

Try it online!

This would work except it gives an error for the empty string. The idea is to have the inverse encode a,b -> sep + a + sep + b, where the separator sep has the same length as a+b so we can extract it as the first third of the string. A similar idea of putting the separator interspersed runs into the same issue.

Python 2, 43 bytes

lambda s:[s[i::2].lstrip()[1:]for i in 0,1]

Try it online!

The idea for encoding is to intersperse the two input strings with alternating characters. The problem there is that they may have different lengths. So, we pad them to the same length by prepending each one with some number of leading spaces then | (any non-space char will do). For example, abcd, ef goes to

|abcd
  |ef

This can be undone for each string by stripping off all leading spaces then removing the first character. Note that any spaces or | in the actual strings are left unharmed.

Python 3.8 (pre-release), 44 bytes

lambda s:(s[(i:=s.find('_'))+1:2*i],s[2*i:])

Try it online!

Inverse:

F=lambda a,b:(len(a)+1)*"?"+"_"+a+b

For instance, F("ab","cdef") = ???_abcdef. The number of symbols before the _ tells us where to split the remainder -- it's one more than the length of the first string.

We need the submission not to error when there's no _, but this works out because Python's string find uses -1 for missing, which still gives valid slices.


Vertically collapse text Say I have text like this (each word on one line, with no spaces)

Programming
Puzzles
&
Code
Golf

That makes no sense! It totally defies the laws of physics.

Your challenge is to remedy this impossible situation and collapse the text like so:

P
Prog
&uzz
Coderam
Golflesming

So that there is no empty space underneath any character but the characters retain their vertical order.

The goal is to satisfy the requirements but use the fewest bytes of source code possible.

Pyth, 10 bytes

jb_.T.T_.z

Try it online in the Pyth Compiler/Executor.

Idea

We can achieve the desired output by applying four simple transformations:

Reverse the order of the lines:

Golf
Code
&
Puzzles
Programming

Transpose rows and columns:

GC&PP
oour
ldzo
fezg
lr
ea
sm
m
i
n
g

This top justifies, collapsing the original columns.
Transpose rows and columns:

Golflesming
Coderam
&uzz
Prog
P

Reverse the order of the lines:

P
Prog
&uzz
Coderam
Golflesming

Code

        .z  Read the input as a list of strings, delimited by linefeeds.
       _    Reverse the list.
   .T.T     Transpose the list twice.
  _         Reverse the list.
jb          Join its strings; separate with linefeeds.


Is it a geometric sequence or not? Well, last time I asked for an arithmetic sequence, now comes the geometric sequence
Challenge
In this challenge, the input will be an unordered set of numbers and the program should be able to tell if the set of numbers is a Geometric Sequence.
Input

The input will be a set separated by ,(comma).

Output

The Output can be a Boolean (True or False), or a number (1 for True, 0 for False).

Test cases
In: 1,3,9
Out: True

In: 1,4,16
Out: 1

In: 2,6,14
Out: 0

In: 2,8,4
Out: True

In: 4,6,9
Out: 1

Rules

This is code-golf, so the shortest code by bytes wins.
The minimum length of the input set would be 3 elements.

Best of Luck

Jelly, 4 bytes
Ṣ÷ƝE

Try it online!
Thanks to fireflame241 for pointing out a mistake
How it works
Ṣ÷ƝE - Main monadic link, takes an array as input
     - e.g                            A = [2, 8, 4] or   A = [2, 6, 14]
Ṣ    - Sort                               [2, 4, 8]          [2, 6, 14]
  Ɲ  - Over overlapping pairs [x, y]...   [[2, 4], [4, 8]]   [[2, 6], [6, 14]]
 ÷   - ...divide x by y?                  [0.5, 0.5]         [0.33, 0.43]
   E - Is the list all the same?          1                  0


Rational Counting Function Create a function that takes a natural number (starting from 0 inclusive), and returns a pair of positive integers, which are the numerator and denominator respectively.
Use the diagonal traversal. Previous-counted numbers must be skipped. (you can memorize the set of skipped values)

Diagram:

Red are skipped values

Values:

f(0) = 1, 1
f(1) = 2, 1
f(2) = 1, 2
f(3) = 1, 3
f(4) = 3, 1 (notice the skip)
f(5) = 4, 1
f(6) = 3, 2
f(7) = 2, 3
f(8) = 1, 4
f(9) = 1, 5
f(10) = 5, 1 (notice the skip)

You may use the Rational data structure and their operations if they exist.
Shortest code wins.

Haskell, 78 characters

q(r,f)=[(r-b,b)|b<-f[1..r-1],r`gcd`b==1]
d=reverse:id:d
f=((zip[2..]d>>=q)!!)

Sample run:

> map f [0..10]
[(1,1),(2,1),(1,2),(1,3),(3,1),(4,1),(3,2),(2,3),(1,4),(1,5),(5,1)]
> f 100
(17,1)
> f 1000
(3,55)

Edit: (100 → 87) silly me, just testing the gcd is enough!
Edit: (87 → 85) clever trick with cycle and functions to alternate row order
Edit: (85 → 82) replace cycle with the hand-built infinite list d
Edit: (82 → 78) applied gcd identity as suggested by Matías


Generate a deck of cards Here's an array representing a standard deck of cards, including two Jokers.

[
  "AS", "2S", "3S", "4S", "5S", "6S", "7S", "8S", "9S", "10S", "JS", "QS", "KS",
  "AD", "2D", "3D", "4D", "5D", "6D", "7D", "8D", "9D", "10D", "JD", "QD", "KD",
  "AH", "2H", "3H", "4H", "5H", "6H", "7H", "8H", "9H", "10H", "JH", "QH", "KH",
  "AC", "2C", "3C", "4C", "5C", "6C", "7C", "8C", "9C", "10C", "JC", "QC", "KC",
  "J", "J"
]

It's composed in this manner:

There are four suits; hearts, spades, diamonds, and clubs (H, S, D, C).
Each suit has one card for the numbers 2 to 10, plus 4 'picture' cards, Ace, Jack, Queen, and King (A, J, Q, K).
For each combination of suit and value, there should be one item in the array, which is a string, and is made up of the value followed by the suit (Whitespace between these is permitted).
On top of that, there are two Joker cards ('J').
Write in any language you please.
Golf it up! Try to produce this output in the smallest number of bytes.
It does not matter what order the output is in.


Cyclic Weak Levenquine This question asking us to make a "Cyclic Levenquine" has gone unanswered. So today we will ask a slightly simpler version.  In this challenge we will define a K-Levenquine to be a program whose output is Levenshtein distance K from its source.

Task

Your goal in this challenge is to write a program with some output different from its own source; running that output as a program should also do the same. Eventually, the sequence of repeatedly running the outputs of each successive program (in the same language) must eventually output the original program.

As with the last challenge there must be two distinct programs in this cycle such that they do not share any two bytes (i.e. their byte sets are disjoint).

As with most quine challenges, reading your own source code is forbidden.

Scoring

Each program in your cycle will be a K-Levenquine for some K.  The largest K of any of the programs in your cycle will be your score.  Your goal should be to minimize this score, with 1 being the optimal score.

><>, Score: 41

'd3*}>a!o-!<<8:5@lI55>@z:5ll55>>q:>|q::|,

and the disjoint program

"r00gr40g44++bb+0p64++?b6+0.22#eW4s )Z

Try it online!

A copy of my answer to the Mutually Exclusive Quine question. A mutually exclusive quine is made of two programs, A and B sharing no common characters, where A outputs B and B outputs A. This means it is a 2-cycle Levenquine and also qualifies for this question. This can act as a baseline for other more inventive answers (though I'm not very confidant this won't go the way of the original Levenquine question).

A more detailed explanation can be found here.


How long until this date? The idea is this: Write a function to print the length of time from now/today's date (at the time the function is called) until a date supplied as an argument.

Assumptions:

Input date will always be tomorrow or later, in the future.
Input date will never be more than 10 years in the future.

Rules:

Output must be in this format: "[z year(s)], [x month(s)], y day(s) until -Input Date-"
Output time frame (day/month/year) must be pluralized correctly. i.e. 1 month, not 1 months
Input can be in whichever date format you prefer (3/15/12 - March 15, 2012 - 2012.03.15).

Example:
Assuming program is run on March 15, 2012:

Input date of 3/20/12 = 5 days until 3/20/12
NOT Input date of 4/16/12 = 1 month, 1 days until 3/20/12
Input date of 2012.04.20 = 1 month, 5 days until 2012.04.20
NOT Input date of 2012.04.20 = 36 days until 2012.04.20
Input date of 10/31/17 = 5 years, 7 months, 16 days until 10/31/17
Input date of 3/15/13 = 1 year until 3/15/13

This is code golf, so shortest length code wins.

I suppose for the sake of having a deadline, I will be selecting an answer on:

March 23, 2012!

(This is my first CG question, so I'll be happy to correct any question errors on my part!)

R, 99 characters

I know it is sort of cheating, but R is all about its packages and lubridate is so convenient for this kind of tasks!

f=function(x){library(lubridate);cat(show(as.period(interval(mdy("3/15/2012"),mdy(x)))),"until",x)}

Usage:

f("10/31/2017")
[1] 5 years, 7 months and 16 days
5 years, 7 months and 16 days  until 10/31/2017


Spot all (anti)diagonals with duplicated values Challenge:

Given a matrix input, determine the amount of diagonals and anti-diagonals with duplicated numbers.
So if we have a matrix like this:

[[aa,ab,ac,ad,ae,af],
 [ba,bb,bc,bd,be,bf],
 [ca,cb,cc,cd,ce,cf],
 [da,db,dc,dd,de,df]]

All diagonals and anti-diagonals would be:

[[aa],[ab,ba],[ac,bb,ca],[ad,bc,cb,da],[ae,bd,cc,db],[af,be,cd,dc],[bf,ce,dd],[cf,de],[df],
 [af],[ae,bf],[ad,be,cf],[ac,bd,ce,df],[ab,bc,cd,de],[aa,bb,cc,dd],[ba,cb,dc],[ca,db],[da]]

Example:

[[1,2,1,2,1,2],
 [1,2,3,4,5,6],
 [6,5,4,3,2,1],
 [2,1,2,1,2,1]]

All diagonals and anti-diagonals would be:

[[1],[2,1],[1,2,6],[2,3,5,2],[1,4,4,1],[2,5,3,2],[6,2,1],[1,2],[1],
 [2],[1,6],[2,5,1],[1,4,2,1],[2,3,3,2],[1,2,4,1],[1,5,2],[6,1],[2]]

Removing all diagonals and anti-diagonals only containing unique numbers:

[[2,3,5,2],[1,4,4,1],[2,5,3,2],[1,4,2,1],[2,3,3,2],[1,2,4,1]]

So the output is the amount of diagonals and anti-diagonals containing duplicated numbers:

6

Challenge rules:

If the input matrix is empty, contains only 1 number, or contains only unique numbers across the entire matrix, the output is always 0.
Input is guaranteed to only contain positive digits [1,9] (unless it's completely empty).
The matrix will always be rectangular (i.e. all the rows are the same length).
I/O is flexible. Input can be taken as a list of lists of integers, or 2D array of integers, or a Matrix-object, as a string, etc. etc. You are also allowed to take one or both of the dimensions of the matrix as additional input if it would save bytes in your language of choice.

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 with default I/O rules, 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 (i.e. TIO).
Also, adding an explanation for your answer is highly recommended.

Test cases:

Input:                     Output:

[[1,2,1,2,1,2],            6
 [1,2,3,4,5,6],
 [6,5,4,3,2,1],
 [2,1,2,1,2,1]]

[[]]                       0

[[1,2],                    0
 [3,4]]

[[1,1],                    2
 [1,1]]

[[9,9,9],                  6
 [9,9,9],
 [9,9,9]]

[[7,7,7,7],                8
 [7,7,7,7],
 [7,7,7,7]]

[[1,1,1],                  1
 [2,3,4],
 [2,5,1]]

[[1,8,4,2,9,4,4,4],        12
 [5,1,2,7,7,4,2,3],
 [1,4,5,2,4,2,3,8],
 [8,5,4,2,3,4,1,5]]

[[1,2,3,4],                4
 [5,6,6,7],
 [8,6,6,9],
 [8,7,6,5]]

R, 92 86 82 78 bytes

function(m,x=row(m),y=col(m),`|`=split,`^`=Map)sum(max^table^c(m|x-y,m|x+y)>1)

Try it online!

Explanation

First, we declare additional variables \$x\$  and \$y\$ that stand for row and column indices, respectively. Then we can delineate the diagonals and anti-diagonals by taking their difference and sum. E.g., for a 4x4 matrix:

\$x-y\$ gives:

0 -1 -2 -3
 1  0 -1 -2
 2  1  0 -1
 3  2  1  0

\$x+y\$ gives:

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

Now split(m, x-y) and split(m, x+y) produce the actual lists of diagonals and anti-diagonals, which we join together.

Finally, we count the entries of the resulting list where duplicates are present.

Thanks for bytes saved:

-4 by CriminallyVulgar
-4 by digEmAll


Display numbers lacking 2's Display numbers from one to one-hundred (in increasing order), but number 2 shouldn’t appear anywhere in the sequence. So, for example, the numbers two (2) or twenty-three (23) shouldn't be in the sequence.

Here is an example output, with newlines separating the numbers:

1
3
4
5
6
7
8
9
10
11
13
14
15
16
17
18
19
30
31
33
34
35
36
37
38
39
40
41
43
44
45
46
47
48
49
50
51
53
54
55
56
57
58
59
60
61
63
64
65
66
67
68
69
70
71
73
74
75
76
77
78
79
80
81
83
84
85
86
87
88
89
90
91
93
94
95
96
97
98
99
100

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

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

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

Try it online!


Length of the Longest Descent Your task is to determine the length of the longest descent down a "mountain" represented as a grid of integer heights. A "descent" is any path from a starting cell to orthogonally adjacent cells with strictly decreasing heights (i.e. not diagonal and not to the same height). For instance, you can move from 5-4-3-1 but not 5-5-4-3-3-2-1. The length of this path is how many cell movements there are from the starting cell to the ending cell, thus 5-4-3-1 is length 3.

You will receive a rectangular grid as input and you should output an integer indicating the longest descent.

Examples

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

The length of the longest descent down this mountain is 5. The longest path starts at the 7, moves left, up, left, up, and then left (7-6-5-4-2-1). Since there are 5 movements in this path, the path length is 5.

They might be all the same number.

1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1

Since this height map is flat, the longest descent is 0. (not 19, since the path sequence must be strictly descending)

Height maps can be made up of larger numbers than single-digit numbers.

10 12 13 14 15 15
17 14 15 15 15 16
18 20 21 15 15 15
21 14 10 11 11 15
15 15 15 15 15 15

The longest path here is of length 6. (21, 20, 18, 17, 14, 12, 10)

...And even bigger numbers are fine too.

949858 789874  57848  43758 387348
  5848 454115   4548 448545 216464
188452 484126 484216 786654 145451
189465 474566 156665 132645 456651
985464  94849 151654 151648 484364

The longest descent here is of length 7. (786654, 484216, 484126, 474566, 156665, 151654, 151648, 132645)

Rules and Notes

Grids may be taken in any convenient format. Specify your format in your answer.
You may assume the height map is perfectly rectangular, is nonempty, and contains only positive integers in the signed 32-bit integer range.
The longest descent path can begin and end anywhere on the grid.
You do not need to describe the longest descent path in any way. Only its length is required.
Shortest code wins

JavaScript (ES7),  106 103 102  98 bytes

f=(m,n=b=-1,x,y,p)=>m.map((r,Y)=>r.map((v,X)=>(x-X)**2+(y-Y)**2-1|v/p?b=n<b?b:n:f(m,n+1,X,Y,v)))|b

Try it online!

Commented

f = (                        // f = recursive function taking:
  m,                         //   m[]  = input matrix
  n = b = -1,                //   n    = length of the current path; b = best length so far
  x, y,                      //   x, y = coordinates of the previous cell
  p                          //   p    = value of the previous cell
) =>                         //
  m.map((r, Y) =>            // for each row r[] at position Y in m[]:
    r.map((v, X) =>          //   for each value v at position X in r[]:
      (x - X) ** 2 +         //     compute the squared Euclidean distance
      (y - Y) ** 2           //     between (x, y) and (X, Y)
      - 1                    //     if A) the above result is not equal to 1
      | v / p ?              //     or B) v is greater than or equal to p:
        b = n < b ? b : n    //       end of path: update b to n if n >= b
      :                      //     else:
        f(m, n + 1, X, Y, v) //       do a recursive call
    )                        //   end of inner map()
  ) | b                      // end of outer map(); return b

How?

During the first iteration, \$x\$, \$y\$ and \$p\$ are all undefined and both tests (A and B in the comments) evaluate to NaN, which triggers the recursive call. Therefore, all cells are considered as a possible starting point of the path.


"Convenient palindrome" checker If you've ever tried to write palindromic code before, you'd know how much brackets tend to get in your way. ()() is not a palindrome, even though it kinda looks like it should be, while ())( and ()( are both palindromic and both very dumb looking. Wouldn't it be convenient if it was the other way around?

A string is conveniently palindromic if it is equal to the string derived when its reverse has all its parentheses (()), brackets ([]), and braces ({}) flipped. No other characters are special and require flipping. (<> are sometimes paired but often not so they are left out.)

Your task is to write, in your language, a program (taking input on STDIN) or a function (taking a single string argument) which (a) gives a consistent true value* when its argument is conveniently palindromic and a different, consistent false value otherwise, and (b) is itself conveniently palindromic.

For example, the following inputs are conveniently palindromic:

racecar
(a)(bb)(a)
void main(int argc, *char[] argv) {} (vgra []rahc* ,cgra tni)niam diov

And the following are not:

non-palindrome
A nut for a jar of tuna?
(old [style] parens) )snerap ]elyts[ dlo(
ingirumimusnocte)etconsumimurigni

You may not rely on any external state (specific filename, directory structure, other user input, web access, etc) except interpreter/compiler flags.

Also, you may not use "the comment trick" where you comment out or render unused some piece of code by taking advantage of your language's commenting facilities. For instance, all of the following are not allowed, because they contain non-functional parts that can be safely removed or destroyed (at the expense of losing conveniently-palindromic-ness):

{some code} // {edoc emos}
{some code} NB.BN {edoc emos}
"n\" ;{edoc emos} ;"; {some code}; "\n"

Obviously this might not cover every such case, but the spirit of the challenge here is not to use comments and unparsed** code to achieve palindrominess, instead making use of the corrected parens and brackets. I'm looking at you, LISP, Brainfuck.

This is a code-golf, so the shortest code wins, but all lengths of code are welcome.

* By consistent true and false values, I mean that you can return one of a pair of values, such as 1 for true and 0 for false, or False for true and "no" for false, so long as these values are different from each other, and do not change from run to run of your program. Use whatever saves you characters.

** Not to be confused with unexecuted: code that is valid and might do weird things but never called is fine.

GolfScript, 107 91

.4:ab-1:ba=;1
%ba%{...fi@@=
c43.=;)('"([{
}])"'~?~'"([{
}])"')(;=.34c
=@@if...}%ab%
1;=ab:1-ba:4.

Newlines are artistic. fi, c43 and c are noops, but the entire code is executed.

Prints -3-1-1 for convenient palindromes, -4-1-1 otherwise. Try it online!

Alternate version, 155 bytes

At the cost of 64 bytes, this can be improved upon:

0!*1{!}\;:);0:f;0:i;-1:ab;9:ba;
...=;1%ab%{....i@f@@fi@@=@.=@\)
+""'"([{}])"'~+?+~'"([{}])"'""+
(\@=.@=@@if@@f@i....}%ba%1;=...
;ab:9;ba:1-;i:0;f:0;(:;\{!}1*!0

As before, the entire code is executed and every single byte affects the output.

Prints 010 for convenient palindromes, -100 otherwise. Try it online!

Tests and examples

$ base64 > palindrome.gs -d <<< LjQ6YWItMTpiYT07MSViYSV7Li4uZmlAQD1jNDMuPTspKCciKFt7fV0pIid+P34nIihbe31dKSInKSg7PS4zNGM9QEBpZi4uLn0lYWIlMTs9YWI6MS1iYTo0Lg==
$ wc -c palindrome.gs
91 palindrome.gs
$ rev palindrome.gs | tr '([{}])' ')]}{[(' | diff - palindrome.gs
$ echo -n 'r(a[c{"e"}c]a)r' | golfscript palindrome.gs
-3-1-1
$ echo -n 'totallynotapalindrome' | golfscript palindrome.gs
-4-1-1
$
$ base64 > pal.gs -d <<< MCEqMXshfVw7Oik7MDpmOzA6aTstMTphYjs5OmJhOy4uLj07MSVhYiV7Li4uLmlAZkBAZmlAQD1ALj1AXCkrIiInIihbe31dKSInfis/K34nIihbe31dKSInIiIrKFxAPS5APUBAaWZAQGZAaS4uLi59JWJhJTE7PS4uLjthYjo5O2JhOjEtO2k6MDtmOjA7KDo7XHshfTEqITA=
$ wc -c pal.gs
155 pal.gs
$ rev pal.gs | tr '([{}])' ')]}{[(' | diff - pal.gs
$ echo -n 'r(a[c{"e"}c]a)r' | golfscript pal.gs
010
$ echo -n 'totallynotapalindrome' | golfscript pal.gs
-100
$ for i in {1..154}; do head -c $i pal.gs > tmp.gs; tail -c +$[i+2] pal.gs >> tmp.gs
> [ "$(echo -n 'r(a[c{"e"}c]a)r' | golfscript tmp.gs 2> /dev/null)" = "010" ] && echo $i
> done; rm tmp.gs
1
for i in {1..154}; do head -c $i pal.gs > tmp.gs; tail -c +$[i+2] pal.gs >> tmp.gs
>  [ "$(echo -n '42' | golfscript tmp.gs 2> /dev/null)" = "-100" ] && echo $i
> done | grep '^1$'; rm tmp.gs

How it works

.             # Duplicate the input string.
4:ab-1:ba     # Save 4 in “ab” and -1 in “ba”.
=;            # Compare 4 to -1 and discard the result.
1%            # Save every element from the input string in a new string.
ab%           # Reverse the input string.
{             # For each character in the input string:
  ...         # Duplicate the character thrice.
  fi          # Variable “fi” is undefined; this does nothing.
  @@=         # Verify that the character is equal to itself; push 1.
  c43         # Variable “c43” is undefined; this does nothing.
  .=;         # Verify that 1 is equal to itself and discard the result.
  )(          # Increment and decrement the character.
  '"([{}])"'~ # Push that string and evaluate it. Result: '([{}])'
  ?           # Retrieve the character's position in '([{}])'. -1 means not found.
  ~           # Negate the position.. Examples: -1 -> 0    0 -> -1    2 -> -3
  '"([{}])"') # Push that string and pop its last element. Result: '"([{}])' 34
  (;          # Decrement 34 (the ASCII code of a double quote) and discard.
  =           # Retrieve the corresponding character.
  .34         # Duplicate the character and push 34.
  c           # Variable “c” is undefined; this does nothing.
  =           # If the character is a double quote, the index was -1.
  @@if        # In that case, replace the double quote with the original character.
  ...         # Duplicate the new character thrice.
}%            #
ab%           # Save every fourth element in a new string to discard dummy values.
1;            # Push 1 and discard.
=             # Push 1 if the modified string matches the original, 0 otherwise.
ab:1-         # Save 4 in “1” and subtract.
ba:4.         # Save -1 in “4” and duplicate.

0!*           # Pop and push the input string.
1{!}\;:);     # Make “)” an alias for “!”.
0:f;0:i;      # Variables.
-1:ab;9:ba;   # Moar variables.
...=;         # Duplicate the input string.
1%ab%         # Reverse the copy.
{             # For each character in the input string:
  ....        # Duplicate the character four times.
  i@          # Push 0 and rotate a string copy on top of it.
  f@@fi@@     # Push 0 and rotate 0 on top of it.
  =@          # Push 1 and rotate a string copy on top of it.
  .=@         # Push 1 and rotate 1 on top of it.
  \)+         # Negate a 1 and add. Result: 1
  ""          # Push that string.
  '"([{}])"'  # Push that string.
   ~+         # Evaluate the second string and concatenate. Result: '([{}])'
   ?          # Retrieve the characters position in '([{}])'. -1 means not found.
   +~         # Add 1 to the position and negate. Ex.: -1 -> -1 | 0 -> -2 | 1 -> -3
  '"([{}])"'  # Push that string.
  ""          # Push that string.
  +           # Concatenate. Result: '"([{}])"'
  (\          # Pop the first double quote and swap it with the rest of the string.
  @=.         # Retrieve the corresponding character and duplicate it.
  @=          # If the character is a double quote, the index was -1.
  @@if        # In that case, replace the double quote with the original character.
  @@          # Rotate the modified character to the bottom.
  f@i....     # Push dummy values.
  }%          #
  ba%         # Save every ninth element in a new string to discard dummy values.
  1;          # Push 1 and discard.
  =           # Push 1 if the modified string matches the original, 0 otherwise.
  ...;        # Duplicate thrice and discard the last copy.
  ab:9;ba:1-; # Variables.
  i:0;f:0;    # Moar variables.
  (:;\        # Negate, override “;” and swap.
  {!}1*!0     # Negate twice and push 0.


Code golf: Solve a Knights and Knaves logic problem by parsing English Background

There are two people, Bill and John. One of them is a knight, which always tells the truth, and the other is a knave, which always tells a lie. You don't know who is the knight and who is the knave. Each person then says several statements about who is the knave and who is the knight. Using this information, you must come to a conclusion as to who is the knight and who is the knave.

The Knights and Knaves logic problem is based on Booleen algebra. The words that a person says form a Booleen satisfiability problem. The knave's statements must always be false and the other knight's statements must always be true.

John says "Both I am a knave and Bill is a knave". If John were the knight, then this statement would be false, so he can't be the knight. If he were the knave and Bill were the knight, this statement would still be false, even thought the first part is true. So, John is the knave.

The Challenge

Your challenge is to write the shortest program possible that will take a list of statements made by each person and will figure out who is the knave and who is the knight. There are a lot of details to cover, so this problem is described in three sections.

Input

Input will be two lines followed by a newline. Each line will give the name of one of the characters, followed by a colon, followed by several sentences said by that person. If one person is the knight, then all of his sentences will be true, and all of the knave's sentences will be false. The first letter of a sentence will always be capitalized, and every sentence will end with a period. Here is an example:

Joe: Both I am a knight and neither Steve is a knave nor I am a knave.
Steve: Joe is a knave. Either Joe is a knight or I am a knight.

Parsing

Each sentence consists of at least one clause. Each clause contains one of several things (hopefully you can understand my notation):

both [clause] and [clause]
either [clause] or [clause]
neither [clause] nor [clause]
[I am | (other person's name) is] a [knight | knave]

This is unambigious becuase it can be understood in a way similar to Polish notation. Here is an example of a sentence:

Both I am a knight and neither Steve is a knave nor I am a knave.

The translation into Booleen algebra is straightforward. The "both" statements are ANDs, the "either" statements are XORs, and the "neither" statements are NORs.

(I am a knight) AND ((Steve is a knave) NOR (I am a knave))

Output

Output will consist of two lines. Each line consists of a person's name (in order) and then says whether he is the knight or the knave. There will always be one knight and one knave. Here is the output for the above example:

Joe is the knave.
Steve is the knight.

If the problem is unsolvable (either you can't tell who is what, or there is no solution), then your program can do anything EXCEPT produce a valid output.

More examples

Input

Sir Lancelot: Either both I am a knight and Merlin is a knave or both I am a knave and Merlin is a knight.
Merlin: Either both I am a knight and Sir Lancelot is a knight or both I am a knave and Sir Lancelot is a knave.

Output

Sir Lancelot is the knight.
Merlin is the knave.

Input

David: Neither I am a knave nor Patrick is a knight. Either I am a knight or Patrick is a knave.
Patrick: Either I am a knight or both I am a knight and David is a knight.

Output

David is the knave.
Patrick is the knight.

Input

Lizard: I am a knight.
Spock: I am a knave.

One possible output

Rock Paper Scissors

Rules, Regulations and Notes

Standard code golf rules apply
Your program must be only made up of printable ASCII
All input and output will be from STDIN and STDOUT

Python, 491 chars

Works by converting each line to a Python expression, and eveluating it.
The knave and knight are evaluated as 0 and 1. For the two people, we try both options.
For example, Joe: Steve is a knave becomes Joe==(Steve==knave). This way, if Joe is a knave, the result is true only if he's lying.
You get ugly errors when it's impossible or undecided. If impossible, r[0] is an index error, because r is empty. If undecidable, concatenating r[1:] to a list of strings causes trouble.

import sys
def p():
    a=s.pop(0)
    try:return{"both":"(%s*%s)","either":"(%s|%s)","neither":"(1-(%s|%s))"}[a.lower()]%(p(),p())
    except KeyError:r=s[2];del s[:4];return"(%s==%s)"%((a,m)[a=="I"],r)
x=[];w=[]
for l in sys.stdin:
    m,l=l.split(":");w+=[m]
    for s in l.split("."):
        s=s.split()
        while s:x+=["%s==%s"%(m,p())]
k=("knave","knight")
r=[a for a in[{w[0]:z,w[1]:1-z}for z in(0,1)]if all(eval(l,{k[0]:0,k[1]:1},a)for l in x)]
print"\n".join(x+" is the "+k[r[0][x]]+"."for x in w+r[1:])


Intersection Point of Two Line Segments Given two line segments, determine if the line segments intersect and if so, where. In the case that the two given line segments are co-linear and overlap, determine the midpoint of the overlapping segment. Lines will be specified in pairs of (x, y) coordinates.

Examples

[(-1, -1), (1, 1)], [(-1, 1), (1, -1)] => (0, 0)
[(-1, -1), (1, -1)], [(-1, 1), (1, 1)] => No intersection
[(-2, 0), (1, 1.32)], [(-1, 0.44), (2, 1.76)] => (0, 0.88)
[(-2, -2), (0, 0)], [(1, -1), (1, 1)] => No intersection

Rules

Standard rules and loopholes apply
Input and output may be in any convenient format. Please state your convention along with your solution.

Examples for output conventions would be null for no intersection and a point for an intersection; a boolean and a tuple; string output in (x, y) format or "no intersection"; x and y will be NaN for no intersection. Other conventions are allowed, but these may give you a good starting point.

A minimum of 2 decimal places (or equivalent) precision is required.
Final results should be accurate to within 0.01 when at a scale of -100 - +100. (32-bit floats will be more than accurate enough for this purpose)
This is code-golf, so shortest code wins.

Related: This is not a duplicate of 2D Collision Detection because it only concerns line-line tests and requires an intersection point for intersecting line segments. This is also not a duplicate of Intersection of Two Lines because this concerns line segments specified with two endpoints rather than functions.

R, 95 bytes

function(m,a=c(1,3),r=range){plot(0,,"n",r(m[a,]),r(m[-a,]));segments(m[1,],m[2,],m[3,],m[4,])}

Try it online!

Here's a graphical solution as an appetizer while I'm working on a full-blown solution.
TIO link will not plot anything.


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

Iɴꜱᴘɪʀᴇᴅ ʙʏ @ConorO'Brien's ᴜꜱᴇʀɴᴀᴍᴇ.

Aʟꜱᴏ ᴛʜᴀɴᴋꜱ ᴛᴏ @Dᴏᴏʀᴋɴᴏʙ ꜰᴏʀ ꜱʜᴏᴡɪɴɢ ᴍᴇ ᴛʜᴇ ᴇxɪꜱᴛᴇɴᴄᴇ ᴏꜰ ǫ ᴀɴᴅ x.

Sᴍᴀʟʟ Cᴀᴘꜱ ᴀʀᴇ ᴘʀᴇᴛᴛʏ ᴄᴏᴏʟ. Tʜᴇʏ ᴀʀᴇ ᴜɴɪᴄᴏᴅᴇ ᴄʜᴀʀᴀᴄᴛᴇʀꜱ ᴛʜᴀᴛ ʀᴇᴘʟᴀᴄᴇ ꜱᴍᴀʟʟ ʟᴇᴛᴛᴇʀꜱ. Tʜᴇʏ ʟᴏᴏᴋ ᴊᴜꜱᴛ ʟɪᴋᴇ ᴛʜᴇ ᴄᴀᴘɪᴛᴀʟ ᴏɴᴇꜱ, ʙᴜᴛ ꜱᴍᴀʟʟᴇʀ, ᴀɴᴅ ʟᴏᴏᴋ ʀᴇᴀʟʟʏ ᴏꜰꜰɪᴄɪᴀʟ. Yᴏᴜʀ ᴛᴀꜱᴋ ɪꜱ ᴛᴏ ᴡʀɪᴛᴇ ᴀ ᴘʀᴏɢʀᴀᴍ ᴛʜᴀᴛ ᴄᴏɴᴠᴇʀᴛꜱ ʀᴇɢᴜʟᴀʀ ᴛᴇxᴛ ɪɴᴛᴏ ꜱᴍᴀʟʟ ᴄᴀᴘꜱ.

Hᴇʀᴇ ɪꜱ ᴀ ʟɪꜱᴛ ᴏꜰ ᴛʜᴇ ᴜɴɪᴄᴏᴅᴇ ᴄʜᴀʀᴀᴄᴛᴇʀꜱ ꜰᴏʀ ꜱᴍᴀʟʟ ᴄᴀᴘꜱ:

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

Cʟᴀʀɪꜰɪᴄᴀᴛɪᴏɴꜱ

Rᴇɢᴜʟᴀʀ ᴄᴀᴘꜱ ʀᴇᴍᴀɪɴ ʀᴇɢᴜʟᴀʀ ᴄᴀᴘꜱ ᴀɴᴅ ꜱᴏ ᴅᴏ ᴘᴜɴᴄᴛᴜᴀᴛɪᴏɴꜱ, ꜱᴘᴀᴄᴇꜱ, ᴇᴛᴄ.
Iɴᴘᴜᴛ ᴄᴀɴ ʙᴇ ᴍᴜʟᴛɪᴘʟᴇ ʟɪɴᴇꜱ.
Tʜɪꜱ ɪꜱ code-golf, ꜱᴏ ꜱʜᴏʀᴛᴇꜱᴛ ᴄᴏᴅᴇ ɪɴ ʙʏᴛᴇꜱ ᴡɪɴꜱ!

Tᴇꜱᴛ Cᴀꜱᴇꜱ

Hello World -> Hᴇʟʟᴏ Wᴏʀʟᴅ

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

Welcome to Programming Puzzles and Code Golf Stackexchange!
It is a website ->
Wᴇʟᴄᴏᴍᴇ ᴛᴏ Pʀᴏɢʀᴀᴍᴍɪɴɢ Pᴜᴢᴢʟᴇꜱ ᴀɴᴅ Cᴏᴅᴇ Gᴏʟꜰ Sᴛᴀᴄᴋᴇxᴄʜᴀɴɢᴇ!
Iᴛ ɪꜱ ᴀ ᴡᴇʙꜱɪᴛᴇ.

Retina, 73 bytes

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

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

Try it online.


Compute all close strings quickly Input
A string S of length between 10 and 16 inclusive. The characters are taken from the 95 printable ASCII characters, byte values 32 (0x20) to 126 (0x7E) (  to ~)
Output
Your code must compute and output all strings within Levenshtein distance 2 of S. You can have duplicates as long as you also have all the different strings and the output can be in any order.
Scoring
I will generate a set of 5 strings of random lengths between 10 and 16, each consisting of a selection of printable ASCII characters. Each answer will be tested on the same set of strings, and your score is the total runtime over all 5, when run on my computer (spec details below). This means you need to give me simple and complete instructions on how to compile and run your code in Linux.
Example
Input string obenquillo. Using my test code the first output string is 8benquifllo and the last is o^be9quillo.  There are 1871386 different strings in the output.
My PC
I have an AMD Ryzen 5 3400G running Ubuntu 20.04.
Winning
The fastest code wins.
League table

My test Python code. 14.00s
C++ by the default. 0.15s. Bounty awarded.
C by ngn. 0.07s
Python by ReedsShorts sped up by ovs. 10.5s
Rust by wizzwizz4 . 2.45s

C

cat >a.c <<.
#define _(a...) {return({a;});}
#define F(i,x,n,a...) for(I i=(x),n_=(n);i<n_;i++){a;}
#define i(a...) F(i,0,a)
#define j(a...) F(j,0,a)
#define k(a...) F(k,0,a)
#define I(a...) F(i,a)
#define S static
#define O const
#define mc __builtin_memcpy
#define sl __builtin_strlen
typedef void V;typedef char C;typedef int I;

#include<sys/syscall.h>
#define M1(x) #x
#define M2(x) M1(x)
#define h(x,a...) ".globl "#x";"#x":"a"mov $"M2(SYS_##x)",%rax;syscall;ret;"
asm(".globl _start;_start:pop %rdi;mov %rsp,%rsi;call main;"h(write)h(exit));I write(I,C*,I);V exit(I);
V*memcpy(V*x,O V*y,I n)_(C*a=x;O C*b=y;i(n,a[i]=b[i])a)I strlen(O C*s)_(I r=0;while(*s++)r++;r)

S O C A0=32,A1=126+1,AN=A1-A0;S C o0[1<<20],*o=o0;
S V rpt(C*a,I n,I m){m*=n;while(2*n<m){mc(a+n,a,n);n+=n;}mc(a+n,a,m-n);}
S I fd(C*s,I n,I p)_(i(p,j(n,*o++=s[j+(i<=j)]))p)
S I fc(C*s,I n,I p)_(mc(o,s,n+1);rpt(o,n+1,p*AN);I(A0,A1,j(p,o[j]=i;o+=n+1))p)
S I fi(C*s,I n,I p)_(p++;i(p,j(n+2,o[i*(n+2)+j]=s[j-(i<j)]))rpt(o,p*(n+2),AN);I(A0,A1,j(p,o[j]=i;o+=n+2))p)
I main(I c,C**v)_(S C s[32];I n=sl(v[1]);mc(s,v[1],n);s[n]=10;S typeof(fd)*f[]={fd,fc,fi};
 i(3,o=o0;I g=f[i](s,n,n);j(g*(i?AN:1),C*b=o;k(3,f[k](o0+(n+i)*j,n+i-1,j%g))write(1,b,o-b);o=b))
 exit(0);0)
.
clang -O3 -march=native -nostdlib -ffreestanding a.c && strip a.out -R .comment
time ./a.out abcdefghijklmnop >/dev/null

Try it online!
for the record, here's why this answer didn't win the bounty: https://chat.stackexchange.com/transcript/message/56646474#56646474


Coding Convention Conversion In that Coding Golf, you should convert one coding convention with TitleCase to lower_case_with_underscores. And... vice versa!
Specification
Change the casing in a following way:

If underscore character is a delimiter, change the casing to Title Case without any of delimiter.
If there are multiple words with no delimiter, change the casing to lower case and add an underscore character as a delimiter.
In case of only one word (or one character): change the casing to Title Case if the word starts with lower case; change the casing to lower case if the word starts with the upper case.

Allowed characters:

A to Z
a to z
underscore (_).

Input with mixed cased words are disallowed. Examples of disallowed cases:

Coding_Convention_Conversion
a_BC

Example Cases
Input                        | Expected Output
===========================================================
CodingConventionConversion   | coding_convention_conversion
coding_convention_conversion | CodingConventionConversion
abc                          | Abc
Abc                          | abc
ABC                          | a_b_c
a_b_c                        | ABC
a                            | A
A                            | a

Rules

It is allowed to use ToUpper, ToLower and ToTitleCase functions.
Using regular expressions is allowed.
code-golf: shortest code in bytes wins!

Jolf, 35 bytes

Saves 1 byte thanks to @Cᴏɴᴏʀ O'Bʀɪᴇɴ. This is encoded in ISO 8859-7.

? hI'_ΜGI'_dpyH0pxRGIL0"(?=[A-Z])'_

Woohoo my first Jolf program!

Explanation

   // I = input
? hI'_                              // If input contains _
       GI'_                          // Split on _
      Μ    d                         // Loop, then join
            pyH0                     // Make the first character uppercase
                                    // ELSE...
                  RGIL0"(?=[A-Z])    // Split *after* all uppercase chars
                                 '_  // join with _
                px                   //Make lowercase

Try it online


Draw An ASCII Double Helix Write a program that takes in an integer N via stdin or the command line.

If N is 0, the single letter O must be printed to stdout.

If N is positive, this horizontal ASCII art double helix, drawn N segments wide, must be printed.

If N is 1, the output is:

 /\
O  O
 \/

If N is 2, the output is:

 /\ /\
O  /  O
 \/ \/

If N is 3, the output is:

 /\ /\ /\
O  /  /  O
 \/ \/ \/

If N is 4, the output is:

 /\ /\ /\ /\
O  /  /  /  O
 \/ \/ \/ \/

The pattern continues in the exact same way for larger N. Note that forward slash (/) must be used in all places the helixes cross, except for the O ends.

If N is negative, this vertical ASCII art double helix, drawn -N segments tall, must be printed.

If N is -1, the output is:

 O
/ \
\ /
 O

If N is -2, the output is:

 O
/ \
\ /
 \
/ \
\ /
 O

If N is -3, the output is:

 O
/ \
\ /
 \
/ \
\ /
 \
/ \
\ /
 O

If N is -4, the output is:

 O
/ \
\ /
 \
/ \
\ /
 \
/ \
\ /
 \
/ \
\ /
 O

The pattern continues in the exact same way for smaller N. Note that backward slashes (\) must be used in all places the helixes cross, except for the O ends.

Details

Instead of a program, you may write a function that takes N as an integer and prints the result normally or returns it as a string.
The output for any N may optionally contain a trailing newline.
Any line of output for any N may optionally contain 4 or fewer trailing spaces.
There should never be any leading space that aren't part of the specified pattern.
The shortest code in bytes wins.

CJam, 56 55 53 52 50 bytes
S'O:Ori:X0>"\/"=" / \\\ / "+Xz*1>O]s3/X"z"<~N*X\O?

Look at that size! The main culprits are N = 0 special case and the \ instead of / in the vertical helix.
Here is how it works:
S'O:O                                  e# Put a space on stack. Now put char O on stack
                                       e# and assign it to variable O. This is not really
                                       e# helping in golfing as using 'O everywhere is
                                       e# same number of bytes
     ri:X                              e# Read input as in integer and store it in X
         0>"\/"=                       e# If X is greater than 0, choose /, otherwise \
                " / \\\ / "            e# Put this string on stack
                           +           e# Append to chosen \ or /
                            Xz*        e# Repeat it abs(X) times
1>                                     e# Remove the first character from repeated string
  O]                                   e# Put char O on stack, wrap everything in an array
                                       e# and convert it to string.
    3/                                 e# Split the string into parts of length 3
      X"z"<~                           e# If X is positive, transpose the array to get a
                                       e# horizontal helix, otherwise it would be vertical
            N*                         e# Join the parts with newline
              X\O?                     e# If X was 0, then pick char O instead of this
                                       e# final joined string.

The code is divided into three parts:

The part X0>"\/"=" / \\\ / "+ gives either "/ / \\\ / " or "\ / \\\ / " which is crucial as the helix is simply made up of alternate "/ \" and "\ /" joined by either " / " or " \ ". For instance, if you consider input to be 2, then your final repeated string would be "/ / \\ / / / \\ / " (without escaping). This obviously has extra /  at the beginning and an extra space at the ending.
Second part is to correct the above string with additional things and split. For an input 2, the desired final string without newlines would be " O / \\\ / / / \\\ / O", but after the above point, we only have "/ / \\\ / / / \\\ / ". So we remove the first character, add a space and 'O at the beginning and another 'O at the end. Then we finally split it into parts of 3
Finally, we decide whether to transpose this split string for a vertical helix or not; Join the parts by newlines; And choose between this and a single character 'O (for input 0 case)

Try it online here


Break some standards! Everyone knows the phrase "Rules are made to be broken!", so here is your task:

Write some code in any language that breaks a standard. This can be anything, from putting
240 volts down a USB cable, to pinging your router (NOT somebody else's website!) with a 10mb packet! (Don't get any ideas, both of these will probably cause all sorts of doom!)

The most upvoted answer after 10 days (i.e the most serious violation) will win!

Rules:

The code must be explained.
The standard that you are breaking must be linked to, and you must explain what you are doing (implies 1) to break it. Otherwise answers will not be accepted.
Answers that just crash the interpreter, or make it stop working will not be accepted. I would like some creative answers, not just pasting something like  into IDLE (which crashes it)
Exploiting bugs are not allowed, unless they break a standard. Otherwise answers will not be accepted

Begin, and have fun!

Python

print 'Hello World'

Explanation:

The standard of the Programming Puzzles & Code Golf Stack Exchange is to

  Read the question carefully. What, specifically, is the question asking for? Make sure your answer provides that

This code is not answering the question, so it breaks the standard.


Use 16 colors while writing Hey! 4 times i.e each byte appears in a different ANSI shell colour.
Rules

Resetting the color of the shell after output is not required
Must be output in STDOUT or the primary colour text output of your language.
Must be done programmatically (iterating through each color and letter of the string induvidually) instead of just writing a fixed string to shell like the reference command.
Must output the same as the reference command:
echo -e '\e[30mH\e[31me\e[32my\e[33m!\e[34mH\e[35me\e[36my\e[37m!\e[90mH\e[91me\e[92my\e[93m!\e[94mH\e[95me\e[96my\e[97m!'
on a recent version of bash (I am using 4.3 installed via Homebrew on OS X) i.e like this:

Obviously colours will vary based on terminal colour scheme.

Scoring
This is code-golf, so lowest bytes wins.

Bash, 62

h=y!He
for i in {3,9}{0..7};do printf \\e[${i}m${h:i%4:1};done

Must be run from an actual script file.  If you want to try it from the command line, you'll need to escape the !, i.e. h=y\!He
Online.


Program your favorite phrase Pick a quote or phrase that is exactly 5 words long, such as Programming puzzles and code golf!.
Write a program that, when appended to itself n times, outputs the first n + 1 words of your phrase in order.
For example, if your program code was MYPROG and your phrase was Programming puzzles and code golf!, running...

MYPROG should output Programming
MYPROGMYPROG should output Programming puzzles
MYPROGMYPROGMYPROG should output Programming puzzles and
MYPROGMYPROGMYPROGMYPROG should output Programming puzzles and code
MYPROGMYPROGMYPROGMYPROGMYPROG should output Programming puzzles and code golf!

Appending more than 4 times is undefined, your program may do anything.
Rules

Your phrase must be grammatical meaningful English. Ideally it should be properly capitalized and punctuated.
Your phrase may be any length but its entropy, as calculated by http://www.shannonentropy.netmark.pl/, may not be less than 3.5.
(Paste in your phrase, hit Calculate and look for the last H(X).)
Your phrase can only contain printable ASCII characters (hex 20 to 7E). Your code can only contain printable ASCII and tabs and newlines.
Your phrase must contain exactly 5 unique words and 4 spaces. All non-spaces count as parts of words. Spaces are the word boundaries. They may not be leading or trailing; there should be one after all but the last word.
The output should contain one space between words as well. The output at each appending step may contain trailing spaces but not leading spaces.
Output to stdout. There is no input.

Scoring
Your score is the length in bytes of your initial un-appended program. (e.g. MYPROG scores 6)
As this is code-golf, the lowest score wins.

Piet (honorary answer)

Snakes its way downwards, running out the right through blue and re-entering through green. Prints out "Fruit flies like a banana."

I used PietCreator to make this, but you can try it out here. Remaking Piet programs is a pain, so I started out at 35x35 and continued that way, meaning that I used a lot more codels than I needed.

Actual size versions


Rosetta Stone Challenge: Draw a Box Plot The goal of a Rosetta Stone Challenge is to write solutions in as many languages as possible. Show off your programming multilingualism!

The Challenge

Your challenge is to implement a program that will input a list of numbers and output a box plot of the data, in as many programming languages as possible.  The box plot will display the quartiles and outliers in the data, and it will even have a scale.  You are allowed to use any sort of standard library function that your language has, since this is mostly a language showcase.

What is a "box plot?"

A box plot is a way of graphing data.  A box plot has a few essential features.  The first feature is a box, with either side being located at the first and third quartiles of the data.  There is a line down the center of the box plot that gives the median.  On either end of the box plot, there are "whiskers" that help show the variance of the data.  The whisker extends from the box to the least and greatest points in the data set, excluding the outliers. The outliers are plotted as individual points.

First, take the median of the data.  Then, take all of the data points that are strictly less than the median, and compute the median of this set to become the first quartile (Q1).  Take all of the data points that are strictly greater than the median, and compute the median of this set to become the third quartile (Q3). Find the value of R = 1.5*(Q3 - Q1). Any numbers less Q1 - R this are outliers. Any numbers greater than Q3 + R are outliers.  Take the set of all data points that are not outliers, and the minimum and maximum of this set determines the ends of the two whiskers.

Input

Input will begin with n= followed by a number.  There will then be n numbers, one per line.  All of the numbers will be integers from 0 to 63, inclusive.

n=8
29
1
22
18
12
16
16
22

Output

Output will be a rendition of the box plot.  One possible way to draw the plot is by rendering it in ASCII.  You can render the box plot in many ways other than ASCII, but the main requirement is that drawn large enough so that it is possible to tell the exact locations of the important features.  The box plot should have a scale, consisting of around 5-10 numbers equally spaced.  Here is one example plot of the above data:

              +--+----+
              |  |    |
 X          +-+  |    +------+
              |  |    |
              +--+----+

0    0    1    1    2    2    3
0    5    0    5    0    5    0

The Objective Winning Criterion

As for an objective winning criterion, here it is: Each language is a separate competition as to who can write the shortest entry, but the overall winner would be the person who wins the most of these sub-competitions. This means that a person who answers in many uncommon languages can gain an advantage. Code-golf is mostly a tiebreaker for when there is more than one solution in a language: the person with the shortest program gets credit for that language.

Rules, Restrictions, and Notes

Your program can be written in any language that existed prior to April 11th, 2013. I will also have to rely on the community to validate some responses written in some of the more uncommon/esoteric languages, since I am unlikely to be able to test them.

Current Leaderboard

This section will be periodically updated to show the number of languages and who is leading in each.

Julia (604) - plannapus
Mathematica (71) - chyanog
Python2.X (85) - Abhijit
R (34) - plannapus

Current User Rankings

plannapus - 2
Abhijit - 1
chyanog - 1

R: 34 characters

Of course, R being a language used for statistics, it comes with a function boxplot to do this (which needs a wrapper here to accomodate the input style):

f=function(x)boxplot(scan(x,sk=1))

Usage:
Given a file input1.txt containing the following:

n=10
29
1
22
19
9
13
15
22
63
2

Then f("input1.txt") produces:

Julia: 604 characters

This is my first ever function in Julia, so my apologies to fans of Julia if this is badly written.

function g(f)
a=int(split(readall(open(f)),'\n')[2:])
b,c,d=int(quantile(a,[.25,.5,.75]))
w=1.5*(d-b)
o=a[a.<b-w]
O=a[a.>d+w]
t=int(b-w>0?b-w:0)
u=int(d+w<63?d+w:63)
S=s=""
if !isempty(o)
for i in 1:length(o)
s=s*lpad('x',[0,o][i+1]-[0,o][i]-1,' ')
end
end
if !isempty(O)
for i in 1:length(O)
S=S*lpad('x',[0,O][i+1]-[0,O][i]-u-1,' ')
end
end
x="0"
for i in 9:9:63
x=x*lpad(string(i),i-(i-9)," ")
end
v=isempty(o)?b-1:b-o[length(o)]-1
print(x*"\n"*lpad('+'*'-'^(d-b-1)*'+',d,' ')*'\n'*s*lpad('-'^(b-t-1),v,' ')*'|'*lpad('|',c-b,' ')*' '^(d-c-1)*'|'*'-'^(u-d)*S*'\n'*lpad('+'*'-'^(d-b-1)*'+',d,' '))
end

Usage:

g("input1.txt")
0        9       18       27       36       45       54       63
         +-----------+
---------|      |    |------------------                     x
         +-----------+


Generate Newton fractals You all know the Newton method to approximate the roots of a function, don't you? My goal in this task is to introduce you into an interesting aspect of this algorithm.

Newton's algorithm converges only for certain, but most of all complex input values. If you picture the convergence of  the method for all input values over the complex plane, you usually get a beautiful fractal like this:

 Image from Wikimedia commons

Specifications

The goal of this task is, to generate such fractals. This means, that you get a polynomial as the input and have to print out the corresponding fractal as an image in a format of your choice as the output.

Input

The input is a whitespace-separated list of complex numbers. They are written down in the style <Real part><iImaginary part>, like this number: 5.32i3.05. You may assume, that the input number has no more than 4 decimal places and is smaller than 1000. The first of them must not be zero. For example, this could be an input to your program:

1 -2i7.5 23.0004i-3.8 i12 0 5.1233i0.1

The numbers are interpreted as the coefficients of a polynomial, beginning with the highest power. Throughout the rest of this specification, the input polynomial is called P. The above input is equal to this polynomial:

f(x) = x5 + (-2 + 7.5i)x4 + (23.0004 - 3.8i)x3 + 12ix2 + 5.1233 + 0.1i

The input may come to you either from stdin, from an argument passed to the program or from a prompt displayed to your program. You may assume, that the input does not contain any leading or trailing whitespace characters.

Rendering

You have to render the fractal in the following way:

Choose as many colors as roots of P plus an extra color for divergence
For each number in the visible plane, determine whether the method converges and if yes to which root. Color the point according to the result.
Do not print rulers or other fancy things
Print a black point at the points, that are the polynomials roots for orientation. You may print up to four pixels around each root.
Find a way to choose the visible plane in a way, that all roots are distinguishable and spread widely across it, if possible. Although a perfect placement of the output frame is not required, I reserve the right to refuse to accept an answer that chooses the frame in an unacceptable way, eg. always at the same coordinates, all roots are in one point, etc.
The output image should have a size of 1024*1024 pixels.
Rendering time is 10 minutes maximum
Using single precision floating-point values is enough

Output

The output should be a raster graphics image in a file format of your choice, readable by standard software for a brand X operating system. If you want to use a rare format, consider adding a link to a website where one can download a viewer for it.

Output the file to stdout. If your language does not support putting something to stdout or if you find this option less convenient, find another way. In any way, it must be possible to save the generated image.

Restrictions

No image processing libraries
No fractal generating libraries
The shortest code wins

Extensions

If you like this task, you could try to color the points according to the speed of convergence or some other criteria. I'd like to see some interesting results.

Java, 1093 1058 1099 1077 chars

public class F{double r,i,a,b;F(double R,double I){r=R;i=I;}F a(F c){return
new F(r+c.r,i+c.i);}F m(F c){return new F(r*c.r-i*c.i,r*c.i+i*c.r);}F
r(){a=r*r+i*i;return new F(-r/a,i/a);}double l(F c){a=r-c.r;b=i-c.i;return
Math.sqrt(a*a+b*b);}public static void main(String[]a){int
n=a.length,i=0,j,x,K=1024,r[]=new int[n];String o="P3\n"+K+" "+K+"\n255 ",s[];F z=new
F(0,0),P[]=new F[n],R[]=new F[n],c,d,e,p,q;for(;i<n;)P[i]=new
F((s=a[i++].split("i"))[0].isEmpty()?0:Float.parseFloat(s[0]),s.length==1?0:Float.parseFloat(s[1]));double
B=Math.pow(P[n-1].m(P[0].r()).l(z)/2,1./n),b,S;for(i=1;i<n;){b=Math.pow(P[i].m(P[i-1].r()).l(z),1./i++);B=b>B?b:B;}S=6*B/K;for(x=0;x<K*K;){e=d=c=new
F(x%K*S-3*B,x++/K*S-3*B);for(j=51;j-->1;){p=P[0];q=p.m(new
F(n-1,0));for(i=1;i<n;){if(i<n-1)q=q.m(c).a(P[i].m(new
F(n-1-i,0)));p=p.m(c).a(P[i++]);}c=c.a(d=q.r().m(p));if(d.l(z)<S/2)break;}i=j>0?0:n;for(;i<n;i++){if(R[i]==null)R[i]=c;if(R[i].l(c)<S)break;}i=java.awt.Color.HSBtoRGB(i*1f/n,j<1||e.l(c)<S&&r[i]++<1?0:1,j*.02f);for(j=0;j++<3;){o+=(i&255)+" ";i>>=8;}System.out.println(o);o="";}}}

Input is command-line arguments - e.g. run java F 1 0 0 -1. Output is to stdout in PPM format (ASCII pixmap).

The scale is chosen using the Fujiwara bound on the absolute value of the complex roots of a polynomial; I then multiply that bound by 1.5. I do adjust brightness by convergence rate, so the roots will be in the brightest patches. Therefore it's logical to use white rather than black to mark the approximate locations of the roots (which is costing me 41 chars for something which can't even be done "correctly". If I label all points which converge to within 0.5 pixels of themselves then some roots come out unlabelled; if I label all points which converge to within 0.6 pixels of themselves then some roots come out labelled over more than one pixel; so for each root I label the first point encountered to converge to within 1 pixel of itself).

Image for the example polynomial (converted to png with the GIMP):


Music: what's in this chord? Input

The symbol of any triadic chord (see http://en.wikipedia.org/wiki/Chord_(music)#Triads).

Output

The notes constituting the given chord.

Examples

Input: AM
Output: A C# E

Input: C#m
Output: C# E G#

Input: Db+
Output: C# F A

Input: C0
Output: C D# F#

Bonuses

-50 if you can also deal with seventh chords

-150 for actually playing the sound of the chord

-150 for using printable characters to show how to play the chord on a piano; example for AM:

┌─┬─┬┬─┬─┬─┬─┬┬─┲┱─┬─┬─┲━┱┬─┲━┱─┬─┬┬─┬┬─┬─┐
│ │ ││ │ │ │ ││ ┃┃ │ │ ┃ ┃│ ┃ ┃ │ ││ ││ │ │
│ │ ││ │ │ │ ││ ┃┃ │ │ ┃ ┃│ ┃ ┃ │ ││ ││ │ │
│ │ ││ │ │ │ ││ ┃┃ │ │ ┃ ┃│ ┃ ┃ │ ││ ││ │ │
│ └┬┘└┬┘ │ └┬┘└┲┛┗┱┘ │ ┗┯┛└┲┛ ┃ └┬┘└┬┘└┬┘ │
│  │  │  │  │  ┃  ┃  │  │  ┃  ┃  │  │  │  │
└──┴──┴──┴──┴──┺━━┹──┴──┴──┺━━┹──┴──┴──┴──┘

-100 for using printable characters to show how to play the chord on a guitar; example for AM:

x   o   o   o   o   o
┌───┬───┬───┬───┬───┐
│   │   │   │   │   │
├───┼───┼───┼───┼───┤
│   │   │   │   │   │
├───┼───┼───┼───┼───┤
│   │   █   █   █   │
├───┼───┼───┼───┼───┤
│   │   │   │   │   │

(see https://en.wikipedia.org/wiki/Box-drawing_character)

Rules

The result must be a command-line program or script.
The input and output can be in any form, as long as it follows a music notation standard.
A guitar or piano representation is considered valid if and only if it contains the three (triadic) or four (seventh) required notes and nothing else. The same note can be present several times in the chord.
External libraries are not allowed, except for sound generation (in which case the #include, import... directives are not added to the character count).
This is code golf, the shortest code wins!

A little bit of music theory...

In modern Western tonal music, every octave is made of twelve successive notes, often noted:

A A# B C C# D D# E F F# G G#

Or:

La La# Si Do Do# Re Re# Mi Fa Fa# Sol Sol#

In this system, we consider that two successive notes (e.g. A and A#, or E and F) are separated by one semitone. Also, the notes are kind of "looping": what immediately follows G# is A.

A chord is constituted by a few (2, 3, 4, sometimes more) notes that "sound good together". For instance, triadic chords contain three different notes, and seventh chords contain four different notes.

Let's define the four triadic chords as:

Major triad: contains the root of the chord (in this question, the note given as input), the major third for the root (4 semitones higher than the root), and the perfect fifth for the root (7 semitones higher than the root); this can be symbolized 0-4-7
Minor triad, symbolized 0-3-7
Augmented triad, symbolized 0-4-8
Diminished triad, symbolized 0-3-6

So for example, if you want to make a C major triad, noted C, CM, Cmaj, you will need three noted:

0: the root, in this case a C
4: the minor third, 4 semitones higher than the root; that's an E
7: the perfect fifth, 7 semitones higher than the root: a G

This is what the 0-4-7, 0-3-7, 0-4-8 and 0-3-6 notations used above mean! For the seventh chords, use the following pattern:

That's it for today! Now, amaze me with amazing code... If you have any question, add some comments below.

As you can tell, I didn't try to golf this at all. I'm a music geek, and a pet peeve of mine is when people write things using the wrong enharmonics (e.g. saying that a C diminished chord is C D# F# instead of C Eb Gb), so I wrote this program that gets the enharmonics right. It does so by representing each note as the number of perfect fifths above F.

For what it's worth, if you want to distinguish enharmonics, any musical interval can be represented nicely in a computer program as a number of perfect fifths and a number of octaves. An augmented fourth, for example, is 6 perfect fifths and -3 octaves, and a diminished fifth is -6 perfect fifths and 4 octaves.

Haskell, 441 characters

import Data.List

notes = "FCGDAEB"

fromNum x = [notes !! (mod x 7)] ++ if x < 0 then replicate (-(div x 7)) 'b' else replicate (div x 7) '#'

toNum (x:xs) = y + 7 * if isPrefixOf "b" xs then -length xs else length xs
    where Just y = elemIndex x notes

chord xs = unwords . map (fromNum . \x -> toNum (init xs) + x) $ case last xs of 'A' -> [0,4,8]; 'M' -> [0,4,1]; 'm' -> [0,-3,1]; 'd' -> [0,-3,-6]

main = getLine >>= putStrLn . chord

Some example invocations:

jaspers:junk tswett$ ./chord
AM
A C# E
jaspers:junk tswett$ ./chord
C#m
C# E G#
jaspers:junk tswett$ ./chord
DbA
Db F A
jaspers:junk tswett$ ./chord
Cd
C Eb Gb
jaspers:junk tswett$ ./chord
A#M
A# C## E#
jaspers:junk tswett$ ./chord
Dbm
Db Fb Ab


Topple some dominoes! Thanks to this question for some inspiration

In this challenge we will represent a line of dominoes as a string of |, / and \.  You will be given a string of dominoes as input and you must determine what they look like when they have settled.  Here are the rules for how dominoes fall over

A standing domino, |, left of a left fallen domino, \, will become a left fallen domino as well.
A standing domino, |, right of a right fallen domino, /, will become a right fallen domino as well.
If a standing domino is between a left fallen \ and a right fallen / domino, it will remain standing.

These rules are applied repeatedly until the arrangement no longer changes.

Here is an example of how a single input might arrive at its conclusion

|||||||\/|||||||\||\|||/||||||\|||||

||||||\\//|||||\\|\\|||//||||\\|||||
|||||\\\///|||\\\\\\|||///||\\\|||||
||||\\\\////|\\\\\\\|||////\\\\|||||
|||\\\\\////|\\\\\\\|||////\\\\|||||
||\\\\\\////|\\\\\\\|||////\\\\|||||
|\\\\\\\////|\\\\\\\|||////\\\\|||||

\\\\\\\\////|\\\\\\\|||////\\\\|||||

Your task is to write code that finds and outputs the end result of a input.  You may assume that the input is always valid and contains at least 2 characters.

This is code-golf so answers will be scored in bytes with fewer bytes being better.

Test cases

|||/||||  -> |||/////
|||\||||  -> \\\\||||
|/||||\|  -> |///\\\|
||/|||\|  -> ||//|\\|
||\|||/|  -> \\\|||//

Retina, 32 bytes

+`(/.\\)|(/)\||\|(\\)
$1$2$2$3$3

Try it online!

Explanation

The + tells Retina to run the replacement in a loop until it fails to change the string. Each replacement computes one step the falling dominoes. The replacement itself is really three replacements in one, but this ensures that they happen simultaneously:

(/.\\)...
$1

This just matches /|\ (as well as /\\ and /\\, but those don't matter) and reinserts it unchanged. The purpose of this is to skip over | with fallen dominoes on both sides, because this is shorter than ruling out those cases with separate lookarounds in the other two cases.

...(/)\|...
$2$2

This matches /| and turns it into //.

...\|(\\)
$3$3

This matches |\ and turns it into \\.


A penny saved is a penny ...counted!
You will pass your program a variable which represents a quantity of money in dollars and/or cents and an array of coin values.  Your challenge is to output the number of possible combinations of the given array of coin values that would add up to the amount passed to the code.  If it is not possible with the coins named, the program should return 0.
Note on American numismatic terminology:

1-cent coin: penny
5-cent coin: nickel
10-cent coin: dime
25-cent coin: quarter (quarter dollar)

Example 1:
Program is passed:
12, [1, 5, 10]

(12 cents)
Output:
4

There are 4 possible ways of combining the coins named to produce 12 cents:

12 pennies
1 nickel and 7 pennies
2 nickels and 2 pennies
1 dime and 2 pennies

Example 2:
Program is passed:
26, [1, 5, 10, 25]

(26 cents)
Output:
13

There are 13 possible ways of combining the coins named to produce 26 cents:

26 pennies
21 pennies and 1 nickel
16 pennies and 2 nickels
11 pennies and 3 nickels
6 pennies and 4 nickels
1 penny and 5 nickels
16 pennies and 1 dime
6 pennies and 2 dimes
11 pennies, 1 dime, and 1 nickel
6 pennies, 1 dime, and 2 nickels
1 penny, 1 dime, and 3 nickels
1 penny, 2 dimes, and 1 nickel
1 quarter and 1 penny

Example 3:
Program is passed:
19, [2, 7, 12]

Output:
2

There are 2 possible ways of combining the coins named to produce 19 cents:

1 12-cent coin and 1 7-cent coin
1 7-cent coin and 6 2-cent coins

Example 4:
Program is passed:
13, [2, 8, 25]

Output:
0

There are no possible ways of combining the coins named to produce 13 cents.

This has been through the Sandbox.  Standard loopholes apply.  This is code golf, so the answer with the fewest bytes wins.

Haskell, 37 34 bytes

s#l@(c:d)|s>=c=(s-c)#l+s#d
s#_=0^s

Usage example: 26 # [1,5,10,25] -> 13.

Simple recursive approach: try both the next number in the list (as long as it is less or equal to the amount) and skip it. If subtracting the number leads to an amount of zero, take a 1 else (or if the list runs out of elements) take a 0. Sum those 1s and 0s.

Edit: @Damien: saved 3 bytes by pointing to a shorter base case for the recursion (which also can be found in @xnors answer).


Name your novel disease Introduction

The current coronavirus disease is officially named COVID-19, from the 3 words corona virus disease, and the year 2019. (Technically it's coronavirus, making 2 words, but whatever...)

Given this example, we can apply this naming convention to name other potential diseases.

Challenge

You will be given 3 words and a year.

Take the first letters of the first 2 words, up to and including the first vowel, and append them together.
Then, append the first letter of the 3rd word.
Finally, append the character -, followed by the last 2 digits of the year.

Thus, corona,virus,disease,2019 -> co + vi + d + - + 19 -> covid-19.

Challenge rules

It is guaranteed that each of the three words have at least one vowel. For the purposes of this challenge, vowels are defined as the letters a, e, i, o, u.
You may assume that words consist only of lowercase letters a-z, or only uppercase letters A-Z if you prefer. Your output may be in either case.
It's guaranteed that the date is exactly four digits.
Input may be specified in any format, as long as there is a delimiter between the words. For example, ['corona', 'virus', 'disease', '2019'], corona,virus,disease,2019, [['corona', 'virus'], 'disease', 2019] and corona virus disease 2019 are all valid inputs.

This is code-golf, so shortest answer wins.

Example test cases

corona,virus,disease,2019 -> covid-19
computer,addiction,syndrome,1970 -> coas-70
code,golf,fun,2020 -> cogof-20
a,ba,ca,1234 -> abac-34
tree,string,create,9000 -> trestric-00
love,time,cholera,1985 -> lotic-85

Python 3, 83 81 bytes

lambda a,b,c,d:g(*a)+g(*b)+c[0]+"-"+d[2:]
g=lambda c,*s:c[:c in"aeiou"]or c+g(*s)

Try it online!

-2 bytes thanks to @JonathanAllan!

Explanation:

g is a recursive function that takes in a splatted string and return the string, truncated after the first vowel.

lambda c,*s gather the splatted string into the first character c and the rest s.
c[:c in"aeiou"] or c+g(*s) evaluates to:

if c is a vowel, then c[:c in"aeiou"] evaluates to c[:1] which is c. Since c is Truthy, it is returned.
if c is not a vowel, then c[:c in"aeiou"] evaluates to c[:0] aka the empty string. The empty string is Falsy, so c+g(*s) (the recursive case) is returned.

Old solution, kept here for sentimental reason

Python 3, 89 bytes

lambda a,b,c,d:g(a)+g(b)+c[0]+"-"+d[2:]
g=lambda s:s[:[x in"aeiou"for x in s].index(1)+1]

Try it online!


Compute height of Bowl Pile Bowl Pile Height

The goal of this puzzle is to compute the height of a stack of bowls.

A bowl is defined to be a radially symmetric device without thickness.
Its silhouette shape is an even polynomial. The stack is described by a list of radii, each associated with an even polynomial, given as input as a list of coefficients (e.g. the list 3.1 4.2 represents the polynomial \$3.1x^2+4.2x^4\$).

The polynomial may have arbitrary degree. For simplicity, the height of the pile is defined as the altitude of the center of the top-most bowl (see plot of Example 3 for an illustration).

Test cases are in the format radius:coeff1 coeff2 ...: each line starts with a float number representing the radius of the bowl, followed by a colon and a space-separated list containing the coefficients for the even powers, starting with power 2 (zero constant part is implied). For example, the line 2.3:3.1 4.2 describes a bowl of radius 2.3 and the shape-polynomial 3.1 * x^2 + 4.2 * x^4.

Example 1

42:3.141

describes a pile of zero height since a single bowl has no height.

Example 2

1:1 2
1.2:5
1:3

describes a pile of height 2.0 (see plot).

Example 3

1:1.0
0.6:0.2
0.6:0.4
1.4:0.2
0.4:0 10

describes a pile of height 0.8 (see green arrow in the plot).

This is code golf, so the shortest code wins.

I have reference code.

Edit:

The reference implementation relies on a library to compute the roots of polynomials.
You may do that as well but you don't need to.
Since the reference implementation is only a (quite good) numerical approximation, I will accept any code which produces correct results within common floating-point tolerances.

The idea counts. I don't care if there are small erros \$<\varepsilon\$.

Another variant of this puzzle is to minimize the height by reordering the bowls. I'm not sure if there's a fast solution (I guess it's NP-hard). If anyone has a better idea (or can prove NP-completeness), please tell me!

Jelly, 54 53 bytes

J×$ÆrAƑƇ«⁹;⁹*€J{ḋ⁸ŻṀ
Œcz€0ḢṂç@I0;ⱮFƲƲ€ṚṁL’R€Ɗ;+Ṁ¥¥ƒ0Ṁ

Try it online!

A monadic link that takes as its argument the list of bowls from top to bottom in the format [[b1_radius, b1_coef1, ...], [b2_radius, b2_coef1, ...]] and returns the y position of the bottom of the top bowl.

Now correctly handles bowls which meet at places other than the minimal radius.

Explanation

Helper link: takes as left argument l the differences in coefficients of the polynomials representing the bowls from 1 upwards, and its right argument r the minimum radius; returns the maximum y value where the two bowls meet

  $                   | Following as a monad:
J                     | - Sequence from 1..<len(l)>
 ×                    | - Multiply (by l)
   Ær                 | Roots of polynomial
     AƑƇ              | Keep only those invariant when passed through absolute function (excludes negative, imaginary and complex numbers)
        «⁹            | Min of these filtered roots and r
          ;⁹          | Concatenate r to the list
            *€        | Each root/radius to the power of:
              J{      | - Sequence from 1..<len(l)>
                ḋ⁸    | Dot product with l
                  Ż   | Prepend zero
                   Ṁ  | Maximum

Main link, takes a bowl pile as its argument and returns y value of base of top bowl

Œc                               | Combinations length 2
  z€0                            | Transpose each using 0 as a filler
               Ʋ€                | For each one, do the following as a monad:
     Ḣ                           | - Take the head (the radii)
      Ṃ                          | - Minimum
       ç@     Ʋ                  | - Call the helper link with this (min radius) as right argument and the following as left argument:
         I                       |   - Increments (difference between second and first polynomial for each coefficient)
          0;Ɱ                    |   - Prepend each with a zero (odd coefficients are all zero)
             F                   |   - Flatten
                 Ṛ               | Reverse
                  ṁ    Ɗ         | Mould to the following as a monad:
                   L             | Length
                    ’            | Decrease by 1
                     R€          | Range of each (e.g. [1],[1,2],[1,2,3],[1,2,3,4]
                            ¥ƒ0  | Reduce using the following as a dyad and starting with 0
                        ;  ¥     | - Concatenate the following as a dyad
                         +       |   - Add
                          Ṁ      |   - Take the maximum
                               Ṁ | Finally take the overall maximum

Python reference

Finally, here’s a TIO version of the Python reference that @pasbi included for the main problem.  It reads from stdin.


Self-growing code codee codeee codeeee Write a program (or function) (let's call it P1), that when run, outputs another program P2 of the same language and exactly 1 byte longer than P1.

Program P2 when run, should output a 3rd program P3 that's 1 byte longer than P2. P3 must output a program P4 that's one byte longer than P3, etc. The same for P5, P6, ..., P∞.

The program chain should go indefinitely, or to a place where the interpreter can't handle anymore (but must remain as a theoretically valid program in the language)

Rules

Standard loopholes forbidden
All programs in the chain should be in one language
No input is given. Output goes to stdout or function return value
The program must end after a period of time. A program that stops generating output after a certain time spot but never terminates does not qualify

The shortest program P1 in bytes in each language wins!

JavaScript (ES6), 14 12 bytes

-2 bytes thanks to @Shaggy

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

Testing snippet

s=`f=_=>"f=_"+f`;

for(i=10;i--;s=eval(s)())
  o.innerText+=s+"\n";


Help me with my chemistry homework! Near the middle of the semester in chemistry, we get problems like:

  Convert 1.283850057 to Scientific Notation

and

  Convert 3.583✕106 to Standard Notation

This is just stupid busy work for people who already know how to do this. So…

The Challenge

Given an input in any reasonable, convenient format, in either standard notation or scientific notation, output the same number in the other notation. However, note that e will not be accepted in place of *10^, as this gives a significant advantage to languages with builtins with e.

If not otherwise specified, standard notation will take this format:

x             (an integer)
xxxxxxxxxx    (a large integer with no more than 10 digits)
x.xxxx        (a float)
x.xxxxxxxxxx  (a float with no more than 10 x's after the decimal point)

While scientific notation will take this format:

x*10^x
x.zzzz*10^z (x will be >= 1)
x*10^-x
x.zz*10^-xx (x will be >= 1)

I/O

Input will never contain more than 10 leading+10 trailing digits, and you may decide how to deal with trailing zeroes after the decimal point. The exponent will never be so large as to max out your language's allowance for large numbers. You should only need to handle up to about 1010.

input => output

---scientific to standard---

4.5*10^7 => 45000000
1*10^0 => 1
8.9*10^-2 => 0.089
1.0001*10^5 => 100010
9.999999*10^9 => 9999999000
4.00038*10^2 => 400.038

---standard to scientific---

7354 = 7.354*10^3
385.43 => 3.8543*10^2
0.32 = 3.2*10^-1
0.00044 => 4.4*10^-4
0.053 => 5.3*10^-2

As always, standard loopholes are disallowed. This is code-golf, so shortest bytes wins!

R, 70 bytes

function(s)sub("e","*10^",format(eval(parse(t=s)),sc=!grepl("\\^",s)))

Try it online!

An anonymous function. Takes input as a string and outputs as a string.

This function evaluates the string eval(parse(t=s)), then formats it, with the flag scientific set to whether the string contains a ^ or not. Then it replaces e with *10^ to match the right output spec.


Panfix to parenthesized infix Quylthulg is a language by Chris Pressey that attempts to solve the problem of infix notation using what it calls panfix:

  like postfix, panfix does not require the deployment of arcane contrivances such as parentheses to override a default operator precedence. At the same time, panfix allows terms to be specified in the same order and manner as infix, an unquestionably natural and intuitive notation to those who have become accustomed to it.

How do you get the convenience of infix notation along with the unambiguity of prefix or postfix? Use all three, of course!

=y=+*3*x*+1+=

More formally, let + be an operator, and a and b be expressions. Then (a+b) is a valid (parenthesized) infix expression, the panfix representation of that expression is +a+b+, where juxtaposition represents concatenation.

Your goal is to take a panfix string and convert it to fully parenthesized infix:

(y=((3*x)+1))

For simplicity, we'll make the following changes:

Operators can only consist of two unique characters (you can choose any, but here I'll use * and +).
There is only one literal, which consists of another distinct character (you can choose any, but here I'll use _).
The input will be a well-formed panfix expression.

For complexity, we'll make the following change:

Operators can consist of any positive number of characters, not just one.

This makes the challenge more tricky because you can't necessarily determine how a given substring of operator characters is partitioned without looking at the rest of the string.

Here is a reference implementation for the challenge, courtesy of @user202729.

Test Cases

format: input -> output
+*+_*+_*+++_+*+_*+_*+++ -> ((_*+_)+(_+(_*+_)))
**++*+***++_+_++_+*++*+***_*++*+*****_**_*_*** -> ((((_+_)+_)*++*+***_)*(_*(_*_)))
***_**_***_* -> ((_**_)*_)
+_+_+ -> (_+_)
*+*+++**+***+++++_*+*+++**+***+++++_*+*+++**+***+++++ -> (_*+*+++**+***+++++_)
*++++*+*_*_*+*+++****+_++****+_++****++*+*+++_*+++ -> (((_*_)+*+(_++****+_))*+++_)
+**+_*+_*+*_*+*_*+*_+*_+**+ -> (((_*+_)*_)+(_*(_+*_)))
+**+++++_+++++_+++++*_*+*+_++++++_+++++_+++++++* -> (((_+++++_)*_)+*(_+(_+++++_)))
+*+*+_+*+_+*+*_*+*_*+*+_+*+_+*+*+ -> (((_+*+_)*_)+(_*(_+*+_)))
**_**_**_*_****_* -> ((_*(_*(_*_)))*_)

I used this program to generate infix strings for this challenge (converting to panfix was trivial, but reversing is not).

Prolog (SWI), 194 163 bytes

Saved a whopping 31 bytes using this tip from 0 '!

[C|T]/O/R:-C\=x,(T/P/R,concat(C,P,O);O=C,R=T).
[x|R]-x-R.
L-X-R:-L/O/A,A-Y-B,B/O/C,C-Z-D,D/O/R,atomics_to_string(['(',Y,O,Z,')'],X).
X^P:-string_chars(X,L),L-P-[].

The operator ^ takes for its left argument a string containing a panfix expression and sets its right argument to a string containing the corresponding parenthesized infix expression. It uses x as the literal in place of _.

Try it online!

Explanation

Since Prolog is a declarative language, we just have to describe the relation between a panfix and a parenthesized expression.

The explanation uses this slightly ungolfed version:

oper([C|T],O,R) :- C\=x, oper(T,P,R), concat(C,P,O).
oper([C|T],C,T).

expr([x|R],x,R).
expr(L,X,R) :- oper(L,O,A), expr(A,Y,B), oper(B,O,C), expr(C,Z,D), oper(D,O,R),
               atomics_to_string(['(',Y,O,Z,')'],X).

parenthesize(X,P) :- string_chars(X,L), expr(L,P,[]).

Our main production is parenthesize, which takes in a panfix expression X as a string and sends out the corresponding parenthesized infix expression P as a string. It uses string_chars to convert the input string into a list of characters and then simply passes it on to expr.

expr takes in a list of characters L, parses the first panfix expression it finds in L, and sends out the parenthesized equivalent X and the remainder of the list of characters R. There are two possible kinds of expressions:

If the first character of L is x, then the expression is x and the remainder is everything after the x.
Otherwise, parse an operator O (see oper below); parse an expression Y; parse O again; parse another expression Z; and parse O a third time. The remainder is everything after the third instance of O. The expression is the result of joining Y, O, and Z, surrounded by parentheses, into a string.

oper takes in a list of characters, where the first character is C and the rest are T; it parses an operator (i.e. a run of one or more operator characters) and sends out the operator O and the remainder of the list of characters R. To form an operator, the character C must be something other than x; also, either

an operator P must be parseable from T, with remainder R; in this case, O is the concatenation of C and P; or,
O is the single character C; in this case, R is just T.

A worked example

Let's take the input +*+x+x++*x+* for an example.

We want to parse an expression from +*+x+x++*x+*. This doesn't start with x, so we parse an operator from the beginning.
oper will parse as big of an operator as possible, so we try +*+.

Next we parse an expression from x+x++*x+*. This has to be x.
Now we try to parse the same operator, +*+, from +x++*x+*. However, this fails.

So we backtrack and try parsing the operator +* instead.

We parse an expression from +x+x++*x+*. This doesn't start with x, so we need to parse an operator.
The only possibility is +.
Now parse a subexpression from x+x++*x+*. This has to be x.
Now parse + again from +x++*x+*.
Now parse another subexpression from x++*x+*. This has to be x.
Finally, parse + again from ++*x+*.
The expression has been successfully parsed. We return the string (x+x).

Back at the previous recursion level, we parse the operator +* again from +*x+*.
Now parse another subexpression from x+*. This has to be x.
Finally, parse +* again from +*.
The expression has been successfully parsed. We return the string ((x+x)+*x).

Since there are no more characters left, we have successfully translated the expression.


HE COMETH NOT - a zalgo challenge Write a program or function that, given a string, will strip it of zalgo, if any exists.

Zalgo

For this post, zalgo is defined as any character from the following Unicode ranges:

Combining Diacritical Marks (0300–036F)
Combining Diacritical Marks Extended (1AB0–1AFF)
Combining Diacritical Marks Supplement (1DC0–1DFF)
Combining Diacritical Marks for Symbols (20D0–20FF)
Combining Half Marks (FE20–FE2F)

https://en.wikipedia.org/wiki/Combining_character#Unicode_ranges

Input

May be passed via command line arguments, STDIN, or any other standard method of input supported by your language
Will be a string that may or may not contain zalgo or other non-ASCII characters

Output

Output should be a string that does not contain any zalgo.

Test Cases

Input -> Output

HE̸͚ͦ ̓C͉Õ̗͕M͙͌͆E̋̃ͥT̠͕͌H̤̯͛ -> HE COMETH
C͉̊od̓e͔͝ ̆G̀̑ͧo͜l͔̯͊f͉͍ -> Code Golf
aaaͧͩa͕̰ȃ̘͕aa̚͢͝aa͗̿͢ -> aaaaaaaaa
ññ        -> ñn
⚡⃤       -> ⚡

Scoring

As this is code-golf, shortest answer in bytes wins.

Retina, 35 bytes

T`̀-ͯ᪰-᫿᷀-᷿⃐-⃿︠-︯

Try it online!

Simply removes all characters in the ranges given in the challenge from the input. The code is super unreadable of course, but the code is conceptually no different from something like T`0-9A-Za-z which would delete all alphanumeric characters.


Linear integer function generator Inspired by a recent challenge involving Fibonacci numbers in which OEIS was mentioned, I would like to present a challenge of creating a function that generates a wide array of different linear integer sequences, depending on user input.
Specifically, the user should provide three inputs:

the kernel (a representation of the recurrence relation). More about this below.
the starting value of every 'seed' needed for the sequence, and
the number of integers to generate and display.

For example, the Fibonacci sequence has two members in the kernel and needs two starting seeds (0, 1). Then \$F(n) = F(n-1) + F(n-2)\$.
The Padovan sequence has three members in its kernel and needs three seeds, (1,0,0). Then \$F(n) = F(n-2) + F(n-3)\$.
I am not going to mandate the format of the 'kernel' input, though the natural form would be, I think, a list of the same length of the list of seeds, composed of integers corresponding to the weight to give to each of integers in the previous row.
This means that the kernel of the Fibonacci sequence, which adds together the previous two numbers, can be represented as (1,1). By contrast, the kernel of the Padovan sequence, which ignores the first member of the previous row and adds the second and third terms, can be represented as (0,1,1).
Your code should be able to handle an arbitrary number of seeds and lists of arbitrary length. For each sequence, the number of members of the kernel and the length of the seed list should be the same positive integer. For the sake of this challenge, assume all members of the kernel and all seed values are integers (though I suspect that most of the responses to this challenge will work for all real numbers). Similarly assume the required sequence length will be a positive integer.
My examples below use (parentheses) to encapsulate lists, but use whatever notation is most natural to your programming language.
Examples!
For the Fibonacci sequence, your function should take three inputs like
(1, 1), (0, 1), 10

(that's kernel, seed, and sequence length), and generate
(0, 1, 1, 2, 3, 5, 8, 13, 21, 34)

For the Padovan sequence, input like
(0, 1, 1), (1, 0, 0), 20

should generate
(1, 0, 0, 1, 0, 1, 1, 1, 2, 2, 3, 4, 5, 7, 9, 12, 16, 21, 28, 37)

The Perrin Sequence takes input like
(0, 1, 1), (3, 0, 2), 10

to produce
(3, 0, 2, 3, 2, 5, 5, 7, 10, 12)

For edge cases,
(1, 1), (0, 0), 5

should produce
(0,0,0,0,0)

and
(-1, 0, 1, 0), (0, -1, 0, 1), 20

should produce
(0, -1, 0, 1, -2, 2, -1, -1, 3, -4, 3, 0, -4, 7, -7, 3, 4, -11, 14, -10).

I suspect there are going to be some extremely concise responses to this.

Kakoune, 62 keystrokes
<a-l>"ndd<a-l>S
"hddQxy<a-p><a-p>_S
a*<c-r>h+<a-;> <backspace><esc><a-h>|bc
k<a-i>ndd<a-j>Q:ex<tab> <c-r>nq
K<a-x>d%<a-s><a-h>w<a-l>d<a-j>

(note the trailing spaces on line 1 and 2)
Assumes the input in the following format, with the cursor at the start of the buffer:
number of items
kernel separated with spaces in reverse
seed separated by spaces

Gives the output as the numbers space separated.
Here is a video of the solution in action, with a few minor human errors :)


Measuring Rectangles Challenge

Your goal is to write a program which will output the 8 measurements of a rectangle, with only some measurements in the input. Your program should throw an error if it cant be done.

Here is what each measurement means:

|          left
|          |      centerX
|          |      |      right
|          |      |      |
|          v      v      v
|           _____________
|       ^  |             |  <---top
|       |  |             |
|       |  |             |
|height |  |             |  <---centerY
|       |  |             |
|       |  |             |
|       v  |_____________|  <---bottom
|
|          <----width---->
|________________________________________

Input/Output Formats:

Input is in the form of some measurements of a box, one on each line. Output should be all 8 measurements of the corresponding box (or an error if the given measurements can not be used to find the other measurements).

For example, an input of

left 6
centerX 10
top 40
height 20

should print out

left 6
right 14
top 40
bottom 20
centerX 10
centerY 30
width 8
height 20

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

Python 2 with SWI Prolog ('typical' install), on Windows, 595 565 bytes.
import sys,subprocess as w;o='left right top bottom centerX centerY width height'
g={k:v for k,v in [l.strip().split() for l in sys.stdin.readlines()]};s='L,R,T,B,C,D,W,H';
open('t','w').write(
":-use_module(library(clpfd)).\nr(%s):-L#=R-2*(R-C),L#=R-W,L#=C-W//2,B#=T-2*(T-D),B#=T-H,B#=D-H//2,%s."%
(s,','.join('writeln(%s)'%x for x in s.split(','))));r='\n'.join([a+' '+b for (
a,b) in zip(o.split(),w.check_output("swipl -q -f t -t r(%s)."%(','.join(g.get(
x,x[0].replace('centerY','d').upper()) for x in o.split()))).split('\r\n'))])
print '!' if '_' in r else r

e.g. with a text file for input, containing:
right 14
centerX 10
top 40
height 20

it does this:
D:\>type rectin.txt|c:\python27\python.exe d:\rect.py
left 6
right 14
top 40
bottom 20
centerX 10
centerY 30
width 8
height 20

And in the error condition if the contents of the stdin file are not enough to calculate the other values, it does this:
D:\>type rectin.txt|c:\python27\python.exe d:\rect.py
!

NB. It relies on swipl.exe being in the PATH
Explanation
I started writing in Python, got bored of expressing all the possible combinations of relationship (each one can be derived from three different combinations). I thought "must be a job for Prolog". So I installed a Prolog, headed for a tutorial, and got something that just about works. It's this:
:-use_module(library(clpfd)).

r(L,R,T,B,C,D,W,H):-
    L#=R-2*(R-C),
    L#=R-W,
    L#=C-W//2,
    B#=T-2*(T-D),
    B#=T-H,
    B#=D-H//2,

    writeln(L),
    writeln(R),
    writeln(T),
    writeln(B),
    writeln(C),
    writeln(D),
    writeln(W),
    writeln(H).

It uses the clpfd library (part of the 'typical install' requirement), which provides 'declarative integer arithmetic'. This gives the big advantage that I only need to define Left in terms of (Right and CenterX), (Right and Width), (CenterX and Width). From that, it can derive Right, Center and Width. (Same with the vertical set Top/Bottom/CenterY/Height).
This also means I don't have to check which specific values are provided; I give all the available values and placeholders for the rest, and it either calculates the answers, or outputs some unknown variable placeholders.
Being extremely novice at Prolog, handling STDIN was too much for me right now, so I wrapped it with Python. I don't have an ungolfed version of the Python, but it's not doing anything too amazing; it reads STDIN into a dictionary of {measurement:value} pairs, then puts them in the preset order the Prolog code is expecting, merged with the uppercase first letter of the unknowns.
(There's an annoyance where all the measurements are unique by first letter, except centerX and centerY, so it replaces centerY with D).
Then it writes the Prolog script out to a file, shells out to Prolog to run it and read the result, parses the number output and pairs them up with the measurements in order.
Then checks if any of the outputs were uncomputable and throws an error (!), otherwise prints the result.