As of recently I've been trying to get better at algorithms and I've stumbled onto one that I can't seem to solve.
The idea behind the algorithm is to try to find as many different ways as possible to store each object of size K in an array of N*N given certain restraints.
So take this grid right here
.X.X
.XX.
...X
....
There are 6 possible ways to store 4 different objects of sizes 1 - 4
4X.X
4XX1
422X
4333
4X1X
4XX.
422X
4333
3X.X
3XX1
322X
4444
3X1X
3XX.
322X
4444
2X1X
2XX.
333X
4444
2X.X
2XX1
333X
4444
The problem I'm facing is trying to come up with an algorithm that could solve this problem. The first thing that comes to mind is to utilize recursion to find each possible solution for each size, but then I draw a blank. I've also read about backtracking but I can't seem to make it fit this problem even though I feel as if it should be possible by creating some sort of state space tree.
What's a good way to approach this problem? Is there a typical algorithm one would use? I'm not looking to have the problem solved for me but rather having broken down into logical steps if possible.
The original description for the problem can be found here https://vjudge.net/problem/Kattis-minibattleship