The Knapsack Problem


Productivity

Updated Mar 12th, 2022

I ran across the when learning about the fantasy football lineup generator.

The math behind the lineup generator

You have a set of n items carrying weight and value

Fantasy terms you have a set of end players carrying salary and projected points

You’re trying to find the number of possible outcomes or lineups that will fit in the knapsack

The number of potential lineup s sends you back to math class with combination and permutations in factorials.

Permutations is like how many ways can you pick two things from four things

nPr = n! / (n – r)!

Where n is the number in the group p is the number of permutations and r is the selections

Permutation is the number of ways of choosing in which order counts combination is the number of possible outcomes and it doesn’t consider order of choice.

Combination formula

nCr = n! / (n-r)!r!