Also posted at Placement algorithm assistance - Dev Shed

Can you post code showing what you have tried so far?