snip

Assuming you have a maximum amount of holes, you should look into MPCs.