This is a verified interview question from Gs-(goldman-sachs). Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Seating Arrangement Scatter Calculation" covers key patterns like Other.
"Malathi is a teacher who teaches Grade 2. She has fifteen students in her class, with seats assigned in a 4x4 grid, and one seat left empty. The assigned seating arrangement is as follows, with students represented from A to O, and a '.' (dot) representing the empty seat: A B C D E F G H I J K L M N O .  However, every morning when the students come in, they sit in any seat randomly. When Malathi arrives and sees this, she asks all the children to move to their assigned seats. Since this happens on a daily basis, Malathi began to wonder how different the seating arrangement is compared to the assigned seating. To measure this, she wants to calculate the "scatter" of the seating arrangement. To calculate the scatter, one needs to measure the Manhattan distance for each student between their current position and their assigned position, and sum up all these distances. The Manhattan distance between two seats is the sum of absolute differences between the rows and columns of the two seats. Write a program that calculates the scatter of the given seating arrangement. Read the input from STDIN and print the output to STDOUT. Do not print arbitrary strings anywhere in the program, as these contribute to the standard output and test cases will fail. Constraints: - The seating arrangement is always a 4x4 grid, and assigned seating is fixed as given above. - The empty seat is also to be included in the scatter calculation. Input Format: The input will consist of four lines, each containing four characters. Together, the 16 characters will include the uppercase letters A to O and a '.' (dot). Output Format: A single line of output should contain the scatter value."
Join thousands of developers practicing for Gs-(goldman-sachs).