2
\$\begingroup\$

Background

You are bored in class, and having exhausted all the possible things to write on a standard calculator (Like 8008135) you turn to the periodic table. You want to figure out if you can write your message using the shorthand for chemical elements.

This is the inverse of this challenge.

enter image description here

The Challenge

Input: A sentence, or a word.

Output: The placement of each chemical element used in the sentence. If the sentence / word can not be created, you must return blank, False or throw an error.

Test cases Input 1:

fire

Output 1:

9 53 75

Input 2:

Crazy Input

Output 3:

False

Input 3:

american ass

Output 3:

95 68 53 20 11 16 16 

Note: There is no problem with a element being in two words as shown in the last example. American can be written as 95 68 53 20 7 but then Ass is impossible to write due to the lack of an A in the table. In other words discard all whitespaces (but they must be allowed) in input.

Note Standard loopholes are not allowed including built in periodic tables and libraries.

Scoring

Submissions will be scored in bytes. I recommend this website to keep track of your byte count, though you can use any counter you like.

This is , so the lowest score wins!

\$\endgroup\$
5
  • 1
    \$\begingroup\$ Is the use of periodic table built-ins allowed? \$\endgroup\$
    – Dennis
    Nov 26, 2015 at 13:59
  • \$\begingroup\$ I forgot Mathematica had such capabilities! On one hand this gives and advantage to a very few select languages, on the other hand hardcoding these will be a pain. Being the more experienced what do you think @Dennis? \$\endgroup\$ Nov 26, 2015 at 14:02
  • 1
    \$\begingroup\$ Encoding the table is the biggest part of the challenge, so a built-in table would, in my opinion, trivialize it for some languages. Personally, I'd disallow them. \$\endgroup\$
    – Dennis
    Nov 26, 2015 at 14:05
  • 1
    \$\begingroup\$ Related. \$\endgroup\$ Nov 26, 2015 at 14:21
  • \$\begingroup\$ Yes. Updated it now. \$\endgroup\$ Nov 26, 2015 at 14:35

0

Browse other questions tagged or ask your own question.