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

Course Content

Binary Search in Python

Binary Search in Python

1. Binary Search
2. Problems

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!

Task

  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.

Task

  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.

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

Section 2. Chapter 4
toggle bottom row

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!

Task

  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.

Task

  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.

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

Section 2. Chapter 4
toggle bottom row

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!

Task

  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.

Task

  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.

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

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!

Task

  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.

Switch to desktop for real-world practiceContinue from where you are using one of the options below
Section 2. Chapter 4
Switch to desktop for real-world practiceContinue from where you are using one of the options below
We're sorry to hear that something went wrong. What happened?
some-alt