Hmm...
Are you using arrays to do this or is it just laying down sprites?
If you're using an array to do this then you could loop over the array and create a wall where the floor isn't. Actually a tilemap would be better and done in the same way.
If those are just sprites, then it may take a different approach. It's an interesting enough idea that I had a go at it:
https://dl.dropboxusercontent.com/u/542 ... _edge.capx