text:
Arithmetic... tock... tick... tock
This question brought to you by a game I like to play when stuck in long phone meetings.
Given any two times from a 24 hour clock (from 00:00 to 23:59), how many valid mathematical equations can be generated with all of the times in between using only basic arithmetic operations?
Input: two four digit strings (no colon) representing valid times in a 24 hours cycle.
Examples:
For input=0000, 1300
03:26 produces: "0+3*2=6" and "03*2=6" etc.
11:10 produces quite a few, including: "1*1=1+0" and "1=1=1^0" and  "1=11^0" etc.
12:24 produces: "1/2=2/4" and "1=(2*2)/4" etc.

Valid operations are:

addition
subtraction
multiplication
division (floating point)
exponentiation
factorial

Other allowable symbols

Parentheses
Equal signs

Shortest code wins.
Notes

The goal is to find the number of valid expressions between two times, not the number of times that contain a valid expression.
The two times given as input are included in the range of times.
You may group the digits in any way possible, so "1223" can be "12 23" or " 1 2 23" or "1 223" etc. etc.
You may use as many parentheses as needed.
You may use more than one = sign. For instance, the time 11:11 has the valid expression 1=1=1=1.
If the first time occurs chronologically after the second time, the range of times should wrap as if crossing into the next day.
The numbers must remain in their original order- you may not re-order the digits.
When clustering numbers, zero's may absolutely be the front most digit, in which case, they are ignored ("0303" clustered as "03 03" is just two digits with the value of 3.)
You MAY NOT use the minus sign as unary negation. Therefore, "12:01" does NOT produce "1-2=-(01)", but DOES produce "1-2=0-1".
You MAY NOT add decimal points to digits. Therefore, "12:05" does NOT produce "1/2=0.5".
No chaining of factorials- a digit may be followed by at most one "!", no more, otherwise, many times would have infinite solutions. Ex: "5!" is valid but "5!!" is not valid.

I changed "expression" to "equation" and some other things. Please tell me if these edits conflict with your intent.

Looks good, thank you very much.

http://apps.getpebble.com/en_US/application/5309427924c4582908000046

It's not stated explicitly but it appears from the examples that reordering the digits is invalid / does not need to be considered. Is this correct? I assume decimal points are not required either, such as 1/2=0.5

"The numbers must remain in their original order." Should answer the first question. And you are correct on the second point, no decimal points. I have edited to make that explicit.

"Valid operations include" seems to prevent you from being able to add test cases. It would be a better question if you changed that to "Valid operations are" and added some test cases. It would also be useful to be precise about the endpoints: for input 0000 1300 should equations derived from 0000 and 1300 be included in the count?

Given digits "1423", do "1+4=2+3", "(1+4)=(2+3)", "(1+4)=2+3" and "1+4=(2+3)" count as one or four equations? And... what are all equations of "0000"? I think of about 100 possibilities, or even more... Could this be?

+1 this is similar to a game my daughter plays :) albeit on a 12 hour clock.

Is there any restriction on the use of unary operators? Absent such a restriction in the rules, factorial can be applied repeatedly and thus a perfect solution may prove impossible.

Michael, that's a great observation. So for the sake of the puzzle, I think I'll limit it to one factorial per "digit", if that makes sense. Therefor, 5! is valid but 5!! is not valid.

You should post some examples with the number of solutions they generate. Your example doesn't have that.

Because the current time only lasts for a minute, you need to write the smallest code possible.

Python3, 363 chars
Since no answer is given till today, I hand in what I got. Sadly, the try/except block is too fat, I didn't found a way to save chars there. It is really tricky with the nested loops there, not all can be done with list comprehensions I think, but maybe someone can tell me how.
However, I restricted the challenge myself to only use basic math '+-*/' and no parentheses.
a,b = input().split()
r=0
for time in [c for c in range(int(a),int(b)) if c/10%10<6]:
 t,*ts='%04d'%time
 e=[t]
 for d in ts:
  e=[(n+o+d,n+d)[o==' '] for o in ' -+*/=' for n in e]
 for h in [g for g in [e.split('=') for e in e if '='in e] if len(g)>1]:
  for k in h:
   try:
    if eval(h[0]) != eval(k):
     break
   except:
    break
  else:
   r+=1
print(r)

My full code (hope something explanatory) on this CodeGolf can be found on my pastebin.


text:
Rise, sequence, rise
We have a strictly increasing sequence of non-negative integers, like:
12 11 10

Wait! This sequence isn't strictly increasing, is it? Well, the numbers are written in different bases. The least possible base is 2, the biggest is 10.
The task is to guess bases each number is written, so that:

the sequence is strictly increasing,
the sum of the bases is maximised.

For instance, the solution for the sample will be:
6 8 10

because under those bases the sequence becomes 8 9 10 decimal - a strictly increasing sequence, and we are not capable of finding bases for which the sequence remains strictly increasing and whose sum is bigger than 6+8+10 .
Due to the second limitation a solution 3 5 7 is not satisfactory: in spite of fact that the sequence becomes 5 6 7 under those bases - we need to maximise the bases sum, and 3+5+7 < 6+8+10.
If under no bases 2<=b<=10 is it possible for the series to be strictly increasing, for instance:
102 10000 10

single
0

should be output.
The input sequence can be passed in the way it's most convenient for your solution (standard input / command line parameters / function arguments...).

Is 1 3 5 a rising sequence? What about 1 7 22? (in base 10)

Yes, 1 3 5 and 1 7 22 are both rising under base 10. So, the solution for both cases is 10 10 10 , because we need to maximize the sum of bases while assuring that the sequence is rising when n-th number is interpreted as being written in base equal to n-th term of solution.

Okay, so a rising sequence does not necessarily have to consist of consecutive numbers.

By rising, do you mean strictly increasing, i.e., that 1 1 1 is not a rising sequence?

@Dennis Yes, I mean strictly increasing sequence. 1 1 1 or 3 3 4 are not rising.

Are the inputs always 3 numbers, or are you just missing examples of other lengths?

@Geobits Inputs of any length are accepted. Just a simple example: for 11 10 10 10 the solution is 6 8 9 10 , and for 10 10 10 10 10 - 6 7 8 9 10 .

Cool, I just wanted to make sure I wasn't missing something where you said it would always be length 3.

Proposed test case: 19 18 17. My answer was failing that one.

If comments indicate that the question is open to misinterpretation, don't just reply in comments. Edit the question so that other people don't waste time writing answers which interpret it differently to you.

And on the subject of ambiguities, one of the comments on my answer claims that we should assume that the numbers are written in canonical form in the given base. If this is so, please correct the phrase "The least possible base is 2" to something like "The least possible base is one greater than the largest digit value".

Pyth, 31 30 29 bytes
e+0f.x!sgM.:iVczdT2ZosN^STlcz

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

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

CJam, 43 bytes
0B,2>ea,m*{:+~}${ea::~_2$.b__Q|$=*@.b=}=p];

Reads command-line arguments and prints an array.
Try it online in the CJam interpreter.
Examples
$ cjam rise.cjam 12 11 10
[6 8 10]
$ cjam rise.cjam 19 18 17
0

How it works
0       e# Push a 0 (default return value).
B,2>    e# Push [0 ... 10] and remove the first two elements.
ea,     e# Push the number of command-line arguments (n).
m*      e# Cartesian power. Pushes all vectors of {2 ... 10}^n.
{:+~}$  e# Sort by the negated sums.
{       e# Find; for each vector V in {2 ... 10}^n:
  ea::~ e#   Evaluate each character of each command-line argument.
  _2$   e#   Copy the results and V.
  .b    e#   Vectorized base conversion (list to integer).
  __    e#   Push two copies.
  Q|$   e#   Deduplicate and sort the last copy.
  =     e#   Compare it to the first. Pushes 1/0 if equal/unequal.
  *     e#   Repeat the original result of .b that many times.
  @.b   e#   Vectorized base conversion (integer to list).
  =     e#   Compare the result to the modified command-line arguments.
        e#   Equality makes sure that the base was greater than all digits.
}=      e# If pushed 1, push V and break.
p       e# Print. Either prints the last V or 0 if none matched.
];      e# Clear the stack to avoid implicitly printing the 0 (if still present).

Julia, 176 156 145 118 109 99 97 bytes
A->try p=NaN;flipud(map(i->(k=11;t=p;while t<=(p=parseint("$i",k-=1))end;k),flipud(A)))catch;0end

Ungolfed:
function anonfunc(i)
  # Start with k=11 so that it evaluates to 10 on first while iteration
  k=11
  # set t to the previous value of p
  # Note: p here gets held over between iterations within the map
  t=p
  # Iterate through, dropping k by 1 and evaluating the integer in
  # base k and stopping if the value drops below t
  # Note: "p=" expression inside conditional to ensure k-=1 is evaluated
  # at least once (to make NaN work as desired)
  while t<=(p=parseint("$i",k-=1))
  end
  # if it dropped below t, return the base, k to be the corresponding
  # element in the map
  return k
end

function f(A)
  # Using try/catch to return 0 if no acceptable base found
  try
    # This is a trick to make sure the comparison in the while loop
    # evaluates to false on the first use of it (last value in A)
    p=NaN
    # Apply anonfunc to each element of A, starting with the last element
    # and store the result in S
    S=map(anonfunc,flipud(A))
    # S is backwards, so flip it and return it
    return flipud(S)
  catch
    # Will throw to here if parseint fails with the base due to having
    # a digit not acceptable in the base
    return 0
  end
end

Used with a 1d array input. If the function is assigned to c, then you would call c([12,11,10]) and it would output [6,8,10].
Note: I had used dec(i) inside the parseint command, but because i is a single-character variable name, and I don't need to access a component, I used "$i" to get the same result.

You've got some good tricks in here. Nice work.

This code seems to check bases for strictly decreasing sequence under usual left-to-right order of reading.

@pawel.boczarski - I'm not sure what you mean, but if you'd like, I can provide some examples of what it outputs for certain inputs. For instance, if you assign the function the name c, then c([12,11,10]) outputs [6,8,10], which are the required bases.

@GlenO Oh, I see. I used row vector [12 11 10] instead of [12,11,10] and that gave the undesired effect.

@pawel.boczarski - ah, I see. Yeah, if you want it to work with row vectors, you'd need to replace "flipud" with "fliplr", in which case it will return a row vector of the bases.

Julia, 259 204 183 bytes
Saved a bunch with help from Glen O.
A->(M(x)=maxabs(digits(x))+1:10;S=[];X={};for i=M(A[1]),j=M(A[2]),k=M(A[3]) s=map(parseint,map(dec,A),[i,j,k]);all(diff(s).>0)&&(S=[S,sum(s)];X=[X,{[i,j,k]}])end;X==[]?0:X[indmax(S)])

Ungolfed + explanation:
function f(A)
    # Define a function to obtain the smallest possible base range
    M(x) = (maxabs(digits(x)) + 1):10

    # Define container arrays for the sums and bases
    S = []
    X = {}

    # Loop over all possible bases for each of the elements
    for i = M(A[1]), j = M(A[2]), k = M(A[3])
        # Parse each element of the input as a string
        # in the given base
        s = map(parseint, map(dec, A), [i,j,k])

        # Push the sum and bases if s is rising
        if all(diff(s) .> 0)
            S = [S, sum(s)]
            X = [X, {[i,j,k]}]
        end
    end

    # If X is empty, return 0, otherwise return the bases
    isempty(X) ? 0 : X[indmax(S)]
end

OK, some golfing to be done... use "repr" instead of "string" in the map command, they'll work the same in this context and save two bytes. And we can save a few more by using an infix operator for parseint by writing "\ =parseint" and then using x[1]\i rather than p(x[1],i) - one more byte in the "\ " part, and then saving three for each use of p for a net saving of 8 bytes. Another one byte saved by replacing "maximum(digits(x)) with max(digits(x)...)"

For a bigger saving, merge the for loops - use for i=M(A[1]):10,j=M(A[2]):10,k=M(A[3]):10 <code here>end;, saving eight for the dropped two end;s and eight for replacing for with ,.

Actually, we can do even better for the parseint part. Drop the renaming of parseint entirely, and use s=map(parseint,x,[i,j,k]), saving 18 bytes relative to your original solution and 10 compared with my previous suggested improvement. And rather than s==sort(unique(s)), use all(diff(s).>0) to save another 3 bytes.

There's certainly more that can be done, but I'll leave it to you, and try to come up with my own approach instead.

Minor correction - I suggested using max(...) rather than maximum... but while it saves one byte, it fails for single-digit input values, so you have to use maximum.

@GlenO Cool, thanks for the suggestions. Honestly I hadn't put much effort into golfing it before but it's much better now.

No problems. Incidentally, I discovered that there's another way to save a byte on "maximum", if you know all values will be non-negative: maxabs.

@GlenO Nice one.

A few more that you can do - initialise X={} rather than X=Any[], replace repr with dec, replace push!(S,sum(s)) with S=[S,sum(s)] and push!(X,[i,j,k]) with X=[X,{[i,j,k]}], and use indmax(S) rather than findmax(S)[2].

Also, using S=[S,sum(s)] rather than push!(S,sum(s)) lets you use S=[] to initialise (no need for "Int").

@GlenO Wow, thanks for all the tips. I also saved a couple bytes by making M return a range rather than an integer.

CJam (39 bytes)
{Afb:X,9,2f+m*{X\.b__$_&=*},{:+}$0\+W=}

This is an anonymous function which takes the input as an array of decimal integers on the stack and leaves the output as an array or the integer 0 on the stack. Online demo.

Also, this seems to sort by the sum of the resulting integers instead of the bases and it has the same problem my previous revision had (19 cannot be a base 9 number).

Hmm. The question seems to need some improvement.

@PeterTaylor Pah, excuses ;)

Python 2 (147 bytes)
def x(s):
 q=int;c=10;o=q(s[-1])+1;l=[]
 for i in map(str,s)[::-1]:
    n=q(i,c)
    while o<=n:
        c-=1;n=q(i,c)
        if 3>c:return 0
    l=[c]+l;o=n
 return l

Call the function x with a list of the ints.
Example:
print x([12,11,10])

prints
[6, 8, 10]

Jelly, 18 bytes
⁵ḊœċLḅI>0Pʋ@ƇDSÐṀḢ

Try it online!
How it works
⁵ḊœċLḅI>0Pʋ@ƇDSÐṀḢ - Main link. Takes a sequence S on the left
⁵                  - 10
 Ḋ                 - Dequeue; [2, 3, 4, 5, 6, 7, 8, 9, 10]
    L              - Length of S
  œċ               - Combinations with replacement
             D     - Convert each in S to digits
          ʋ@       - Group the previous 4 links together into a dyad f(s, l):
     ḅ             -   Convert from base
      I            -   Forward differences
       >0          -   Greater than 0?
         P         -   True for all?
            Ƈ      - Filter the combinations over f(s, l) with the digits on the right
              SÐṀ  - Take those with a maximal sum
                 Ḣ - Take the first one or 0 if empty

source: Stack Exchange

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

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

sort: votes


text:
Cryptic Kicker //
Cryptic Kicker
A common but insecure method of encrypting text is to permute the letters of the alphabet. In other words, each letter of the alphabet is consistently replaced in the text by some other letter. To ensure that the encryption is reversible, no two letters are replaced by the same letter.
Your task is to decrypt several encoded lines of text, assuming that each line uses a different set of replacements, and that all words in the decrypted text are from a dictionary of known words.
Input
The input consists of lowercase words, in alphabetical order. These words compose the dictionary of words which may appear in the decrypted text. Following the dictionary are several lines of input. Each line is encrypted as described above.
There are no more than 1,000 words in the dictionary. No word exceeds 16 letters. The encrypted lines contain only lower case letters and spaces and do not exceed 80 characters in length.
Output
Decrypt each line and print it to standard output. If there are multiple solutions, any one will do. If there is no solution, replace every letter of the alphabet by an asterisk.
Sample Input
and dick jane puff spot yertle

bjvg xsb hxsn xsb qymm xsb rqat xsb pnetfn
xxxx yyy zzzz www yyyy aaa bbbb ccc dddddd

Sample Output
dick and jane and puff and spot and yertle
**** *** **** *** **** *** **** *** ******

Here's the solution. Please note that I am not a horse running in the race for the shortest bytes / Competitive programmer. I just like puzzles!
(Source)

Please relax your >input< constraints to something that is applicable for each language. For example a lot of languages will hate, and not appreciate that the format starts with a 6. I'd suggest leaving the format totally unspecified, and only say that the input is a list of words and a list of lines to encrypt.

Okay, There you go!

Are there runtime constraints to this?  Can I simply iterate through every possible replacement combination, until one works (which would likely take years to finish)?

@NathanMerrill Do that, and if it's gonna take years,  just print it in the star form. Vihan, It's not a duplicate, please read the question properly.

Can we just output the words or do we have to join them?

It's your wish :)

Can we have an end constraint of some kind. Some languages have a hard time guessing when you are done with input. For now I am going to operate on the assumption that an empty line denotes the end of input.

Python 3, 423 bytes
import sys,re
S=re.sub
D,*L=sys.stdin.read().split('\n')
def f(W,M=[],V="",r=0):
 if len({d for(s,d)in M})==len(M):
  if[]==W:return V.lower()
  for d in D.split():p='([a-z])(?%s.*\\1)';m=re.match(S(p%'=',')\\1=P?(',S(p%'!',').>\\1<P?(',W[0].translate(dict(M))[::-1]))[::-1]+'$',d.upper());r=r or m and f(W[1:],M+[(ord(s),m.group(s))for s in m.groupdict()],V+d+" ")
  return r
for l in L:print(f(l.split())or S('\w','*',l))

Reads input from STDIN and writes output to STDOUT, using the same format as the sample input/output.
Explanation
For each line of ciphertext, we perform the following procedure:
We keep a map, M, of all the letter transformations we've already established (which is initially empty).
We do it in such a way that the source letters are all lowercase and the destination letters are all uppercase.
We process the words in the ciphertext in order.
For each word, we find all the words in the dictionary it might match, as follows:
Suppose that our word, w, is glpplppljjl and that M contain the rule j -> P.
We first transform w using the existing rules in M, getting glpplpplPPl.
We then transform w into the following python-flavored regex:
(?P<g>.)(?P<l>.)(?P<p>.)(?P=p)(?P=l)(?P=p)(?P=p)(?P=l)PP(?P=l)

The rules of the transformation are as follows:

The first occurrence of each lowercase letter, x, is replaced with (?P<x>.).
This defines a named capture group, called x, that matches a single cahracter.
Every subsequent occurrence each lowercase letter, x, is replaced with (?P=x).
This is a backreference to the character previsouly captured by the named group x.

We perform this transformation by reversing w, then applying the two following regex substitutions:
s/([a-z])(?!.*\1)/)>\1<P?(/
s/([a-z])(?=.*\1)/)\1=P?(/

and then reversing the result.
Note that the characters previously transformed by M appear as uppercase, and therefore remain unchanged.
We match the resulting regex against each of the dictionary words, where the dictionary words appear as uppercase.
For example, the above regex would match the word MISSISSIPPI.
If we find a match, we extract the new transformation rules from it, and add them to M.
The new transformation rules are simply the characters captured by each of the capture groups.
In the above regex, the group g matches M, the group l match I, and the group p matches S, giving us the rules g -> M, l -> I, p -> S.
We have to make sure that the resulting rules are consistent, that is, that no two source letters map to the same destination letter; otherwise, we reject the match.
We then proceed to the next word, using the augmented transformation rules.
If we can match all the ciphertext words using this process, we have decrypted the text.
If we can't match a word against any of the dictionary words, we backtrack and try to match the previous words against different dictionary words.
If this process fails, there is no solution, and we print a row of asterisks.

CJam, 62 56 bytes
qN%Sf/(f{\:C,m*{C..+`Sa`m2/Q|z_''f-Qf|=},C:,'*f*a+0=S*N}

Quite slow and memory hungry, but works for the test case with the Java interpreter.
Example run
$ cat input; echo
and dick jane puff spot yertle

bjvg xsb hxsn xsb qymm xsb rqat xsb pnetfn
xxxx yyy zzzz www yyyy aaa bbbb ccc dddddd
$ time cjam kicker.cjam < input
dick and jane and puff and spot and yertle
**** *** **** *** **** *** **** *** ******

real    5m19.817s
user    6m41.740s
sys     0m1.611s

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


text:
GolfScript, CJam, or Pyth?
Which language usually produces shorter golfed code: Pyth, CJam or Golfscript?
In asking this, I do not mean which has a prettier syntax or which has the most useful commands, I mean overall, which one is usually the shortest? What types of problems would we expect each language to have an advantage in?

I'm not 100% sure if this is on topic here, but if it isn't, the next most logical place would be Meta. And somehow this would seem the more logical place. I think it's an entirely valid refinement of http://codegolf.stackexchange.com/q/2070/15599 choosing languages for golfing.

I'd say that Pyth usually ends up being the shortest. If not, it will likely be soon, as it's still under heavy development.

GolfScript seems to usually lose to CJam, I assume because of CJam's one-character builtins.

Since I have no idea where the chat is, should I delete this post and post it on meta?

For chat, click the arrow to the right of the Stack Exchange logo, then chat or here.

I would go for meta, because in future it will be easier to find the question there than on chat. But (for @Sp3000 and those close voting) I don't entirely disagree with your position, but does that mean we should move the question I linked to meta too? I admit there are some differences between the two questions.

@steveverrill (and Sp3000), this is not on-topic for meta. Meta is for discussion of this Stack Exchange site (PPCG) itself, not for discussion about programming puzzles or code golf.

@Doorknob Then would you suggest keeping it here or just deleting the question altogether? Or maybe just asking in chat?

@TreFox Chat seems like the best place to ask a question like this.

Trefox, @doorknob has posted some data on chat showing Pyth better than Cjam better than Golfscript, but obviously it depends on the specific challenge, and the languages are under constant development.

All Stack Exchange sites are fundamentally Q/A, and we should try to include as much helpful, high-quality content as possible. Even if this isn't currently on-topic, we should make the necessary changes to accommodate questions like these.

Voting to reopen. I don't see how this is off-topic. This is a tips questions about golfing. Selecting a fitting language is a way to shorten code. (Though I personally believe that only comparisons within the same language are meaningful.)

@xnor If this is on topic, it's arguably a duplicate of the post steveverrill linked, and I'm not sure there is any benefit in asking the same question but limit it to three languages.

@MartinBüttner In the post steveverrill linked they are only talking about well known langauges, such as Java, C++, etc. they do not mention golfing languages, which I think differentiates the two questions.

They do cover GolfScript, J and APL. Pyth and CJam are younger than the question, but in any case, that's not the question's fault but the answers'. The right thing to do would be to encourage updated or specific answers to that question, e.g. by offering a bounty.

@xnor Even if this is conceptually on-topic, how would it not be too broad or primarily opinion-based?

@MartinBüttner Hmm, perhaps it is a dupe. We can see how a close vote for dupe goes if it reopens. The answers here are quite nice though -- might it be possible to merge them into the other question.

@AlexA. The question is specific and people have given well-justified answers including statistics, so I think it's fine on the broadness front.

There is no simple answer to this question.
GolfScript almost never beats CJam. It has a lot less built-ins than CJam and the overall syntax is a bit more verbose. For example, print and {+}* become
o and :+ in CJam.
The only exceptions are extremely trivial problems where the fact that GolfScript implicitly reads from STDIN is an advantage and the few occasions where block concatenation is useful (example).
With CJam and Pyth, it's a bit more complicated. Both languages can beat the other in particular challenges, although, by my completely unscientific observation, Pyth seems to have the upper hand on more occasions.
A few particular cases where picking one over the other is rather easy:

Choose Pyth if it has a built-in that CJam lacks and significantly simplifies the task.
For example, Pyth has r<iterable>2, which is Python's swapcase(). If that's useful in a challenge (example), it will be hard to beat with CJam.
On occasions, you have to build the output piece by piece. After finishing the program, CJam implicitly prints the entire stack, so you can just dump the pieces and let the interpreter do the rest.
For example, ascii-art challenges are usually won by CJam.
The length of a single built-in may be a decisive factor in a challenge.
Here, Pyth's C, which is shorter than CJam's 256b, was enough to outgolf CJam.
This would be longer in Pyth, partly because trigonometric functions are 3-character built-ins in Pyth and 2-character built-ins in CJam.

To sum it up, there is no single language that will magically make you win all code golf competitions. You haven't even considered APL, J, K, O, Q, TI-BASIC, Retina, Perl, sed and Mathematica, which all have beaten both CJam and Pyth in a few occasions.
You have several options:

Learn Pyth and CJam. Use the one that's more suited for each task.
Learn the one (first) you like better.
Personally, I'm crazy about stack-based languages, which I find much more easier to write and read.
Learn the one suited better for the challenges you enjoy.
ascii-art is your thing? Go with CJam. Nothing beats array-manipulation? Forget about both and learn J.

+1, this is a nice and comprehensive answer. However, it basically boils down to "it depends," which is more a fault of the question than of your answer.

Doorknob posted the following statistics on Chat, which I understand are based on answers to existing challenges. All credit goes to him. They certainly agree what I would have imagined.
golfscript is shorter than pyth 6 times (~13.043%)
golfscript is shorter than cjam 16 times (~20.513%)
pyth is shorter than golfscript 39 times (~84.783%)
pyth is shorter than cjam 59 times (~60.204%)
cjam is shorter than golfscript 57 times (~73.077%)
cjam is shorter than pyth 31 times (~31.633%)

I was going to leave these to Doorknob to post, but I found them interesting and thought if the question is going to stay open a while longer, it would be nice to post them for posterity, before it gets closed.
Obviously the best language will depend on each specific challenge, and this data only considers the corpus of challenges that we have at the moment. A change in the type of challenges would alter the balance between the languages.
Additionally, this data reflects the state of the languages today (Aug 2015). The languages are still in development, so it will be interesting to see how they perform in later versions.
This only covers challenges where at least two of the languages participated, which is probably fairer than considering all challenges. Nevertheless, as in virtually any statistical analysis, it is arguable that there could be some selection bias. It's possible that many challenges were so suited to a particular language that the others were not even considered.

It's worth mentioning that these statistics are for challenges where at least two of the relevant languages participated, which as Martin discusses in chat could be subject to selection bias

Considering that the point of code golf is to think in terms of a given language's kolmogerov complexity, in my opinion it doesn't matter much which language you use as long as you are clever. All of {Golfscript,CJam,Pyth,J} allow you to exercise creativity as do non-golfing languages. While code-golf technically claims "shortest code wins" this typically only really matters within each language. Often more important (as far as I can tell from looking at voting patterns, etc) is how creative or difficult your solution is.
For example HQ9+ while hilarious doesn't really win a 99 bottles of beer competition, because writing 9 isn't exactly showing effort. Meanwhile the Malbolge execution of 99 bottles of beer is considered incredibly cool despite being very lengthy due to its creative nature and the effort put in to make it. If HQ9+ did win we could merely define a language L which states: L outputs the solution to this problem, otherwise the code is compiled as C and executed.
This is why most old golfing sites still in operation are language-specific (Perl, Vim, C [if you count IOCCC]) because comparing code-sizes of different languages just doesn't make much sense. Most languages will have at least one challenge where they win. That doesn't make them 'better' than the alternatives.
Interestingly enough I have found that if you stretch the definition of language too much you get very creative/odd solutions to problems. (EG: many ASCII-art competitions could be won by a series of Vim keystrokes over at vimgolf.com).
If code-length is really all you care about, there are even more terse languages then the mentioned Golf-oriented languages. The reason they are often used for golfing is that their code-size is typically directly related to algorithmic complexity, whereas in for example C, you may sacrifice algorithmic complexity for shorter syntax to out-golf the competition. Meanwhile the even terser languages aren't really designed to be human programmable, and are more oriented to approximating kolmogorov complexity or theoretical applications.
My recommendation: learn whichever golfing language is based on a language you like. If you enjoy Python, learn Pyth. If you enjoy Ruby, learn GolfScript. If you like C/C++/Java learn CJam (and if you find you enjoy CJam you may wish to look into Joy which is a similarly concatenative-stack-based language designed for usability rather than golfability)


text:
Tips for golfing in CoffeeScript
What tricks do you know to make CoffeeScript code shorter?
CoffeeScript is language that compiles into JavaScript ("transpiles" into ES3, to be exact). The golden rule is "It's just JavaScript", meaning there's no runtime overhead. Most of JavaScript Tips & Tricks apply as well.
As a side-effect that also means: developers coming from JavaScript (including myself) tend to use JavaScript constructs instead of shorter CoffeeScript alternatives.
This thread focuses on tips specific to CoffeeScript.
Links to related topics:
Tips for golfing in JavaScript
Tips for Golfing in ECMAScript 6 and above

Can coffeescript compile to ES6? Is it compatible?

@proudhaskeller It compiles into ES3 in general, with one exception: if you yield, it compiles into ES6 generator. Otherwise it tries to be as browser-compliant as possible.

Use destructuring assignments, if structure elements are used often
Eg. get elements of first argument array
func = ([x,y,z])->
    [i,j] = doSomething x, y, x+y
    doSomethingElse i, j

# instead of

func = (a)->
    b = doSomething a[0], a[1], a[0]+a[1]
    doSomethingElse b[0], b[1]

This can be combined with splats
[first, rest..., last] = doSmth()

It may be better if you separate each tip into a separate answer :)

@BetaDecay Deal.

Short-circuit evaluation in place of ternary operator
CoffeeScript does not have JavaScript's ternary operator ?, however the functionality of short-circuit evaluation can sometimes be used instead:
foo = a && b || c

# Long form:
foo = if a then b else c

Is somewhat equivalent to in JavaScript:
foo = a ? b : c

It will not work if b is (or can evaluate to) a falsy value such as 0.

Integer division operator //
Saves up to 10 bytes by avoiding the need to floor numbers when dividing.
Using the // operator:
foo = 61/3                 # foo = 20.333333333333332
foo = Math.floor 61/3      # foo = 20 (15 bytes)
foo = 61/3|0               # foo = 20 (6 bytes)
foo = 61//3                # foo = 20 (5 bytes)

Compared to JavaScript:
foo = 61/3                // foo = 20.333333333333332
foo = Math.floor(61/3)    // foo = 20 (16 bytes)
foo = 61/3|0              // foo = 20 (6 bytes)

(61/3|0) works just as well for vanilla JS.

@ETHproductions I've added it into the post to indicate the difference in bytesize

// is actually a .floor(), so it works differently for negative numbers:
foo = -61//3   # -21, while foo = -61/3|0 # -20

You can also use //1 for a plain floor.

Space is fun. Space is significant for calling functions
a=b[i]  # get i-th element of array b
a=b [i] # a = b( [i] ) # pass [i] to function b

m=n+k   # simple math
m=n +k  # m = n( +k ) # convert k to number and pass to function n
m=n -k  # m = n( -k ) # pass -k to function n
m=n + k # simple math again

a(b c)+d   # a( b( c ) ) + d
a (b c)+d  # a( b( c ) + d )
a (b c) +d # a( b( c )( +d ) )

Omit parentheses when possible
func1 func2 func3(a),func3 b

#instead of

func1(func2(func3(a),func3(b))

Not null but possibly falsy (0, NaN, "", false, etc.)
If you need to check if a variable is defined and not null, use the trailing question mark:
alert 'Hello world!'if foo?

Compiles to:
if (typeof foo !== 'undefined' && foo !== null) {
    alert('Hello world!')
}

This probably won't apply to many code golf entries but might be useful if you need to distinguish from a zero, false, empty string, or other falsy value.

Exponentiation operator **
Saves 9 bytes:
foo = 2**6
# foo = 64

Compared to JavaScript:
foo = Math.pow(2,6)
// foo = 64

For powers of two, this is irrelevant as 1<<x is equal to 2**x

Searching arrays
Save approximately 8 bytes if you just want to check if an element is in an array, you can use the in operator.
y = x in['foo', 'bar', 'baz']

Compared to alternatives in JavaScript:
y = ~['foo', 'bar', 'baz'].indexOf(x)   // ES5, returns Number
y = ['foo', 'bar', 'baz'].includes(x)   // ES7, returns boolean
y = ~$.inArray(x,['foo', 'bar', 'baz']) // jQuery, returns Number

However in the rare case that you need the index of the element then this trick won't work for you.

Same applies for searching strings, or detecting if character is in specific set: b = c in'|-+'

Use splats
obj.method a, params...

# instead of

obj.method.apply obj, [a].concat params

# especially useful with new objects

obj = new Obj a, params...

# alternative is complicated, unreadable and not shown here.

Safe accessors: ?. and func? args...
Existential operator ? has many forms and uses. Apart from just checking if variable is set, you can access object methods and properties without prior checking if object is null:
obj.property?.method? args...

will execute obj.property.method args... only if obj.property and obj.property.method are defined and not null.
Useful if you iterate over several sparse arrays at the same time:
arr1[i]?.prop = arr2[i]?.method? args... for i in[0..99]


text:
Tips for golfing in INTERCAL
What general tips do you have for golfing in INTERCAL? I'm looking for ideas which can be applied to code golf challenges and are also at least somewhat specific to INTERCAL (i.e. "remove comments" is not a useful answer).
I know exotic languages can be really useful to win golf contests, but I don't see much INTERCAL code around here. Do you have any advice that can help people get competitive code sizes with INTERCAL? Could this language ever be competitive?
INTERCAL is so underutilized that it doesn't even have a tag. So sad...

Most languages don't have or need their own tags here, as language-specific challenges are generally discouraged.

A hint that this might not be the best golfing language, from its wikipedia page: Despite the language's intentionally obtuse and wordy syntax,

INTERCAL doesn't specify precedence, but it also doesn't error on ambiguous precedence
An expression like
#1$#2~#3

is ambiguous, and could mean
'#1$#2'~#3

or
#1$'#2~#3'

The INTERCAL spec leaves it intentionally unclear which is meant, and in general there's no standard (although C-INTERCAL and CLC-INTERCAL make an effort to match each other in the simpler cases). That said, the original isn't incorrect; it's ambiguous and I wouldn't advise using it in production code (but then, I wouldn't advise using INTERCAL itself in production code), but it will have some meaning in the majority of compilers.
In other words, it may be worth just removing grouping characters and hoping your program still works. Most interpreters will parse any given ambiguous expression consistently, so for each pair of grouping characters, there's a 1 in 2 chance it's unnecessary; that can add up to quite some savings. (Unfortunately, INTERCAL parsers tend to be sufficiently confusing that nobody's entirely sure what the rules actually are, but it can normally be determined by experiment. In the simplest cases, operators tend to all have equal precedence and to have a consistent associativity.)

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

it's strongly worth considering overloading a random variable to allow you to assign both at once:
DO:1<-#1$#2

(with :1/!1$.2' thrown in somewhere earlier in the program; note that this notation postdates INTERCAL-72 by quite a way, so you'll need to use a modern INTERCAL for this to work). This is only slightly longer even if you take the setup into account, and becomes shorter if you ever need to, or can arrange to, simultaneously assign to .1 and .2 more than once.
It's not just calculate commands where this trick works. If you need to stash a variable twice, don't do it like this:
DOSTASH.1DOSTASH.1

but like this:
DOSTASH.1+.1

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

Use a single RESUME for all INTERCAL-72-style if consructs
If you need to write the equivalent of an "if" statement, the normal method using INTERCAL-72 code is to NEXT twice and then do a computed RESUME. (In modern code, often a computed COME FROM will be better, but this tip assumes your code prefers NEXT.) You almost certainly have to pay the bytes for the first NEXT, as it jumps from one branch of the "if" to the other. Sharing the second NEXT is also nontrivial, unless you have a lot of "if" statements that go to the same place upon seeing a #1. However, the RESUME can be anywhere in the program (because control is going to leave it instantly anywhere).
There are two ways to handle this. If you have a lot of "if" statements, then the RESUME probably warrants a single-digit line number, so that your second NEXT statement can be as short as possible. If possible, try to make it a computed RESUME that would naturally occur in your code (admittedly, this is difficult, as it's rare for those to appear in the "normal flow" of code rather than being NEXTed to); then, the only cost is the line number. You'll have to use a single boolean variable for all these NEXTs; the universal consensus here is to use .5, mostly because it's the variable that the standard library uses for boolean return values.
Alternatively, it's possible to make use of an undocumented (technically underdocumented, because I slipped a hint into the INTERCAL documentation when I noticed) feature of the standard library. Because a central location for a RESUME is so useful, the standard library uses one internally. Line numbers in INTERCAL are global (with namespacing conventions, but which can be broken if you know what you're doing), so you can NEXT right into the standard library internals if you want to, and in particular, can NEXT to its central RESUME location. This is sufficiently popular in existing INTERCAL code that standard library replacements tend to have to implement it to avoid breaking existing programs.
The line in question is (either literally or effectively, depending on the implementation):
(1001) DO RESUME .5

The main reason not to use this is its long line number; if you need to do a lot of INTERCAL-72-style if constructs, it'll be better to use your own to give it a shorter number.
Of course, you can combine the techniques, writing something like
(9)DO(1001)NEXT

which is only marginally longer than
(9)DORESUME.5

and has the benefit that the booleans become #2 and #3 (which is harder to read, but normally easier to generate). Actually, it might even be worth putting in the extra code to handle #0 and #1 if you're going to be iffing a lot (but computed COME FROM will probably work better in this case unless your requirements are very weird).

Whitespace / "noise" removal can go further than you might expect
INTERCAL is a whitespace-insensitive language. Unlike most whitespace-insensitive languages, though, the insensitivity goes much further than you might expect.
For example, DO NOT is two tokens, but can be written DONOT without the parser complaining (in pretty much any widely used implementation). (Of course, you could also write DON'T, but it isn't any terser. It might be easier to read, though. PLEASEN'T is probably harder to read than PLEASE NOT, though.) Actually, there's some debate as to whether whitespace does anything at all; at least one INTERCAL parser allows it even inside numerical constants (not that that's very useful when golfing). One thing to bear in mind is that removing whitespace from DO READ OUT gives DOREADOUT which can confuse some older INTERCAL parsers due to the embedded DO (although their authors generally consider this a bug, and thus nowadays it typically works in a valid program, it's not advisable to put code like this in the vicinity of a syntax error, as it can be much harder to disambiguate then).
Also remember that you can overpunch characters to save space. In ASCII, you can only really pull this off with '. → !, but that's a highly useful trick in its own right. (When you aren't using arrays, there's no possibility of a sparkears ambiguity even when all your grouping characters are the same, so for golfing entries, it's recommended to stick to just ' unless an array subscript genuinely requires a ".) A bookworm can be represented in one byte by using the ? abbreviation (C-INTERCAL) or Latin-1 for ¥ (CLC-INTERCAL), rather than the three that INTERCAL-72 needs.

In C-INTERCAL, consider abbreviating code using CREATE
The CREATE statement allows you to create new syntax. This is particularly useful in golfing because it allows you to give statements shorter names. You can also use it to effectively "define a function" via creating a new operator (which has the huge advantage that it lets you call the function in the middle of an expression).
The setup cost here is fairly high, but if there's a construct that you use a lot, inventing shorter syntax for it is probably going to be a good idea.

This is useful for CLC-INTERCAL, too.

Golfing off GIVE UP statements

Trailing GIVE UP statement can be removed, as it will cause E633 error in C-INTERCAL or error 000 or 633 in CLC-INTERCAL to abort.
Replace GIVE UP statements with incomplete statements such as DO or D (D worked on CLC-INTERCAL but not on C-INTERCAL, if without compiler option.).
RETRIVE unSTASHed variable, RESUME #0, and many other runtime errors can also be alternatives.
ABSTAINFROM non-existing labels, invalid labels, etc. Same applied for REINSTATE.

Calculated COMEFROM, NEXTFROM.

COMEFROM(9) and COMEFROM#9 are equivalent. This works for C-INTERCAL and CLC-INTERCAL.
CLC-INTERCAL has NEXTFROM, as DO(XXX)NEXT to be obsolete (which requires a compiler option). As well as COMEFROM statement, it supports labels to be computed.
Since label numbers can be calculated, some complicated equations such as DOCOMEFROM.1~.1 can be available.

Dividing a variable by two.
DONOTe this is very long. Using C-INTERCAL library.
DO.1<-.9DO.2<-#2DO(1040)NEXTDO.9<-.3
DONOTe shorter way.
DONOTe The number can be smaller if you know that
DONOTe .9 shall have smaller value.
DO.9<-.9~#65534

Similar goes to dividing by 2^n.

Golfing newline output in CLC-INTERCAL
DO,1<-#1DOREADOUT;1+,1

where ;1 is a string to output.

CLC-INTERCAL (sick) can ABSTAIN and/or REINSTATE non-existing label.
C-INTERCAL (ick), on the other hand, makes it compiler error.

Similarly, for NEXTFROM, COMEFROM in CLC-INTERCAL.

CLC-INTERCAL 1.-94 does not check politeness of the program.
So every PLEASE and PLEASEDO can be replaced with DO.


text:
Binary Stream With Unknown Byte-Width
Context:

You are a cryptographer. You have stumbled upon a mysterious group of individuals, who present you with a challenge, which you must solve in order to join their secret society.

Description:

You have been given a binary stream consisting of 3 byte sequences that have a random width (unchanging per-stream). This stream has the following properties:

The first two bytes in a sequence are randomly generated unsigned binary numbers.

The third byte is the sum of the first two bytes.

If the sum overflows, the carry-bit disappears (That is, it does not affect the first 2 bytes).

The bytes are big-endian.

The byte-width will always be between 3 and 16.

Examples of potential streams:

A stream is an infinite series of 3 byte sequences, where the first 2 bytes are randomly generated for each sequence in the series.
Byte-width = 5: 01001 01010 10011 10010 11101 01111 ... is a valid stream (without spaces, of course). 01001 + 01010 = 10011, and 10010 + 11101 = 01111 (after integer overflow).
Byte-width = 10: 1100110011 0101010101 0010001000 ... is a valid stream. 1100110011 + 0101010101 = 0010001000 (after overflow).

The Rules:

Write a program that consumes the binary stream, and outputs (with 100% certainty) the byte-width. This puzzle has two parts, efficiency and code-golf.
Efficiency: Your score in this section is determined by the average number of bits your program must consume to make it's determination (after N>=1000 runs).
Golf: Your score in this section is determined by the number of characters used in your code. This number does not include the scaffolding to generate the stream, includes/imports, or boilerplate. For example, in C/C++: int main(){ ONLY_THIS_COUNTS }.
Your final score is equal to the multiplication of your scores in both sections. The lowest score wins.

@Sp3000 Added 2 examples for base 5 and base 10. Does that make any more sense?

@LivingInformation Suppose the program has read 110. Can the program terminate and return bit width 1? If not, what is the maximum base, so the program can actually terminate?

@isaacg oops, I forgot to give a range on the bit-widths! The width will always be between 3 and 16, sorry about that.

In nearly all modern contexts the byte refers to an octet of bits. Perhaps you could use a word that causes less confusion? (word, grouping, chunk, etc).

Also, I assume we have to read the stream bit by bit, and can not skip elements?

Is the bit stream a literal bit stream in the form of random bytes that are shoved into stdin, or is it a string of characters, each representing a 1 or a 0? e.g. "1001110101100..." Also, is it necessary that we write a full program?

@BrainSteel you can treat it as either, but its probably easier to consume bit-by-bit if you use characters representing 1 and 0 (due to being unable to consume single bits in stdin, I believe you can only consume byte-by-byte in most environments, making consuming it one bit at a time difficult). When I have time, I'll be posting a python controller producing proper input for a program, but if you use another language, you'll need some way of generating streams.

Does the code for counting the bits that are consumed add to the golf score or are they part of the scaffolding/stream generation/boilerplate?

@nimi I would consider that part of stream generation, as the generation could be set up in such a way as to report the bit number in addition to the bit, on every consume. For example, in Python, you could return a tuple of (bit, bit_num).

Haskell 59.5 * 228 = 13566
import Data.List
import Data.List.Split
import Prelude.Unicode
import System.Random

findBW strm
 | i == 0    = (16, rest)
 | i < 3     = findBW rest
 | otherwise = (i, rest)

 where
 (bw,rest) = splitAt 4 strm
 i = sum $ zipWith ((*).(2^)) [0..] bw

mkStream i strm = first ++ second ++ sum ++ mkStream i rest
 where
 (first,tmp) = splitAt i strm
 (second,rest) = splitAt i tmp
 sum = reverse $ g (reverse first) (reverse second) 0

run 100000 reps _ = print $ (reps*16*3) / 100000
run n reps gen = do
 p validstream
 run (n+1) (reps+rep) gen2

 where
 (gen1,gen2) = System.Random.split gen
 (bytewidth, rndstream) = findBW $ randomRs (0::Int,1) gen1
 validstream = mkStream bytewidth rndstream
 rep = fst $ until(\(_,t)->sum[1|x<-h#t,x]<2)(\(n,s)->(n+1,tail#s))(1,f validstream)

main = do
 gen <- getStdGen
 run 0 0 gen

r=reverse
(#)=map
h=head
g[]_ _=[]
g(a:b)(c:d)e=mod(a+c+e)2:g b d(div(a+c+e)2)
c(m:n:o:p)=(g(r m)(r n)0≡r o):c p
f s=(scanl1(∧).c.(`chunksOf`s))#[3..16]
p=print.(3+).h.elemIndices True .(h#).until(\t->sum[1|x<-h#t,x]<2)(tail#).f

The average bits consumed in a run on 100,000 streams are around 59.3x / 59.4x , so I take 59.5 as the multiplier. For the golf part I count the characters of function p and it's helper functions, i.e. all characters beginning with r=reverse to the end. p is the function that analyses a bit stream and prints the byte-width.  Note: there are some unicode characters, all counting 1.
How it works: split the bit stream in chunks of 3 bits, 4 bits, ... 16 bits and check for validity. Repeat taking 3 of the chunks for every size until there's only one valid set. That means I consume 3*16 = 48 bits per repetition. Most of the time one ore two repetitions are enough.

Nice answer! Haskell is an interesting choice for this problem.


text:
Take It or Leave It III: A Game Show for Computers
This is the third in a series of puzzles that I will be posting every Monday at Midnight PST, and the final variant of "Take It or Leave It".
The first puzzle is located Here
The second puzzle is located Here
Context:

A reclusive billionaire has created a game show to attract the world's best and brightest programmers. On Mondays at the stroke of midnight, he chooses one person from a pool of applicants to be the contestant of the week, and provides them with a game. You are this week's lucky contestant!

This week's game:

The host provides you with API access to a stack of 15,000 digital envelopes. These envelopes are randomly sorted, and contain within them a dollar value, between $1 and $15,000 (no two envelopes contain the same dollar value).
You have 5 commands at your disposal:

Read(): Read the dollar figure in the envelope at the top of the stack.

Take(): Add the dollar figure in the envelope to your game show wallet, and pop the envelope off the stack.

Pass(): Pop off the envelope on the top of the stack.

Oracle(M): Returns the mean value of the next M envelopes in the stack, not including the one you can currently Read().

End(): Stop the game, and walk away the money currently in your wallet (your final score).

The Rules:

If you use Pass() on an envelope, the money within is lost forever.

If you use Take() on an envelope containing $X, from that point forward, you may never use Take() on an envelope containing < $X. Take() on one of these envelopes will add $0 to your wallet.

If you use Oracle(M) on turn T, envelopes T+1 through T+M's mean will be returned. Oracle() is disabled until turn T+M.

If you use Take() or Pass() on turn T, $T is removed from your wallet.

Write an algorithm that finishes the game with the maximal amount of money.
Note 1: "Maximal" in this case means the median value in your wallet after N >= 1000 runs. I expect, though I would love to be proven wrong, that the median value for a given algorithm will converge as N increases to infinity. Feel free to try to maximize the mean instead, but I have a feeling that the mean is more likely to be thrown off by a small N than the median is.
Note 2: This puzzle has a significant difference from the first two iterations (namely, needing to pay for each envelope you take). Feel free to use any strategies from the first puzzles as a base, but be warned: They will probably (read: definitely) get a negative score without some kind of modification.
Edit: The prize condition has been removed, in light of this post on meta.

I don't like the idea of giving out real-world prizes here.

Can the final score be negative? I don't think I've seen any game shows where they make the contestants pay if they play poorly. :) Good strategies will hopefully get a positive score on a consistent basis, but it would still be useful to know how a bad run gets scored.

@Reto yes, the final score can be negative, but any good strategy should come out with a net positive score. I guess you can consider a negative final score to mean that the contestant walks away with nothing (as opposed to needing to pay).

@Geobits The prize condition has been removed, in light of this post on meta.

I read that as "a recursive billionaire" first

is End() strictly necessary? Couldn't an entrant just Pass() through all remaining envelopes if they are done?

@Sparr I was conflicted on adding End(), I had a choice between one of two mutually exclusive mechanics. The first mechanic would have been paying only for the envelopes you Take() on, and the second was paying for every envelope you have the privilege of reading, incurring a fee on both a Take(), and a Pass(). I decided that the second mechanic was more interesting, as it requires the player to choose some fixed point to end the game, else they can't make any money at all. I have a feeling that this mechanic will have an interesting interplay with the Oracle.

I have a feeling that this is the most attention that this is going to get due to there already being two puzzles of a similar nature

@LivingInformation Thanks for editing the prize offers out yourself! Just wanted to say, even though there are too many problems with doing so here, giving things out to strangers on the internet for nothing in return was a pretty awesome thing to do regardless. :)

When I test the answer below I get a much bigger result than what the answer claims, which mans there is something wrong with my test harness.  https://onlinegdb.com/rkXD6-2LL  Does anyone see what I did wrong?  If I can figure out how to test my submission I will write an answer.

Java, $3889.5 Median
        int highest=0;
        int topp=0,tott=0;
        for(int i=0;i<1000;i++){
            if(Read()>topp&&tott+Read()-i>tott){
                topp=Read();
                tott += Read();
                tott -= i;
                Take();
            }else{
                if(tott-i>i/2){
                    tott -= i;
                    Pass();
                }else{
                    End();
                    break;
                }
            }
            if(highest/1.1>tott){
                End();
                break;
            }
            if(tott>highest)
            highest=tott;
        }

Try it Online

Can you please add a TIO link and format your code?

When I test your algorithm I get  much bigger amount of money.  How did you test it?

This code snippet is Java compatible but also C and C++ compatible and maybe other languages too.

I ran it 1000 times and took the median, may you please clarify what you mean by format the code?

Here is a link to my version of your code.  https://onlinegdb.com/SyqqtXhII  I must have written the test harness part wrong because I get much bigger numbers than you do.  Maybe you could post all your code so I can see where I went wrong?

I have all the code in the try it online link


text:
Implement INTERCAL's Binary Operators
The Compiler Language With No Pronounceable Acronym, abbreviated INTERCAL, is a very unique programming language. Among its unreproducible qualities are its binary operators.
INTERCAL's two binary operators are interleave (also known as mingle), and select. Interleave is represented with a change (¢), and select is represented with a sqiggle (~).
Interleave works by taking two numbers in the range 0-65535 and alternating their bits. For instance:
234 ¢ 4321
234   = 0000011101010
4321  = 1000011100001
Result: 01000000001111110010001001
Output: 16841865

Select works by taking two numbers in the range 0-65535, taking the bits in the first operand which are in the same position as 1s in the second operand, and right packing those bits.
2345 ~ 7245
2345  = 0100100101001
7245  = 1110001001101
Taken : 010   0  10 1
Result: 0100101
Output: 37

In this challenge, you will be given a binary expression using either the interleave or select operation. You must calculate the result, using the fewest possible bytes.
The expression will be given as a space separated string, consisting of an integer in 0-65535, a space, either ¢ or ~, a space, and an integer in 0-65535.
Input and output may be through any standard system (STDIN, function, command line, etc.). Standard loopholes banned.
Examples:
5 ¢ 6
54

5 ~ 6
2

51234 ¢ 60003
4106492941

51234 ~ 60003
422

This is code golf - fewest bytes wins. Good luck.
EDIT: Since some languages do not support INTERCAL's change (¢) symbol, you may use the big money ($) symbol instead, at a 5 byte penalty.

I was going to suggest doing this in INTERCAL, then I saw Standard Loopholes banned. Damn! Can we use a symbol other than the "change" symbol for the interleave operator? The symbol given is not ASCII, which will be a problem for some languages. According to the linked wikipedia page $ and c have been used.

@steveverrill I adressed the non-ASCII issue. Using INTERCAL is fine, as long as you take the input from STDIN. INTERCAL has no other concept of a string.

It's a bit harsh penalising people for the use of the dollar sign. That is something that cannot be helped.

@BetaDecay I don't want submissions which use the wrong symbol just because it saves a single byte - I only want languages that really need to use the $ to do so.

@isaacg Well why don't you just penalise them for the number of times they use a dollar sign instead of a cent sign?

I just realized that CLWNPA is perfectly pronouncable in Welsh. The W is pronounced as U in Spanish or OO in English.

I don't get the 5 byte penalty. C-INTERCAL uses the $.

Is ¢ as ASCII 155 (per the old Codepage 437) OK? If so I can remove the penalty. I'm told it works, but I am having difficulty making it work on my own (Spanish) computer due to operating system issues. C doesn't properly support the unicode value 0x00A2. BTW @betadecay, your suggestion would suit me perfectly, as none of the operator symbols appear in my code, heheh!

What are you all arguing about? A $ is clearly more expensive than a ¢. What, you want 99¢ for nothing?

I didn't think INTERCAL would allow you to input numbers with decimal numerals.  Don't you have to write FIVE ONE TWO THREE FOUR?  And shouldn't the output be in Roman numerals?

@NateEldredge The challenge is to implement a feature of INTERCAL, not the whole language. That horrible input format rather neatly means that in this case there is no need to invoke the standard loophole about emulating a language with the language itself. To answer the challenge in (original) INTERCAL (or CLaWNPA / CLOWNPA as I like to call it) you would have to write code for parsing decimal numbers. Some modern variants  apparently have easier I/O, but I couldn't find one  that takes decimal input.

Pyth, 32 31 29 bytes
isummFdG}\~zCm.[Z16jvd2%2cz)2

Try it online: Regular Input / Test Suite
Thanks to @isaacg for golfing off one byte.
Explanation:
                         cz)   split input at spaces
                       %2      only take every second item (the numbers)
             m                 map each number d to:
                    vd           convert d to int
                   j  2          convert to base 2
              .[Z16              pad zeros at the left
            C                  zip
  u     }\~z                   apply the following function ("~" in input) times:
   m   G                         map each pair d to:
    mFd                          convert [x,0] to [] and [x,1] to [x]
 s                             take sum (unfold all lists)
i                           2  convert back from base 2 and print

You can save one byte by changing hMfeT to smmFd and then moving the duplicate s outside the ternary. Also, your current code is 32 bytes, not 33.

@isaacg Wow. I would never have thought that clever golf. Thanks. And yeah, did a last minute golf while writing the explanation and didn't update the byte count.

It's really interesting to see Pyth and CJam answers, almost always the same byte count, but Pyth often beats CJam by a few

Python 2, 115 112 bytes
x,y,z=input().split()
d=y<""
f=lambda a,b:a+b and(b%2+5&4-d)*f(a/2,b/2)+(a%2*2+b%2)/3**d
print f(int(x),int(z))

The string on the second line contains a single unprintable character \x7d, the next char after ~.
All hopes of a nice, single lambda get crushed by the input format. There's probably a better way to read in input. Input like "51234 ¢ 60003" via STDIN.
The function f combines the following two recursive functions:
g=lambda a,b:a+b and 4*g(a/2,b/2)+a%2*2+b%2    # ¢
h=lambda a,b:a+b and(b%2+1)*h(a/2,b/2)+a*b%2   # ~

(-3 bytes with the help of @xnor)

+1 for the first really competitive Python answer. I was wondering why you bothered with the lambda and didn't just use an expression, but it looks like there's some recursion in there? I don't know Python, I look forward to an explanation.

Some great bit bashing! I'm looking at compressing the constant term expression. The expression (a%2*2+b%2)/3**d saves 3 chars but uses the complement d=1-c. Do you have a way to do -~(3*c|b%2) with the complement? At worst it loses 2 chars with 3-3*d. Also, the format and-~x+y can be andy-~x as long as y starts with a symbol or number.

@xnor Got it, (b%2+5&4-d). Thanks!

CJam, 31 bytes
rrc\r]{i2bF0e[}%(7=\zf{_)*?~}2b

Try it online in the CJam interpreter.
How it works
rr                              e# Read two tokens from STDIN.
  c\                            e# Cast the second to char and swap with the first.
    r                           e# Read a third token from STDIN.
     ]                          e# Wrap everything in an array.
      {       }%                e# For all three elements:
       i2b                      e#   Cast to int and convert to base 2.
          F0e[                  e#   Left-pad with zeroes to complete 15 digits.
                (               e# Shift out the first base 2 array.
                 7=             e# Select its eighth MSB (1 for '¢', 0 for '~').
                   \            e# Swap with the array of base 2 arrays.
                    z           e# Zip to transpose rows with columns.
                     f{     }   e# For each pair of base 2 digits:
                                e#   Push the bit, then the pair.
                       _        e#   Copy the pair.
                        )       e#   Pop the second digit.
                         *      e#   Repeat the first digit that many times.
                          ?     e#   Ternary if. Select the pair if the bit is
                                e#    truthy, the repeated first bit if it's falsy.
                           ~    e#   Dump the selected array on the stack.
                             2b e# Convert from base 2 to integer.

JavaScript (ES6), 103 117 119 124
Edit now working with numbers instead of strings
(not counting leading spaces, newlines and comments)
Test running the snippet on any EcmaScript 6 compliant browser (notably not Chrome not MSIE. I tested on Firefox, Safari 9 could go)

I=s=>
  (i=>{
    for(m=r=0,[a,o,b]=s.split` `;i>0;i<<=1) // loop until bit 31 of i is set
      o>'~'?r+=(b&i)*i+(a&i)*2*i:b&i?r+=(a&i)>>m:++m
  })(1)||r

// TEST
out=x=>O.innerHTML+=x+'\n\n';

[ ['234 ¢ 4321', 16841865], ['2345 ~ 7245', 37]
, ['5 ¢ 6', 54], ['5 ~ 6', 2]
, ['51234 ¢ 60003',4106492941], ['51234 ~ 60003', 422]]
.forEach(([i,o,r=I(i)])=>{
  out('Test '+ (o==r?'OK':'Fail')+'\nInput:    '+ i+'\nResult:   '+r+'\nExpected: '+o)})

Matlab, 119 113 bytes
function f(s)
t=dec2bin(str2double(strsplit(s,{'¢' '~'}))');u=any(s>'~');[~u u]*bin2dec({t(1,t(2,:)==49) t(:)'})

Ungolfed:
function f(s)                                     % input s is a string
t = dec2bin(str2double(strsplit(s,{'¢' '~'}))');  % get the two numbers and convert to
                                                  % two-row char array of zeros of ones
u = any(s>'~');                                   % 1 indicates '¢'; 0 indicates '~'
[~u u]*bin2dec({t(1,t(2,:)==49) t(:)'})           % compute both results and display
                                                  % that indicated by u

Examples:
>> f('234 ¢ 4321')
ans =
    16841865

>> f('2345 ~ 7245')
ans =
    37

R, 145 bytes
s=scan(,"");a=as.double(c(s[1],s[3]));i=intToBits;cat(packBits(if(s[2]=="~")c(i(a[1])[i(a[2])>0],i(0))[1:32] else c(rbind(i(a[2]),i(a[1]))),"i"))

Ungolfed + explanation:
# Read a string from STDIN and split it on spaces
s <- scan(, "")

# Convert the operands to numeric
a <- as.double(c(s[1], s[3]))

o <- if (s[2] == "~") {
    # Get the bits of the first operand corresponding to ones in
    # the second, right pad with zeros, and truncate to 32 bits
    c(intToBits(a[1])[intToBits(a[2]) == 1], intToBits(0))[1:32]
} else {
    # Interleave the arrays of bits of the operands
    c(rbind(intToBits(a[2]), intToBits(a[1])))
}

# Make an integer from the raw bits and print  it to STDOUT
cat(packBits(o, "integer"))

Python 3, 174 166 148 126
Pretty straightforward, string operations, then conversion back to integer.
Limited to numbers which in binary have 99 digits (max 2^99-1 = 633825300114114700748351602687).
Thanks, Sp3000 and Vioz!
a,o,b=input().split()
print(int(''.join([(i+j,i[:j>'0'])[o>'~']for i,j in zip(*[bin(int(j))[2:].zfill(99)for j in(a,b)])]),2))

Or 165 chars, without limit:
a,o,b=input().split()
a,b=[bin(int(j))[2:]for j in(a,b)]
print(int(''.join([(i if j=='1'else'')if o=='~'else i+j for i,j in zip(a.zfill(len(b)),b.zfill(len(a)))]),2))

Ungolfed:
a, op, b = input().split()
a, b = [bin(int(j))[2:] for j in(a,b)] #convert to int (base 10), then to binary, remove leading '0b'
m = max(len(a), len(b))
a = a.zfill(m) #fill with leading zeroes
b = b.zfill(m)
if op == '~':
    ret = [i if j=='1' else'' for i, j in zip(a, b)]
else:
    ret = [i + j for i, j in zip(a, b)]
ret = ''.join(ret) #convert to string
ret = int(ret, 2) #convert to integer from base 2
print(ret)

You can use zfill instead of rjust for padding with zeroes

Inputs max out at 16 bits, and outputs at 32 bits. 99 bits is more than enough.

I know, but since '99' takes as much characters as '16', there's no benefit of limiting it.

A few more: 1) You don't need to save a,b, just put it in the zip with a * splat, 2) (i if j=='1'else'')  ->  i[:j>'0'] 3) You can use this tip to save on the other if/else

My solution ended up being too close to yours, so here's as short as I could get yours (126 bytes).

Pyth, 43 bytes
Part of me feels nervous posting such a long Pyth answer on isaacg's question... :oP
J.(Kczd1Am.BvdKiu?qJ\~u+G?qeH\1hHk+VGHk.iGH2

Explaination:
                                               Implicit: z=input(), k='', d=' '
   Kczd                                        Split z on spaces, store in K
J.(    1                                       Remove centre element from K, store in J
         m    K                                For each d in K
          .Bvd                                 Evaluate as int, convert to binary string
        A                                      Store pair in G and H
                                               ~ processing:
                                 +VGH          Create vectorised pairs ([101, 110] -> [11, 01, 10])
                     u               k         Reduce this series, starting with empty string
                        ?qeH\1                 If 2nd digit == 1...
                              hHk              ... take the 1st digit, otherwise take ''
                      +G                       Concatenate
                                      .iGH     ¢ processing: interleave G with H
                ?qJ\~                          If J == ~, take ~ processing, otherwise take ¢
               i                          2    Convert from binary to decimal

I love your profile picture! :)

@kirbyfan64sos Blue Kirby is best Kirby :o)

K5, 53 52 bytes
{b/({,/x,'y};{x@&y})[*"~"=y][b\.x;(b:20#2)\.z]}." "\

53-byte version:
{b/({,/x,'y};{x@&y})[*"¢~"?y][b\.x;(b:20#2)\.z]}." "\

Still needs a bit more golfing.

Haskell, 77
g=(`mod`2)
h=(`div`2)
0¢0=0
a¢b=g a+2*b¢h a
a?0=0
a?b=g a*g b+(1+g b)*h a?h b

input is given by applying the input to the functions/operators ? and ¢ defined in the code (Haskell can't define an operator ~ for technical reasons).
basically works the old recursive approach.

CJam, 61 50 46 41 34 bytes
Thanks @Dennis for pointing out a 4 bytes golf.
rrc'~=:X;r]{i2bF0e[}/.{X{{;}|}&}2b

Try it online.

]{}/ is a noop.

@Dennis Thanks. I should probably get some sleep...

C, 127 123 bytes + 5 penalty = 128
scanf counts the unicode symbol as more than one character which complicates things a lot, so I'm applying the 5-byte penalty for using $.
a,b,q,x,i;main(){scanf("%d %c %d",&a,&q,&b);for(i=65536;i/=2;)q%7?x=x*4|a/i*2&2|b/i&1:b/i&1&&(x=x*2|a/i&1);printf("%u",x);}

The changes from the original version are:
-The test for $ or ~ has been revised from q&2 to q%7. This reverses the true/false values, allowing the code for $ operator to go before the  : which means a set of parentheses can be eliminated.
-The i loop now counts down in powers of 2 which is longer, but permits >> to be substituted by / and saves some parentheses.
Original version 127 bytes
a,b,q,x,i;
main(){
  scanf("%d %c %d",&a,&q,&b);
  for(i=16;i--;)
    q&2?
      b>>i&1&&(x=x*2|a>>i&1):    // ~ operator. && used as conditional: code after it is executed only if code before returns truthy.
      (x=x*4|(a>>i&1)*2|b>>i&1); // $ operator
  printf("%u",x);
}

I went with a single loop with the conditionals inside to avoid the overhead of two loops. In both cases I rightshift the bits of the operands down to the 1's bit, and build up the result from the most significant to least significant bit, leftshifting the result (multiplying by 2 or 4) as I go.

I golfed it for you: main(a,b,q,x,i){scanf("%d %c %d",&a,&q,&b);for(i=16;i--;)q&2?b>>i&1&&(x=x2|a>>i&1):(x=x4|(a>>i&1)*2|b>>i&1);printf("%u",x);}
I tried golfing away the >>i&1 parts, but couldn't find a cost effective way to do it. I was able to save 1 character however by putting the variable definitions in main. Note: untested.

@LamdaBeta thanks, I couldn't find a macro for >>i&1 but I have managed to golf it another way. Putting the variables as arguments of main causes q to be corrupted on my machine, which is strange. I expect the real problem is with scanf, but because of that I have left them as normal declarations.

I hadn't thought of that. You are right, q will be corrupted. The reason is that while we learn that main takes two arguments, the count of command-line arguments and an array of the arguments itself, most systems actually provide a third argument (typically called char*envp[]) which describes the environment the code is run in (granting access to EG: environment variables). Thus the third value in main may also be assigned a value by the system, scanf is innocent this time.

@steveverill I think you can also remove the 5 byte penalty. I just tested your code (using ALT+155 to make ¢) and it seems to work fine. :)

@LambdaBeta actually experimentation shows it's a combination of both. With the normal declaration q is guaranteed to be zero, but with the declaration as a function parameter q contains 32-bit garbage. That wouldn't be a problem if I assigned a value to q, but scanf with "%c" only overwrites the least significant 8 bits of the garbage, leaving the other 24 undefined. I might get lucky on another compiler!

J, 173
f=:|."1@(>@(|.&.>)@(#:@{:;#:@{.))
m=:2&#.@:,@:|:@:|.@:f
s=:2&#.@#/@:f
a=:{&a.@-.
(1!:2)&2(s@".@:a&126)^:(126 e.i)((m@".@:a&194 162)^:(1 e.194 162 E.i)i=._1}.(a.i.((1!:1)3)))

expects one line of input
input expected to terminate after new line with EOF

Javascript ES6 (3 arguments) 141 138 136 121 119 bytes
b=x=>(65536|x).toString`2`
f=(x,o,y)=>+eval(`'0b'+(b(y)+b(x)).replace(/^1|${o=='~'?1:'(.)'}(?=.{16}(.)())|./g,'$2$1')`)

Test:
;[f(234,'¢',4321),f(2345,'~',7245)]=="16841865,37"

Javascript ES6 (1 argument) 135 133 bytes
b=x=>(65536|x).toString`2`
f=s=>([x,o,y]=s.split` `)|eval(`'0b'+(b(y)+b(x)).replace(/^1|${o=='~'?1:'(.)'}(?=.{16}(.)())|./g,'$2$1')`)

Test:
;[f('234 ¢ 4321'),f('2345 ~ 7245')]=="16841865,37"

PS: New line is counted as 1 byte as it can be replaced by ;.

0x10000 == 65536 (save 2 chars)

@edc65, I've updated the answer.

65536|x to avoid ~~

Only the second version is allowed - the input must be in the form of a space delimited string.

@isaacg, ok. But I don't want to delete the first for historical reasons.

@Qwertiy No problem. As long as you have a valid submission, that's fine.

Python 3, 157 bytes
a,x,y=input().split()
i=int
b=bin
print(i(''.join(([c for c,d in zip(b(i(a)),b(i(y)))if d=='1'],[c+d for c,d in zip(b(i(a))[2:],b(i(y))[2:])])['¢'==x]),2))

Full and explanatory version can be found on my pastebin.

You can same a few chars by removing spaces around '==' operator, before 'if' and by passing 'base' as positional argument.

Thank you, that and some others have saved 15 chars! but the doubled way of formatting the return is still to much.

Also, do you use 4 spaces per indent? One (or tab) is enough.

Yes, removed extra spaces and now also undoubled output formatting - almost got ya! ;-)

For more I would have to take your splitting into 3 variables and I refuse to do that - and would get to 174C. Thank you @TrangOul!

And a last space could be removed. Finally would it end up 173C - got ya! :-)

Feel free to use shorter answer. You can save a few chars by unassigning zip (only 2 uses => (len('zipzip') < len('z=zipzz'))) and even more by not wrapping code into a function.

Isn't code as a function a part of the game?

@BeowulfOF Unless otherwise specified, you can submit a full program or a function. Generally, which is shorter will depend on the way your language parses the specific input for the challenge (ruby is surprisingly clumsy with numbers from stdin for example). You also have two possible ways to output: stdout or return value, which are applicable to both (though return values from programs are rare.)

You only appear to use e once, can't you just inline it?

Vyxal, 201 bitsv2, 25.125 bytes
⌈sṫ£⌊vΠ:ḣ∆Z$tJvf⌊÷¥\¢=[Y|Tİ]B

Try it Online!
Bitstring:
110010100100100000011011100010011001001100101100100000110010011100111001000101011101011101101110001000110011011101000000100101011000110100110001000010010001101001011101001011100110111111100100110010111

Possibly golfable?

22

@emanresuA You can remove ₈²+ and vḢ and get the exact same results. Try it Online!

Mathematica, 155 bytes
f=IntegerDigits[#,2,16]&;
g=#~FromDigits~2&;
¢=g[f@#~Riffle~f@#2]&;
s=g@Cases[Thread@{f@#,f@#2},{x_,1}->x]&;
ToExpression@StringReplace[#,{" "->"~","~"->"s"}]&

Evaluates to an anonymous function taking the string as input. Line breaks added for clarity.
f and g convert to/from base 2. Riffle does exactly what interleave is supposed to. I wanted to use Select for select but Cases is better unfortunately. The last line is a bit of trickery; spaces are changed to ~ which is Mathematica's infix operator, then the string is eval'd.

Go, 186 bytes
func c(a,b uint)(o uint){for i:=0;i<16;i++{o|=(a&1<<(2*i+1))|(b&1<<(2*i))
a>>=1
b>>=1}
return}
func s(a,b uint)(o uint){for i,j:=0,0;i<16;i++{if b&1>0{o|=a&1<<j;j++}
a>>=1
b>>=1}
return}

Attempt This Online!
c is interleave, and s is select.
Explanations
Interleave
func c(a,b uint)(o uint){       // init return value in `o` with zero value
for i:=0;i<16;i++{              // for each bit (in the uint16)...
o|=                             // OR to `o`...
   (a&1                         // the last bit of `a`
       <<                       // shifted left by
         (2*i+1))               // the current bit * 2 + 1
                 |              // OR-ed with
                  (b&1          // the last bit of `b`
                      <<        // shifted left by
                        (2*i))  // the current bit * 2
a>>=1;b>>=1}                    // discard the last bit of `a` and `b`
return}

Select
func s(a,b uint)(o uint){ // init return value in `o` with zero value
for i,j:=0,0;i<16;i++{    // for each bit (in the uint16)...
if b&1==1{                // if the current bit in `b` is 1...
          o|=             // OR to `o`...
             a&1          // the last bit of `a`
                <<j       // shifted over by the number of 1s so far
                   ;j++}  // increment the number of 1s
a>>=1;b>>=1}              // discard last bit of `a` and `b`
return}

does this work with ¢ and ~

@Pacmanboss256 It does not, because it does not parse STDIN. These are 2 functions, each of which does the operations described in the OP. Doing input parsing as well would just add some code that would call this submission's code anyway.