Tracks
/
Odin
Odin
/
Exercises
/
Robot Name
Robot Name

Robot Name

Easy

Instructions

Manage robot factory settings.

When a robot comes off the factory floor, it has no name.

The first time you turn on a robot, a random name is generated in the format of two uppercase letters followed by three digits, such as RX837 or BC811.

Every once in a while we need to reset a robot to its factory settings, which means that its name gets wiped. The next time you ask, that robot will respond with a new random name.

The names must be random: they should not follow a predictable sequence. Using random names means a risk of collisions. Your solution must ensure that every existing robot has a unique name.

Odin-specific instructions

To solve this exercise, you will need to keep track of the names of the robots you created. The Robot_Storage data structure is provided for this purpose.

Since robot names are string in Odin and will have to be manually allocated as you create the robots, it is your responsibility to reclaim the associated memory in the delete_storage() procedure.


Source

A debugging session with Paul Blackwell at gSchool.
Edit via GitHub The link opens in a new window or tab
Odin Exercism

Ready to start Robot Name?

Sign up to Exercism to learn and master Odin with 73 exercises, and real human mentoring, all for free.