# Wanna be an Alchemist

## Wanna be an Alchemist

I've been watching Full Metal Alchemist these past days and I've been wondering, It is really possible to trans-mutate matter? In the real world, I don't know if it is possible, but in the machine world, we think we "can".

Problem

Your task is, Given an input of N chemical elements (K, Mg, C, O, etc...), you are going to:

1. Get the first letter of the element
2. Convert that letter into binary
3. Rotate 2 bits to the right
5. If the result is more that 8 bits then get the one's complement of the result and removes the highest bit
6. Output the ASCII (ISO 8859-1) representation of the result

Example

Given Chemical Elements: (K, Ca, Mg)

1. Get the first letter of the element

K, C, M

1. Convert that letter into binary

K => 01001011, C => 01000011, M => 01001101

1. Rotate 2 bits to the right

K => 11010010, C => 11010000, M => 01010011

1. Sum bits

K => 11010010 + C => 11010000 + M => 01010011 = 111110101

2. If the result is more that 8 bits then get the one's complement and removes the highest bit

00001010

1. Output the ASCII representation of the result. Result:

Test Cases

(H, Mn, C) =>  Ê

(I, H, Se) =>  Ç

(K, Ca, Mg) =>


This is code golf so the shortest answer wins

• When you say "Convert that letter into binary" am I correct in thinking you mean using ASCII? Or is it ok to use EBDIC or UTF-32? :) – Andrew Piliser Mar 6 '18 at 20:58
• @AndrewPiliser ASCII. Sorry if i was misunderstood – Luis felipe De jesus Munoz Mar 6 '18 at 20:59
• This is a great idea! In the future though, if you have an idea but it isn't a complete challenge, or if you just need help, you can use the Sandbox. – NoOneIsHere Mar 6 '18 at 21:01
• The binary sum question needs addressing, the test cases don't work and the given link is about adding numbers that are represented in binary (which does not work out with the examples either). I am voting to close this as unclear in the interim (i.e. will vote to reopen when that is addressed). – Jonathan Allan Mar 6 '18 at 21:13
• Step 3 of the problem and example don't match (shift discards bits, rotate keeps them). Also, your test cases are wrong because the problem requires "ASCII" and the result characters are not in the seven-bit character set known as ASCII (perhaps you want ISO 8859-1?) – Fox Mar 7 '18 at 14:00

# Perl 5, 44 bytes

$n+=257*ord>>2&255}{$_=chr($n>>8?~$n%256:\$n)


Try it online!

# Python 2, 78 bytes

e=sum(ord(e[0])/4+ord(e[0])%4*64for e in input());print chr([e,~e][e>255]%256)


Try it online!

-8 bytes thanks to Jonathan Frech