A coastal lighthouse keeps a channel safe by hailing passing ships in strict numeric order, from 1 up to some n. Every hail is announced immediately after one foghorn blast (a foghorn blast is represented by the value 0). Two duty officers share the hailing: the odd-hail officer calls out every odd-numbered hail and the even-hail officer calls out every even-numbered hail, each strictly in increasing order among their own numbers, and the two officers alternate turns starting with the odd-hail officer on hail 1. Given n, reconstruct the exact sequence of foghorn blasts and hail numbers broadcast over the channel, from the first blast to the last hail.
A single integer n on one line.
Print 2 * n space-separated integers: the full broadcast sequence, in order.
1 <= n <= 1000Example 1
Input
5
Expected
0 1 0 2 0 3 0 4 0 5
Explanation
For n=5 the officers hail 1 through 5 in order, each preceded by one foghorn blast: blast, hail 1, blast, hail 2, blast, hail 3, blast, hail 4, blast, hail 5, giving the sequence 0 1 0 2 0 3 0 4 0 5.
Example 2
Input
1
Expected
0 1
Explanation
With only one hail to make, the sequence is a single foghorn blast followed by hail number 1: 0 1.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →