Print the Periodic Table

40

7

Your challenge is to print/output/return this text:

 _____                                                                                                 _____
|  1  |                                                                                               |  2  |
|  H  |                                                                                               |  He |
|_____|_____                                                             _____________________________|_____|
|  3  |  4  |                                                           |  5  |  6  |  7  |  8  |  9  |  10 |
|  Li |  Be |                                                           |  B  |  C  |  N  |  O  |  F  |  Ne |
|_____|_____|                                                           |_____|_____|_____|_____|_____|_____|
|  11 |  12 |                                                           |  13 |  14 |  15 |  16 |  17 |  18 |
|  Na |  Mg |                                                           |  Al |  Si |  P  |  S  |  Cl |  Ar |
|_____|_____|___________________________________________________________|_____|_____|_____|_____|_____|_____|
|  19 |  20 |  21 |  22 |  23 |  24 |  25 |  26 |  27 |  28 |  29 |  30 |  31 |  32 |  33 |  34 |  35 |  36 |
|  K  |  Ca |  Sc |  Ti |  V  |  Cr |  Mn |  Fe |  Co |  Ni |  Cu |  Zn |  Ga |  Ge |  As |  Se |  Br |  Kr |
|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|
|  37 |  38 |  39 |  40 |  41 |  42 |  43 |  44 |  45 |  46 |  47 |  48 |  49 |  50 |  51 |  52 |  53 |  54 |
|  Rb |  Sr |  Y  |  Zr |  Nb |  Mo |  Tc |  Ru |  Rh |  Pd |  Ag |  Cd |  In |  Sn |  Sb |  Te |  I  |  Xe |
|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|
|  55 |  56 |  57 \  72 |  73 |  74 |  75 |  76 |  77 |  78 |  79 |  80 |  81 |  82 |  83 |  84 |  85 |  86 |
|  Cs |  Ba |  La /  Hf |  Ta |  W  |  Re |  Os |  Ir |  Pt |  Au |  Hg |  Tl |  Pb |  Bi |  Po |  At |  Rn |
|_____|_____|_____\_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|
|  87 |  88 |  89 / 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 |
|  Fr |  Ra |  Ac \  Rf |  Db |  Sg |  Bh |  Hs |  Mt |  Ds |  Rg |  Cn |  Nh |  Fl |  Mc |  Lv |  Ts |  Og |
|_____|_____|_____/_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|

                  ____________________________________________________________________________________ 
                  \  58 |  59 |  60 |  61 |  62 |  63 |  64 |  65 |  66 |  67 |  68 |  69 |  70 |  71 \
                  /  Ce |  Pr |  Nd |  Pm |  Sm |  Eu |  Gd |  Tb |  Dy |  Ho |  Er |  Tm |  Yb |  Lu /
                  \_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____\
                  /  90 |  91 |  92 |  93 |  94 |  95 |  96 |  97 |  98 |  99 | 100 | 101 | 102 | 103 /
                  \  Th |  Pa |  U  |  Np |  Pu |  Am |  Cm |  Bk |  Cf |  Es |  Fm |  Md |  No |  Lr \
                  /_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____/

Rules:

  • The empty line count between the two parts can be any amount (including 0)
  • Each line can have prepending and appending spaces as long as the two parts look correctly and the second part is indented at least one space more than the first one.
  • You may have appending/prepending newlines and/or spaces.
  • You may not use tabs for spacing (as long as there isn't an interpreter which replaces them correctly with spaces).
  • Because of a mistake of mine, you can choose to use ______ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ as the 1st line of the second part.

Data:

you can use this text as a reference (but not as input):
Contents: symbol, atomic number, group, period groups 8 & 9 and periods 4-17 are used for the second part.

H 1 1 1
He 2 18 1
Li 3 1 2
Be 4 2 2
B 5 13 2
C 6 14 2
N 7 15 2
O 8 16 2
F 9 17 2
Ne 10 18 2
Na 11 1 3
Mg 12 2 3
Al 13 13 3
Si 14 14 3
P 15 15 3
S 16 16 3
Cl 17 17 3
Ar 18 18 3
K 19 1 4
Ca 20 2 4
Sc 21 3 4
Ti 22 4 4
V 23 5 4
Cr 24 6 4
Mn 25 7 4
Fe 26 8 4
Co 27 9 4
Ni 28 10 4
Cu 29 11 4
Zn 30 12 4
Ga 31 13 4
Ge 32 14 4
As 33 15 4
Se 34 16 4
Br 35 17 4
Kr 36 18 4
Rb 37 1 5
Sr 38 2 5
Y 39 3 5
Zr 40 4 5
Nb 41 5 5
Mo 42 6 5
Tc 43 7 5
Ru 44 8 5
Rh 45 9 5
Pd 46 10 5
Ag 47 11 5
Cd 48 12 5
In 49 13 5
Sn 50 14 5
Sb 51 15 5
Te 52 16 5
I 53 17 5
Xe 54 18 5
Cs 55 1 6
Ba 56 2 6
La 57 3 6
Hf 72 4 6
Ta 73 5 6
W 74 6 6
Re 75 7 6
Os 76 8 6
Ir 77 9 6
Pt 78 10 6
Au 79 11 6
Hg 80 12 6
Tl 81 13 6
Pb 82 14 6
Bi 83 15 6
Po 84 16 6
At 85 17 6
Rn 86 18 6
Fr 87 1 7
Ra 88 2 7
Ac 89 3 7
Rf 104 4 7
Db 105 5 7
Sg 106 6 7
Bh 107 7 7
Hs 108 8 7
Mt 109 9 7
Ds 110 10 7
Rg 111 11 7
Cn 112 12 7
Nh 113 13 7
Fl 114 14 7
Mc 115 15 7
Lv 116 16 7
Ts 117 17 7
Og 118 18 7
Ce 58 4 8
Pr 59 5 8
Nd 60 6 8
Pm 61 7 8
Sm 62 8 8
Eu 63 9 8
Gd 64 10 8
Tb 65 11 8
Dy 66 12 8
Ho 67 13 8
Er 68 14 8
Tm 69 15 8
Yb 70 16 8
Lu 71 17 8
Th 90 4 9
Pa 91 5 9
U 92 6 9
Np 93 7 9
Pu 94 8 9
Am 95 9 9
Cm 96 10 9
Bk 97 11 9
Cf 98 12 9
Es 99 13 9
Fm 100 14 9
Md 101 15 9
No 102 16 9
Lr 103 17 9

Built-ins that give any info about the periodic table of elements are allowed but should be viewed separately from non-built-in solutions.
The shortest code per language wins!

dzaima

Posted 2017-03-31T13:40:16.250

Reputation: 19 048

Is it okay to invert the slashes (all of them)? Is it okay to make the cells bigger or smaller? – John Dvorak – 2017-03-31T13:45:46.350

@JanDvorak I'd say no as it changes the shape of the bottom portions joining – dzaima – 2017-03-31T13:48:56.477

@dzaima I'd change those slashes as well, of course – John Dvorak – 2017-03-31T13:49:35.480

@JanDvorak All that you can change is what's specified in the post. – dzaima – 2017-03-31T13:57:01.300

I was expecting a challenge to generate the electron shells of the known elements :) – JollyJoker – 2017-03-31T14:44:13.237

@JollyJoker I was thinking to make that an another challenge after this! – dzaima – 2017-03-31T14:46:18.700

The upper border of the lantanidies features a few whitespaces in between, while the upper borders in the main table doesn't. Is this intentional? – Victor Stafusa – 2017-03-31T15:28:09.040

@dzaima I think that allowing both is the best option since that was a mistake. – Victor Stafusa – 2017-03-31T15:52:35.677

3@dzaima Can we use the power of THE INTERNET? – Feathercrown – 2017-03-31T23:35:18.563

2

@Feathercrown pretty sure that counts as this standard loophole

– dzaima – 2017-04-01T10:13:38.833

@dzaima thought so :P – Feathercrown – 2017-04-02T00:10:41.040

1

@JollyJoker http://codegolf.stackexchange.com/questions/62030/electron-configuration-diagrams

– Beta Decay – 2017-04-03T16:25:41.057

2Working on a 400-ish byte answer that may blow everything out of the water... incoming in 10 days lol. – Magic Octopus Urn – 2017-06-07T14:15:26.550

7THOSE SLASHES ARE PURE EVIL. PURE EVIL I TELLS YA! – Magic Octopus Urn – 2017-06-08T15:14:39.043

The newline count between the two parts can be any amount. Is zero allowed as they are still separated? – l4m2 – 2018-07-12T08:49:26.370

@l4m2 if you mean 0 empty lines (as 0 newlines would mean the two lines are on the same line (which should be mentioned in the spec..)), yes – dzaima – 2018-07-12T08:52:57.787

You may not use tabs for spacing (as long as there isn't an interpreter which replaces them correctly with spaces). what if tabs before the second part so any amount of spaces was allowed – l4m2 – 2018-07-12T14:46:26.550

(if I interpreted your question correctly) no, tabs before the second part aren't allowed as tabs don't have a consistent defined width (besides, 1 space is enough so why bother with tabs?) – dzaima – 2018-07-12T15:06:46.963

Answers

13

Excel VBA, 1,023 1,020 990 983 975 595 495 494 Bytes

Full subroutine that takes no input and outputs the periodic table to the range [A1:R10] on the ActiveSheet object. Note that because Excel cannot implement squiggles on borders, (so far as I know) this implementation instead uses a colored red border to indicate the lanthanide and actinide series.

Sub p
Dim r as Range
For each r in[A1,R1,A2:B2,M2:R2,A3:B3,M3:R3,A4:R4,A5:R5,A6:C6,D9:Q9,D6:R6,A7:C7,D10:Q10,D7:R7]
i=i+1
r=i &vbLf+Trim(Mid("  HHeLiBe B C N O FNeNaMgAlSi P SClAr KCaScTi VCrMnFeCoNiCuZnGaGeAsSeBrKrRbSr YZrNbMoTcRuRhPdAgCdInSnSbTe IXeCsBaLaCePrNdPmSmEuGdTbDyHoErTmYbLuHfTa WReOsIrPtAuHgTlPbBiPoAtRnFrRaAcThPa UNpPuAmCmBkCfEsFmMdNoLrRfDbSgBhHsMtDsRgCnNhFlMcLvTsOg",2*i,2))
r.Borders.LineStyle=1
Next
[D6:D7,D9:D10,R9:R10].Borders(7).Color=255
[A:R].HorizontalAlignment=3
End Sub

-3 Bytes for Whitespace

-30 Bytes for changing Range("A1:R10") to [A1:R10], removing whitespace from all a "some stuff" calls, and changing delimiter from "," to " "

-7 Bytes for changing Range("D6:D7,D9:D10,R9:R10") to [D6:D7,D9:D10,R9:R10]

-8 Bytes for changing from String cell addresses to [...] wrapped cell references

-380 Bytes thanks to @Alexander (removed numbering from data and used a for loop instead)

-100 bytes for converting array to String and using Mid function

-1 byte for replacing  & with +

Output

PTable.xlsm

Taylor Scott

Posted 2017-03-31T13:40:16.250

Reputation: 6 709

5Doesn't implement the zig-zags... – boboquack – 2017-04-01T02:13:08.617

7@boboquack, I could not find a way to do zig-zags so in their place, I implemented a red line to indicate this difference; They are visible to the left of cells D6:D7 and D9:D10 – Taylor Scott – 2017-04-01T03:06:27.503

1@TaylorScott Is there anyway to automate the numbering in that string, to save room? – Alexander - Reinstate Monica – 2017-07-28T00:59:57.120

@Alexander, yes, there probably is. Let me check that out – Taylor Scott – 2017-07-31T12:01:18.537

@Alexander, there was, and that was a massive improvement (380 BYTES!!!) Thanks :) – Taylor Scott – 2017-07-31T15:22:00.167

1@TaylorScott IMO you should mark this as non-competing as it does not fully meet the reqs: including the slashes and you are not using the pipe chars. – FantaC – 2017-11-15T18:28:04.717

@tfbninja Excel, Excel VBA, and Google Sheets are all accepted languages that use the worksheet as alternate STDOUTS for codegolf. In general, if a challenge involves outputting a table of any kind it is accepted that these languages may output an actual table (unless there is a specific requirement to match an MD5 or similar hash). I have implemented replacements for both of your concerns including black borders in place of pipes and red in place of the slashes that you can see in the sample output above- Hope this helps :) – Taylor Scott – 2017-11-15T19:35:26.310

1

@tfbninja oh and one last note - the (non-competing) tag <s>is</s> was reserved for use on answers in which the language is newer than question - this rule has since been removed from the community but the more appropriate tag to suggest in this case would still have been a (cheating) or similar tag much like the one on my other answer to this question

– Taylor Scott – 2017-11-16T05:49:03.250

12

Bubblegum, 535 bytes

0000000: e0 0c 4a 02 0f 5d 00 10 17 f0 84 1b a9 df 70 5a  ..J..]........pZ
0000010: a9 c3 a0 9d ad 4f 8b 91 5d a2 33 5c b1 1d 4d 48  .....O..].3\..MH
0000020: 0d 80 c4 80 7f da b5 6f 8a 4a 45 20 34 51 d7 2c  .......o.JE 4Q.,
0000030: bc 47 4c ea c5 45 24 db a1 3d 46 42 e0 c8 51 ed  .GL..E$..=FB..Q.
0000040: b6 b8 2b fb 42 dd 7b 44 bc e2 bf a8 c8 80 be 8a  ..+.B.{D........
0000050: 30 2b e1 c7 39 c6 41 30 36 c6 c2 93 0b b2 ac 42  0+..9.A06......B
0000060: 06 5b bd b7 f9 40 11 9e 57 78 ff 0f 8a 45 f8 d7  .[...@..Wx...E..
0000070: b9 ea 6c 8a 6c e5 bf bb 9c f5 18 db 98 85 13 cc  ..l.l...........
0000080: d3 a8 38 9c 55 fe b2 f1 31 1d e0 0e 67 84 b6 48  ..8.U...1...g..H
0000090: 8e 68 2a 8a c6 99 0a 13 1b 10 f0 b5 e2 e0 43 02  .h*...........C.
00000a0: 6f 52 b0 3e d5 27 a9 eb a4 99 4e b2 c2 8b 51 49  oR.>.'....N...QI
00000b0: 9b 7e 46 99 22 31 4f 8c 70 6d 16 b4 a7 79 01 08  .~F."1O.pm...y..
00000c0: 42 01 a8 af 98 d1 38 d3 77 35 c9 3f fc f5 ae 88  B.....8.w5.?....
00000d0: 47 be 91 a0 ab ac ab b7 04 9a fc 81 60 92 61 a1  G...........`.a.
00000e0: 54 f9 92 46 2f bd 70 20 ba dc 29 63 35 29 c4 48  T..F/.p ..)c5).H
00000f0: be ee 7f 3d d6 8c 1e b9 f3 ab 17 23 0e 1d 86 2c  ...=.......#...,
0000100: d4 28 ce 4a 46 df 6e 3a c3 25 7d 3f 1b e4 3c 03  .(.JF.n:.%}?..<.
0000110: c9 1f 38 96 30 1e c9 6e de fa 26 8f a1 59 18 69  ..8.0..n..&..Y.i
0000120: 68 9a 35 c4 42 56 2a 6f b2 3b 3f b3 ae 60 96 a8  h.5.BV*o.;?..`..
0000130: 5d c4 9d 0d cc 0b d6 ec b9 58 28 d3 3c bb 0d f3  ]........X(.<...
0000140: b6 56 1d b2 f8 da 3b f1 3c 11 9e e7 56 c8 20 27  .V....;.<...V. '
0000150: 76 65 3e d9 1e 17 e5 d2 4f 65 8e 83 c2 27 5a bf  ve>.....Oe...'Z.
0000160: 1f 80 bf f4 4b 78 b0 0e 3f 1e 4d 96 63 b9 65 5a  ....Kx..?.M.c.eZ
0000170: 34 43 c8 9a a9 8e 62 5a cc af ab 10 ff 26 1f ae  4C....bZ.....&..
0000180: 03 ef 4c 8f ba 09 b8 1e 7a 1e bb 5d 77 d3 f8 06  ..L.....z..]w...
0000190: 71 53 67 60 26 91 28 81 2e 5e bc 84 9f 48 cc ce  qSg`&.(..^...H..
00001a0: 60 ec b4 b3 fa 27 32 60 27 98 63 a3 80 66 65 d2  `....'2`'.c..fe.
00001b0: ed 0b af e7 ba d1 d8 85 d3 af 93 7f a2 48 15 68  .............H.h
00001c0: a8 78 74 f8 ed 6f 6b 25 5f ca 7d 28 fb 0c 94 ce  .xt..ok%_.}(....
00001d0: 7a fc 6e b6 32 88 6a 62 b3 84 b8 98 d3 b9 01 73  z.n.2.jb.......s
00001e0: e4 76 07 3e 4e a0 15 82 1b 4a e1 89 13 75 4c ee  .v.>N....J...uL.
00001f0: 09 06 05 75 cc 0a 51 88 38 31 f6 7e e8 f8 74 b7  ...u..Q.81.~..t.
0000200: 59 9c e6 00 53 4f e7 80 ae 8c a5 85 55 e7 08 ae  Y...SO......U...
0000210: 84 69 18 84 dc c0 00                             .i.....

Uses LZMA compression.

Try it online!

Dennis

Posted 2017-03-31T13:40:16.250

Reputation: 196 637

2Polite query; is using a language you invented yourself considered cheating?! (Even if it's categorised under 'joke languages'?!) – Grim – 2017-03-31T15:28:30.097

9@Grim No, it's not cheating since the language existed before the challenge. Many many many users use their own languages (including me). – James – 2017-03-31T15:31:25.177

15Unfortunately, many many many users (including myself) don't have a clue what you code golfers are on about 99% of the time! Still makes interesting reading though :D – Grim – 2017-03-31T15:35:15.993

@Grim IMO it's not considered cheating, why would someone create a programming language other than to use it? – ASCII-only – 2017-04-06T01:05:23.907

8To sell it. $$$! – CalculatorFeline – 2017-04-09T20:57:46.530

@CalculatorFeline so that's what happens to the Try It Online donations... – caird coinheringaahing – 2017-07-26T00:17:44.130

9

Ruby, 567 558 bytes

a=[?|]*21
j=r=0
118.times{|i|a[r]+="%4s |"%("%-2d"%-~i)
a[r+1]+="  #{'H HeLiBeB C N O F NeNaMgAlSiP S ClArK CaScTiV CrMnFeCoNiCuZnGaGeAsSeBrKrRbSrY ZrNbMoTcRuRhPdAgCdInSnSbTeI XeCsBaLaCePrNdPmSmEuGdTbDyHoErTmYbLuHfTaW ReOsIrPtAuHgTlPbBiPoAtRnFrRaAcThPaU NpPuAmCmBkCfEsFmMdNoLrRfDbSgBhHsMtDsRgCnNhFlMcLvTsOg'[i*2,2]} |"
a[r+2]+=?_*5+?|
i>j&&(j+=(r/6+2)**2*2;r+=3)}
a<<' '+?_*84
6.times{|r|a[r+3][13]=' _'[r/5]*59+?|+d='  _'[r%3]
r<3&&a[r][7]=d*5+' '*61+d*29+?|+d
a[r+=15][18]=a[r][102]='/\\'[r%2]
a<<' '+a[r][18,85]
a[r][18,84]=''}
puts ' _____'+' '*97+?_*5,a

Try it online!

Brought the La/Ac series closer to the main table (re reading of the rules suggests it's allowed; rearranged formatting section so d is used immediately when calculated; and next row calculated mathematically instead of by regex.

Ruby, 587

score excludes 3 unnecessary newlines added for clarity

a=[?|]*21
r=0

118.times{|i|
a[r]+="%4s |"%("%-2d"%(i+1))
a[r+1]+="  #{e='H HeLiBeB C N O F NeNaMgAlSiP S ClArK CaScTiV CrMnFeCoNiCuZnGaGeAsSeBrKrRbSrY ZrNbMoTcRuRhPdAgCdInSnSbTeI XeCsBaLaCePrNdPmSmEuGdTbDyHoErTmYbLuHfTaW ReOsIrPtAuHgTlPbBiPoAtRnFrRaAcThPaU NpPuAmCmBkCfEsFmMdNoLrRfDbSgBhHsMtDsRgCnNhFlMcLvTsOg'[i*2,2]} |"
a[r+2]+="_____|"
"HeNeArKrXeRn"=~/#{e}/&&r+=3}

6.times{|r|d='  _'[r%3]
r<3&&a[r][7]=d*5+' '*61+d*29+?|+d
a[r+3][13]=' _'[r/5]*59+?|+d
a[r+15][18]=a[r+15][102]='\//'[r%2]
a[r+23]=' '*18+a[r+15][18,85]
a[r+15][18,84]=''}

a[22]=' '*18+?_*84
puts ' _____'+' '*97+?_*5,a

Explanation

The idea is to produce the following, then modify it by adding the correct padding and formatting, and moving the lanthanides and actinides to the bottom.

|  1  |  2  |
|  H  |  He |
|_____|_____|
|  3  |  4  |  5  |  6  |  7  |  8  |  9  |  10 |
|  Li |  Be |  B  |  C  |  N  |  O  |  F  |  Ne |
|_____|_____|_____|_____|_____|_____|_____|_____|
|  11 |  12 |  13 |  14 |  15 |  16 |  17 |  18 |
|  Na |  Mg |  Al |  Si |  P  |  S  |  Cl |  Ar |
|_____|_____|_____|_____|_____|_____|_____|_____|
|  19 |  20 |  21 |  22 |  23 |  24 |  25 |  26 |  27 |  28 |  29 |  30 |  31 |  32 |  33 |  34 |  35 |  36 |
|  K  |  Ca |  Sc |  Ti |  V  |  Cr |  Mn |  Fe |  Co |  Ni |  Cu |  Zn |  Ga |  Ge |  As |  Se |  Br |  Kr |
|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|
|  37 |  38 |  39 |  40 |  41 |  42 |  43 |  44 |  45 |  46 |  47 |  48 |  49 |  50 |  51 |  52 |  53 |  54 |
|  Rb |  Sr |  Y  |  Zr |  Nb |  Mo |  Tc |  Ru |  Rh |  Pd |  Ag |  Cd |  In |  Sn |  Sb |  Te |  I  |  Xe |
|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|
|  55 |  56 |  57 |  58 |  59 |  60 |  61 |  62 |  63 |  64 |  65 |  66 |  67 |  68 |  69 |  70 |  71 |  72 |  73 |  74 |  75 |  76 |  77 |  78 |  79 |  80 |  81 |  82 |  83 |  84 |  85 |  86 |
|  Cs |  Ba |  La |  Ce |  Pr |  Nd |  Pm |  Sm |  Eu |  Gd |  Tb |  Dy |  Ho |  Er |  Tm |  Yb |  Lu |  Hf |  Ta |  W  |  Re |  Os |  Ir |  Pt |  Au |  Hg |  Tl |  Pb |  Bi |  Po |  At |  Rn |
|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|
|  87 |  88 |  89 |  90 |  91 |  92 |  93 |  94 |  95 |  96 |  97 |  98 |  99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 |
|  Fr |  Ra |  Ac |  Th |  Pa |  U  |  Np |  Pu |  Am |  Cm |  Bk |  Cf |  Es |  Fm |  Md |  No |  Lr |  Rf |  Db |  Sg |  Bh |  Hs |  Mt |  Ds |  Rg |  Cn |  Nh |  Fl |  Mc |  Lv |  Ts |  Og |
|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|

Commented code

a=[?|]*21                                #setup array with |s for left hand side
r=0                                      #row counter

118.times{|i|                            #For each element add to the correct row
a[r]+="%4s |"%("%-2d"%(i+1))             #the atomic number
a[r+1]+="  #{e='H HeLiBeB C N O F NeNaMgAlSiP S ClArK CaScTiV CrMnFeCoNiCuZnGaGeAsSeBrKrRbSrY ZrNbMoTcRuRhPdAgCdInSnSbTeI XeCsBaLaCePrNdPmSmEuGdTbDyHoErTmYbLuHfTaW ReOsIrPtAuHgTlPbBiPoAtRnFrRaAcThPaU NpPuAmCmBkCfEsFmMdNoLrRfDbSgBhHsMtDsRgCnNhFlMcLvTsOg'[i*2,2]} |"
a[r+2]+="_____|"                         #the element symbol and the blank space at the bottom.
"HeNeArKrXeRn"=~/#{e}/&&r+=3}            #If it is element from last column, increment r

6.times{|r|d='  _'[r%3]                  #What symbol (_ or space)do we need to pad?
r<3&&a[r][7]=d*5+' '*61+d*29+?|+d        #Move He to the right
a[r+3][13]=' _'[r/5]*59+?|+d             #Move row 2&3 elements to the right
a[r+15][18]=a[r+15][102]='\//'[r%2]      #Draw breaks for La and Ac series
a[r+23]=' '*18+a[r+15][18,85]            #Copy La and Ac series 
a[r+15][18,84]=''}                       #Delete original La and Ac series from main table

a[22]=' '*18+?_*84                       #Draw top on La and Ac series
puts ' _____'+' '*97+?_*5,a              #Output top of row 1, followed by array containing the rest of the table.

Level River St

Posted 2017-03-31T13:40:16.250

Reputation: 22 049

1IMO it should be allowed to leave the rare earths inline. What would be your score in that version? – ceased to turn counterclockwis – 2017-04-01T08:59:43.117

I just commented the code. I could delete a[r+15][18]=a[r+15][102]='\//'[r%2];a[r+23]=' '*18+a[r+15][18,85];a[r+15][18,84]='' saving 83 bytes, and possibly a[22]=' '*18+?_*84 On the other hand I would have to put a gap in rows 4 and 5 above the rare earths so there would be additional code for that. It's difficult to say what the score would be without doing it but it would be shorter. – Level River St – 2017-04-01T09:22:57.610

9

JavaScript (ES6), 756 750 bytes

j=i=1
r=s=>s[0].replace(/.(\d+)/g,(s,n)=>s[0].repeat(n))
f=s=>[(s=s[0].match(/../g)).map(_=>(i>99?` `:`  `)+i+(i++>9?` `:`  `)),s.map(s=>`  ${s} `),s.map(_=>r`_5`)].map(a=>a.join`|`)
g=(a,b,c)=>a.map((s,i)=>s+b[i]+c[i])
document.write(r`<pre> _5 97_5
|`+[...g(f`H `,[s=r`| 95|`,s,r`|_5 61_29|`],f`He`),...g(f`LiBe`,[s=r`| 59|`,s,s],f`B C N O F Ne`),...g(f`NaMg`,[s,s,r`|_59|`],f`AlSiP S ClAr`),...f`K CaScTiV CrMnFeCoNiCuZnGaGeAsSeBrKr`,...f`RbSrY ZrNbMoTcRuRhPdAgCdInSnSbTeI Xe`,...g(f`CsBaLa`,(a=f`CePrNdPmSmEuGdTbDyHoErTmYbLu`,`\\/\\`),f`HfTaW ReOsIrPtAuHgTlPbBiPoAtRn`),...g(f`FrRaAc`,(a=[...a,...f`ThPaU NpPuAmCmBkCfEsFmMdNoLr`],`/\\/`),f`RfDbSgBhHsMtDsRgCnNhFlMcLvTsOg`)].join`|
|`+r`|

 18_84
 `+a.map(s=>r` 17`+`\\/`[j^=1]+s+`\\/`[j]).join`
 `)

Explanation:

  • a contains the (formatted) Lanthanides and Actinides
  • j is used to track which character is used to draw the zigzag of the Lanthanides and Actinides
  • i is simply the number of the next element to be formatted. Although it's not strictly necessary to format the elements in order, I think there's a small byte saving in doing so.
  • r is a run-length decoding function. It expects to be called using a template string parameter. Any number in the string causes the preceding character to be repeated that many times, e.g. r`_5` is the same as `_____` (but 2 bytes shorter of course). I did originally have a more sophisticated version that could handle r`${i<100} `+i+r`${i++<10} ` but it turned out to be shorter to keep that as a special case.
  • f is an element formatting function. It expects to be called using a template string parameter that contains the elements as pairs of characters (space padded out for single-character element names). An array of three strings is returned, one for the element numbers, one for the element names, and one for the underlines. If more than one element is formatted, they are joined with a | separator.
  • g is a glue function. It expects to be called with three arrays (the second and third parameters can be strings if only one character is needed) and returns a single array with all the corresponding strings concatenated together.

The first three rows of elements are handled by gluing the formatted elements from each side with an appropriate amount of space. The fourth and fifth rows need no glue. The sixth and seventh rows are handled by gluing the formatted elements from each side with the appropriate zigzag. The 21 rows are then joined together with | borders and newlines. Meanwhile the 6 rows of the Lanthanides and Actinides are given their padding and zigzag and joined together with newlines. Finally the pieces are concatenated with the necessary remaining formatting elements. Edit: Saved 6 bytes because I forgot to substitute literal newlines after developing the code.

If a full table with the Lanthanides and Actinides in situ is acceptable, then for 556 bytes:

document.write(`<pre>`+[[/\w./g,`|  $& |`],[/\|\|/g,`|`],[/(.*)-(.*)/g,(_,l,r)=>l+` `.repeat(193-r.length-l.length)+r],[/\n.*/g,s=>s.replace(/ \w./g,_=>(++i<100?` `:``)+i+(i<10?` `:``))+s+s.replace(/  \w. /g,`_____`)],[/ {5}(?=[^]{191}\d)/g,`_____`],[/_ _/g,`___`]].reduce((s,[r,t])=>s.replace(r,t),`-
H -He
LiBe-B C N O F Ne
NaMg-AlSiP S ClAr
K CaSc-TiV CrMnFeCoNiCuZnGaGeAsSeBrKr
RbSrY -ZrNbMoTcRuRhPdAgCdInSnSbTeI Xe
CsBaLaCePrNdPmSmEuGdTbDyHoErTmYbLuHfTaW ReOsIrPtAuHgTlPbBiPoAtRn
FrRaAcThPaU NpPuAmCmBkCfEsFmMdNoLrRfDbSgBhHsMtDsRgCnNhFlMcLvTsOg`,i=0))

Explanation: A string contains the list of elements with - and newline added as formatting elements. A number of replacements are used to transform the list of elements into the desired table.

  1. Each element is padded inside a pair of |s.
  2. Consecutive |s are then deleted.
  3. -s are replaced with enough padding to result in a width of 193 characters.
  4. Each line after the first is then replaced with three lines:
    1. A line with all the elements replaced with consecutive integers
    2. The original line of elements
    3. A line with all the elements replaced with _s.
  5. Each integer then has _s placed above it (if it doesn't already have them)
  6. Space-separated _s are joined with _s.

I could probably save a few more bytes using the widely available padStart and padEnd methods.

Neil

Posted 2017-03-31T13:40:16.250

Reputation: 95 035

Great! Thanks! My tiny suggestion: replace 19_84 ``+a.map(s=>r`` 18 to 18_84 ``+a.map(s=>r`` 17. It's does not affect the code length. – mazzy – 2018-07-18T09:19:59.557

1@mazzy Huh, I hadn't even noticed that. Thanks! – Neil – 2018-07-18T09:26:49.820

8

C, 1415 1401 1395 1367 1345 1277 1159 1052 1043 bytes

#define P printf(
#define L;P"|\n")
#define M;p(18," ")
#define D L;B
#define K;P"\\\n")M;P
#define Q;P"|%59c",32)
char*l="HHeLiBeBCNOFNeNaMgAlSiPSClArKCaScTiVCrMnFeCoNiCuZnGaGeAsSeBrKrRbSrYZrNbMoTcRuRhPdAgCdInSnSbTeIXeCsBaLaTaWReOsIrPtAuHgTlPbBiPoAtRnFrRaAcDbSgBhHsMtDsRgCnNhFlMcLvTsOgPrNdPmSmEuGdTbDyHoErTmYbLuPaUNpPuAmCmBkCfEsFmMdNoLr",U[]="|_____",*u=U+1;a;p(n,s)int*s;{while(n--)P s);}A(n){for(n+=a;a<n;++a)P a>9?"%c%4d ":"%c%3d  ",a^72*a^58?a^90*a^104?'|':47:92,a);}B(n){for(;n--;P"%c ",*l>96?*l++:32))P"|%3c",*l++);}N(){A(18)D(18)L;p(18,U)L;}f(){P" %s%102s\n",u,u);A(a=1);P"|%95c",32);A(1)D(1);P"|%95c",32);B(1)L;P"%s%-67s",U,U);p(5,u);P"____%s|\n",U);A(2)Q;A(6)D(2)Q;B(6)L;p(2,U)Q;p(6,U)L;A(2)Q;A(6)D(2)Q;B(6)L;P"|%s|%s|",u,u);p(11,u);P u+1);p(6,U)L;N(N());A(3);a=72;A(15)D(3);P"/  Hf ");B(14)L;p(3,U);P"\\%s",u);p(14,U)L;A(3);a=104;A(15)D(3);P"\\  Rf ");B(14)L;p(3,U);P"/%s",u);p(14,U)L;P"\n")M;p(84,"_");P"\n")M;a=58;A(14)K"/  Ce ");B(13);P"/\n")M;P"\\%s",u);p(13,U)K"");a=90;A(14);P"/\n")M;P"\\  Th ");B(13)K"/%s",u);p(13,U);P"/");}

Thanks to @Conor O'Brien for saving 6 bytes!

Thanks to @Zacharý for saving 22 90 bytes!

Thanks to @gastropner for saving 118 225 bytes!

Thanks to @ceilingcat for saving 8 9 bytes!

Try it online!

Unrolled (1159 bytes version):

#define P printf(
#define L;P"|\n")
#define M;p(18," ")
#define D L;B
#define N(n)A(n,n+18)D(18)L;p(18,U)L;
#define K;P"\\\n")M;P
#define C char
#define Q;P"|%*c",59,32)
C*u,
*l,
*U="|_____",
S[4];

p(n,s)C*s;
{
    P s,
    --n&&p(n,s));
}

b(k)
{
    k=P"|  %s",S);
    P"%*c",6-k,32);
}

e(s)C*s;
{
    *s++=*l++;
    *s=*l>96?*l++:0;
}

A(a,n)
{
    for(;a<n;++a)
        P a>9?"|%4d ":"|%3d  ",a);
}

B(n)
{
    for(;n--;)
        b(e(S));
}

f()
{
    u=U+1;
    l="HHeLiBeBCNOFNeNaMgAlSiPSClArKCaScTiVCrMnFeCoNiCuZnGaGeAsSeBrKrRbSrYZrNbMoTcRuRhPdAgCdInSnSbTeIXeCsBaLaTaWReOsIrPtAuHgTlPbBiPoAtRnFrRaAcDbSgBhHsMtDsRgCnNhFlMcLvTsOgPrNdPmSmEuGdTbDyHoErTmYbLuPaUNpPuAmCmBkCfEsFmMdNoLr";
    P" %s%*s\n",u,102,u);
    A(1,2);
    P"| %*c",94,32);
    A(2,3)
    D(1);
    P"| %*c",94,32);
    B(1)L;
    P"%s%s%*c",U,U,61,32);
    p(5,u);
    P"____%s|\n",U);
    A(3,5)Q;
    A(5,11)
    D(2)Q;
    B(6)L;
    p(2,U)Q;
    p(6,U)L;
    A(11,13)Q;
    A(13,19)
    D(2)Q;
    B(6)L;
    P"|%s|%s|",u,u);
    p(11,u);
    P u+1);
    p(6,U)L;
    N(19)
    N(37)
    A(55,58);
    P"\\  72 ");
    A(73,87)
    D(3);
    P"/  Hf ");
    B(14)L;
    p(3,U);
    P"\\%s",u);
    p(14,U)L;
    A(87,90);
    P"/ 104 ");
    A(105,119)
    D(3);
    P"\\  Rf ");
    B(14)L;
    p(3,U);
    P"/%s",u);
    p(14,U)L;
    P"\n")M;
    p(84,"_");
    P"\n")M;
    P"\\  58 ");
    A(59,72)
    K"/  Ce ");
    B(13);
    P"/\n")M;
    P"\\%s",u);
    p(13,U)
    K"/  90 ");
    A(91,104);
    P"/\n")M;
    P"\\  Th ");
    B(13)
    K"/%s",u);
    p(13,U);
    P"/");
}

Steadybox

Posted 2017-03-31T13:40:16.250

Reputation: 15 798

You can save at least 1 byte by reducing the space count before the 2nd part as it just has to be one space longer than the 1st part – dzaima – 2017-03-31T19:53:05.287

@dzaima Thanks, but I think it looks much nicer when the second part is aligned with the first. – Steadybox – 2017-03-31T20:35:14.737

You can save 2 bytes by #defineing char* – Conor O'Brien – 2017-03-31T20:52:56.133

1@ConorO'Brien 6 bytes, actually. Thanks! – Steadybox – 2017-03-31T21:06:20.840

1

And ... you forgot three printf( occurrences, here is a link to your code with those three occurrences replaced with the P macro: https://repl.it/Jeat/1

– Zacharý – 2017-07-23T14:58:56.067

1

Even more bytes can be shaved by #define-ing ;L;B: https://repl.it/Jeat/3

– Zacharý – 2017-07-23T15:17:58.317

1

Sorry for all the spamming, but I got it down to 1,277 with extreme macro abuse https://repl.it/Jeat/9.

– Zacharý – 2017-07-29T13:53:06.497

@Zacharý That's quite impressive! – Steadybox – 2017-08-07T04:44:56.930

1

Found a few more things to squeeze to get it to 1157

Code and changes

– gastropner – 2017-11-15T16:33:47.567

I was too hasty it seems! 1159 after having made f() reusable again: Code

– gastropner – 2017-11-15T17:19:50.997

@gastropner Thanks! 118 bytes shorter, that's quite an improvement! – Steadybox – 2017-11-15T17:25:54.623

1

-107 for 1052 Code

– gastropner – 2017-11-16T21:35:02.207

1016 bytes – ceilingcat – 2020-02-16T06:58:28.767

7

05AB1E, 517 500 494 459 458 bytes

¾36ו=∊à¢[ΔζÃΓÖo›àƶØ4.æßðùùO∊ŸßeÑΘ²9Êλ*βUθÇΔn4üÁ¬₁÷6öć®λJƒÐtvý¢ƶ³≠qΣĆ}εùeÆv]_|ˆ±q₅yÜƵтY¿в{àéÙ•4B«S2ôvyć'#×s'@×})˜2ôvyDJ'@åi'_©5×ëð5×}‚˜.C.B}})18ôvyøvy'|ý2F'|3úûð7×:}D4£ð4×Êi'|ëð}.ø}})ø„ #„_#:ø»…  _û®5×:…__ 2ú®5×:„_ û®3×:.•$›“₄≠÷/¤¿M5PËð—ΓY¢ö>7*ƒße∞™¶£nˆU‘´¾Ã‹Š\S¬ǝüÑ;:œ η|9HœÇâ`η_т<%£¾ÉöJ₄ª"eÄŸµ2ƶ3^_Ω~Ç∍”pgH¤δ%6ΣŽΔΔ9üηΩ+₃¹ºι"¤Qy¶O£ÄˆU«AJdc=ûö÷O´η,lð¢ʒƵy•v'@y.;}57L72 89Ÿ«Ƶ3ƵHŸ«58 71Ÿ«90Ƶ2Ÿ«Jv'#y.;}"57 |""57 $":¶¡ø'$'|6×2úRû©¦«„/\3×2úR.∞:®'|6ׄ\/3×3ú«:ø»™

Try it online!

-10ish thanks to Emigna

Lets out a long guttural victory screech... Will golf more, but since it's still the shortest...


The Basic Idea

11 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 12
12 12 00 00 00 00 00 00 00 00 00 00 11 11 11 11 11 22
22 22 00 00 00 00 00 00 00 00 00 00 22 22 21 21 22 22
21 22 22 22 21 22 22 22 22 22 22 22 22 22 22 22 22 22
22 22 21 22 22 22 22 22 22 22 22 22 22 22 22 22 21 22
22 22 22 22 22 21 22 22 22 22 22 22 22 22 22 22 22 22
22 22 22 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 22 22 22 22 22 22 22 22 22 22 22 22 22 22 00
00 00 00 22 22 21 22 22 22 22 22 22 22 32 32 32 32 00

I mapped out each of the squares with the first digit being the length of the number and the second digit being the length of the element name. Used this to create the skeleton (if .C and .B didn't exist this would easily be 300-400 bytes):

 _____                                                                                                 _____ 
|  #  |                                                                                               |  #  |
|  @  |                                                                                               |  @@ |
|_____|_____                                                             _____________________________|_____|
|  #  |  #  |                                                           |  #  |  #  |  #  |  #  |  #  |  ## |
|  @@ |  @@ |                                                           |  @  |  @  |  @  |  @  |  @  |  @@ |
|_____|_____|                                                           |_____|_____|_____|_____|_____|_____|
|  ## |  ## |                                                           |  ## |  ## |  ## |  ## |  ## |  ## |
|  @@ |  @@ |                                                           |  @@ |  @@ |  @  |  @  |  @@ |  @@ |
|_____|_____|___________________________________________________________|_____|_____|_____|_____|_____|_____|
|  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |
|  @  |  @@ |  @@ |  @@ |  @  |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |
|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|
|  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |
|  @@ |  @@ |  @  |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @  |  @@ |
|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|
|  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |
|  @@ |  @@ |  @@ |  @@ |  @@ |  @  |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |
|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|
|  ## |  ## |  ## | ### | ### | ### | ### | ### | ### | ### | ### | ### | ### | ### | ### | ### | ### | ### |
|  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |
|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|


                   ___________________________________________________________________________________       
                  |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |      
                  |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |      
                  |_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|      
                  |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## |  ## | ### | ### | ### | ### |      
                  |  @@ |  @@ |  @  |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |  @@ |      
                  |_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|      

This is what the first half of the code accomplishes...

05AB1E, 229 bytes

0 36ו=∊à¢[ΔζÃΓÖo›àƶØ4.æßðùùO∊ŸßeÑΘ²9Êλ*βUθÇΔn4üÁ¬₁÷6öć®λJƒÐtvý¢ƶ³≠qΣĆ}εùeÆv]_|ˆ±q₅yÜƵтY¿в{àéÙ•4B«S2ôvyć'#×s'@×})˜2ôvyDJ'@åi'_5×ëð5×}‚˜.C.B}})18ôvyøvy'|ý2F"   |"ûð7×.:}D4£ð4×Êi'|ëð}.ø}})ø„ #„_#:ø»…  _û'_5×:"  __ "'_5×:„_ û'_3×:

Try it online!

Through ugly one-off manipulation and other bullshit that shouldn't exist, I manage to piece together the entire skeleton.


The next part is basically "insert the massive string of letters and numbers that represent the elements". I essentially just compressed, sequentially, all of the letters:

.•$›“₄≠÷/¤¿M5PËð—ΓY¢ö>7*ƒße∞™¶£nˆU‘´¾Ã‹Š\S¬ǝüÑ;:œ η|9HœÇâ`η_т<%£¾ÉöJ₄ª"eÄŸµ2ƶ3^_Ω~Ç∍”pgH¤δ%6ΣŽΔΔ9üηΩ+₃¹ºι"¤Qy¶O£ÄˆU«AJdc=ûö÷O´η,lð¢ʒƵy•

To get:

hhelibebcnofnenamgalsipsclarkcasctivcrmnfeconicuzngageassebrkrrbsryzrnbmotcrurhpdagcdinsnsbteixecsbalahftawreosirptauhgtlpbbipoatrnfrraacrfdbsgbhhsmtdsrgcnnhflmclvtsogceprndpmsmeugdtbdyhoertmybluthpaunppuamcmbkcfesfmmdnolr

You then see me iterate replacing all @ symbols with the appropriate letter (at the end, after placing them all in their appropriate positions, it allows me to use "Title Cased" for the capitals, as each element is separated by whitespace).


Next I make the number string and do the same thing (thanks Emigna):

57L72 89Ÿ«Ƶ3ƵHŸ«58 71Ÿ«90Ƶ2Ÿ«J

Results in:

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657727374757677787980818283848586878889104105106107108109110111112113114115116117118585960616263646566676869707190919293949596979899100101102103

Which I then iterate and replace each # with.


After this, the final annoyance was the slashes... My god...

"57 |""57 $":¶¡ø'$'|6×2úRû©¦«"\/\/\/  ".∞.;®'|6×"   \/\/\/"«.;ø»

This 50 byte monstrosity is what I want to fix, along with multiple other small things... So I'll continue to golf, and until I fix the things I want to this will be the informal explanation.

Magic Octopus Urn

Posted 2017-03-31T13:40:16.250

Reputation: 19 422

10 36 to ¾36. 104 118Ÿ to Ƶ3ƵHŸ. 90 103Ÿ to 90Ƶ2Ÿ. – Emigna – 2017-06-08T16:01:02.300

Letter string can be žn•2ƒj#GÂjηCóÛƒüq™ôD ‡yΣ›aÎý1õçñ}ÂćÕ%…7¬vù~GÈž£_DвÌi¸7âòÜë8{~å≠’ˆ—d*^ݬ©Úì#Ï»cDYyÍæηмm¾/5ä):Ω8+“j¼[)ÿ—θ7I₆н¦ʒâÒ₂иofÞIa¥©ÂÛé/VÖt[¼m¦mćó,≠+ŒtC?8@Ú¬¼½k]αεßÁ'‡≠=aÔºø•51вè. – Emigna – 2017-06-08T16:19:36.150

1The number string could be 57L72 89Ÿ«Ƶ3ƵHŸ«58 71Ÿ«90Ƶ2Ÿ«J – Emigna – 2017-06-08T16:23:51.460

That letter compression doesn't seem to be correct. – Magic Octopus Urn – 2017-06-08T16:33:05.437

It appears that SE removes something so it doesn't work pasted here but it works on TIO.

– Emigna – 2017-06-08T16:46:02.027

1@Emigna found a better solution anyhow :). – Magic Octopus Urn – 2017-06-08T16:48:38.703

You beat bubblegum? What is this madness? – eaglgenes101 – 2017-11-17T05:25:55.697

@eaglgenes101 this can still easily drop off ~50 bytes with the newest 05AB1E commands for sure. Also this took 3 hours of mildly infuriating trial and error. – Magic Octopus Urn – 2017-11-17T13:23:51.987

6

PowerShell, 1562 bytes

cls
nal w write-host
$u="_"
$q=" "
$a=@('','H','He','Li','Be','B','C','N','O','F','Ne','Na','Mg','Al','Si','P','S','Cl','Ar','K','Ca','Sc','Ti','V','Cr','Mn','Fe','Co','Ni','Cu','Zn','Ga','Ge','As','Se','Br','Kr','Rb','Sr','Y','Zr','Nb','Mo','Tc','Ru','Rh','Pd','Ag','Cd','In','Sn','Sb','Te','I','Xe','Cs','Ba','La','Ce','Pr','Nd','Pm','Sm','Eu','Gd','Tb','Dy','Ho','Er','Tm','Yb','Lu','Hf','Ta','W','Re','Os','Ir','Pt','Au','Hg','Tl','Pb','Bi','Po','At','Rn','Fr','Ra','Ac','Th','Pa','U','Np','Pu','Am','Cm','Bk','Cf','Es','Fm','Md','No','Lr','Rf','Db','Sg','Bh','Hs','Mt','Ds','Rg','Cn','Nh','Fl','Mc','Lv','Ts','Og')
function b($s,$x,$y){[console]::setcursorposition($x,$y);w $s -n}
function v($n,$m,$i,$p){$x=$n;$i..$p|%{$y=$m;b $_ $x $y;$y++;if($_-gt99){$x++};b $a[$_] $x $y;if($_-gt99){$x--};$x=$x+6}}
w (($u*6)*18)-n;w""
0..8|%{if($_-eq7){w"";w (($u*6)*18)-n;w""}w ("|     "*18)-n;w "|";w ("|     "*18)-n;w "|";w ("|_____"*18)-n;w "|"}
$y=0;0..2|%{7..101|%{b $q $_ $y};$y++};$x=12;$t=$q;0..84|%{if($_-eq61){$t="_"}b $t $x 3;$x++};4..9|%{$y=$_;$t=$q;if($_-eq9){$t=$u};13..71|%{b $t $_ $y}}
$y=23;0..6|%{$x=0;0..18|%{b $q $x $y;$x++};$x=103;0..5|%{b $q $x $y;$x++};$y++}
$x=18;$y=16;0..6|%{b "\" $x $y;$y++;b "/" $x $y;$y++}
$x=102;$y=24;0..2|%{ b "\" $x $y;$y++;b "/" $x $y;$y++}
0,6,102|%{b $q $_ 0}
22,23|%{b $q 18 $_}
b $q 102 23
v 3 10 19 36;v 3 13 37 54;v 3 16 55 57;v 21 16 72 86;v 3 19 87 89;v 20 19 104 118;v 21 24 58 71;v 21 27 90 99;v 80 27 100 103;v 3 1 1 1;v 105 1 2 2;v 3 4 3 4;v 75 4 5 9;v 105 4 10 10;v 3 7 11 12;v 75 7 13 18
b "" 0 30
pause

enter image description here

This approach is not optimal. Can't use tio since this leverages [console]::setcursorposition.

root

Posted 2017-03-31T13:40:16.250

Reputation: 241

5

SOGL V0.11, 311 bytes (non-competing)

f¤o3,hģ_lμgΣ│Τ┐xC‚¦⁽?%□f⁵↕υ/gκ÷⌠‚ξ#.ν⁵‰↕¦δ┌_jυ1ιīΒ=λ←ļ,ξ╚Ƨu≡ā⁄b⅔►<≡7⅛±√‽ε¶&⁶7zV¾UΥY○ΝΚq╬#∫⅜āΡ⁴7‼%Æ«∑+‼Ψ_№QΕ¦→3γ:Ηρ':υy7▒Ξυσ╤ņcΗOī{═─⁷׀Uγlλ№γjΒ%G≤§┐⌠≈δ{oR{ΘKUƨA▒V⁶ ³‘2n '`Δ"²zōdΕ«⅝←╝⅔πφ“'³─◄"³υ≥τk┐?№L‚↑γ°“'³─6«{K;K;A{:I}a}X¹¹Hā;{⁾J6*;J3*;Jl1=@*+l3κ@*ΚΚ"<Ψ:$ō∫ΣO±>⁄‘7nž}"‛‽‛№l№’2n{_"□׀⁵‘čž}"O⁶‛±0±‛¤3¤M¤’2n{_"Ρ8‘ž

This took a while. To make this that compact, I've, with the cost of a non-competing answer, implemented many things into SOGL (most of which were already documentated). Most notably,
- "ž", which places an array inside another array at specific coordinates, and
- "►" and "◄" - run-length encode and decode. I really thought I had documentated them, but I guess I hadn't.

Try it Here! (compression (lazily) updated to comply with 0.12)

So, overly long explanation ahead:

First part: setup

f¤o3,hģ_lμgΣ│Τ┐xC‚¦⁽?%□f⁵↕υ/gκ÷⌠‚ξ#.ν⁵‰↕¦δ┌_jυ1ιīΒ=λ←ļ,ξ╚Ƨu≡ā⁄b⅔►<≡7⅛±√‽ε¶&⁶7zV¾UΥY○ΝΚq╬#∫⅜āΡ⁴7‼%Æ«∑+‼Ψ_№QΕ¦→3γ:Ηρ':υy7▒Ξυσ╤ņcΗOī{═─⁷׀Uγlλ№γjΒ%G≤§┐⌠≈δ{oR{ΘKUƨA▒V⁶ ³‘2n

...‘    push "h helibeb c n o f nenamgalsip s clark casctiv crmnfeconicuzngageassebrkrrbsry zrnbmotcrurhpdagcdinsnsbtei xecsbalaceprndpmsmeugdtbdyhoertmybluhftaw reosirptauhgtlpbbipoatrnfrraacthpau nppuamcmbkcfesfmmdnolrrfdbsgbhhsmtdsrgcnnhflmclvtsog"
    2n  split into an array with items of length 2
These are the element names, conveniently already shaped how they should be.


'`Δ
'`   push 118
  Δ  range - all numbers from 1 to 118
These are atomic numbers


"²zōdΕ«⅝←╝⅔πφ“'³─◄
"...“      push 794198124771504466790502538
     '³    push 19
       ─   base [19] decode - resulting to array [1, 2, 2, 8, 3, 8, 4, 18, 5, 18, 6, 3, 9, 14, 6, 15, 7, 3, 10, 14, 7, 15]
        ◄  run-length decode
Final result: [1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]
These are the periods, with 9 and 10 for lanthanides and actinides respectively.


"³υ≥τk┐?№L‚↑γ°“'³─6«{K;K;A{:I}a}X¹

"...“                     push 270687554118568732622432847987
     '³─                  base 19 decode, resulting in [1, 0, 18, 0, 1, 1, 13, 5, 1, 1, 13, 5, 1, 17, 1, 17, 1, 16, 4, 14, 1, 16, 4, 14]
        6«{          }    repeat 12 times
           K;K;             get the 1st 2 items of the array below the array (e. g:      ..., 13, 5, [1, 1, 13, 5, 1, 17, 1, 17, 1, 16, 4, 14, 1, 16, 4, 14])
               A            save the array on variable A (so it doesn't get in the way)  ..., 13, 5
                {  }        repeat POP times                                             ..., 13
                 :            duplicate the number                                       ..., 13, 13
                  I           increase it                                                ..., 13, 14
                              and so on (e.g. 5 times, resulting in 6 numbers)           ..., 13, 14, 15, 16, 17, 18, [1, 1, 13, 5, 1, 17, 1, 17, 1, 16, 4, 14, 1, 16, 4, 14]
                    a       load back the array
                            repeating that all 12 times
                      X   remove the array off of the stack
                       ¹  wrap all of those numbers in an array
Final result: [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, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 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, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]
These are the periods, which could be so nicely compressed, because if the atomic numbers are sorted, these are too. 

Second part: loop

¹Hā;{
¹      wrap all those 4 arrays into one big array
 H     rotate it left
            [[a, b, c],         [["c", 3, 6]      
         So  [1, 2, 3], becomes  ["b", 2, 5] . Now the sub-array structure is [name, atomic number, group, period]
             [4, 5, 6]]          ["a", 1, 4]]     
         A couple important things about this:
           - it makes each new sub-array contain all the data from all the arrays at a constant index
           - it reverses the indexes - a,b,c were given in, but now, in each sub-array, the first items are c, b, a.
             This is important because the last elements would get drawn first, so everything would appear correctly. See https://gist.github.com/dzaima/221d1792e03d0429e3403cf255c66926 for what would happen if it didn't get reversed.
  ā;   push an empty array below that big array
    {  for each sub-array


⁾J6*;J3*;
⁾          sentence-case the items in the array, ignoring the numbers. Capitalizes the 1st letter of the name
 J         pop get the last item of the array               [["Au", 79, 6], 11]
  6*       multiply it by 6 - the X coordinate              [["Au", 79, 6], 66]
    ;      swap, geting the array above                     [66, ["Au", 79, 6]]
     J     pop get the last item of the array               [66, ["Au", 79], 6]
      3*   multiply it by 6 - the Y coordinate              [66, ["Au", 79], 18]
        ;  swap, geting the array above                     [66, 18, ["Au", 79]]


Jl1=@*+l3κ@*ΚΚ"<Ψ:$ō∫ΣO±>⁄‘7nž}
J                        get the 1st item of the array               [84, 6, ["C "], 6]             [66, 18, ["Au"], 79]            [96, 21, ["Lv"], 116]
 l                       get length                                  [84, 6, ["C "], 6, 1]          [66, 18, ["Au"], 79, 2]         [96, 21, ["Lv"], 116, 3]
  1=                     push if [length] = 1                        [84, 6, ["C "], 6, 1]          [66, 18, ["Au"], 79, 0]         [96, 21, ["Lv"], 116, 0]
    @*                   get that many spaces                        [84, 6, ["C "], 6, " "]        [66, 18, ["Au"], 79, ""]        [96, 21, ["Lv"], 116, ""]
      +                  join                                        [84, 6, ["C "], "6 "]          [66, 18, ["Au"], "79"]          [96, 21, ["Lv"], "116"]
       l                 get length                                  [84, 6, ["C "], "6 ", 2]       [66, 18, ["Au"], "79", 2]       [96, 21, ["Lv"], "116", 3]
        3κ               do 3-[length]                               [84, 6, ["C "], "6 ", 1]       [66, 18, ["Au"], "79", 1]       [96, 21, ["Lv"], "116", 0]
          @*             get that many spaces                        [84, 6, ["C "], "6 ", " "]     [66, 18, ["Au"], "79", " "]     [96, 21, ["Lv"], "116", ""]
            Κ            prepend those                               [84, 6, ["C "], " 6 "]         [66, 18, ["Au"], " 79"]         [96, 21, ["Lv"], "116"]
             Κ           prepend that in the array                   [84, 6, [" 6 ", "C "]]         [66, 18, [" 79", "Au"]]         [96, 21, ["116", "Lv"]]
              "...‘      push " _____ | ŗ ||  ŗ ||_____|", replacing ŗ with the correspoding item form the array  [66, 18, " _____ |  79 ||  Au ||_____|"]
                   7n    split that into an array of items of length 7                                            [66, 18, " _____ ", "|  79 |", "|  Au |", "|_____|"]
                     ž   set that array at the positions [66, 18] in the array below
                      }  end the for-each loop

So now the output looks like this.

Third part: Add-ons

"‛‽‛№l№’2n{_"□׀⁵‘čž}
"...’           }  push code page indexes of the chars          [24, 19, 24, 28, 108, 28]
     2n            split into an array of items of length 2     [[24, 19], [24, 28], [108, 28]]
       {           for each sub-array
        _            push all the arrays contents on the stack  [24, 19]
         "...‘       push "\/\/\/"                              [24, 19, "\/\/\/"]
              č      split into a char-array                    [24, 19, ["\", "/", "\", "/", "\", "/"]]
               ž     replace in the mother array at coordinates [e.g. 24, 19] with those chars


"O⁶‛±0±‛¤3¤M¤’2n{_"Ρ8‘ž
"...’           push code page indexes of the chars          [79, 6, 24, 12, 48, 12, 24, 27, 51, 27, 77, 27]
     2n         split into an array of items of length 2     [[79, 6], [24, 12], [48, 12], [24, 27], [51, 27], [77, 27]]
       {        for each sub-array (implicitly closed)
        _         push all the arrays contents on the stack  [79, 6]
         "Ρ8‘     push "_____________________________"       [79, 6, "_____________________________"]
             ž    replace in the mother array at coordinates [e.g. 79, 6] with that string

dzaima

Posted 2017-03-31T13:40:16.250

Reputation: 19 048

1Oh lord, why was this non-competing? This mauls the answer I wasted 3 days on. – Magic Octopus Urn – 2017-06-08T15:48:06.697

@carusocomputing he implemented new builtins for it I believe – Stephen – 2017-06-08T16:40:58.207

@caruscomputing Yes, the first paragraph says that I implemented new builtins – dzaima – 2017-06-08T16:43:07.663

Ahhh.. I misread "(most of which were already documentated)." – Magic Octopus Urn – 2017-06-08T16:44:26.620

4

Excel VBA +, 674 296 293 bytes (Definitely Cheating)

Too fun of a novel solution to not share.

REQUIRES:

  • Windows 10
  • Microsoft Excel 2016 +
  • Microsoft Edge

Breaks this standard loophole

Subroutine that takes no input and outputs the periodic table to the activesheet object; Hardcoded to work with 118 elements

This periodic table includes

  • Atomic Number
  • Element Symbol
  • Element Name
  • Atomic Mass

Code

Sub p
With Sheet1.QueryTables.Add("URL;http://ptable.com",[A1])
.FieldNames=0
.PreserveFormatting=0
.AdjustColumnWidth=0
.Refresh
End With
[73:78,67:71,58:64,52:56,47:50,43:45,40:41,38:38,3:36].Delete
[E:AE,AS:AU].Delete
[C2:D2,E9]=""'<- Second `"` included only for syntax highlighting
[D7:D11,D9:Q9].Interior.Color=255
Cells.WrapText=1
End Sub

Output

PTable


Old Version, 674 Bytes

NOTE: Uses References to

  • Microsoft HTML Object Library
  • Microsoft Internet Controls

REQUIRES:

  • Windows 10
  • Microsoft Excel 2016 +
  • Microsoft Edge
Sub p
Set x=New InternetExplorer
x.navigate"ptable.com"
a=10:b=11:c=12:d=13:e=14:f=15:g=16:h=17:i=18
For j=0To 118
Cells(IIf(j<3,1,IIf(j<11,2,IIf(j<19,3,IIf(j<37,4,IIf(j<55,5,IIf(j<72,6,IIf(j<89,7,IIf(j<104,a,b)))))))),IIf(j,Choose(j,2,i,1,2,d,e,f,g,h,i,1,2,d,e,f,g,h,i,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,1,2,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,1,2,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i),1)).Value=Replace(x.document.getElementsByTagName("big")(j).outerText," ",vbCrLf)
Next
[C6:C11,C9:R9].Interior.Color=255
[A1,A2:B7,C4:R5,M2:R3,R1,D6:R7,D10:R11].Borders.LineStyle=1
End Sub

Output

Output

Taylor Scott

Posted 2017-03-31T13:40:16.250

Reputation: 6 709

3Sorry, but if it breaks a standard loophole I'm afraid it isn't valid. – Erik the Outgolfer – 2017-06-05T18:55:52.060

2@EriktheOutgolfer, hence the "Definitely Cheating" at the top - this is entended more as a fun novel solution to the problem rather than an entirely serious response, my other solution, however, is an entirely serious response – Taylor Scott – 2017-06-05T21:11:14.820

1I don't know how you fetched the contents and still lost to bubblegum. – Magic Octopus Urn – 2017-06-07T19:11:29.190

@carusocomputing, welcome to the wonderful world of VBA – Taylor Scott – 2017-06-07T20:24:56.677

4

Bash, 728 bytes

Tested on Ubuntu, requires base64 and xz programs

echo "XQAAgAD//////////wAQF/CEG6nfcFqpw6CdrU+LkV2iM1yxHU1IDYDEgH/atWuFbJGeeBZu5o8S+/6JEYEvLgTKL3JLS1cREFe2iyLK+lMZU9vuTOkuUG6NIz7n9f+iz8j4iMrKqTRVBrSzmeiXXQJA2EEOcgg/Y7Cb6ZjVoTXmo4dAV4bjgMUS0paPWZHNKKZ101VPerG6mof4Rv8UrX/CNmkvxSGG0GKHhaWpHsM6WnTzEU2L8BbDQjYsHlSUzsLj0JdMO8SFR1mlbNtyxZej1s7c4eGy2jBUCq+dCMxFt5W0AOoEHIGKy3zsmqcrJqTnKXVHOUKDiDTel3GaRm3+5fBEc1lXeN1nPli3Id6D1hzIN92eYP4JSrgyrp4t142mJ3U22iTdzO4mctwmjbmdAmFqp8hwIHM4M1n0F6DgfF0bNkROTMRWJC/CQBAkJHARwwol3z2lFsjaReJnTr0rvDvkBfuIPgzjNhFPR2xT55MaN1DKZbPOSsd1r+zZre+XSZD9ViDuGq5xlpmOyiIPRcbNJWpwo7s5mjGkDGtu6+FHygaV5bmTnnGTV0uKtxpSn1MdttXh9CRWTMXBVaIT6RllKQhzgoSUMFbrVQBqKJ/7t7fNouBxhORQRb4DmZJbZ5A1cFhvQflxdHxNkdzZDs7U4DE31j96IhXbO5MirWl2ENWMO1s//QpX8w=="|base64 -d|xz -d

Script result

Explanation

LZMA (Lempel-Ziv-Markov chain-Algorithm) produced about 0,5K archive with periodic table.

It contains unprintable symbols, and can't be used directly in console. To use it i encoded it by Base64

echo "base64_string" | base64 -d | xz -d

Stream redirection is used to decode and uncompress archive.

Tricks

To save about 30 bytes i deleted newline and some spaces

Евгений Новиков

Posted 2017-03-31T13:40:16.250

Reputation: 987

You can save a couple of bytes using a here document (base64 -D<<Q|xz -d followed by the base64 code on its own line and a trailing Q). – Charphacy – 2017-07-02T22:32:17.857

@Charphacy What you mean? I tried to replace Q by base64 string and by "echo base64_string", and it doesn't working. Can you upload example to pastebin? – Евгений Новиков – 2017-07-03T04:03:39.633

what a lazy approach. I love it. – phil294 – 2017-07-12T18:18:41.220

3

Bubblegum, 600 bytes

00000000: c4d5 4572 e430 0040 d17d 4ea1 1bb4 d9ee  ..Er.0.@.}N.....
00000010: 5d98 9999 9b86 990f 3ff6 cb2e 1546 2f5e  ].......?....F/^
00000020: a94c 8abe d595 70d4 1ce1 b90f b30c fd0b  .L....p.........
00000030: 210e a1f6 190f ef4f 6a9b d9a6 5f64 b6e9  !......Oj..._d..
00000040: 4e33 9b25 5ef8 f854 d71d ff68 6da9 b933  N3.%^..T...hm..3
00000050: 3ee6 afcf 59b0 64c5 36e3 48c9 303f 08b5  >...Y.d.6.H.0?..
00000060: a39d c7ce 36ca 312e 7289 935c bc5c f251  ....6.1.r..\.\.Q
00000070: b379 c32d da93 b195 268f 5d5b 9c32 63ce  .y.-....&.][.2c.
00000080: 8225 2b25 c3e2 49a8 5de8 3d76 b691 778d  .%+%..I.].=v..w.
00000090: 6bbe cb72 30e6 d83b 57bf 5c2a c907 1e77  k..r0..;W.\*...w
000000a0: 2fd9 f6eb 8b18 3361 ca8c 390b 96ac e8d9  /.....3a..9.....
000000b0: 3462 cc84 2933 e62c 940c 73c1 7af5 5c3b  4b..)3.,..s.z.\;
000000c0: 6b5c 5763 3338 ff45 e70f 7657 c799 8ff6  k\Wc38.E..vW....
000000d0: d8c0 f87b e3ae ab53 27ec e8f6 d5db 8c47  ...{...S'......G
000000e0: bd61 ee72 c967 d7af 5b99 b4a2 3259 c498  .a.r.g..[...2Y..
000000f0: 0953 66cc 59b0 6445 cfe6 1163 264c 9929  .Sf.Y.dE...c&L.)
00000100: 1956 4fad da7a 7782 32c6 8bce 2fe8 b6ae  .VO..zw.2.../...
00000110: f0ea 77f6 edba 73c5 7a7a 1acf e8b9 76a1  ..w...s.zz....v.
00000120: 67d7 3bce 7be7 76e7 354a e6ca e405 cbb0  g.;.{.v.5J......
00000130: 1f42 a940 9932 63ce 8225 2baa 5745 8c99  .B.@.2c..%+.WE..
00000140: 3065 c69c 8592 61cc fe19 b5a3 e64f 422b  0e....a......OB+
00000150: 84e9 ae0e ce6c 05f5 3459 faaa cc17 25bf  .....l..4Y....%.
00000160: 29a9 edb4 9eeb ef9c d770 7460 fcd1 3dee  )........pt`..=.
00000170: 5cfd 7065 c9fd e72d 5929 5355 6cd7 6b8b  \.pe...-Y)SUl.k.
00000180: a3ba 406d ce82 252b b61b e388 3113 a6cc  ..@m..%+....1...
00000190: 98b3 60c9 4ac9 30a9 ccea 8955 9f35 df6d  ..`.J.0....U.5.m
000001a0: 55c9 714d d654 1aed 2ba6 e4c2 3757 8d57  U.qM.T..+...7W.W
000001b0: 5d1d b30f 17dd 33a9 e782 3d3c ff43 6177  ].....3...=<.Caw
000001c0: 2ef5 ae2c d97a c692 43d7 fdcf 0f4f eb15  ...,.z..C....O..
000001d0: f3d4 1173 9f2f b7b1 8b88 3113 a6cc 98b3  ...s./....1.....
000001e0: 60c9 8a9e 2d23 c661 ff8a 795a 75fc 8e4d  `...-#.a..yZu..M
000001f0: eb23 2e9e 1bbf f7e1 3861 ab4f 39bf 7eea  .#......8a.O9.~.
00000200: c3fd f629 3fba fac5 7977 eeb8 3aff 3db4  ...)?...yw..:.=.
00000210: ae98 e739 36fc 35eb 695b 6f3b 66c2 9419  ...96.5.i[o;f...
00000220: 7316 2c59 d14f 208a 1833 617a f57a ea55  s.,Y.O ..3az.z.U
00000230: f7b5 b2ed 3782 7a9f 9c51 6c44 9331 8ebe  ....7.z..QlD.1..
00000240: 35ee 2af6 d526 777e 41d5 4525 e7ff af08  5.*..&w~A.E%....
00000250: 7bfc d020 dcf4 b900                      {.. ....

Try it online!

You can reverse this hexdump with xxd -r.

This is the result of Zopfliing the text 747 times in DEFLATE format.

Erik the Outgolfer

Posted 2017-03-31T13:40:16.250

Reputation: 38 134

22Congratulations. You have just been outgolfed in Bubblegum. – John Dvorak – 2017-03-31T14:14:21.467

And It'll not be easy to counter-outgolf because of the unwritten rules of PPCG. – Matthew Roh – 2017-03-31T14:17:00.207

@JanDvorak That means he had a solution ready and I outgolfed him, and then he used some billions of iterations, that's why it took so long. – Erik the Outgolfer – 2017-03-31T14:18:50.840

3

PHP, 758 Bytes

After very little chance to golf down my array approach I decide to work only with strings

Online Version

$p=($d=str_pad)("",3410,$d("",109)."\n");foreach(str_split("H HeLiBeB C N O F NeNaMgAlSiP S ClArK CaScTiV CrMnFeCoNiCuZnGaGeAsSeBrKrRbSrY ZrNbMoTcRuRhPdAgCdInSnSbTeI XeCsBaLaCePrNdPmSmEuGdTbDyHoErTmYbLuHfTaW ReOsIrPtAuHgTlPbBiPoAtRnFrRaAcThPaU NpPuAmCmBkCfEsFmMdNoLrRfDbSgBhHsMtDsRgCnNhFlMcLvTsOg",2)as$k=>$v){!in_array($k,$b=[2,10,18,36,54,86])?:$c++;foreach([" _____ ","| ".$d($k+1,3," ",$k<9?2:0)." |","|  $v |",$o="|_____|"]as$m=>$n)$p=substr_replace($p,$m<1&substr($p,-110+$q=(($i=($k>70&$k<86|$k>102?$k-14:$k)-$b[$c-1])+($k!=1?$c<3&$i>1?10:0:16))*6+110*$m+330*($k>56&$k<71|$k>88&$k<103?$c+3:$c),1)=="|"?$o:$n,$q,7);}$p[342]=" ";for($w=5;$w<9;$w++)for($u=0;$u<3;){$p[$l=($w>6?$w+1:$w)*330+128+$u*110]=$j=($w+$u++)%2?"\\":"/";if($w>6)$p[$l+84]=$j;}echo$p;

Expanded

$p=($d=str_pad)("",3410,$d("",109)."\n");
foreach(str_split("H HeLiBeB C N O F NeNaMgAlSiP S ClArK CaScTiV CrMnFeCoNiCuZnGaGeAsSeBrKrRbSrY ZrNbMoTcRuRhPdAgCdInSnSbTeI XeCsBaLaCePrNdPmSmEuGdTbDyHoErTmYbLuHfTaW ReOsIrPtAuHgTlPbBiPoAtRnFrRaAcThPaU NpPuAmCmBkCfEsFmMdNoLrRfDbSgBhHsMtDsRgCnNhFlMcLvTsOg"
,2)as$k=>$v){
!in_array($k,$b=[2,10,18,36,54,86])?:$c++;
foreach([" _____ ","| ".$d($k+1,3," ",$k<9?2:0)." |","|  $v |",$o="|_____|"]as$m=>$n)
$p=substr_replace($p,
$m<1&substr($p,-110+$q=(($i=($k>70&$k<86|$k>102?$k-14:$k)-$b[$c-1])+($k!=1?$c<3&$i>1?10:0:16))*6+110*$m+330*($k>56&$k<71|$k>88&$k<103?$c+3:$c),1)=="|"?$o:$n
,$q,7);
}
$p[342]=" ";
for($w=5;$w<9;$w++)for($u=0;$u<3;){
$p[$l=($w>6?$w+1:$w)*330+128+$u*110]=$j=($w+$u++)%2?"\\":"/";
if($w>6)$p[$l+84]=$j;}
echo$p;

PHP, 892 Bytes

First working solution that is under the byte count of the compress version a solution with arrays

Online version

$p=array_fill(0,9,($z=($d=str_pad)("",109)."\n").$z.$z);foreach(str_split("H HeLiBeB C N O F NeNaMgAlSiP S ClArK CaScTiV CrMnFeCoNiCuZnGaGeAsSeBrKrRbSrY ZrNbMoTcRuRhPdAgCdInSnSbTeI XeCsBaLaCePrNdPmSmEuGdTbDyHoErTmYbLuHfTaW ReOsIrPtAuHgTlPbBiPoAtRnFrRaAcThPaU NpPuAmCmBkCfEsFmMdNoLrRfDbSgBhHsMtDsRgCnNhFlMcLvTsOg",2)as$k=>$v){if(array_search($k,$b=[0,2,10,18,36,54,86]))$c++;$g=$k>56&$k<71|$k>88&$k<103?$c+2:+$c;$x=$k>70&$k<86|$k>102?$k-14:$k;foreach(["| ".$d($k+1,3," ",$k<9?2:0)." |","|  $v |","|_____|"]as$m=>$n)$p[$g]=($r=substr_replace)($p[$g],$n,(($i=$x-$b[$c])+($c<3&$i>1?10:(!$c&$i>0?16:0)))*6+110*$m,7);}for($w=5;$w<9;$w++)for($u=0;$u<3;$u++){$p[$w][18+$u*110]=($w+$u)%2?"\\":"/";if($w>6){$p[$w][102+$u*110]=($w+$u)%2?"\\":"/";}}echo$d(" _____",103)."_____\n";$p[0]=$r($p[0],_____,227,5);$p[0]=$r($p[0],$d("",29,"_____ "),293,29);$p[2]=$r($p[2],$d("",59,"_____ "),233,59);echo join($p);

PHP, 783 Bytes

Try it online!

Only using compressing

<?=bzdecompress(base64_decode("QlpoNDFBWSZTWYVVkt4AAXB/gCATACBAAP/gP+/f/r/v3yRAAlyZOzuIImgm0BNCJp6T0yQyaAeo000aNqYQrVMU895VSANAAAAAAGmnpAhqoB+1U9QaDQGgAA0ADQAESiieo/SgAAAAAAAANOlBWqLi6XHyC67CCYFu36ImFcCYYSqFERuisi0SA3RCkEKQBkUSsQARADINCeNmOimrFjyW6NWiy7Vp78ujxo434qwygFgmA4mABAxjGA1f9k1pmrrQfSjNsDbvcgetiknNCks756IrcRERRYABMoAAqAEzczMzKCqgAACqgTMzMoaftix6GTLlyYsd92rSy+qyuyu38Ja5t2r3njIeaoULsW+FtUVTKXFADFjUAp1EHjMhLOQkUqZJhPNPGSkUz0IbVHm+kYpfJF1111ttttpERXMYxjQ+QENZxYzMzM5zmVUdJjEkkkzCAqoAioAAAAAEC4AAVRiKVVKqrLEUtqAAGWIpgAVVGIpYVqqtzEUtqkAVliI9MFVFcOHDfffZStrWta1rWsKJfEUyYZUIUpUEVOelAgBgA2nYcAOIHEABglv/sNt+u/gI3pwL6w4LQTEk79PxgktzXtEWfjlwmU9zEyStSha5DECpMVMdyJe5cHqWeGEIzOY2PKEx5RlU9sjzoJFDVLzGN1AYAEQ4CI5xMB8VBKRZEaxKQAJBaRJFaRSRlaDSEgkgJIAOADFArBJJJEHCRUaMP8XckU4UJCFVZLeA"));

PHP, 948 Bytes

<?=gzinflate(base64_decode("vZbbattAFEXfA/mH+QNrNPdHSb4S35CVtgkGk6ZpWtqmxW0KBX98pTVuKfgCRSh62Mjj2XM4a/aMLTbNI7p+qHJ5sRNCCrHruFi9flor5cYvUm78QDm63LUnujn37KvQnaK6btdj7TWoRR3q0YDKZA9z+rH5mD+0LZejBTpHF+gwjhzAbFXu33VOaUympNm0bXdSoRo1qEUd6vcw53fNx9lj23LZ50ZXbM2SkVXEy3i2PYB5Nl3nn/+AGTiGCQrYFLApcFLgpMBJgZMCJ/UoXoVX4VV4FV6FV+FVdg/zKrYM0tV9oxVAXsXxLaifyBjpLb6SNOYUz43e8u2IFUbMyb6zGu85K1ydgNmhxmMOHAUcBRwNHA0cDRwNHA0cDRwNWI1X49V4DV6D1+A1eI3ewyzf0jgt3wDwlvc54zPQVUAuQVd+IHvvgEaeC94nIF1FxVsBc8Kabw6P+YvANMAxwDFOrOsbDwgOCA6AjjmOOQ6ADoAOgB6AHoAer8fr8Xq8/k8yC1KUk6vpnejVPxbvQcHIa1CUYFkwcwLq5Q9ggncM0orjvARjHg87G5Exs3w6DnPdMUwPHA8cH+ruZNJAkIlBLepQjzYAZfODUqtEU1SheLkzJXem5M6Uf+/MIXBK0GX3zd6VwOzHxAIqJ41jYM6A0+e9jMkkjXPmDEE6I8nTn0Bm5uLxOMxelzAvLw5v900HjzhWqAZp2ENDwC0BtwTcEnBLwC0BtwTccjgs+2/xWrwOr5NifaxQHf+CsC/jjcI9sfzC7qEDIj9ivGJX+7/YT8I+wFUx84Zvp8+id7SjDnbpVEeBlgO4ArgCuAK4ArgCuAK4ArgCRyHhKCQchYSjkKgTHdWNx4uW+F/H/0rfGAFaBpYCzT/xzuEYEOoh4zPAzoE53Z7Yow7Q9X4D"));

Jörg Hülsermann

Posted 2017-03-31T13:40:16.250

Reputation: 13 026

3

GW-Basic, 598 bytes (tokenised file)

Unfortunately GW-Basic's text mode is limited to 80 columns. I tried squishing the table to make it fit, but that didn't look too pleasing so I had to use a graphical mode instead.

Below is the text source, with lines wrapped around at 80 columns for readability; take care that for the program to work it must be saved in code page 437. Should you try it out, you'll find it will flicker a lot while it's drawing. Sorry.

0 S$="+#zB¢0(Y%5k%2GkCUq*Y$ù╝%65SÅ.5H8ú¿ÅÅxIö}¥6Ç{NMLòΩ/ΘÉ}òY'=zI⌂úÅ8V├)û;tùU2δY
#EJ2$++£╪&Θ}óÉ{,ÇN7àmYƒ+7z)ÆH55<IPmTZ¥KÆûwyHS7┐₧óOk5╕æ┴âTtöPo2KWµÅ[╗%ú##mVWíkàƒ,
£q┘6▌òMso⌂/&#
1 SCREEN 9:DIM A%(169):L%=1:FOR R%=4 TO 314 STEP 35:FOR C%=4 TO 604 STEP 35:GOSU
B 3:IF K%GOTO 5ELSE GOSUB 3:C%=K%*35+C%:IF I%=118 THEN R%=R%+12
2 NEXT:NEXT:FOR R%=1 TO 3:LINE(109-(R%=3)*490,(R%=1)*82+330)-STEP(0,-68),0:FOR C
%=1 TO 3:LINE-STEP(6,12):LINE-STEP(-6,11):NEXT:LINE STEP(0,-35)-STEP(5,0),(R%AND
 1)*15:NEXT:LOCATE 23:END
3 IF L%<36 THEN B%=(ASC(S$)-35)*L%+B%:L%=L%*216:S$=MID$(S$,2)
4 K%=B%MOD 36:B%=B%\36:L%=L%\36:RETURN
5 SCREEN,,1:CLS:I%=ASC(MID$("`nn#r",INSTR("9YvG",CHR$(I%))+1))+I%-95:PRINT RIGHT
$(STR$(I%),3):PRINT" ";CHR$(K%+64);:GOSUB 3:PRINT CHR$((K%=0)*64+K%+96):GET(0,0)
-(23,27),A%:SCREEN,,0:PUT(C%+2,R%+5),A%:LINE(C%,R%)-STEP(35,35),,B:GOTO 2

GW-Basic doesn't save its files as efficiently as it could, so to get it down to 660 bytes you need to open the tokenised file in an editor and manually remove all the spaces but one, the end of file character and the garbage character before it. This will reduce its size to 660 bytes and it will still load and run just fine.

Edit: Since in this case it doesn't matter that the variables are integers, because the expected error is small and operations like MOD and \ round anyway, we might as well turn them into floating point variables, saving a % token on each mention. And I noticed the number 35 occurs often enough that the five bytes it takes to save it into a variable are (just!) worth it. If you've been keeping score, you'll have noticed we saved 43 bytes and the file system agrees: we're down to 617 bytes.

Edit: By slightly changing S$ I was able to shave off six more bytes: (K=0)*64+ became AND 127.

Edit: Okay, so I remembered I wanted to change the way I store empty areas. This shaved off seven more bytes, four in S$ and three more because GOSUB 3: was swapped out for >9. And I sacrificed some efficiency for another two bytes.

Edit: I broke through the 600 byte barrier! It's one thing to get something compact in a golfing language, but another thing to do it in a real-world language. And quite another thing yet if you manage it in GW-Basic of all things. S$ got five bytes bigger, but I saved nine bytes by replacing ASC(MID$(...))+I-95 with I+1 and adding IF K=1 ... ELSE on line 1.

0 S$="|R▐CñföfCσé╕»σε¡┤P╝l½║╙τ/a}µS╦┌]èp┼zµkµ\¢°┴+τ_╞E.₧í3?≥≈ö麵9¬╚O?Ql'zç═┘E}ε
(ùRíHM4╥lΦ≥│6Æäb∞O@╗┘Z¿aú{2╚┤6╪╚M1cf▀ùütóQw»ùmÑíφÖ_0$kLô╩╣└u¥å█3Tìzæd±æñk)τW`╫≈å
¿b0sΓlqùV⌐█Ç8&
1 SCREEN 9:DIM A(180):L=1:W=35:FOR R=4 TO 314 STEP W:FOR C=4 TO 604 STEP W:GOSUB
 3:IF K=1 THEN GOSUB 3:I=K*2+57:C=C-WELSE IF K>9 GOTO 5ELSE C=K*W+C:IF I=118 THE
N R=R+12
2 NEXT:NEXT:FOR R=1 TO 3:LINE(109-(R=3)*490,(R=1)*82+330)-STEP(0,-68),0:FOR C=1
TO 3:LINE-STEP(6,12):LINE-STEP(-6,11):NEXT:LINE STEP(0,-W)-STEP(5,0),(R AND 1)*1
5:NEXT:LOCATE 23:END
3 IF L<36 THEN B=(ASC(S$)-W)*L+B:L=L*216:S$=MID$(S$,2)
4 K=B MOD 36:B=B\36:L=L\36:RETURN
5 SCREEN,,1:CLS:I=I+1:PRINT RIGHT$(STR$(I),3):PRINT" ";CHR$(K+55);:GOSUB 3:PRINT
 CHR$(K+96 AND 127):GET(0,0)-(W,W),A:SCREEN,,0:PUT(C+2,R+5),A:LINE(C,R)-STEP(W,W
),,B:GOTO 2

Anonymous

Posted 2017-03-31T13:40:16.250

Reputation: 161

3

Kotlin, 1688 1667 1664 bytes

Probably find some improvements to save bytes. But, got it working so I'm posting it. Thanks mazzy for 21 bytes declaring u. 3 more bytes removing template string and using u directly.

data class T(val n:String,val a:Int,val c:Int,val r:Int)
val n="H HeLiBeB C N O F NeNaMgAlSiP S ClArK CaScTiV CrMnFeCoNiCuZnGaGeAsSeBrKrRbSrY ZrNbMoTcRuRhPdAgCdInSnSbTeI XeCsBaLaCePrNdPmSmEuGdTbDyHoErTmYbLuHfTaW ReOsIrPtAuHgTlPbBiPoAtRnFrRaAcThPaU NpPuAmCmBkCfEsFmMdNoLrRfDbSgBhHsMtDsRgCnNhFlMcLvTsOg"
val l=List(118){i->T(""+n[i*2]+n[i*2+1],i+1,when(i){0->1;1->18;2,3->i-1;in 4..9->i+9;10,11->i-9;in 12..17->i+1;in 18..35->i-17;in 36..53->i-35;in 54..56->i-53;in 57..70->i-53;in 71..85->i-67;in 86..88->i-85;in 89..102->i-85;else->i-99},when(i){0,1->1;in 2..9->2;in 10..17->3;in 18..35->4;in 36..53->5;in 57..70->8;in 54..85->6;in 89..102->9;else->7})}
val u="_____"
fun Int.c()={val t=this
when {t<10->"  $t  "
t<100->"  $t "
else->" $t "}}()
fun g(r:Int,c:Int)=l.find{t->t.r==r&&t.c==c}
fun b(r:Int,c:Int)={val e=g(r,c)
val n=g(r+1,c)
if(e==null)Array(3){if(c<2)if(n==null||it<2)"       "
else " $u "
else if(g(r,c+1)!=null)if(n==null||it<2)if(r>7&&c==3)if((r+it)%2<1)"     \\"
else "     /"
else "     |"
else "$u|"
else if(n==null||it<2)"      "
else if((r<2&&c>12)||(r==3&&c>2&&c<12))"_$u"
else "$u "}
else if(c<2)arrayOf("|${e.a.c()}|","|  ${e.n} |","|$u|")
else if(r==6&&c==3)arrayOf("${e.a.c()}\\","  ${e.n} /","$u\\")
else if(r==7&&c==3)arrayOf("${e.a.c()}/","  ${e.n} \\","$u/")
else if(r==8&&c==17)arrayOf("${e.a.c()}\\","  ${e.n} /","$u\\")
else if(r==9&&c==17)arrayOf("${e.a.c()}/","  ${e.n} \\","$u/")
else arrayOf("${e.a.c()}|","  ${e.n} |","$u|")}()
fun p()={val a=Array(30){""}
var s=1
for(r in 0..8){for(c in 1..18){val o=b(r+1,c)
for(i in 0..2)a[r*3+i+s]+=o[i]}
if(r==6)s+=2}
a[0]=" $u"+" ".repeat(97)+u
a[23]=" ".repeat(19)+"_".repeat(83)
a}()

Try it online!

JohnWells

Posted 2017-03-31T13:40:16.250

Reputation: 611

1great! you can save 16 bytes if: 1. insert val u="_____" before fun Int.c() and 2. replace all occurence of 5 underscore on $u. for example if((r<2&&c>12)||(r==3&&c>2&&c<12))"_$u" – mazzy – 2018-07-11T08:17:21.413

1@mazzy was 21 bytes. You likely missed two replacements. Thank you! – JohnWells – 2018-07-11T17:39:42.577

3

C (gcc), 623 611 bytes

#define E(a)s[x/18*3+a/7][x%18*6+a%7]
#define e(a,b,c)E(a)=E(b)=E(c)=
i;x;char*p="H HeLiBeB C N O F NeNaMgAlSiP S ClArK CaScTiV CrMnFeCoNiCuZnGaGeAsSeBrKrRbSrY ZrNbMoTcRuRhPdAgCdInSnSbTeI XeCsBaLaCePrNdPmSmEuGdTbDyHoErTmYbLuHfTaW ReOsIrPtAuHgTlPbBiPoAtRnFrRaAcThPaU NpPuAmCmBkCfEsFmMdNoLrRfDbSgBhHsMtDsRgCnNhFlMcLvTsOg",s[999][110];P(x){e(14,28,42)47,e(7,21,35)92;}main(){for(memset(s,32,4e3);*p;s[++i][-1]=10,E(17)=*p++,E(18)=*p++,sprintf(&E(9)," %-2d "+i/100,i),e(7,14,21)e(13,20,27)124,x+=x?i-4&~8?i-57&~32?i-71&~32?1:-67:55:11:17)e(1,2,3)e(4,5,22)e(23,24,25)e(26,(i<5|E(0)&4),1)P(P(P(147)+1)+69)+3;puts(s);}

Try it online!

Thank gastropner for 2 bytes(and more the thought) and cailingcat for 7 bytes

l4m2

Posted 2017-03-31T13:40:16.250

Reputation: 5 985

You can save another two bytes by extending the e() macro. Link.

– gastropner – 2018-07-12T09:38:28.330

@ceilingcat s[x/18*3+i<5|E(0)&4/7][x%18*6+i<5|E(0)&4%7] seem don't have same meaning – l4m2 – 2019-10-22T21:23:28.177

2

Bash + openssl + bzcat, 787 bytes

echo 'QlpoOTFBWSZTWU4gJ1IAAWJ/gCARACBAAP/gP+/f/r/v3yRAAlzt0bO4giaaJsgT
Uymg0PKAADRpoM00IVqnqhn7ypRAaBkAABpo0AACMqQHtU9QaPUDJoGjQAAAACJR
RlH6oAAAAA0AAANMSCuPE35BdLsIJgW7goiXLgTDCVQoiN8VkWiQG+IUghSAMiiV
iBIIJQbSowuqP1azrEUckcN2TFkgjzP/NbraQIlwhHiEQoAFArk2cXwzozZiX2Fd
oDTrgQ9SNYtUrT6Y12TdAzMzmiIiBMoAAqAEzeZmZlBVQAABV70RDMzM3olunLqr
w27cODVi7KDMVsJhVbEN5HVmxiudB3tlkdzOjK62bamumQDNHkDYZJRGomJuEzpZ
Rkq6q50aVleQn2z3xsGbI0K++++66664zM70REeHz9AsBWiIiMY1rWAI2Y8qqqqq
z1JAQlAhJJJJJQgsYwFUYilaqqrLEUu1AAGWIpcAVVGIpnmcqq3mIpdrIArLER43
K0Vta1rWVK2ta1rWtawomVEUy4ZkIUpUEVMfJWACgBXdpWALEFiAAgnr2YfmfRnx
Ec7MD/cMXEaMOGC9smHqfF4imuDpVNjBGUY5rRfAkIWsm1IbjdqdKLXLljKdUEfP
dKpdJ0ti+i6yMsj2u51K5QUACIYCI9AqBe9YKKRZEaxKQAJBaRJFaRSRlaDSEgkg
JIAOADHArBJJJEHCRUaMP8XckU4UJBOICdSA'|openssl enc -d -base64|bzcat

The newlines are required. Outputs the periodic table to stdout.

R. Kap

Posted 2017-03-31T13:40:16.250

Reputation: 4 730

1You can replace openssl enc -d -base64 with base64 -D – ovs – 2017-04-01T09:50:21.173

2

Powershell, bytes 1077 937 934 906 902 888 878 842 784 688 677 673 667 651 596 bytes

Port of Neil's Javascript

filter l{"{0,5}"-f("{0,-2} "-f$_)}filter m{"|$_|"}$z=(,(' '*95)*2+(($u='_'*5)+' '*61+'_'*29)+,(' '*59)*5+'_'*59|m)+,'|'*6+'\','/'*6
" $u"+' '*97+$u
-split"H,He
LiBe,BCNOFNe
NaMg,AlSiPSClAr
KCaSc,TiVCrMnFeCoNiCuZnGaGeAsSeBrKr
RbSrY,ZrNbMoTcRuRhPdAgCdInSnSbTeIXe
CsBaLa,CePrNdPmSmEuGdTbDyHoErTmYbLu,HfTaWReOsIrPtAuHgTlPbBiPoAtRn
FrRaAc,ThPaUNpPuAmCmBkCfEsFmMdNoLr,RfDbSgBhHsMtDsRgCnNhFlMcLvTsOg"|%{if(($b=$_-split','|%{(($s=$_-csplit'(.[a-z]?)'-ne'')|%{++$i|l}),($s|l),($s|%{$u})|%{$_-join'|'}})[8]){$a+=$b[3..5]}0..2|%{$b[$_]+$z[$j++]+$b[$_-3]}}|m
''
' '*18+'_'*84
$a|%{' '*18+($s=$z[$j++])+$_+$s}

Append rv i,j,a to the end of the script to able restart.

Ungolfed

# return formated label or number
filter l{"{0,5}"-f("{0,-2} "-f$_)}

filter m{"|$_|"}

# fillers
$z=(,(' '*95)*2+(($u='_'*5)+' '*61+'_'*29)+,(' '*59)*5+'_'*59|m)+,'|'*6+'\','/'*6

# output the periodic table rows
" $u"+' '*97+$u

# transform each label row to array of numbers, labels and separators
# insert a filler from $z[$j++] between first and last groups of 3 lines
# return 3 completed lines (left+filler+right) 
# append middle group (Lanthanides and Actinides) to $a if the group is specified
-split"H,He
LiBe,BCNOFNe
NaMg,AlSiPSClAr
KCaSc,TiVCrMnFeCoNiCuZnGaGeAsSeBrKr
RbSrY,ZrNbMoTcRuRhPdAgCdInSnSbTeIXe
CsBaLa,CePrNdPmSmEuGdTbDyHoErTmYbLu,HfTaWReOsIrPtAuHgTlPbBiPoAtRn
FrRaAc,ThPaUNpPuAmCmBkCfEsFmMdNoLr,RfDbSgBhHsMtDsRgCnNhFlMcLvTsOg"|%{
    if(($b=$_-split','|%{
        (($s=$_-csplit'(.[a-z]?)'-ne'')|%{++$i|l}),
        ($s|l),
        ($s|%{$u})|%{
            $_-join'|'
        }
    })[8]){
        $a+=$b[3..5]
    }
    0..2|%{
        $b[$_]+$z[$j++]+$b[$_-3]
    }
}|m
''
' '*18+'_'*84
$a|%{' '*18+($s=$z[$j++])+$_+$s}

mazzy

Posted 2017-03-31T13:40:16.250

Reputation: 4 832

1

Retina, 888 bytes


 }~~xJ }¶|J1J|~~x>JwHJ|~~x{He@|}|}xJ q____|}w3j4J|x;j6j7j8j9j10 wLi{Be |x{BjCjNjOjFjNe@|}|}|x "w11{12 |x{13{14{15{16{17{18 wNa{Mg |x!l{Si:jSjCl!r@]qq____"w19>0>1>2>3>4>5>6>7>8>9-0-1-2-3-4-5-6 wKjCa{Sc{Ti{VjCr{Mn{Fe{Co{Ni{Cu{Zn{Ga{Ge!s{Se{Br{Kr@"""w37-8-9=0=1=2=3=4=5=6=7=8=9;0;1;2;3;4 wRb{Sr{YjZr{Nb{Mo{Tc{Ru{Rh:d!g{Cd{In{Sn{Sb{Te{IjXe@"""w55;6;7 \J72,3,4,5,6,7,8,9'0'1'2'3'4'5'6 wCs{Ba{La /JHf{Ta{WjRe{Os{Ir:t!u{Hg{Tl:b{Bi:o!t{Rn@]\Q|}w87'8'9 / 104&5&6&7&8&9%0%1%2%3%4%5%6%7%8 wFr{Ra!c \JRf{Db{Sg{Bh{Hs{Mt{Ds{Rg{Cn{Nh{Fl{Mc{Lv{Ts{Og@]/Q|}|¶¶~qqq}____ ¶~\J58;9<0<1<2<3<4<5<6<7<8<9,0,1 \¶~/JCe:r{Nd:m{Sm{Eu{Gd{Tb{Dy{Ho{Er{Tm{Yb{Lu /¶~\Q\¶~/J90#1#2#3#4#5#6#7#8#9&0&1&2&3 /¶~\JTh:a{UjNp:u!m{Cm{Bk{Cf{Es{Fm{Md{No{Lr \¶~/Q/
!
{A
"
]]
#
{9
%
z1
&
z0
'
{8
,
{7
-
{3
:
{P
;
{5
<
{6
=
{4
>
{2
@
 |¶
J
  
Q
}]]]]|}
j
 {
q
}}}}}
w
|¶|  
x
~~~    
z
 | 1
]
|}|}|}
{
 |  
}
_____
~
                  

Try it online!

ovs

Posted 2017-03-31T13:40:16.250

Reputation: 21 408

1

C++, 866 bytes

#import<bits/stdc++.h>
#define S std::string
#define R .replace
#define F(a,b,c,d)for(a=b;a<c;a+=d)
#define G(b)F(i,b,31,1)
#define a A[i]
int i,j,t;main(){S*A=new S[31];G(0)a="|"+(i%3?S(108,32):S(107,95)+' ');A[0]R(6,95,95,32);A[6]=A[3]R(12,59,59,32);F(j,6,109,6)G(t=1)!t|A[i-1][j-1]^32?t=0,a[j]='|':0;G(22)a=' '+a.substr(0,i<24?j=0:85);F(i,1,31,3)for(t=0;~(t=a.find("|     |",t));j=j^56?j^88?j^117?j^70?j+1:89:57:103:71)A[i+1]R(t+3,2,"H HeLiBeB C N O F NeNaMgAlSiP S ClArK CaScTiV CrMnFeCoNiCuZnGaGeAsSeBrKrRbSrY ZrNbMoTcRuRhPdAgCdInSnSbTeI XeCsBaLaCePrNdPmSmEuGdTbDyHoErTmYbLuHfTaW ReOsIrPtAuHgTlPbBiPoAtRnFrRaAcThPaU NpPuAmCmBkCfEsFmMdNoLrRfDbSgBhHsMtDsRgCnNhFlMcLvTsOg",j*2,2),a R(t+2,j>8?3:2,(j>98?"":" ")+std::to_string(j+1));G(25)a[1]=a[85]=A[i-9][18]=i&1?92:47;A[24]=" "+S(84,95);i=0;a[0]=a[101]=a[102]=A[3][71]=A[3][72]=A[6][71]=32;G(0)std::cout<<a<<'\n';}

Ungolfed version:

#include <bits/stdc++.h>

using namespace std;

string els = "H HeLiBeB C N O F NeNaMgAlSiP S ClArK CaScTiV CrMnFeCoNiCuZnGaGeAsSeBrKrRbSrY ZrNbMoTcRuRhPdAgCdInSnSbTeI XeCsBaLaCePrNdPmSmEuGdTbDyHoErTmYbLuHfTaW ReOsIrPtAuHgTlPbBiPoAtRnFrRaAcThPaU NpPuAmCmBkCfEsFmMdNoLrRfDbSgBhHsMtDsRgCnNhFlMcLvTsOg";

int main()
{
    vector<string> ans(31, "|" + string(108, 32));
    for (int i = 0; i < 31; i += 3)
        ans[i] = "|" + string(107, 95)+' ';             // horizontal lines
    ans[0].replace(6,95,95,32);
    ans[3].replace(12,59,59,32);                        // clear some lines
    ans[6].replace(12,59,59,32);
    for (int i = 6; i <= 108; i += 6)
        for (int j = 1, t = 0; j < 31; j++)
            if (t|ans[j-1][i-1]!=32) t=1,ans[j][i]='|'; // vertical lines
    for (int i = 22; i < 31; i++)
        ans[i]=' '+ans[i].substr(0,i<24?0:85);          // remove cells between parts
    for (int i = 1, j = 0; i < 31; i += 3) {
        int t=0;
        while(~(t = ans[i].find("|     |",t))) {        // find a cell
            ans[i+1].replace(t+3,2,els,j*2,2);          // fill name
            ans[i].replace(t+2,j>8?3:2,(j>98?"":" ")+to_string(j+1)); // fill atomic number
            j=j^56?j^88?j^117?j^70?j+1:89:57:103:71;    // next cell
        }
    }
    for (int i = 25; i < 31; i++)
        ans[i][1]=ans[i][85]=ans[i-9][18]=i&1?92:47;    // wavy lines
    ans[24]=" "+string(84,95);                          // reset the first line of the second part
    ans[0][0]=ans[0][101]=ans[0][102]=ans[3][71]=ans[3][72]=ans[6][71]=32; // minor edits
    for (auto i : ans) cout << i << endl;
}

Python 3, 730 bytes

import lzma,base64
print(lzma.decompress(base64.b85decode("T>t=p0RR90|NsC0{{Rpd@Pr$w-*8%~!=Rn5Pm7UVqBC5v9Zg6LfW&}*+O=ziY>}RL7H;N`68rv%5rHo*1j;XROG{S~5LdQ~BFg$x8B^QtOzAFAZjB>8=k@=h&&c?Q%F3xURR*-Pndp~Y0zlY74sr-TW3Zd)nAM>*=A(x|SBB$&#S+q%k6Dq;D5iDORZn`cx|)ahM*kG8f5J9tFU28-&|-&$rKujnI$Ct|5lxHm7Q;d|EFM&p&cfr+mrOgvg-2PXY}<0hm!sCs+~MJ}+AvfKubl|YMYol-0O|xBfr`s~?3$-5CZy*nbw@cugNQWVmvNd#ZT{u(L~~hJc-?0{ShpeGgVr3#H{G6K{s~IBGOnI2*NvtpbvD{0-OTPLa@;13xt#)GYNyC>Aagh~S@aj6;Cx*hHbhQL#8xCP!axutBybVK3MJn?r54EAMdD{py(_#s<OTbPJ`CeF5l=^KQ|FT!H&DuDv(8G#b+7E%t?!pfko{I5?i#LfmYI&qA`eBz%_VAZqq{kpF{BJ@ZtLMk$_AC?xs#r8lUGZMw;EEPQysR|;q)X{OvS-fq7&&EWhn@Af`pVXR_j#&YAB!kx3|rr;BkcHP({82nUY&)kTq~vZ$bHSbbL*b+}RG!)Zj5U)<1e8727+LBCTn55Y>!3TR;5@SMv")).decode())

Colera Su

Posted 2017-03-31T13:40:16.250

Reputation: 2 291

844 bytes – ceilingcat – 2018-07-13T16:42:49.153

1

///, 987 958 bytes

/J/\/\///í/				Jù/____Jú/
x\\Jà/z1Já/\/!JQ/q
J	/ :Jj/  Jq/ |Jx/$^^Jw/$$$$Jz/ | J:/ù_J;áTJ~áSJ`áRJ-áLJ+áHJ=áBJ?áAJ>áNJ<áPJ.áFJ,áMJ"áCJ'á9J]á8J[á7J}á6J{á5J)á4J(á3J*á2J&á1J^/    J%/@@@@@@J$/  ^^J#/|  J@/ù_|/á/ |  /	ww$^j	
#1 !ww$j* Q#H !ww$j+eQ|@:w$$	:::ù@@
#3 ) !w$^j{ } [ ] ' &0Q#Li=e!w$^j= " > !O . >eQ|@@wxq%
#11&2!w$^j&3&4&5&6&7&8Q#Na,g!w$^j?l~i< ~ "l?rQ|@@::::::::::ù%@
#19*/§/0*1*2*3*4*5*6*7*8*9/§(0(1(2(3(4(5(6Q#K "a~c;i!V "r,n.e"o>i"u!Zn!Ga!Ge?s~e=r!KrQ|%%%
#37(8(9)/*/)/§{0{1{2{3{4Q#Rb~r!Y !Zr>b,o;c`u`h<d?g"d!In~n~b;e!I !XeQ|%%%
#55{6{7 \\j72[3[4[5[6[7[8[9]0]1]2]3]4]5]6Q#Cs=a-a \/jHf;a!W `e!Os!Ir<t?u+g;l<b=i<o?t`nQ|@@:\\%%@@@
#87]8]9 \/ 104à05à06à07à08à09à10à11à12à13à14à15à16à17à18Q#Fr`a?c \\jRf!Db~g=h+s,t!Ds`g"n>h.l,c-v;s!OgQ|@@:\/%%@@@

x:_ííí	ú\j58{9}/*/}/§[0[1 \\ú/jCe<r>d<m~m!Eu!Gd;b!Dy+o!Er;m!Yb-u \/ú\%%@:\\ú/j9/*/'/§à00à01à02à03 \/ú\jTh<a!U >p<u?m"m=k"f!Es.m,d>o-r \\ú/%%@:\/

Try it online!

I tried

Asone Tuhid

Posted 2017-03-31T13:40:16.250

Reputation: 1 944

1

Canvas, 289 bytes

ø“^,>ø0pk↶┘?6-wF-c⁶DI2Er„‾⁴┬3n0X{┤Y┘┘{┐┌ω+┤6×y3× 3_×+|2*∔┼(v:“ko±╫JH(:)⇵↙↕l╷-N6 ↶±A)!|¾bki#LOiC0÷1c─↔k⁵IYh╬%÷╶1B--ul@%A%⁵KU/iE╷@L0≤}nJD«↑7E;pMJ2↓Zx^9{t9╴Y0[9◂ ?↙ø╬0N4@⇵║MXh#H«;g→zc-X84]Fk`⁸OO^»^L]U4Z¼e\0w┤∙pjp8←|═9±±→╵Mt⁵L@|On !±b⁹2R⁰‟2n├@ 4×)r32╋∙╋}}“57q‼(„‾;┬3n{┤_×╋}“¾├W↓5„‾X┬2n{┤/\3×↷╋

Try it here!

dzaima

Posted 2017-03-31T13:40:16.250

Reputation: 19 048

-5

Text, 3148 bytes

 _____                                                                                                 _____
|  1  |                                                                                               |  2  |
|  H  |                                                                                               |  He |
|_____|_____                                                             _____________________________|_____|
|  3  |  4  |                                                           |  5  |  6  |  7  |  8  |  9  |  10 |
|  Li |  Be |                                                           |  B  |  C  |  N  |  O  |  F  |  Ne |
|_____|_____|                                                           |_____|_____|_____|_____|_____|_____|
|  11 |  12 |                                                           |  13 |  14 |  15 |  16 |  17 |  18 |
|  Na |  Mg |                                                           |  Al |  Si |  P  |  S  |  Cl |  Ar |
|_____|_____|___________________________________________________________|_____|_____|_____|_____|_____|_____|
|  19 |  20 |  21 |  22 |  23 |  24 |  25 |  26 |  27 |  28 |  29 |  30 |  31 |  32 |  33 |  34 |  35 |  36 |
|  K  |  Ca |  Sc |  Ti |  V  |  Cr |  Mn |  Fe |  Co |  Ni |  Cu |  Zn |  Ga |  Ge |  As |  Se |  Br |  Kr |
|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|
|  37 |  38 |  39 |  40 |  41 |  42 |  43 |  44 |  45 |  46 |  47 |  48 |  49 |  50 |  51 |  52 |  53 |  54 |
|  Rb |  Sr |  Y  |  Zr |  Nb |  Mo |  Tc |  Ru |  Rh |  Pd |  Ag |  Cd |  In |  Sn |  Sb |  Te |  I  |  Xe |
|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|
|  55 |  56 |  57 \  72 |  73 |  74 |  75 |  76 |  77 |  78 |  79 |  80 |  81 |  82 |  83 |  84 |  85 |  86 |
|  Cs |  Ba |  La /  Hf |  Ta |  W  |  Re |  Os |  Ir |  Pt |  Au |  Hg |  Tl |  Pb |  Bi |  Po |  At |  Rn |
|_____|_____|_____\_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|
|  87 |  88 |  89 / 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 |
|  Fr |  Ra |  Ac \  Rf |  Db |  Sg |  Bh |  Hs |  Mt |  Ds |  Rg |  Cn |  Nh |  Fl |  Mc |  Lv |  Ts |  Og |
|_____|_____|_____/_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|

                  ____________________________________________________________________________________ 
                  \  58 |  59 |  60 |  61 |  62 |  63 |  64 |  65 |  66 |  67 |  68 |  69 |  70 |  71 \
                  /  Ce |  Pr |  Nd |  Pm |  Sm |  Eu |  Gd |  Tb |  Dy |  Ho |  Er |  Tm |  Yb |  Lu /
                  \_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____\
                  /  90 |  91 |  92 |  93 |  94 |  95 |  96 |  97 |  98 |  99 | 100 | 101 | 102 | 103 /
                  \  Th |  Pa |  U  |  Np |  Pu |  Am |  Cm |  Bk |  Cf |  Es |  Fm |  Md |  No |  Lr \
                  /_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____/

Calm down, it's a joke.

SIGSTACKFAULT

Posted 2017-03-31T13:40:16.250

Reputation: 585