Chocolate Triangles and BF

Problem #396

Tags: brainfuck c-1

Who solved this?

No translations... yet

This charming problem was suggested by Kevin Bodurtha, who expresses feeling that the site doesn't have enough problems in BF language. Thanks a lot!

You have just been hired to work in a QA position at a peculiar factory which produces triangular wedges of chocolate containing vitamins to improve focus and concentration.

Your boss explains that the chocolate-making machines produce chocolate wedges in batches consisting of 4 pairs of wedges per batch. In order to ensure that only the highest-quality product is packaged, only the larger wedge of each pair is packaged, while the smaller wedge is recycled back into the machine. If both wedges in a pair are of equal size, then they are both packaged. Given side lengths of each wedge, your job is to report the area of all packaged wedges in a batch, one pair at a time.

All packaged wedges must also be Right triangles, in order to fit properly into the packaging. The chocolate-making machines sometimes drift out of calibration and produce Acute-triangle wedges, and these must never be packaged. In fact, if both wedges in the pair are Acute, then both should be rejected and no wedge is packaged for that pair.

It sounds like a simple enough task for somebody with your experience, so you sit down at your desk and turn on your computer as you begin to plan your program structure and recall your high school Geometry class. However instead of an IDE for your preferred programming language, you realize that of course there's only one programming language allowed at the Brain-Fudge Factory!

Your solution must be in form of BF++ code which performs necessary tests of input data and gives, as output, which wedges of chocolate to pack. I.e. this task assesses not the answer, but solution, which is executed on the server-side.

Input data:
There will be always exactly 4 testcases (so that code running time is more predictable) - all on a single line.
Test cases come in sets of 6 values corresponding to the side lengths of 2 triangles: A1, B1, C1, A2, B2, and C2.
Both A and B will always be less than or equal to their corresponding C.

Answer:
If both triangles in the pair are Right, return the area of the larger one.
If both Right triangles have the same area, return the sum of their areas instead.
If one triangle in the pair is Right and the other Acute, return the area of the Right triangle.
If both triangles in a pair are Acute, return "N" (without the quotes) to indicate that None were selected.

Execution Limit: 2 mln operations for all 4 testcases in total.

Example:

Example:

input data:
4 3 5 6 8 10 3 4 5 4 3 5 3 4 5 3 4 4 4 3 4 3 4 4

answer:
24 12 6 N
You need to login to get test data and submit solution.