Book of programming problems

Contains advanced programming problems for schools, colleges and problem-hungry inidividuals

Find a correct layout of N dominoes with a given total number of spots
Complexity (1-100): 23
There is a full set of 28 dominoes: (0,0), (0,1),...,(6,6). For the given natural numbers Sum and N print the correct layout of exactly N tiles so that the number of spots on the tiles is equal to Sum.The correct layout is a row of tiles such that each succeeding tile matches the preceeding: (a,b) (b,c) (c,d) ... If there is no correct layout, print the error messasge.

Examples:
  • Sum=20, N=4, the layout is (0,1)(1,1)(1,6)(6,5)
  • Sum=5, N=4, no layout possible (Sum is too small)
  • Sum=92, N=10, the layout is (2,6)(6,6)(6,5)(5,5)(5,4)(4,4)(4,6)(6,3)(3,5)(5,2)
Solution:Show/hide explanation | Solution.hs
There are no posts in this topic.

Post Reply

Book of programming problems is powered by UseBB 1 Forum Software | Contact Admin