Retired

Chemical Name (retired)

Description:

Goal

The goal of this Kata is to implement to_chemical which will make some letters in a name uppercase such that it represents valid chemical symbols. We only consider chemical symbols which are either 1 or 2 characters long.

The input name will be a lowercase String and the output should also be a String.

A Set of valid chemical symbols called CHEM_SYMBOLS is preloaded.

Note: Sometimes there may be several correct answers, just return one of them.

Examples

to_chemical("") => ""
to_chemical("admiraal") => ""

"A or Ad are not valid symbols"
to_chemical("codewars") => "C" + "O" + ... => ""

"`C` and `O` are valid but 'D' or `Od` or `De` are not valid symbols"
to_chemical("nam") => "Na" + .. => "N" + "Am" => "NAm"
to_chemical("namo") => "N" + "Am" + "O" => "NAmO"  or  "Na" + "Mo" => "NaMo"
to_chemical("dsb") => "Ds" + "B" => "DsB"
to_chemical("hiphop") => "H" + "I" + "P" + "H" + "O" + "P" => "HIPHOP"  or  "H" + "I" + "P" + "Ho" + "P" => "HIPHoP"
to_chemical("baga") => "B" + "Ag" + .. => "Ba" + "Ga" => "BaGa"
Algorithms

More By Author:

Check out these other kata created by Admiraal

Stats:

CreatedMay 7, 2020
Warriors Trained294
Total Skips120
Total Code Submissions175
Total Times Completed36
Python Completions36
Total Stars8
% of votes with a positive feedback rating68% of 20
Total "Very Satisfied" Votes12
Total "Somewhat Satisfied" Votes3
Total "Not Satisfied" Votes5
Total Rank Assessments21
Average Assessed Rank
6 kyu
Highest Assessed Rank
3 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • Admiraal Avatar
Ad