3) j. Conversion between data-structures Examples (2)




The year is 2039. You are working with a group of scientists to find out the secret key of teleportation. You resolved to transfer the memories and knowledge from a place to another, you just need to transfer the body. You can break the body down into atoms and also can build something from atoms if you know the correct order.
You need to write a program that converts an array of integers with the numeric representation of the atom into a string to be able to transfer from your location to the other place.

1
2
Output:
1 4 85 4 38 7851 1 5 7 6 6 4 9 8 12 8 48




A huge volcanic eruption happened in the middle of the Atlantic Ocean which caused a tsunami that might kill half of the planet.
You have to know which cities are in dangerous altitude and their population. To be able to save everyone you have 10 minutes to create a program that tracks the cities in danger. Each city has a name, an altitude, the number of population and a risk number. You are provided this information in 4 lists that need to be merged.

1
2
Output:
(('Cluj Napoca', 951, 100, 1), ('Warsaw', 700, 845, 2), ('Berlin', 500, 64841, 3), ('Venice', 2, 1324, 4), ('New York', 0, 18449, 5))




There are always appearing stories about aliens are living among us. Well, those stories are true. They are living among us. And the NASA knows. You managed to broke into area 51, where you have found an old computer. You need to know who is human and who is not, but the connection allows you to send only one data at a time.
Write a program that transforms a dictionary into a list of tuples, to be able to send the data one by one.

1
2
Output:
[('Rylee Mcloughlin', 'Apes'), ('Nathanael Hagan', 'Reptilians'), ('Toni Barlow', 'Reptilians'), ('Giselle Charlton', 'Andromedans'), ('Leonardo Easton', 'Andromedans'), ('Daria Ali', 'Anunnaki'), ('Adaline Goodman', 'Human'), ('Paloma Reed', 'Human'), ('Cherie Rowe', 'Andorian'), ('Maya Hayden', 'Aenar')]




You are a crime investigator, who wants to find the easiest way to track crimes that are made by the same person. You already have a database, what you need to reform for your goals. Your database contains a list of tuples, with the values defined by the criminals’ name, and the crimes’ special id.
Write a program that converts the list of tuples into a dictionary where the key is the criminal, and the value is a list of crime IDs.

1
2
Output:
{'Leonardo Easton': [0, 1, 2, 3], 'Maya': [4], 'Carol': [5], 'Petroar': [6]}




Computers are taking over the world. As you have seen in the movies, the age of terminators arrived. You have only one chance to survive if you can warn your superiors about the threat near your city. You are able to send only one message to anybody before the terminators find out your position using your communicator.
Write a program that converts a list of messages into one single message to be able to send it once and survive.

1
2
Output:
They are here. You can stop them if you shoot them with silver bullets. High viltage is also effective to slow them down. Please hurry up. They will find me.




Venice is floating. You need to dave every possible monument before they will disappear for good. You have a list with the treasures, but they are in one file separated by commas sou you need to take much effort to distribute them to your 10 agents.
Write a program that separates a text into a list of texts using a comma as the separator.

1
2
Output:
['THE RIALTO BRIDGE', ' THE DOGE PALACE', ' THE SCALZI BRIDGE', ' THE BRIDGE OF SIGHS', ' THE GHETTO OF VENICE', 'SCUOLA GRANDE DI SAN ROCCO']