The gym of the Geek's School has 1000 lockers. The lockers are in a line along a corridor and are numbered from 1 to 100

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

The gym of the Geek's School has 1000 lockers. The lockers are in a line along a corridor and are numbered from 1 to 100

Post by answerhappygod »

The Gym Of The Geek S School Has 1000 Lockers The Lockers Are In A Line Along A Corridor And Are Numbered From 1 To 100 1
The Gym Of The Geek S School Has 1000 Lockers The Lockers Are In A Line Along A Corridor And Are Numbered From 1 To 100 1 (306.53 KiB) Viewed 17 times
Need code in C.
The gym of the Geek's School has 1000 lockers. The lockers are in a line along a corridor and are numbered from 1 to 1000. Initially all the lockers are closed (but unlocked). There are 4 super nerd geeks in the college who always think of math and do mathematical mischiefs around the campus. They visualize these lockers as 0's and 1's. Q. How? A. If a locker door is opened, they read it as 1. Likewise, if the door is closed, they interpret that as 0. Every night, the 4 math kids pass by the corridor and switch the doors purely for mischievous joy! Each kid does it in her own way. 1) Kid 1 switches the states of all the lockers. (closes if open, opens if closed) 2) Kid 2 switches the state of all lockers with even numbers. (closes if open, opens if closed) 3) Kid 3 switches the state of all locker with triangle numbers. (closes if open, opens if closed) 4) Kid 4 switches the states of all lockers with square numbers. (closes if open, opens if closed) suppose there's a locker whose number is 16. - if Kid 1 enters she'll switch its door. - if Kid 2 enters she'll switch its door.. (because 16 is an even number) - if Kid 3 enters she won't touch 16th locker because 16 not a triangle number. - if Kid 4 enters she'll switch its door because 16 is a square number. These kids may enter the locker room in random order but each one of them does their mischief and sneak out the gym! The gym manager is pissed off and fixes a CCTV camera to track who's entering the corridor to figure who's entering when. Write C program that takes the order in which the 4 kids pass by the corridor as input and outputs the state of the doors within a desired range. Example 1: Input: 2341 45 55 Where: 2 3 4 1 means kid 2 enter first, followed by kid 3, kid 4 and so on. We want the state of the doors whose numbers range from 45 to 55 Output: 1000101000 Example 2: Input: 3142 90 100 Output: 0101010111 Note: 1) Triangle numbers are numbers of the form n*(n+1)/2 for n = 1,2,3.... For example: 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190,... are triangle numbers. 2) Square number are number of the form n^2 for n = 1,2,3... 1, 4, 9, 16, 25, 36... are square numbers.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply