Implement the logic of useToggle(initial) that also records history. Input: line 1 — initial boolean; line 2 — number of toggle calls. Print the full history as a JSON array of booleans (initial value included).
Input: two lines. Output: JSON history array (length = toggles + 1).
Your program reads from stdin and prints to stdout.
Example 1
Input: false 3
Output: [false,true,false,true]
Hints
Implement the logic of useToggle(initial) that also records history. Input: line 1 — initial boolean; line 2 — number of toggle calls. Print the full history as a JSON array of booleans (initial value included).
Input: two lines. Output: JSON history array (length = toggles + 1).
Your program reads from stdin and prints to stdout.
Example 1
Input: false 3
Output: [false,true,false,true]
Hints