Once you went to bowling with your friend. All the bowling pins were labelled with different integer from 0,1,2 .. to 9. The arrangement of pins (in a triangle form) was very interesting. If two pins are side-by-side, the sum of their labels (reduced modulo 10) is equal to the label of the pin in front and between them. For Example
1 2 4 5
3 6 9
9 5
4
But the given above is only for illustration as we can clearly see that some of the pins have the same label and some of the labels like 7,8 are missing.
The question is can you find an arrangement where the label of pin in between two pins is the sum of their labels modulo 10 and all the pins(labelled 0 to 9) are placed exactly once.
Solution: bowlingPinArrangementSolution.pdf
Code: bowlingPinArrangement.cpp
No comments:
Post a Comment