“9Ḳ*!}ḣE’ṃ“¢£Æ¥Ø‘r2/;€"“ⱮḶıð’ḃ7¤µ⁵,12Ṭœṗ;"⁾LAṁ€15¤j“”$⁺³ị
Full program that prints the desired output.
Try it online! (A slightly modified program which prints all input : output
may be seen here).
How?
Builds a list of the 118 possible outputs and then picks the entry at the index of the input.
Some prep:
“9Ḳ*!}ḣE’ - base 250 number: 14334152882934570 (call this A)
“¢£Æ¥Ø‘ - a list using Jelly's code page: [1, 2, 13, 4, 18] (call this B)
“ⱮḶıð’ - base 250 number: 2354944025 (call this C)
The program (shortened by substituting A
, B
, and C
) :
AṃBr2/;€"Cḃ7¤µ⁵,12Ṭœṗ;"⁾LAṁ€15¤j“”$⁺³ị - Main link: atomicNumber
AṃB - number A with digits B: [1,1,18,18,1,2,13,18,1,2,13,18,1,18,1,18,1,2,4,18,1,2,4,18]
2/ - pair-wise reduce with
r - inclusive range: [[1],[18],[1,2],[13,14,15,16,17,18],[1,2],[13,14,15,16,17,18],[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18],[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18],[1,2],[4,5,6,7,8,9,10,11,12,13,14,15,16,17,18],[1,2],[4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]]
¤ - nilad followed by link(s) as a nilad:
C - number C
ḃ7 - converted to bijective base 7: [1,1,2,2,3,3,4,5,6,6,7,7]
" - zip with:
,€ - pair each: [[1,1],[18,1],[[1,2],[2,2]],[[13,2],[14,2],[15,2],[16,2],[17,2],[18,2]],[[1,3],[2,3]],[[13,3],[14,3],[15,3],[16,3],[17,3],[18,3]],[[1,4],[2,4],[3,4],[4,4],[5,4],[6,4],[7,4],[8,4],[9,4],[10,4],[11,4],[12,4],[13,4],[14,4],[15,4],[16,4],[17,4],[18,4]],[[1,5],[2,5],[3,5],[4,5],[5,5],[6,5],[7,5],[8,5],[9,5],[10,5],[11,5],[12,5],[13,5],[14,5],[15,5],[16,5],[17,5],[18,5]],[[1,6],[2,6]],[[4,6],[5,6],[6,6],[7,6],[8,6],[9,6],[10,6],[11,6],[12,6],[13,6],[14,6],[15,6],[16,6],[17,6],[18,6]],[[1,7],[2,7]],[[4,7],[5,7],[6,7],[7,7],[8,7],[9,7],[10,7],[11,7],[12,7],[13,7],[14,7],[15,7],[16,7],[17,7],[18,7]]]
µ - monadic chain separation (call the result x)
⁵ - 10
,12 - pair with 12: [10,12] 10↓ 12↓
Ṭ - truthy indexes: [0,0,0,0,0,0,0,0,0,1,0,1]
œṗ - partition x at the truthy indexes
- (the locations of the runs of L's and A's)
¤ - nilad followed by link(s) as a nilad:
⁾LA - ['L','A']
ṁ€15 - mould each like 15: [['L','L','L','L','L','L','L','L','L','L','L','L','L','L','L'],['A','A','A','A','A','A','A','A','A','A','A','A','A','A','A']]
" - zip with:
; - concatenation: [[[1,1],[18,1],[[1,2],[2,2]],[[13,2],[14,2],[15,2],[16,2],[17,2],[18,2]],[[1,3],[2,3]],[[13,3],[14,3],[15,3],[16,3],[17,3],[18,3]],[[1,4],[2,4],[3,4],[4,4],[5,4],[6,4],[7,4],[8,4],[9,4],[10,4],[11,4],[12,4],[13,4],[14,4],[15,4],[16,4],[17,4],[18,4]],[[1,5],[2,5],[3,5],[4,5],[5,5],[6,5],[7,5],[8,5],[9,5],[10,5],[11,5],[12,5],[13,5],[14,5],[15,5],[16,5],[17,5],[18,5]],[[1,6],[2,6]],'L','L','L','L','L','L','L','L','L','L','L','L','L','L','L'],[[[4,6],[5,6],[6,6],[7,6],[8,6],[9,6],[10,6],[11,6],[12,6],[13,6],[14,6],[15,6],[16,6],[17,6],[18,6]],[[1,7],[2,7]],'A','A','A','A','A','A','A','A','A','A','A','A','A','A','A'],[[4,7],[5,7],[6,7],[7,7],[8,7],[9,7],[10,7],[11,7],[12,7],[13,7],[14,7],[15,7],[16,7],[17,7],[18,7]]]
µ⁵,12Ṭœṗ;"⁾LAṁ€15¤j“”$⁺³ị
$ - last two links as a monad:
j“” - join with [''] (a workaround for no "flatten by 1")
⁺ - repeat last link (flatten once more): [[1,1],[18,1],[1,2],[2,2],[13,2],[14,2],[15,2],[16,2],[17,2],[18,2],[1,3],[2,3],[13,3],[14,3],[15,3],[16,3],[17,3],[18,3],[1,4],[2,4],[3,4],[4,4],[5,4],[6,4],[7,4],[8,4],[9,4],[10,4],[11,4],[12,4],[13,4],[14,4],[15,4],[16,4],[17,4],[18,4],[1,5],[2,5],[3,5],[4,5],[5,5],[6,5],[7,5],[8,5],[9,5],[10,5],[11,5],[12,5],[13,5],[14,5],[15,5],[16,5],[17,5],[18,5],[1,6],[2,6],'L','L','L','L','L','L','L','L','L','L','L','L','L','L','L',[4,6],[5,6],[6,6],[7,6],[8,6],[9,6],[10,6],[11,6],[12,6],[13,6],[14,6],[15,6],[16,6],[17,6],[18,6],[1,7],[2,7],'A','A','A','A','A','A','A','A','A','A','A','A','A','A','A',[4,7],[5,7],[6,7],[7,7],[8,7],[9,7],[10,7],[11,7],[12,7],[13,7],[14,7],[15,7],[16,7],[17,7],[18,7]]
³ - program's first input
ị - index into the list
5I just know that Mathematica will have a built-in for this... – Okx – 2017-03-17T08:49:02.360
@Okx, I'm hoping that the Lanthanides and Actinides mess up any built-ins :) – James Webster – 2017-03-17T08:50:06.587
2Are you allowed to return "6,L" and "7,A" for the Lanthanides and Actinides? – Neil – 2017-03-17T09:05:42.037
@Neil, No. Just "L" and "A" please. – James Webster – 2017-03-17T09:06:25.847
I assume trailing whitespace is fine? – Okx – 2017-03-17T11:08:14.357
1can't comment (yet) but sometimes Hydrogen is placed in group 17 - but I acknowledge that you've used an image to justify why group 1 and don't know if this makes things harder or easier? – sjb-2812 – 2017-03-17T10:58:10.427
can it be
L
? or it has to beL,
– Felipe Nardi Batista – 2017-03-17T12:05:12.4201
L
is fine. That's actually what I intended. But since the CSV outputtedL,
I'll accept both – James Webster – 2017-03-17T12:06:26.993Why not
L,#
for lanthanides (and analogous for actinides), where#
is the element's position within the Ln/An group? – hBy2Py – 2017-03-17T13:18:16.930@hBy2Py, because I came up with an arbitrary way to note those elements :P – James Webster – 2017-03-17T13:18:44.843
@James "Just because." Fair enough! :-) – hBy2Py – 2017-03-17T13:28:09.033
Is the comma as delimiter mandatory, or could we use (example) an underscore as delim? – aross – 2017-03-17T14:42:59.327
@sjb-2812 who is putting H in group 17? That's just wrong. – OrangeDog – 2017-03-17T15:39:24.430
@OrangeDog, with just one electron, is it the first electron in its shell? Or is it missing one from a complete shell? – James Webster – 2017-03-17T15:44:31.967
@JamesWebster does its chemical properties most closely resemble Na or Cl? Hint: H-Cl and Na-Cl are a lot more common than H-H and Na-H. You can (and Mendeleev did) construct the table with no knowledge of atomic structure at all. – OrangeDog – 2017-03-17T15:46:31.377
From what I remember of my high school chemistry, since it has properties of both the alkali metals and the halogens, it is both, yet neither. The books we had placed it in neither group but on its own. This might be better argued on Chemistry SE! – James Webster – 2017-03-17T15:57:28.537