Skip to main content
21 of 22
deleted 11 characters in body

C# (813)

not the greatest but I thought I'd try it with the handicap of c#.

using System;class P{static string s="HyHHe1Li1Be1BoBCaCNitNOxOFlFNe1SoNaMaMgAl1Sil1PhPSuSChClAr1PotKCal1Sc1Tit1VaVChrCrManMnIrFeCo1Ni1CopCuZiZnGa1Ge1ArsAsSe1Br1Kr1RuRbStSrYtYZirZrNioNbMo1TecTcRut1Rh1PaPdSiAgCadCdIn1TiSnAnSbTel1IoIXe1CaeCsBa1La1Ce1Pra1NeoNdPrPmSaSmEu1GadGdTeTbDy1Ho1Er1ThTmYttYbLu1HaHfTa1TuWRheReOs1Iri1PlPtGoAuMeHgThaTlLePbBi1Po1AsAtRaRnFr1Rad1Ac1Tho1ProPaUrUNepNpPluPuAm1CuCmBerBkCaliCfEiEsFeFmMenMdNo1LawLrRuthRfDuDbSeaSgBohBhHasHsMeiMtDaDsRoRgCopeCnUnUutFle1UnuUupLivLvUnunUus",t,k,v;static void Main(){int n=0;var l=new string[999];foreach(var c in s){n=Array.IndexOf(l,null);if(c<91&&k!=null){if(k=="1")k=l[n-1].Substring(0,2);if(n%2==0)k=k.ToLower();l[n]=k;k="";}k+=c;};t=Console.ReadLine().ToLower();while(t!=""&&(n=Array.IndexOf(l,t))%2!=0)t=t.Remove(t.Length-1);Console.Write(l[n+1]);}}

So I wrote a program to turn the full name of elements (e.g. carbon) in to the smallest but still unique string possible and did this for all elements with respect to all the other unique strings. I then serialized that in to a big ugly string where capital letters denote the start of "chunks", with chunks alternating between being keys and values. Like KeyValueKey2Value2 etc.

This script desterilizes that big string and cuts a character off the end of the inputted string until it finds it in the dictionary made from the big string.

(I should add my knowledge of C# isn't amazing and the original submission I made was just using things I knew but I've subsequently had some tricks pointed out to me by others.)