Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Revisions

17 of 18
deleted 10 characters in body
J.Doe
  • 2.7k
  • 12
  • 15

R, (削除) 301 (削除ここまで) (削除) 289 (削除ここまで) (削除) 287 (削除ここまで) 273 bytes

Explanation.

Look up the index of the mass sorted atomic number in a UTF8 encoded hash string s. The hash is taken by taking the element name, encoding it as ASCII, multiplying by a 2-vector encoded with UTF-8 and modding three times in succession. The operator + is used for the UTF8 to integer vector conversion.

Encode the masses of the elements as a UTF8 encoded string of differences, packing 2 differences into each byte as 9*d1 + d2 where d1 is the difference of the nth element and d2 is the successive mass difference of the n+50th element. Then to retrieve the mass, take the corresponding position at the cumulative sum of the differences. This is shorter than a quadratic formula.

function(x)sum(c(o%%9,o%/%9)[1:match(sum(+x*+"")%%740%%623%%278,+'{ćWZ}èċæŸ+Ó>qÿƒ!2Eo&ē_u1⁄28`h›’Hb‰1ĎŽ‹@-if9ÃÛ%ù]V‚:LkXlÙDRŠ•˜OU·m,Sμ5TËt6cC7#­/ąz1A')])
"+"=utf8ToInt
o=+"0%..%$%% 
p

&00(1"

Try it online!

J.Doe
  • 2.7k
  • 12
  • 15

AltStyle によって変換されたページ (->オリジナル) /