Rullst AcademyRullst Academy/Lesson
My first quiz with Rullst · Lesson 05 / 08

Points, one step at a time

Now let's celebrate correct answers. Each correct answer gives a small group of points.

Learning paths6 min

Let's discover together

  1. 1

    One correct answer gives 5 points: ★ ★ ★ ★ ★. Two correct answers give two equal groups.

  2. 2

    We can add 5 + 5. We can also write 2 × 5: two groups of five.

  3. 3

    A function is a recipe: it receives values and gives back a result. Our recipe takes correct answers and points, and returns the total.

✦
YOUR MISSION

Use 2 correct answers and 5 points per answer. Count both groups before writing the total.

Now it's your turn

A moment to understand

What is the total of both groups?

I need a hint

Count: 5 points from the first answer, plus 5 from the second. The total is 10.

Loading your journey…

Take it with you

After finishing, change to 3 correct answers. Count 5 + 5 + 5 before testing. What is the new total?

Show me the Rust behind it

This part is optional. You don't need to memorize the code to continue.

fn score(correct: u8, points: u8) -> u16 {
    u16::from(correct) * u16::from(points)
}
assert_eq!(score(2, 5), 10);
At your own pace

My files and GitHub

Every lesson can become your own record: code, notes or a practice plan. Saving a file to GitHub is optional and does not change your XP.

Student guide

The editor and downloads open when this lesson is available to your account. Check access below or return to the track map.

Checking your access to this lesson…

Rullstpetbot

AI can make mistakes. Check the lesson material.