read_quest(0)
The First Quest
Finally, your first quest!
What will it be?
Kill some monsters? Rescue a lost princess?
Let’s find out!
…well, let’s do it then.
Good morning Adventurer, I’m glad you accepted my request.
My age is starting to show, and it’s hard to keep up with the work here at the grocery store.
Your first task is to help me keep track of the inventory.
Please, follow me.
You follow the owner to the back of the store, where he has crates full of vegetables.
Each crate has a label indicating its contents and a panel with a number.
See all these crates? They are magical boxes!
The number you see on each panel is the amount of vegetables stored, and it updates automatically.
Pretty handy, right?
Unfortunately, only Programmers can mess with them, they are too complicated for people like me.
This is where you come in.
I often find that I need to check the total number of vegetables in the store, but having to add up the numbers by hand is tedious.
So, as a Programmer, could you find a way to automate this?
I have this code thing that represents our magical crates and what’s in them, check it out:
The structure of the code is let <label> = <contents>
, think of the label as being the literal contents of the crate.
What would happen with the code let total = potatoes;
?
What's the total number of vegetables in the grocery?
let potatoes = 5; let carrots = 4; let onions = 2; let total = ? + ? + ?;
Great! Now the grocer knows how many vegetables he has stored.
Thank you so much! I knew you could do it.
While you were working, a shipment of apples arrived.
I don’t have a crate for them, so I need you to make one.
I think I have a kit somewhere… Ah, here it is!
The man picks up a folded crate and sets it on the ground.
Then, looking at the box, he mumbles: let
.
Upon hearing the word, the crate begins to glow, floats slowly in the air and unfolds.
In the panel appears: “Please, fill in the label with the name of the contents of the box and place the items inside”.
You’re on your own for this one. Let’s get to it!
Create a magical box to store 18 apples!
let ? = ?;
After configuring the box, you walk to the counter to tell the grocer of your success, but he yells: Hey, adventurer! Bring me two apples from the box, please .
Okay, that shouldn’t be difficult, just take two apples and… Huh? Why is your hand being stopped in the air?
You look at the panel, maybe something is wrong?
Sure enough, the panel glows red, and says: Anti-theft protection enabled, if you want to change the contents of this box add the mut
directive
mut
what? What does that mean? Why does a grocery store have anti-theft magical boxes?
Knowing that you are making the owner wait, you hurry and try to fix it.
The grocer before said let
to activate the box, maybe you need to do the same with this mut
thing?
Fix the box and take two apples from it!
? apples = 18; apples = apples - 2;
Having dispatched the customer, the owner comes carrying a normal-looking box full of apples and leaves it in the floor.
Seems like some of the shipment was still outside, can you help me add them to the storage crate?
Add 64 apples to their crate!
let mut apples = 16; ?;
Thank you a lot for your help.
I’ll tell the Adventurer’s Guild about your excellent assistance, see you again!
This seems like mission complete!
Satisfied with your work, you return to the nearby inn and retire early to be ready for whatever comes tomorrow.
Join the Adventure!
Love Rust Quest?Your donation can help me keep writing and bring more chapters to life.