Question: Consider you have a piece of paper with you. Fold the paper upwards such that the bottom edge meets the top edge. Once you


Consider you have a piece of paper with you. Fold the paper

upwards such that the bottom edge meets the top edge. Once you

Consider you have a piece of paper with you. Fold the paper upwards such that the bottom edge meets the top edge. Once you do this, a horizontal crease is created at the center of the paper which bends downwards (call it a trough). Next, fold the paper again upwards. Now you get more folds in the paper (this time bending upwards too, call these crests). Keep repeating this as many times as you like. When you unfold the paper completely, you will have a series of creases (crests and troughs). Let us say you folded the paper N times. The resulting sequence of crests and troughs is called the paper-folding sequence. For example, N=1: the sequence is 1. N=2: the sequence is 110, and so on, where 0 denotes a crest and 1 denotes a trough. Given N, find the paper- folding sequence corresponding to it. Input: The first and only line of input contains a single integer N (1 5 N < 24) (the number of folds) Output: For each test case, print the sequence corresponding to N folds. Example: Sample Input 0: 1 Sample Output 0: Sample Input 1: Sample Output 1: 110

Step by Step Solution

3.42 Rating (165 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Explination of logic N1 Ourp... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Algorithms Questions!