You and your friend are deciding to go for a tour by train. But before booking the ticket of the train, your friend asks you to book a ticket in such a way that both of you sit face to face
All Answers
total answers (1)
Severity: 8192
Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Filename: libraries/Filtered_db.php
Line Number: 23
total answers (1)
Algorithm:
Explanation:
Here we are finding mod of N (entered seat number) by 12 because there are 12 seats in a single cabin of the train. Now, if we divide it by 12 we will be able to identify each seat individually by its number, first 6 (1 to 6) are at the left side and next 6 (7 to 12) are at the right side.
For example, if N=52 then, N%12=4, so 52nd seat will get a unique number in that particular cabin and it is at the left side.
Now, by seeing the given picture we can say that difference between seat number 1 and 12 is 11, 2 and 11 is 9 and so on, means its decreasing by two, starting from 11.
So, for seat number 4 difference will be 5, that's why the opposite seat of 52 is 52+5=57.
Similarly, for N=23, the mod value is 11, and the seat difference of the opposite seat will be 9. But in this case, we have to deduct 9 from N because N is at the right side. So, ans: is 23-9=14.
C++ implementation:
Output
![ICP | where is seat output 1](https://www.includehelp.com/icp/Images/where-is-seat-output-1.jpg)
![ICP | where is seat output 2](https://www.includehelp.com/icp/Images/where-is-seat-output-2.jpg)
need an explanation for this answer? contact us directly to get an explanation for this answer