Candy Distribution

Advanced

Candy Distribution Challenge

It's candy time! You've got a bag of candies and a bunch of friends. You need to distribute the candies fairly among your friends, and if there are any leftover candies, you have to decide what to do with them!

Write a function distribute_candies that calculates how many candies each friend gets and how many are left over (if any). You will receive two numbers as input:

  1. candies - The total number of candies.
  2. friends - The number of friends you want to share the candies with.

Your task is to return a tuple where the first element is the number of candies each friend gets, and the second element is the number of leftover candies.

Examples:

# Example 1 candies = 23 friends = 4 output: (5, 3) # Each friend gets 5 candies, and there are 3 candies left over. # Example 2 candies = 10 friends = 2 output: (5, 0) # Each friend gets 5 candies, and no candies are left over. # Example 3 candies = 7 friends = 3 output: (2, 1) # Each friend gets 2 candies, and there is 1 candy left over.

Have fun sharing candies and happy coding!

Geek
Inputs

Arg 1:

23

Arg 2:

4
Expected Output
[5, 3]
Actual Output
Candy Distribution [advanced] | Coding for Kids