diff --git a/exercises/practice/allergies/.meta/proof.ci.cob b/exercises/practice/allergies/.meta/proof.ci.cob index ee45883a..a5eae5d7 100644 --- a/exercises/practice/allergies/.meta/proof.ci.cob +++ b/exercises/practice/allergies/.meta/proof.ci.cob @@ -6,6 +6,8 @@ 01 WS-SCORE PIC 999. 01 WS-ITEM PIC X(12). 01 WS-RESULT PIC A. + 88 IS-ALLERGIC VALUE "Y". + 88 NOT-ALLERGIC VALUE "N". 01 WS-RESULT-LIST PIC X(108). 01 ALLERGENS. @@ -24,13 +26,15 @@ PROCEDURE DIVISION. ALLERGIC-TO. - MOVE "N" TO WS-RESULT + SET NOT-ALLERGIC TO TRUE. PERFORM VARYING INDEX-1 FROM 1 BY 1 UNTIL index-1 > 8 IF ALLERGEN(INDEX-1) EQUAL TO WS-ITEM THEN + * cobol lacks bitwise operators: + * if (score >> (idx - 1)) & 1 == 1 COMPUTE ALLERGEN-VALUE = 2 ** (INDEX-1 - 1) DIVIDE WS-SCORE BY ALLERGEN-VALUE GIVING SHIFTED IF FUNCTION REM(SHIFTED; 2) EQUAL TO 1 THEN - MOVE "Y" TO WS-RESULT + SET IS-ALLERGIC TO TRUE EXIT PERFORM END-IF END-IF @@ -42,7 +46,7 @@ PERFORM VARYING INDEX-2 FROM 1 BY 1 UNTIL index-2 > 8 MOVE ALLERGEN(INDEX-2) TO WS-ITEM PERFORM ALLERGIC-TO - IF WS-RESULT EQUAL TO "Y" THEN + IF IS-ALLERGIC THEN STRING WS-RESULT-LIST DELIMITED BY SPACE LIST-SEPARATOR DELIMITED BY SPACE