PyWeek #12 entry ported to JavaScript with chem