Challenges

Reddit challenges in python language.

Files Code and Result

challenge1_easy

challenge2_easy

challenge3_easy

challenge4_easy

challenge5_easy

challenge6_easy

challenge7_easy

challenge8_easy

challenge9_easy

challenge10_easy

challenge11.easy

challenge12_easy

challenge13_easy

challenge14_easy

challenge15_easy

challenge16_easy

challenge17_easy

challenge18_easy

challenge19_easy

challenge20_easy

challenge21_easy

challenge22_easy

challenge23_easy

challenge25_easy

challenge26_easy

challenge27_easy

challenge28_easy

challenge29_easy

challenge30_easy

challenge31_easy

challenge32_easy

challenge33_easy

challenge34_easy

challenge35_easy

challenge36_easy

challenge37_easy

challenge38_easy

challenge39_easy

challenge40_easy

challenge41_easy

challenge42_easy

challenge44_easy

challenge45_easy

challenge46_easy

challenge47_easy

challenge48_easy

challenge49_easy

challenge50_easy

challenge51_easy

challenge52_easy

challenge53_easy

challenge54_easy

challenge55_easy

challenge56_easy

challenge57_easy

challenge58_easy

challenge59_easy

challenge60_easy

challenge61_easy

challenge62_easy

challenge63_easy

challenge64_easy

challenge65_easy

challenge66_Dev

challenge66_easy

challenge67_easy

challenge68_easy

challenge69_easy

challenge69_easyBonus

challenge70_easy

challenge71_easy.py

challenge72_easy

challenge73_easy

challenge74_easy

challenge76_easy

challenge77_easy

challenge78_easy

challenge79_easy

challenge80_easyone

challenge82_easy

challenge83_easy

challenge84_easy

challenge85_easy

challenge85_easybonus

challenge86_easy

challenge87_easy

challenge88_easy

challenge88_easybonus

challenge89_easy

challenge90_easy

challenge91_easy

challenge92_easy

challenge93_easy

challenge94_easy

challenge95_easy

challenge96_easy

challenge97_easy

challenge98_easy

challenge99_easy

challenge100_easy

challenge100_easybonus

challenge101_easy

challenge101_easybonus

challenge102_easy

challenge103_easy

challenge104_easy

challenge105_easy

challenge106_easy

challenge107_easy

challenge108_easy

challenge109_easy

challenge110_easy

challenge111_easy2

challenge112_easy

challenge113_easy

challenge114_easy

challenge115_easy

challenge116_easy

challenge117_easy

challenge118_easy

challenge119_easy

challenge121_easy

challenge122_easy

challenge123_easy

challenge124_easy

challenge125_easy

challenge126_easy

challenge127_easy

challenge128_easy

challenge130_easy

challenge131_east

challenge132_easy

challenge133_easy

challenge134_easy

challenge135_easy

challenge136_easy

challenge137_easy

challenge138_easy

challenge139_easy

challenge140_easy

challenge141_easy

challenge142_easy

challenge143_easy

challenge144_easy

challenge145_easy

challenge146_easy

challenge147_easy

challenge148_easy

challenge149_easy

challenge153_easy

challenge153_easy

challenge154_easy

challenge156_easy

challenge157_easy

challenge158_easy

challenge158_easybonus

challenge159_easy

challenge160_easy

challenge161_easy

challenge162_easy

challenge163__easy

challenge168_easy

challenge169_easy

challenge169_easybonus

challenge170_easy

challenge171_easy

challenge172_easy

challenge174_easy

challenge175_easy

challenge177_easy

challenge179_easy

challenge180_easy

challenge181_easy

challenge182_easy

challenge184_easy

challenge185_easy

challenge188_easy

challenge189_easy_ascii

challenge191_easy

challenge192_easy

challenge193_easy

challenge195_easy

challenge197_easy

challenge198_easy

challenge199_easy

challenge200_easy

challenge201_easy

challenge202_easy

challenge203_easy

challenge204_easy

challenge204_easyBonus

challenge205_easy

challenge205_easyBonu

challenge206_easy

challenge207_easy

challenge208_easy

challenge210_easy

challenge211_easy

challenge212_easy

challenge212_easybonus

challenge213_easy

challenge214_easy

challenge215_easy

challenge216_easy

challenge217_easy

challenge218_easy

challenge218_easyBonus1

challenge218_easyBunus2

challenge219_easy

challenge220_easy.py

challenge221_easy

challenge221_easy

challenge222_easy

challenge222_easy.py

challenge223_easy

challenge226_easy

challenge226_easy

challenge228_easy.py

challenge228_easydev

challenge229_easy

challenge229_easybonus.py

challenge231_easy

challenge232_easy

challenge232_easy

challenge232_easybonus

challenge234_easy

challenge234_easybonus

challenge235_easy

challenge236_easy

challenge237_easy

challenge238_easy

challenge238_easybonus

challenge239_easy

challenge240_easy

challenge242_easy

challenge242_easy

challenge242_easyBonus

challenge243_easy

challenge245_easy

challenge245_easyBonus

challenge246_easy

challenge247_easy

challenge249_easy

challenge251_easy

challenge251_easy

challenge251_easybonus

challenge252_easy

challenge252_easy

challenge253_easy

challenge254_easy

challenge255_easy

challenge257_easy

challenge261_easy

challenge267_easy

challenge269_easy

challenge270_easy

challenge272_easy

challenge277_easy

challenge282_easy

challenge282_easy_bonus

challenge283_easy

challenge284_easy

challenge286_easy

challenge287_easy

challenge288_easy

challenge290_easy

challenge290_easybonus

challenge291_easy

challenge291_easybonus

challenge302_easy

challenge308_easy

challenge311_easy

challenge313_easy

challenge313_easy

challenge314_easy

challenge315_easy

challenge319_easy

challenge323_easy

challenge324_easy

challenge325_easy

challenge328_easy

challenge330_easy

challenge330_easybonus

challenge335_easy

challenge338_easy

challenge340_easy

challenge341_easy

challenge342_easy

challenge344_easy

challenge302_easy

'''
The IUPAC Periodic Table of the Elements is one of the most recognizable
features of modern chemistry - the organization of all known chemical
elements along with some of their most fundamental properties, together
with their names and symbols. Today we're going to use that as we spell
some words.

Element	Symbol	Z	Atomic Weight	c
Actinium	Ac	89	(227)	1.1
Aluminum	Al	13	26.9815	1.5
Americium	Am	95	(243)	1.3
Antimony	Sb	51	121.75	1.9
Argon	Ar	18	39.948
Arsenic	As	33	74.9216	2.0
Astatine	At	85	(210)	2.2
Barium	Ba	56	137	0.9
Berkelium	Bk	97	(247)	1.3
Beryllium	Be	4	9.0122	1.5
Bismuth	Bi	83	208.980	1.9
Boron	B	5	10.81	2.0
Bromine	Br	35	79.904	2.8
Cadmium	Cd	48	112.40	1.7
Calcium	Ca	20	40.08	1.0
Californium	Cf	98	(251)	1.3
Carbon	C	6	12.011	2.5
Cerium	Ce	58	140.12	1.1
Cesium	Cs	55	132.9054	0.7
Chlorine	Cl	17	35.453	3.0
Chromium	Cr	24	51.996	1.6
Cobalt	Co	27	58.9332	1.8
Copper	Cu	29	63.546	1.9
Curium	Cm	96	(247)	1.3
Dysprosium	Dy	66	162.50	1.1
Einsteinium	Es	99	(254)	1.3
Erbium	Er	68	167.26	1.1
Europium	Eu	63	151.96	1.1
Fermium	Fm	100	(257)	1.3
Fluorine	F	9	18.9984	4.0
Francium	Fr	87	(223)	0.7
Gadolinium	Gd	64	157.25	1.1
Gallium	Ga	31	69.72	1.6
Germanium	Ge	32	72.59	1.8
Gold	Au	79	196.966	2.4
Hafnium	Hf	72	178.49	1.3
Helium	He	2	4.00260
Holmium	Ho	67	164.930	1.1
Hydrogen	H	1	1.0079	2.1
Indium	In	49	114.82	1.7
Iodine	I	53	126.904	2.5
Iridium	Ir	77	192.22	2.2
Iron	Fe	26	55.847	1.8
Krypton	Kr	36	83.80
Lanthanum	La	57	138.905	1.1
Lawrencium	Lr	103	(256)
Lead	Pb	82	207.2	1.8
Lithium	Li	3	6.941	1.0
Lutetium	Lu	71	174.97	1.2
Magnesium	Mg	12	24.305	1.2
Manganese	Mn	25	54.9380	1.5
Mendelevium	Md	101	(258)	1.3
Mercury	Hg	80	200.59	1.9
Molybdenum	Mo	42	95.94	1.8
Neodymium	Nd	60	144.24	1.1
Neon	Ne	10	20.179
Neptunium	Np	93	237.048	1.3
Nickel	Ni	28	58.70	1.8
Niobium	Nb	41	92.9064	1.6
Nitrogen	N	7	14.0067	3.0
Nobelium	No	102	(255)	1.3
Osmium	Os	76	190.2	2.2
Oxygen	O	8	15.9994	3.5
Palladium	Pd	46	106.4	2.2
Phosphorus	P	15	30.9738	2.1
Platinum	Pt	78	195.09	2.2
Plutonium	Pu	94	(244)	1.3
Polonium	Po	84	(210)	2.0
Potassium	K	19	39.098	0.8
Praseodymium	Pr	59	140.908	1.1
Promethium	Pm	61	(147)	1.1
Protactinium	Pa	91	231.036	1.4
Radium	Ra	88	226.025	0.9
Radon	Rn	86	(222)
Rhenium	Re	75	186.207	1.9
Rhodium	Rh	45	102.906	2.2
Rubidium	Rb	37	85.4678	0.8
Ruthenium	Ru	44	101.07	2.2
Rutherfordium	Rf	104	(261)
Samarium	Sm	62	150.4	1.1
Scandium	Sc	21	44.9559	1.3
Selenium	Se	34	78.96	2.4
Silicon	Si	14	28.086	1.8
Silver	Ag	47	107.868	1.9
Sodium	Na	11	22.9898	0.9
Strontium	Sr	38	87.62	1.0
Sulfur	S	16	32.06	2.5
Tantalum	Ta	73	180.948	1.5
Technetium	Tc	43	98.9062	1.9
Tellurium	Te	52	127.60	2.1
Terbium	Tb	65	158.925	1.1
Thallium	Tl	81	204.37	1.8
Thorium	Th	90	232.038	1.2
Thulium	Tm	69	168.934	1.1
Tin	Sn	50	118.69	1.8
Titanium	Ti	22	47.90	1.5
Tungsten	W	74	183.85	1.7
Uranium	U	92	238.029	1.5
Vanadium	V	23	50.9414	1.6
Xenon	Xe	54	131.30
Ytterbium	Yb	70	173.04	1.1
Yttrium	Y	39	88.9059	1.2
Zinc	Zn	30	65.38	1.6
Zirconium	Zr	40	91.22	1.4
Input Description

You'll be given a list of words, one per line. Example:

genius

Output Description

Your program should emit the word as a series of elements by name
with proper capitalization from the above table. Example:

GeNiUS (germanium nickel uranium sulfur)

Challenge Input

functions
bacon
poison
sickness
ticklish

Challenge Output

FUNCTiONS (flourine, uranium, nitrogen, carbon, titanium, oxygen, nitrogen, sulfur)
BaCoN (barium, cobalt, nitrogen)
POISON (phosphorus, oxygen, iodine, sulfur, oxygen, nitrogen)
SiCKNeSS (silicon, carbon, potassium, neon, sulfur, sulfur)
TiCKLiSH (titanium, carbon, potassium, lithium, sulfur, hydrogen)

'''
import re

data = '''Aluminum	Al	13	26.9815	1.5
Americium	Am	95	(243)	1.3
Antimony	Sb	51	121.75	1.9
Argon	Ar	18	39.948	
Arsenic	As	33	74.9216	2.0
Astatine	At	85	(210)	2.2
Barium	Ba	56	137	0.9
Berkelium	Bk	97	(247)	1.3
Beryllium	Be	4	9.0122	1.5
Bismuth	Bi	83	208.980	1.9
Boron	B	5	10.81	2.0
Bromine	Br	35	79.904	2.8
Cadmium	Cd	48	112.40	1.7
Calcium	Ca	20	40.08	1.0
Californium	Cf	98	(251)	1.3
Carbon	C	6	12.011	2.5
Cerium	Ce	58	140.12	1.1
Cesium	Cs	55	132.9054	0.7
Chlorine	Cl	17	35.453	3.0
Chromium	Cr	24	51.996	1.6
Cobalt	Co	27	58.9332	1.8
Copper	Cu	29	63.546	1.9
Curium	Cm	96	(247)	1.3
Dysprosium	Dy	66	162.50	1.1
Einsteinium	Es	99	(254)	1.3
Erbium	Er	68	167.26	1.1
Europium	Eu	63	151.96	1.1
Fermium	Fm	100	(257)	1.3
Fluorine	F	9	18.9984	4.0
Francium	Fr	87	(223)	0.7
Gadolinium	Gd	64	157.25	1.1
Gallium	Ga	31	69.72	1.6
Germanium	Ge	32	72.59	1.8
Gold	Au	79	196.966	2.4
Hafnium	Hf	72	178.49	1.3
Helium	He	2	4.00260	
Holmium	Ho	67	164.930	1.1
Hydrogen	H	1	1.0079	2.1
Indium	In	49	114.82	1.7
Iodine	I	53	126.904	2.5
Iridium	Ir	77	192.22	2.2
Iron	Fe	26	55.847	1.8
Krypton	Kr	36	83.80	
Lanthanum	La	57	138.905	1.1
Lawrencium	Lr	103	(256)	
Lead	Pb	82	207.2	1.8
Lithium	Li	3	6.941	1.0
Lutetium	Lu	71	174.97	1.2
Magnesium	Mg	12	24.305	1.2
Manganese	Mn	25	54.9380	1.5
Mendelevium	Md	101	(258)	1.3
Mercury	Hg	80	200.59	1.9
Molybdenum	Mo	42	95.94	1.8
Neodymium	Nd	60	144.24	1.1
Neon	Ne	10	20.179	
Neptunium	Np	93	237.048	1.3
Nickel	Ni	28	58.70	1.8
Niobium	Nb	41	92.9064	1.6
Nitrogen	N	7	14.0067	3.0
Nobelium	No	102	(255)	1.3
Osmium	Os	76	190.2	2.2
Oxygen	O	8	15.9994	3.5
Palladium	Pd	46	106.4	2.2
Phosphorus	P	15	30.9738	2.1
Platinum	Pt	78	195.09	2.2
Plutonium	Pu	94	(244)	1.3
Polonium	Po	84	(210)	2.0
Potassium	K	19	39.098	0.8
Praseodymium	Pr	59	140.908	1.1
Promethium	Pm	61	(147)	1.1
Protactinium	Pa	91	231.036	1.4
Radium	Ra	88	226.025	0.9
Radon	Rn	86	(222)	
Rhenium	Re	75	186.207	1.9
Rhodium	Rh	45	102.906	2.2
Rubidium	Rb	37	85.4678	0.8
Ruthenium	Ru	44	101.07	2.2
Rutherfordium	Rf	104	(261)	
Samarium	Sm	62	150.4	1.1
Scandium	Sc	21	44.9559	1.3
Selenium	Se	34	78.96	2.4
Silicon	Si	14	28.086	1.8
Silver	Ag	47	107.868	1.9
Sodium	Na	11	22.9898	0.9
Strontium	Sr	38	87.62	1.0
Sulfur	S	16	32.06	2.5
Tantalum	Ta	73	180.948	1.5
Technetium	Tc	43	98.9062	1.9
Tellurium	Te	52	127.60	2.1
Terbium	Tb	65	158.925	1.1
Thallium	Tl	81	204.37	1.8
Thorium	Th	90	232.038	1.2
Thulium	Tm	69	168.934	1.1
Tin	Sn	50	118.69	1.8
Titanium	Ti	22	47.90	1.5
Tungsten	W	74	183.85	1.7
Uranium	U	92	238.029	1.5
Vanadium	V	23	50.9414	1.6
Xenon	Xe	54	131.30	
Ytterbium	Yb	70	173.04	1.1
Yttrium	Y	39	88.9059	1.2
Zinc	Zn	30	65.38	1.6
Zirconium	Zr	40	91.22	1.4'''

names = '''functions
bacon
poison
sickness
ticklish'''

def single_slice(l):
    slice = l[0]
    return slice


def double_slice(l):
    slice = l[0:2]
    return slice


names = names.splitlines()
data = data.splitlines()

element_names = []
symbols = []

for item in data:
    # extract element names
    element_name = re.findall('^\w+', item)
    element_names.append(element_name[0])

for item in data:
    # extract symbols
    symbol = re.findall('\s(\w+)\s', item)
    symbols.append(symbol[0])

for name in names:
    temp = name[::]
    # candidate names
    slice_string = ''
    output = []
    flag = None

    for x in range(0, len(name)):
        # take slices of the candidate name
        slice = double_slice(name)
        slice = slice.capitalize()
        if slice in symbols:
            # get index of the selected slice
            indx = symbols.index(slice)
            # get element name using the index
            ans = element_names[indx]
            # add to the output
            output.append(ans)
            flag = True
        else:
            slice = single_slice(name)
            slice = slice.capitalize()
            if slice in symbols:
                indx = symbols.index(slice)
                ans = element_names[indx]
                output.append(ans)
                flag=False
        # remove the slice from the name
        if flag:
            name = name[2:]
        else:
            name = name[1:]
        slice_string += slice
        test = slice_string.lower()
        if test == temp:
            break
    #output = set(output)
    output = ', '.join(output)
    print('{0}{1}{3}{2}{4}'.format(slice_string, ' ', output, '(', ')'))

Result

FUNCTiONS (Fluorine, Uranium, Nitrogen, Carbon, Titanium, Oxygen, Nitrogen, Sulfur)
BaCoN (Barium, Cobalt, Nitrogen)
PoISON (Polonium, Iodine, Sulfur, Oxygen, Nitrogen)
SiCKNeSS (Silicon, Carbon, Potassium, Neon, Sulfur, Sulfur)
TiCKLiSH (Titanium, Carbon, Potassium, Lithium, Sulfur, Hydrogen)