Tuples 2 - First challenges

Download exercises zip

Browse file online

We now propose some exercises without solution, do you accept the challenge?

Challenge - The Temple Of Rounded Doom

You are exploring an uncharted tropical region, and among the vegetation you discover the entrance of a temple devoted to the ancient God Tuplaranda. Cautiously, you enter. You see a massive door: on a side lies a long series of tablets, some rounded and some squared. They contain tokens with mystical symbols. In order to open the door, you must build a single long round tablet in front of the door, with all the tokens in the same order you find them. Write some code to produce such rounded tablet.

Example - given:

[1]:
t = ('wara', 'zuna', ('nabu', 'zebi'), [('vi','la')], ('gur',), ('gar'), 'zat', ['ben', 'elz','ub'])

The tokens are 'wara', 'zuna', 'vila', 'nabu' etc

Your code must produce:

('wara', 'zuna', 'nabu', 'zebi', 'vi', 'la', 'gur', 'gar', 'z', 'a', 't', 'ben', 'elz', 'ub')

IMPORTANT: DO NOT upset Tuplaranda! Pay attention to the warning signs on the door:

  • DO NOT write strings (so don’t manually write string constants like 'zuna' in your code)

  • DO NOT type more than 8 opening square brackets [

WARNING 1: there are traps - be very careful about commas !

WARNING 2: 'zat' must become 'z','a','t'

[2]:


t = ('wara', 'zuna', ('nabu', 'zebi'), [('vi','la')], ('gur',), ('gar'), 'zat', ['ben', 'elz','ub'])

# write here


[ ]: