Sin
2013-05-16 20:01:25
C4 Assignment The Mad Jailor
*
One night, the Mad Jailor at the Kingston Penitentiary went crazy. The 25 jail cells began like this (u=unlocked, l=locked):
lllllllllllllllllllllllll
After all of the inmates were deeply asleep, the jailor walked down the aisle of 100 cells in the prison and unlocked every one. The doors looked like (u=unlocked, l=locked):
uuuuuuuuuuuuuuuuuuuuuuuuu
Then the jailor walks down the row locking every 3rd cell. The cells then look like:
uuluuluuluuluuluuluuluulu
Then the jailor walks down the row unlocking every 4th cell if it is locked or locking the cell if it is unlocked. The cells then look like:
uullululluuuuullululluuuu
Then the jailor walks down the row unlocking every 5th cell if it is locked or locking the cell if it is unlocked. The cells then look like:
uullllullluuuuululuuluuul
The jailor continues walking down the row unlocking or relocking cells. The jailor begins by walking to the right down the aisle. After one sweep he reverses direction and sweeps left (skipping cell). Therefore, the jailor alternates right, then left when he walks down the aisle. Once he finishes skipping every 5th cell, he resets the skipping sequence to lock/unlock every 3rd cell. He resets back to skipping every 3rd cell after each time he skips every 5th cell. Assuming that the prisoners stayed asleep all night, how many walks down the aisle will it take before ALL cells are locked again?
Write a program that:
Displays in Application mode, not in an Applet.
Uses a char array to store whether the cell is locked (l) or unlocked (u).
After each sweep of key turning, print the array values to the screen.
At the end of the program (cells become ALL ālā again), print the number of sweeps taken to reach that point. Print the number of sweeps taken after each re-arrangement of the array.
Make methods to initialize the arrays, turn the keys, print the number of the unlocked and locked doors to the screen. Print the array.
Can someone help me out with that? It's so freaking annoying, I don't understand what it's even asking…
*
One night, the Mad Jailor at the Kingston Penitentiary went crazy. The 25 jail cells began like this (u=unlocked, l=locked):
lllllllllllllllllllllllll
After all of the inmates were deeply asleep, the jailor walked down the aisle of 100 cells in the prison and unlocked every one. The doors looked like (u=unlocked, l=locked):
uuuuuuuuuuuuuuuuuuuuuuuuu
Then the jailor walks down the row locking every 3rd cell. The cells then look like:
uuluuluuluuluuluuluuluulu
Then the jailor walks down the row unlocking every 4th cell if it is locked or locking the cell if it is unlocked. The cells then look like:
uullululluuuuullululluuuu
Then the jailor walks down the row unlocking every 5th cell if it is locked or locking the cell if it is unlocked. The cells then look like:
uullllullluuuuululuuluuul
The jailor continues walking down the row unlocking or relocking cells. The jailor begins by walking to the right down the aisle. After one sweep he reverses direction and sweeps left (skipping cell). Therefore, the jailor alternates right, then left when he walks down the aisle. Once he finishes skipping every 5th cell, he resets the skipping sequence to lock/unlock every 3rd cell. He resets back to skipping every 3rd cell after each time he skips every 5th cell. Assuming that the prisoners stayed asleep all night, how many walks down the aisle will it take before ALL cells are locked again?
Write a program that:
Displays in Application mode, not in an Applet.
Uses a char array to store whether the cell is locked (l) or unlocked (u).
After each sweep of key turning, print the array values to the screen.
At the end of the program (cells become ALL ālā again), print the number of sweeps taken to reach that point. Print the number of sweeps taken after each re-arrangement of the array.
Make methods to initialize the arrays, turn the keys, print the number of the unlocked and locked doors to the screen. Print the array.
Can someone help me out with that? It's so freaking annoying, I don't understand what it's even asking…