Hello, I am having some trouble on how to solve this bronze problem: Bull In A China Shop I code in Python, and I’m not sure how to start on this problem. Can someone please give me a hint on how to start this problem? Thank you!
Brute force. Hard brute force. Usually when the bounds are really small (less than 10), that means the intended solution is something around O(N!).
But… how would I use brute force in the first place? I’m not sure how I would code something to find if two pieces could fit together to make another…
First of all, how would you store the pieces?
I was thinking I could make a matrix for each piece, so for the sample input it would be
figure = [['#', '#', '#', '#'],['#', '.', '#', '.'],['#', '.', '#', '#'],['#', '#', '#', '#']]
Yeah, that’s a good idea (Side note: you could just store it as an array of strings)
Next, how would you combine two pieces?
I’m not sure, especially if the '.'s are empty spaces… somehow we have to check to see how much empty space we have at the end, and then remove the empty spaces?
All the pieces have the exact same shape, so I don’t think you have to check for spaces.
Okay, suppose I had the code for the combination part. How do I check if it matches the original piece?
You would simply check for equality.