kyu_5.alphabet_wars_nuclear_strike package

Submodules

kyu_5.alphabet_wars_nuclear_strike.alphabet_war module

kyu_5.alphabet_wars_nuclear_strike.alphabet_war.alphabet_war(battlefield: str) → str[source]

A function that accepts battlefield string and returns letters that survived the nuclear strike. :param battlefield: :return:

kyu_5.alphabet_wars_nuclear_strike.alphabet_war.clean_battlefield(battlefield: str) → str[source]

Clean the battlefield and return only survived letters :param battlefield: :return:

kyu_5.alphabet_wars_nuclear_strike.alphabet_war.clean_unsheltered(battlefield: str) → str[source]

Clean letters outside the shelter :param battlefield: :return:

kyu_5.alphabet_wars_nuclear_strike.test_alphabet_war module

class kyu_5.alphabet_wars_nuclear_strike.test_alphabet_war.AlphabetWarTestCase(methodName='runTest')[source]

Bases: unittest.case.TestCase

Testing alphabet_war function

test_alphabet_war()[source]

Testing alphabet_war function

Introduction There is a war and nobody knows - the alphabet war! The letters hide in their nuclear shelters. The nuclear strikes hit the battlefield and killed a lot of them.

Task Write a function that accepts battlefield string and returns letters that survived the nuclear strike.

  1. The battlefield string consists of only small letters, #,[ and ].

2. The nuclear shelter is represented by square brackets []. The letters inside the square brackets represent letters inside the shelter.

3. The # means a place where nuclear strike hit the battlefield. If there is at least one # on the battlefield, all letters outside of shelter die. When there is no any # on the battlefield, all letters survive (but do not expect such scenario too often ;-P ).

4. The shelters have some durability. When 2 or more # hit close to the shelter, the shelter is destroyed and all letters inside evaporate. The ‘close to the shelter’ means on the ground between the shelter and the next shelter (or beginning/end of battlefield). The below samples make it clear for you. :return:

Module contents