Longest Potassium Compound X80665


Statement
 

pdf   zip

thehtml

Write a program that reads several sequences of molecules. For each sequence, the program must print the longest molecule containing some potassium (K) atom.

Input

The input consists of several sequences of molecules. Each sequence is provided as a number n, followed by n molecules.
No molecules containing Krypon (Kr) will appear in the sequences.

Output

The output is the longest molecule containing potassium in each sequence.
If there is not such a molecule in the sequence, the output is none.
If several potassium molecules with the same length are found, the last one should be printed.

Public test cases
  • Input

    7 KCl KI C2H4O2 AsH3 K2S4 K2Te H2O
    4 K2Te C6H8O6 HK C9H8O4
    4 K2S4 K2Se HK C8H12N4O3
    7 KCl KCN CaOH HK H2CO3 H2O NaCl
    5 FeO SiO BaSO4 CaOH H2O 
    7 FeS CaH C9H8O4 C8H12N4O3 AsH3 O3 K2S4
    

    Output

    K2Te
    K2Te
    K2Se
    KCN
    none
    K2S4
    
  • Input

    5 H2O KC2N Se2K3 KCN H2O
    4 C6H8O6 H2O C2H3 HCL
    8 H2SO3 KCN KCl KCl KCl KS4 H2O NaCl
    

    Output

    Se2K3
    none
    KS4
    
  • Information
    Author
    Lluís Padró
    Language
    English
    Official solutions
    Python
    User solutions
    Python