Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Balloons | Problems
Binary Search in Python
course content

Contenu du cours

Binary Search in Python

Binary Search in Python

1. Binary Search
2. Problems

book
Balloons

Imagine you have this figure:

And you want to fill this figure with balloons!

If you have 3 balloons you will need 2 columns to fill them with balloons.

If you have 6 balloons you will need 3 columns to fill them with balloons.

If you have 7 balloons you will need 3 columns to fill them with balloons(in our problem).

Now we will implement the program, which will decide how many columns you need to locate the n number of ballons!

Look at the explanation of the task! How does it work?

Use hints if needed! Be careful with the tabulation!

Tâche

Swipe to start coding

  1. Set while loop to work while the left + 1 is lower than right.
  2. Set the middle variable. The middle equals the (left + right) // 2.
  3. Update the left. The left equals the middle.
  4. Update the right. The right equals the middle.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 4
toggle bottom row

book
Balloons

Imagine you have this figure:

And you want to fill this figure with balloons!

If you have 3 balloons you will need 2 columns to fill them with balloons.

If you have 6 balloons you will need 3 columns to fill them with balloons.

If you have 7 balloons you will need 3 columns to fill them with balloons(in our problem).

Now we will implement the program, which will decide how many columns you need to locate the n number of ballons!

Look at the explanation of the task! How does it work?

Use hints if needed! Be careful with the tabulation!

Tâche

Swipe to start coding

  1. Set while loop to work while the left + 1 is lower than right.
  2. Set the middle variable. The middle equals the (left + right) // 2.
  3. Update the left. The left equals the middle.
  4. Update the right. The right equals the middle.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 4
Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Nous sommes désolés de vous informer que quelque chose s'est mal passé. Qu'est-il arrivé ?
some-alt