We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
The description says "A solid structure can be interpreted in one of the following ways". Either one will do, they are both logically equivalent - but one will be easier depending on your counting algorithm.
Method (1) says, if you are keeping record of where the 'cracks' are on each row of bricks, then any solutions you count must not have a 'crack' in the same place on EVERY row. Probably not too useful for calculations if your wall is very wide...
Method (2) points out an alternative way to look at it, and works just the way the walkthrough does. Calculate all the possible walls, cracked or not. Then subtract all the cracked walls - note that a cracked wall can be considered as two separate structures, side by side. You just have to be very careful that your algorithm correctly handles walls that are 'cracked' in more than one place...
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Lego Blocks
You are viewing a single comment's thread. Return to all comments →
The description says "A solid structure can be interpreted in one of the following ways". Either one will do, they are both logically equivalent - but one will be easier depending on your counting algorithm.
Method (1) says, if you are keeping record of where the 'cracks' are on each row of bricks, then any solutions you count must not have a 'crack' in the same place on EVERY row. Probably not too useful for calculations if your wall is very wide...
Method (2) points out an alternative way to look at it, and works just the way the walkthrough does. Calculate all the possible walls, cracked or not. Then subtract all the cracked walls - note that a cracked wall can be considered as two separate structures, side by side. You just have to be very careful that your algorithm correctly handles walls that are 'cracked' in more than one place...