Santa's elves need help in determining if their current batch of presents will fit into santa's sleigh. Write the shortest program possible in the language of your choice to help them out.
- Santa's sleigh measures 6ft wide by 12ft long and is 4ft deep.
- Presents may be fragile, so they may not be stacked on top of each other.
- You can rotate and flip the presents as you wish, but Santa's quite an obsessive-compulsive chap so keep the rotations to multiples of 90 degrees.
- North Pole health and safety regulations stipulate that presents may not stick out more than 1ft above the top of a sleigh (therefore they may not be more than 5ft high).
Input will be on
STDIN and will be one integer representing the number of presents in the batch followed by a list of the presents' dimensions - 1 present per line, 3 dimensions (in feet) separated by spaces.
1 6 12 5 6 1 12 3 1 12 4 1 12 1 1 12 5 1 12 3 1 12 5 1 4 3 13 1 6 12 6
Output should just be the word 'YES' if the presents can be packed into the sleigh or 'NO' if they cannot.
Output for the above examples:
YES YES NO NO
./test [your program and its arguments]
Each entry which I can verify that meets the spec, passes the tests and has obviously had some attempt at golfing will receive an upvote from me (so please provide usage instructions with your answer). The shortest solution by the end of the 2011 will be accepted as the winner.