Problem 1388. Numbered lottery balls into cells

You are running a lottery, and have a number of different balls numbered 1 to N. Your job is to figure out how many different ways these balls can go into k different buckets. The only stipulation is that each bucket must have at least one ball in it.

For example, if you have 4 balls and 2 buckets, you can divide them up seven different ways:

  • 123, 4
  • 124, 3
  • 134, 2
  • 234, 1
  • 12, 34
  • 13, 24
  • 14, 23

The order of the buckets does not matter, so (12, 34) is the same as (34, 12). Likewise, the order of the balls does not matter, so (12, 34) is the same as (21, 43). Good luck!

Solution Stats

28.13% Correct | 71.88% Incorrect
Last solution submitted on May 14, 2015

Problem Comments

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!

Join the 15-year community celebration.

Play games and win prizes!

Learn more