It is used to split any amount of cards into the specified amount of "piles". I have it set up so it is scalable simply having the array "deckOfCards" to contain cards from multiple decks and then changing the pilesNeeded variable will still split them up into as close to equal sized values as possible. I also have a couple of statements for swing should be able to be ignored.

However, the ternary operator I have in the for condition seems messy to me. It is simply used to distribute the remainder of cards after division if there is a remainder.

How can I do this without having a ternary in the condition? Would I somehow nest the inner for loop in an if condition?