12
1
Given the name of a cation and anion, output "S" (soluble) or "I" (insoluble). The table we will be using is from wikipedia: https://en.wikipedia.org/wiki/Solubility_chart. It is copied at the end of the question for future reference.
Input: The cation, followed by the anion, separated by a space. The cation will be one of the following:
Lithium Sodium Potassium Ammonium Beryllium Magnesium Calcium
Strontium Barium Zinc Iron(II) Copper(II) Aluminium Iron(III) Lead(II) Silver
and the anion will be one of the following:
Fluoride Chloride Bromide Iodide Carbonate Chlorate Hydroxide Cyanide Cyanate
Thiocyanate Nitrate Oxide Phosphate Sulfate Dichromate
Each will have its first letter capitalized.
Example Input: Sodium Chloride
Output: A truthy value, or S
, if it is soluble, falsey or I
otherwise. If the wikipedia page lists anything else (e.g. slightly soluble, or reacts with water) or if the input is not in the form "cation anion," your program may do anything (undefined behavior), so it may output 'S', 'I', or anything else.
Table:
?,S,S,S,?,S,S,S,?,S,S,?,I,S,S
S,S,S,S,S,S,S,S,S,S,S,?,S,S,S
S,S,S,S,S,S,S,S,S,S,S,?,S,S,S
S,S,S,S,S,S,S,S,?,S,S,?,S,S,S
S,S,S,?,?,?,?,?,?,?,S,?,?,S,?
?,S,S,S,I,S,I,?,?,?,S,I,I,S,I
I,S,S,S,I,S,?,S,?,?,S,?,I,?,I
?,S,S,S,I,S,S,?,?,?,S,?,?,I,?
?,S,S,S,I,S,S,S,?,?,S,?,?,I,?
?,S,S,S,I,S,I,I,?,?,S,I,I,S,I
S,S,S,S,I,S,I,?,?,?,S,I,I,S,I
?,S,S,?,I,S,I,?,?,I,S,I,I,S,I
S,S,S,?,?,S,I,?,?,?,S,I,I,S,I
?,S,S,?,?,S,I,?,?,?,S,I,I,?,I
?,?,?,I,I,S,I,?,?,?,S,I,I,I,?
S,I,I,I,I,S,?,I,I,?,S,?,I,?,I
The rows are cations in the order listed above and the columns are anions. For example, since Magnesium Iodide is soluble, and Magnesium was the 6th cation and Iodide was the 4th anion, the 6th row and 4th column has the character 'S'. The ?
indicates undefined behavior.
1I like this because the undefined behaviour of
?
s gives a lot of freedom in what algorithms one can use. – Jo King – 2018-08-07T03:57:49.4831@FryAmTheEggman Despite the
kolmogorov-complexity
tag, the challenge does not ask to output the table, but the correct value for a given (cation, anion) pair. – Arnauld – 2018-08-07T08:48:30.5534I removed the kolmogorov-complexity tag and added the decision-problem tag, since this isn't about creating a fixed (or partially fixed) output, but determining whether a certain input meets a some criteria. – Stewie Griffin – 2018-08-07T08:57:08.103
Would you consider allowing to output any 2 distinct consistent values rather than just
truthy
/'S'
orfalsy
/'I'
? – Arnauld – 2018-08-07T10:22:17.573I'd suggest dropping the "separated by a space" specification and instead saying something along the lines of "in addition to the site defaults, the two inputs may be accepted as a single input separated by a consistent unused character (e.g. a space)". Two inputs may allow more golfing creativity here (e.g. curried functions). – Jonathan Allan – 2018-08-07T13:24:31.307