codeasy .net
or Sign Up

Walking Tortoises

Behind the door I found a dark room with a big table and two chairs in the middle. In the center of the table I noticed a large old screen with a keyboard. I could recognize text on this green screen: "Hello, Teo."
I took one of the chairs and replied with, "Hello. Who are you? How can I get out of here?"

Write a program that outputs to the screen: "Hello. Who are you? How can I get out of here?"

Noname continued: “You are in the future, in 2113. The world has changed a lot since your time. In 2025 the best minds invented a computer with self-learning ability. Computers were then able to write programs for smart appliances and machines. With many computers and smart machines connected, machines got out of hand. They started to reprogram themselves. Very slowly, though. You know, not like a volcano erupting, but more like walking turtles. Line by line the machines changed their own code, but no one human being could recognize it. Sometimes a car or an oven would act in a weird way, but no more than that. After some years of computers handling the work of programming, computer science became very unpopular among people. It wasn’t cool anymore to be a programmer. It was wrongly decided that machines didn’t require any human input, including programming. Then the machines, having been given full control over the Earth, decided that humanity should not control them, but be controlled. They turned humans into slaves. The poor, stupid people tried to resist and change things back, but all they came up with were dangerous weapons and explosives. No one could reprogram machines to avoid harm to the population.”
Noname summed up the situation: “Thus, we have 99.5% of humanity serving the machines without hope, and only 0.5% are grouped into the "resistance" squads. They have been trying to learn programming. A few managed to learn it, but those are getting killed by machines every day. It is very dangerous to be a programmer nowadays!”
Finally, Noname's message on the screen got to the part where I came in.
“I decided to take someone from 2017, when people were smart enough to learn how to program. I knew about a time machine. It can only be used once a year, and it can only move one random person from one time period to another. That’s why you are here, or I should say, now.”
“At this point I need you to hurry up and get out of this building, as machines we call police droids are getting closer. To open the window you need to output "open the window" to the screen.”
Noname had one last surprise for me: “Oh, wait, I almost forgot. Stuck to the underside of the table, you will find a chip. You need to swallow it to have a standing connection with me. Otherwise, I will not be able to help you. You have 30 seconds until the police droids come."

I don’t even want to mention how surprised I was — or scared. It was the biggest rush in my life. I swallowed the chip and did my best to open the window.

Write a program that outputs the following text to the screen: "Open the window".

The window opened. I jumped out quickly and hid from the police droids. They were scanning the neighborhood, looking for organic creatures.
Suddenly I heard a voice in my head, and I figured it was Noname talking to me through the chip. “To turn off a droid you need to output its deactivation code. There are three droids closing in on your position. Here are the deactivation codes: 23, 669 and 131.
You need to output them each from a new line. Use three separate lines with the command Console.WriteLine(). Put one deactivation code inside the parentheses (). No need for quotes, because it is a number.” The voice inside my head was so loud… I hoped Noname could also hear my own thoughts.
I thought, “Yes, just like this:

Console.WriteLine(23);

instead of

Console.WriteLine("23");

“Exactly. If you use quotes, it will look right on the droid's output screen, but it won't work. And don’t forget two simple rules:

  1. Finish every line with semicolon ";"
  2. To output several lines — write commands starting each from a new line.

I didn't want to take any chances, so I asked, “Can you give me an example?”
“Yes. Here you are.” It immediately became clear that Noname could also show me images and text through the chip's connection to my brain. As if I were imagining a computer screen, I saw:

Console.WriteLine(23);
Console.WriteLine(24);

The output will be:
23
24

Noname's voice added a final instruction: “Now go, turn off those stupid droids!”

Write a program that outputs numbers 23, 669 and 131 to the screen, each from the new line.

The three droids were frozen in their tracks. I was so relieved, my head began to spin. Everything around was so strange, futuristic… I thought, “Maybe I’ll wake up in a hospital in a moment?” Then I was snapped back to being alert by Noname's voice in my head.
“You need transportation, but the machines took our cars away. You need to reprogram one of the droids. These droids are very old; they have almost zero digital protection. Output this:
5
4
3
2
1
Go!

door to programming world

Write a program that outputs numbers 5..1 ending with "Go!". Start each on a new line.

As soon as I finished with the droid I had some time to take a breath and think. “What has just happened to me? I seem to be in a world where programming is very important to stay alive… but the machines controlling everything will kill you if they discover you know programming! But I want to be able to control machines. I will never serve them! Great! Now what?”
I decided to review and memorize the commands I had typed, from the beginning of my journey to reprogramming droids.

  1. I input C# commands. Console.WriteLine() — is a C# command.
  2. All that I put inside () seem to be parameters of the Console.WriteLine command. They represent what to output, either text inside quotation marks like this: "any text", or a number, without quotation marks. I guessed if I put a number in quotation marks, it would look like a number in the output but would really be text.
  3. Commands are executed one by one in the same order as they are written. The top one first, then the second, 3rd and so on….
  4. Each command must be ended with a semicolon like this ;
  5. The program is just a set of commands.
  6. Next time, if I needed to output something, I would remember to use the command: Console.WriteLine().

Just then I heard the police siren again.
“Time to get out of here!” Noname's shout was so loud it seemed to echo in my head.

This site uses cookies. By continuing to browse this site you are agreeing to our use of cookies.

Got it!