Placement Aptitude (Quant, Logical, Verbal) Module 12 – Arrangements, relations and puzzles
Ranking and linear seating arrangements
Ranking and seating in a row for aptitude tests: positions from both ends, rows that face north or south, and a method that places the tightest clue first.
What you will learn
- Solve ranking problems from the top, bottom, left and right
- Arrange people in a row from clues about positions and neighbours
- Track left and right correctly when people face north or south
What you’ll learn
What you will learn
- Solve ranking problems from the top, bottom, left and right
- Arrange people in a row from clues about positions and neighbours
- Track left and right correctly when people face north or south
On this page
A ranking question gives someone’s position counted from two ends of a list, a queue or a row, and asks for the total, a missing position or the number of people between two others. Linear seating arrangements put people in a row and give clues about seats and neighbours. Both rest on one count: in a line of n people, a position from one end plus the position from the other end is n + 1. Rows add one trap: left and right belong to the sitters, so they flip when the row faces you. The method: draw the seats, place the most constrained person first, split the rest into cases and cross out each case that breaks a clue. This lesson works five examples, checks a seven-person row against all 5,040 orders, and ends with an untimed set of ten.
Positions from both ends
Ranking questions count positions from the two ends of one line. If Ishaan is 14th from the top of a merit list and 23rd from the bottom, 13 names are above his and 22 below, so the list has 36 names. Adding the two positions counts him twice:
| Asked | Rule | Example |
|---|---|---|
| The total | Add the two positions, subtract 1 | 14th from the top and 23rd from the bottom: 36 |
| A position from the other end | Total − position + 1 | 22nd from the right of 30: 9th from the left |
| People between two others | Count both from one end, then the gap minus 1 | 9th and 12th from the left: 2 between |
From opposite ends, total − a − b counts the people between only while the two have not passed each other; a negative result means they overlap, so convert one position first.
Rows that face north or south
Draw the row as on a map, north at the top, and number the chairs from your left. Your left side is towards the west when you face north, so people facing north have their left on your left. People facing south face you: their left is on your right, and every “left” clue moves towards the right-hand end of your drawing.
Which way is left depends on which way the row faces
Text description of the diagram
Two rows of five chairs, numbered 1 to 5 from your left, with north at the top of the page. In the upper row an arrow above each chair points north: the sitters have their backs to you, so their left is on your left, towards chair 1, and their right is towards chair 5. In the lower row an arrow below each chair points south: the sitters face you, so their right is towards chair 1, on your left, and their left is towards chair 5, on your right. A clue such as "second to the left of the person in chair 3" therefore means chair 1 in the upper row and chair 5 in the lower row.
Read clue words strictly: “immediately left” is the next chair, “second to the left” skips one chair, “somewhere to the left” allows any chair on that side, and “between” means the space separating the two people named, who are never counted.
Place the tightest clue first
- Draw the chairs, number them from your left and write the facing above them.
- Place what is certain: an end, the middle chair, a fixed position.
- Join people that a clue ties together, such as “immediately left of”, into blocks.
- When a clue allows two places, draw one row per case and carry both forward.
- Cross out a case as soon as a clue fails; stop when one row is left or the question has one answer in every row.
The same steps solve linear seating arrangements of any size; only the number of cases grows.
Five solved examples
-
Total. Ishaan is 14th from the top and 23rd from the bottom: 14 + 23 − 1 = 36 names.
-
Swapped places. In a canteen queue, Riya is 7th from the front and Sameer 11th from the back. They swap, and Riya is now 15th from the front. She stands where Sameer stood, 15th from the front and 11th from the back, so the queue has 25 people.
-
Overlap. In a row of 30, Asha is 12th from the left and Kabir 22nd from the right. Kabir is 30 − 22 + 1 = 9th from the left, so 2 people sit between them, not 30 − 12 − 22 = −4.
-
Facing south. Five friends face south, Pia in the middle chair. Om sits second to her left, your right: chair 5.
-
A seven-person row. At a college-fest stall, Anil, Bela, Chetan, Divya, Esha, Farhan and Gauri sit in a row of seven chairs facing south, towards the visitors. Divya sits at one end. Exactly two people sit between Divya and Gauri. Bela sits to the immediate left of Gauri. Chetan sits third to the right of Esha. Anil is not a neighbour of Chetan. Farhan sits somewhere to the right of Anil.
Divya is in chair 1 or 7, so Gauri is in chair 4 either way, and Bela, on Gauri’s left (your right), in chair 5. Chetan sits three chairs towards your left from Esha, which fits only Esha in 6 and Chetan in 3. With Divya in chair 7, Anil must avoid Chetan and take chair 1, leaving no chair on his right for Farhan, so that case fails. With Divya in chair 1, Anil takes chair 7 and Farhan chair 2: Divya, Farhan, Chetan, Gauri, Bela, Esha, Anil.
The program tries all 7! = 5,040 orders and keeps those that fit each clue in turn.
// The lesson's five solved examples: four ranking and facing rules, then the seven-person stall row checked
// against every possible order of the seven volunteers.
// In a line of people, a position from one end plus the position from the other end counts one person twice.
const total = (fromOneEnd, fromOtherEnd) => fromOneEnd + fromOtherEnd - 1;
const fromOtherEnd = (people, position) => people - position + 1;
console.log(`1. 14th from the top and 23rd from the bottom: ${total(14, 23)} names`);
console.log(`2. Riya stands where Sameer stood, 15th from the front and 11th from the back: ${total(15, 11)} people`);
const kabir = fromOtherEnd(30, 22);
console.log(`3. Kabir is ${kabir}th from the left and Asha 12th: ${12 - kabir - 1} people between them (30 - 12 - 22 = ${30 - 12 - 22}: they overlap)`);
// Chairs are numbered from the reader's left. Facing south, one chair to a sitter's left is one chair to the reader's right.
console.log(`4. Pia in the middle chair, 3 of 5, faces south; Om sits second to her left: chair ${3 + 2}, the reader's right-hand end`);
// 5. Seven volunteers in chairs 1 to 7 from the reader's left, all facing south towards the visitors.
const names = ['Anil', 'Bela', 'Chetan', 'Divya', 'Esha', 'Farhan', 'Gauri'];
const LEFT = 1;
const RIGHT = -1;
const clues = [
['Divya sits at one end', (c) => c.Divya === 1 || c.Divya === 7],
['Exactly two people sit between Divya and Gauri', (c) => Math.abs(c.Divya - c.Gauri) === 3],
['Bela sits to the immediate left of Gauri', (c) => c.Bela === c.Gauri + LEFT],
['Chetan sits third to the right of Esha', (c) => c.Chetan === c.Esha + 3 * RIGHT],
['Anil is not a neighbour of Chetan', (c) => Math.abs(c.Anil - c.Chetan) !== 1],
['Farhan sits somewhere to the right of Anil', (c) => (c.Farhan - c.Anil) * RIGHT > 0],
];
/** Every order of the items (7 items give 7! = 5,040 orders). */
function orders(items) {
if (items.length <= 1) return [items.slice()];
const out = [];
items.forEach((first, i) => {
for (const rest of orders([...items.slice(0, i), ...items.slice(i + 1)])) out.push([first, ...rest]);
});
return out;
}
let rows = orders([1, 2, 3, 4, 5, 6, 7]).map((chairs) => Object.fromEntries(names.map((name, i) => [name, chairs[i]])));
console.log(`5. ${rows.length} possible orders of the seven volunteers`);
for (const [clue, fits] of clues) {
rows = rows.filter(fits);
console.log(` ${clue}: ${rows.length} left`);
}
const fromTheLeft = (row) => names.slice().sort((a, b) => row[a] - row[b]).join(', ');
console.log(` From the reader's left: ${fromTheLeft(rows[0])}`); Output
1. 14th from the top and 23rd from the bottom: 36 names 2. Riya stands where Sameer stood, 15th from the front and 11th from the back: 25 people 3. Kabir is 9th from the left and Asha 12th: 2 people between them (30 - 12 - 22 = -4: they overlap) 4. Pia in the middle chair, 3 of 5, faces south; Om sits second to her left: chair 5, the reader's right-hand end 5. 5040 possible orders of the seven volunteers Divya sits at one end: 1440 left Exactly two people sit between Divya and Gauri: 240 left Bela sits to the immediate left of Gauri: 48 left Chetan sits third to the right of Esha: 4 left Anil is not a neighbour of Chetan: 2 left Farhan sits somewhere to the right of Anil: 1 left From the reader's left: Divya, Farhan, Chetan, Gauri, Bela, Esha, Anil
Recorded with Node.js 24.21.0 on macOS 26 arm64. To run it yourself: mise exec node@24.21.0 -- node row_puzzle.mjs
Runs on this device, in your browser. The first run downloads JavaScript (about 0.6 MB), which is kept for the next runs.
Your run, in this browser
Your turn
The exercise counts the people between two others from positions at opposite ends; the ten questions are untimed.
Exercise · Easy · JavaScript
How many people sit between two others
Write between(total, aFromLeft, bFromRight) for a row of total people, where A is aFromLeft-th from the left end and B is bFromRight-th from the right end. All three are whole numbers.
Return the number of people who sit strictly between A and B. Return null when the positions cannot describe two different people of the row: a position below 1 or above total, or two positions that name the same seat.
For the third solved example, between(30, 12, 22) returns 2: Kabir is 9th from the left, Asha 12th, and the people in seats 10 and 11 sit between them. The sample tests include rows where the two people have passed each other, two neighbours, two people at the ends, and positions that do not fit the row.
Starter code · between.mjs
/**
* A row of `total` people; A is aFromLeft-th from the left end and B is bFromRight-th from the right end. Returns the
* number of people strictly between A and B, or null when the positions cannot describe two different people.
*/
export function between(total, aFromLeft, bFromRight) {
// Replace this line with your code (this one subtracts from the total, which fails when the two overlap).
return total - aFromLeft - bFromRight;
} The sample tests · between.test.mjs
import { test, assert } from 'mysmartcopilot:test';
import { between } from './between.mjs';
test('Asha and Kabir: 12th from the left and 22nd from the right of 30', () => {
assert.equal(between(30, 12, 22), 2);
});
test('no overlap: 11th from the left and 19th from the right of 35', () => {
assert.equal(between(35, 11, 19), 5);
});
test('overlap: 18th from the left and 33rd from the right of 45', () => {
assert.equal(between(45, 18, 33), 4);
});
test('the two ends of a row of 8', () => {
assert.equal(between(8, 1, 1), 6);
});
test('neighbours who have not passed each other', () => {
assert.equal(between(9, 4, 5), 0);
});
test('neighbours who have passed each other', () => {
assert.equal(between(9, 5, 6), 0);
});
test('two positions that name the same seat', () => {
assert.equal(between(10, 3, 8), null);
});
test('a position beyond the end of the row', () => {
assert.equal(between(10, 11, 1), null);
});
test('a position of zero', () => {
assert.equal(between(12, 4, 0), null);
}); A hint
Check the ranges first. Then turn B's position into a position from the left, total - bFromRight + 1, so that both are counted from the same end. If the two seat numbers are equal, both positions name one seat. Otherwise the people strictly between two seats are the difference of the seat numbers, minus 1, whichever seat is further left.
Results of the sample tests
| Test | Result | Details |
|---|
What your code printed
The sample tests run on this device, in your browser (QuickJS): nothing is sent to mysmartcopilot.com. The first run downloads JavaScript (about 0.6 MB), which is kept for the next runs. A check in your browser is feedback for you, not proof that the code is right for every input.
Ten questions, untimed
10 questions about this lesson. Every answer and why it is right is on the page, behind “Show the answer”. Your score stays in this browser.
Twelve more ranking and row items, with full working Pro: opens with a Pro, Premium or Ultimate pass
Ranking and row items fall into a few families, each with a trap that catches the hurried reader. Here are twelve new ones, worked line by line, each followed by the wrong answer it is designed to draw.
In this part:
- Totals and positions from two ends, worked
- Rows that face north, south or each other, worked
- Counting rows and spotting ‘cannot be determined’, worked
1 runnable example (JavaScript) · about 5 minutes
Opening this part with your pass…
This part opens with any MySmartCoPilot pass.
- Pro pass · 1 week₹79$2.99
- 30 days₹179$5.99
- 1 year₹1,699$45
One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.
Passes can’t be bought right now, so this part can’t be opened at the moment. The free part above stands on its own. If you have a pass, enter your licence key.
It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).
What each clue does, measured on the stall row by brute force Pro: opens with a Pro, Premium or Ultimate pass
A row puzzle is fair only when exactly one row fits, or when the question asked has the same answer in every row that fits. This part measures both on the stall puzzle, shows what one missing clue and one misread facing do, and counts how much the order of placing people costs a search.
In this part:
- Every clue is needed: rows left when one is dropped, measured
- Two rows, one answer: when to stop early
- A facing slip reproduced: a wrong row that fits every clue
- The order of placing people, with numbers
- An invariant for mixed facing
1 runnable example (JavaScript) · about 3 minutes
Opening this part with your pass…
This part opens with any MySmartCoPilot pass.
- Pro pass · 1 week₹79$2.99
- 30 days₹179$5.99
- 1 year₹1,699$45
One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.
Passes can’t be bought right now, so this part can’t be opened at the moment. The free part above stands on its own. If you have a pass, enter your licence key.
It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).
A ten-minute timed set, with answers and a rubric Pro: opens with a Pro, Premium or Ultimate pass
Ten row and ranking items, ten minutes on the clock: work them in one sitting, then mark yourself with the worked answers below and see where your score falls in the rubric.
In this part:
- Ten items for ten minutes
- Answers, with the shortest working and the trap
- A rubric for what your score says
1 runnable example (JavaScript) · about 4 minutes
Opening this part with your pass…
This part opens with any MySmartCoPilot pass.
- Pro pass · 1 week₹79$2.99
- 30 days₹179$5.99
- 1 year₹1,699$45
One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.
Passes can’t be bought right now, so this part can’t be opened at the moment. The free part above stands on its own. If you have a pass, enter your licence key.
It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).
Interview questions
-
Fresher · Warm-up
Why is a person's position from the top plus their position from the bottom one more than the number of people in the list?
Counting from the top, a position counts everyone above the person and the person once. Counting from the bottom, it counts everyone below and the person once more. The two positions together therefore cover the whole list with that one person counted twice, so their sum is the total plus 1. Ishaan, 14th from the top and 23rd from the bottom, gives 37, and the list has 36 names: 13 above him, 22 below him and Ishaan. The same idea converts a position to the other end: in a row of 30, the 22nd from the right is 30 − 22 + 1 = 9th from the left. A three-name list is a quick check: the middle name is 2nd from both ends, and 2 + 2 = 3 + 1.
-
Fresher
In a row of 25, Neel is 8th from the left and Owen is 20th from the right. A classmate works out 25 − 8 − 20 = −3 and says the question is faulty. Find how many people sit between them, explain the classmate's error and give a check.
-
Fresher
A seven-person row puzzle leaves two rows after all its clues, but the question asks only who sits in the middle chair, and that person is the same in both rows. Do you answer, mark "cannot be determined" or keep searching? Defend the choice with an example.
-
Fresher
Five people sit in a row facing south. A clue says "Hema sits second to the right of Ishaan", and a friend draws Hema two chairs to Ishaan's right on the page. What goes wrong, how do you fix it, and what habit prevents the slip in a timed test?
Key takeaways
- Position from one end + position from the other = total + 1; convert with total − position + 1.
- Count the people between two others only after both positions are counted from one end.
- Facing south, a sitter’s left is your right: write the facing above the chairs first.
- Place the tightest clue first, carry every case, and stop when one row or one answer is left.
References
- permutation (Dictionary of Algorithms and Data Structures) (National Institute of Standards and Technology (NIST))
- backtracking (Dictionary of Algorithms and Data Structures) (National Institute of Standards and Technology (NIST))
- Mathematics, Class 11, Chapter 6: Permutations and Combinations (National Council of Educational Research and Training (NCERT))
- left (adjective), Oxford Advanced Learner’s Dictionary (Oxford University Press)
- between (preposition), Oxford Advanced Learner’s Dictionary (Oxford University Press)
- immediately (adverb), Oxford Advanced Learner’s Dictionary (Oxford University Press)
Related tools
Report a problem with this lesson
Kept only in this browser. Your Learn progress