Skip to content

Inclusion-Exclusion principle using java 8 streams

Notifications You must be signed in to change notification settings

vincentpoon/Sets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

Sets

Java 8 Streams implementation of the Inclusion Exclusion Principle

Counts how many integers from 1 to N are not divisible by a given Set of exclusion integers.

i.e. How many integers in {1,...,N} are not divisible by {exclusions}?

e.g. How many integers in {1,...,100} are not divisible by 2, 3 or 5?

This can be used to solve the caterpillars and leaves programming problem, where we want to count how many leaves are uneaten, given N number of leaves and a set of jumps for each caterpillar.

A powerset function to generate the powerset of a given set is also included.

About

Inclusion-Exclusion principle using java 8 streams

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages