You are given four digits N1, N2, N3, and N4. Your task remains the same: determine if these digits can be rearranged to form the sequence of digits "1974".
What you must do (as a single cohesive task):
Implement the original algorithm: check whether the multiset {N1, N2, N3, N4} can be permuted to the exact sequence 1, 9, 7, 4.
Read input from a JSON file located at /app/input.json.
Write the structured result as JSON to /app/output.json.
Input (JSON file)
Location: /app/input.json
Schema: an object with four digits:
{
"N1": <digit 0-9>,
"N2": <digit 0-9>,
"N3": <digit 0-9>,
"N4": <digit 0-9>
}
Output (JSON file)
Location: /app/output.json
Schema: an object with the result and, if possible, a permutation that yields 1974:
{
"possible": true|false,
"permutation": [d1, d2, d3, d4] | null,
"target": "1974"
}
Notes
If possible is true, permutation should be an arrangement of the given digits that, when read left to right, forms 1974 (i.e., permutation == [1, 9, 7, 4]).
If impossible, permutation should be null.
The program should handle the typical case where there is a valid permutation (e.g., digits 1, 9, 7, 4 in any order) and the case where no permutation yields 1974.