← All premium-model tests
Complex Reasoning · Flagship models only · Jun 21, 2026

Solving a Constraint Logic Puzzle: Which Premium AI Wins?

A five-house constraint-satisfaction puzzle with five interlocking clues and a single valid solution. The model must reason through both cases, eliminate the dead end, and report the exact arrangement and count. We sent this exact task to all 4 top-tier flagship models through the live API and measured real speed, cost, and accuracy. The full output of every model is included below — click any row to read it.

Best value
Claude Opus 4.8
100/100 · Anthropic
Fastest
Claude Opus 4.8
97.3 t/s · 10.1 s
Cheapest run
Gemini 3.1 Pro
$0.006576

The prompt

Every model received exactly this (GLM 5.2 in Max reasoning mode, the others at default settings):

Solve this logic puzzle by reasoning it through, then give a final answer.

Five houses stand in a row, numbered 1 to 5 from left to right. Each house is painted a different color, one of: red, blue, green, yellow, white. The following clues all hold:
1. The green house is immediately to the right of the white house.
2. The red house is somewhere to the left of the blue house (not necessarily adjacent).
3. The yellow house is at one of the two ends of the row.
4. There are exactly two houses between the green house and the yellow house.
5. The blue house is not at either end.

How many distinct color arrangements satisfy ALL of these clues? List every valid arrangement as house 1 through house 5, and then state the final count on its own line.

How accuracy was graded

  • Finds the one valid arrangement: White, Green, Red, Blue, Yellow (houses 1–5).
  • States the correct final count of 1.
  • Shows sound case analysis on both yellow-end positions and uses every clue to eliminate the dead end.
  • Gives a clear final answer with the count on its own line.
Verified ground truth: Exactly one arrangement satisfies all five clues — House 1: White, 2: Green, 3: Red, 4: Blue, 5: Yellow — so the count is 1 (verified by exhaustive search over all 120 permutations).

Results — sortable by speed, cost & accuracy

Click Accuracy, Speed, or Cost to re-sort. Click any row to read the full model output.
Per-model results: accuracy, speed (tokens/sec), provider cost (USD), and the full prompt-vs-output for each model on this task.
#ModelAccuracy Speed Cost Output
Agent grade — 100/100. Correct unique arrangement and count (1) with tight, rigorous case analysis on both yellow positions, final count on its own line. Now that the live API reports real usage for this model, its true cost is shown — by far the priciest run here.
Verbatim output (178 in / 822 out tokens, 37818 ms, $0.1533)
Let the houses be positions 1–5.

- Since the **green house is immediately to the right of the white house**, the pair must be one of:
  - (1,2) = white, green
  - (2,3) = white, green
  - (3,4) = white, green
  - (4,5) = white, green

- The **yellow house is at an end** (position 1 or 5), and there are **exactly two houses between green and yellow**, so green must be 3 positions away from yellow.

## Case 1: Yellow at 1
Then green must be at 4.  
So white must be at 3.

Arrangement so far:
1. yellow
2. ?
3. white
4. green
5. ?

The remaining colors are red and blue.  
Since **red is left of blue**, we must have:
2. red
5. blue

But **blue cannot be at either end**, and position 5 is an end.  
So this case is impossible.

## Case 2: Yellow at 5
Then green must be at 2.  
So white must be at 1.

Arrangement so far:
1. white
2. green
3. ?
4. ?
5. yellow

The remaining colors are red and blue.  
Since **red is left of blue**, we must have:
3. red
4. blue

Blue is not at an end, so this works.

## Valid arrangement
1. white, 2. green, 3. red, 4. blue, 5. yellow

1
Agent grade — 100/100. Correct arrangement and count via tight, fully-verified case analysis on both yellow positions, with a final five-clue check. The leading <think> block is Opus 4.8's reasoning channel surfaced by our gateway, not dumped into the answer — the final solution itself is clean and correct.
Verbatim output (246 in / 985 out tokens, 10119 ms, $0.025855)
<think>
Houses 1-5. Colors: red, blue, green, yellow, white.

Clue 1: green = white+1 (white immediately left of green).
Clue 2: red < blue.
Clue 3: yellow at position 1 or 5.
Clue 4: |green - yellow| = 3.
Clue 5: blue not at 1 or 5.

Let me enumerate by yellow position.

Case yellow=1:
Clue 4: green = 1±3 = 4 (since -2 invalid). So green=4.
Clue 1: white=3.
Remaining: red, blue for positions 2,5.
Clue 5: blue not at 5, so blue=2, red=5. But clue 2: red<blue → 5<2 false. Invalid.

So no valid with yellow=1.

Case yellow=5:
Clue 4: green = 5±3 = 2 or 8. green=2.
Clue 1: white=1.
Remaining: red, blue for positions 3,4.
Clue 5: blue not at 1,5, ok both. 
Clue 2: red<blue. Positions 3,4: red=3, blue=4. Valid.
Arrangement: 1 white, 2 green, 3 red, 4 blue, 5 yellow.

Check all clues: green(2)=white(1)+1 ✓. red(3)<blue(4) ✓. yellow=5 end ✓. |green-yellow|=|2-5|=3 ✓. blue=4 not end ✓.

Only one arrangement.
</think>

## Reasoning

**Clue constraints:**
- Green = White + 1 (adjacent)
- Red < Blue
- Yellow at position 1 or 5
- |Green − Yellow| = 3
- Blue at position 2, 3, or 4

**Case: Yellow = 1**
- Clue 4: Green = 4 (only valid option). So White = 3.
- Remaining positions 2 and 5 get red and blue.
- Clue 5 forbids blue at 5, so Blue = 2, Red = 5.
- But Clue 2 needs Red < Blue → 5 < 2, false. ❌ No solution.

**Case: Yellow = 5**
- Clue 4: Green = 2 (only valid option). So White = 1.
- Remaining positions 3 and 4 get red and blue.
- Clue 2 (Red < Blue): Red = 3, Blue = 4.
- Check Clue 5: Blue = 4, not an end. ✓

This gives:
**House 1: White, House 2: Green, House 3: Red, House 4: Blue, House 5: Yellow**

Verify all clues: Green(2)=White(1)+1 ✓; Red(3)<Blue(4) ✓; Yellow at end ✓; |2−5|=3 ✓; Blue not at end ✓.

## Valid Arrangement(s)
1. White, Green, Red, Blue, Yellow

**1**
Agent grade — 99/100. Reaches the correct arrangement and count with sound, fully-verified case analysis. The long <think> section is GLM's reasoning surfaced by our gateway from its separate reasoning channel (not dumped into the answer), so it isn't penalised — the final solution itself is clean and correct.
Verbatim output (185 in / 2827 out tokens, 38370 ms, $0.012698)
<think>
The problem asks for the number of distinct color arrangements of 5 houses in a row, numbered 1 to 5 from left to right.
The colors are red, blue, green, yellow, white.
Clues:
1. Green is immediately to the right of White. (W, G)
2. Red is somewhere to the left of Blue.
3. Yellow is at one of the two ends (house 1 or house 5).
4. There are exactly two houses between Green and Yellow.
5. Blue is not at either end (so Blue is in house 2, 3, or 4).

Let's analyze the positions of Yellow and the W-G block.
Yellow is at 1 or 5.
Case 1: Yellow is at 1.
Since there are exactly two houses between Green and Yellow, Green must be at 4.
If Green is at 4, White must be at 3 (since Green is immediately to the right of White).
So we have:
1: Yellow
2: ?
3: White
4: Green
5: ?
The remaining colors are Red and Blue.
They must go in houses 2 and 5.
Clue 5 says Blue is not at either end. So Blue cannot be at 5.
Thus, Blue must be at 2, and Red must be at 5.
But Clue 2 says Red is somewhere to the left of Blue.
If Blue is at 2 and Red is at 5, Red is to the right of Blue. This violates Clue 2.
So Case 1 yields no valid arrangements.

Case 2: Yellow is at 5.
Since there are exactly two houses between Green and Yellow, Green must be at 2.
If Green is at 2, White must be at 1 (since Green is immediately to the right of White).
So we have:
1: White
2: Green
3: ?
4: ?
5: Yellow
The remaining colors are Red and Blue.
They must go in houses 3 and 4.
Clue 5 says Blue is not at either end. Houses 3 and 4 are not ends, so this is satisfied.
Clue 2 says Red is to the left of Blue.
So Red must be at 3, and Blue must be at 4.
Let's check all clues for this arrangement:
1: White
2: Green
3: Red
4: Blue
5: Yellow

Clue 1: Green is immediately to the right of White. (W at 1, G at 2) - Yes.
Clue 2: Red is to the left of Blue. (R at 3, B at 4) - Yes.
Clue 3: Yellow is at one of the two ends. (Y at 5) - Yes.
Clue 4: Exactly two houses between Green and Yellow. (G at 2, Y at 5, houses 3 and 4 are between) - Yes.
Clue 5: Blue is not at either end. (B at 4) - Yes.

Are there any other possibilities?
Let's double check.
Could Yellow be at 1 and Green at 4? We checked this, it leads to W at 3, Y at 1. Remaining houses 2, 5 for R, B. B cannot be at 5, so B at 2, R at 5. But R must be left of B. Contradiction.
Could Yellow be at 5 and Green at 2? We checked this, it leads to W at 1, Y at 5. Remaining houses 3, 4 for R, B. B cannot be at 5 (already satisfied). R must be left of B, so R at 3, B at 4. This works.

Wait, are there any other interpretations of "exactly two houses between"?
If Yellow is at 1, Green is at 4. Houses 2 and 3 are between. That's exactly two houses.
If Yellow is at 5, Green is at 2. Houses 3 and 4 are between. That's exactly two houses.
Are there any other positions for Yellow? No, clue 3 says Yellow is at one of the two ends.
Are there any other positions for Green? No, because the distance between 1 and 4 is 2 houses, and between 2 and 5 is 2 houses.
So Green must be at 2 or 4.
If Green is at 4, White is at 3.
If Green is at 2, White is at 1.

Let's quickly review the steps.
Colors: R, B, G, Y, W.
Positions: 1, 2, 3, 4, 5.
Y is at 1 or 5.
If Y=1, G=4. W=3. Remaining: 2, 5 for R, B.
B cannot be at 5 (end), so B=2, R=5.
But R must be left of B. 5 is not left of 2. Invalid.

If Y=5, G=2. W=1. Remaining: 3, 4 for R, B.
B cannot be at ends (3 and 4 are not ends, so both valid).
R must be left of B, so R=3, B=4. Valid.

Is there any ambiguity in "The green house is immediately to the right of the white house"?
No, it means W is at x, G is at x+1.
Is there any ambiguity in "exactly two houses between"?
No, |pos(G) - pos(Y)| = 3.
Is there any ambiguity in "The red house is somewhere to the left of the blue house"?
No, pos(R) < pos(B).

Let's check if there's any other way.
What if Yellow is at 1, Green is at 4, White is at 3.
Houses: 1: Y, 2: ?, 3: W, 4: G, 5: ?
Colors left: R, B.
If B=2, R=5. R is not left of B.
If B=5, R=2. B is at an end, which violates clue 5.
So no solution for Y=1.

What if Yellow is at 5, Green is at 2, White is at 1.
Houses: 1: W, 2: G, 3: ?, 4: ?, 5: Y.
Colors left: R, B.
If R=3, B=4. R is left of B. B is not at an end. Valid.
If R=4, B=3. R is not left of B. Invalid.

So there is exactly 1 valid arrangement.
The arrangement is:
House 1: White
House 2: Green
House 3: Red
House 4: Blue
House 5: Yellow

Let me re-read the prompt to make sure I didn't miss anything.
"Five houses stand in a row, numbered 1 to 5 from left to right."
"Each house is painted a different color, one of: red, blue, green, yellow, white."
"1. The green house is immediately to the right of the white house." -> W, G
"2. The red house is somewhere to the left of the blue house (not necessarily adjacent)." -> R < B
"3. The yellow house is at one of the two ends of the row." -> Y=1 or Y=5
"4. There are exactly two houses between the green house and the yellow house." -> |G - Y| = 3
"5. The blue house is not at either end." -> B != 1, B != 5

Everything seems perfectly straightforward.
Let's write down the solution clearly.
- State the possible positions for Yellow based on Clue 3 (1 or 5).
- Use Clue 4 to find the corresponding positions for Green (4 or 2).
- Use Clue 1 to find the corresponding positions for White (3 or 1).
- Evaluate the two cases:
  - Case 1: Y=1, G=4, W=3. Remaining positions for R and B are 2 and 5. Clue 5 says B cannot be 5, so B=2, R=5. But Clue 2 says R must be left of B, which is violated. So this case is invalid.
  - Case 2: Y=5, G=2, W=1. Remaining positions for R and B are 3 and 4. Clue 2 says R must be left of B, so R=3, B=4. Clue 5 is satisfied since B is not at an end. This case is valid.
- Conclude there is exactly 1 valid arrangement.
- List the arrangement as house 1 through house 5.
- State the final count on its own line.

The arrangement:
House 1: White
House 2: Green
House 3: Red
House 4: Blue
House 5: Yellow

Final count: 1

Let me double check the "exactly two houses between" part.
If Y is at 1, and G is at 4.
Houses between 1 and 4 are 2 and 3. That's exactly two houses.
If Y is at 5, and G is at 2.
Houses between 2 and 5 are 3 and 4. That's exactly two houses.
Yes, this is correct.

What if "exactly two houses between" means the distance is 2?
No, "two houses between" means there are two houses separating them. For example, between house 1 and house 4, there are houses 2 and 3. That's two houses. If it meant distance is 2, it would be "one house between". So |G - Y| = 3 is correct.

Let's do a quick sanity check.
Colors: R, B, G, Y, W.
Arrangement: W, G, R, B, Y.
1. Green immediately right of White: W at 1, G at 2. Yes.
2. Red left of Blue: R at 3, B at 4. Yes.
3. Yellow at an end: Y at 5. Yes.
4. Exactly two houses between Green and Yellow: G at 2, Y at 5. Houses 3 and 4 are between. Yes.
5. Blue not at either end: B at 4. Yes.

Everything is consistent. The logic is solid. No other interpretations seem likely.
I will structure the output to show the reasoning, list the valid arrangement, and then state the final count.
</think>
To solve this logic puzzle, we can deduce the positions of the houses step-by-step using the given clues:

**Step 1: Determine the possible positions for the Yellow and Green houses.**
* Clue 3 states that the yellow house is at one of the two ends (house 1 or house 5).
* Clue 4 states that there are exactly two houses between the green house and the yellow house. 
This gives us two possible scenarios:
* **Scenario A:** Yellow is in house 1, which means Green must be in house 4.
* **Scenario B:** Yellow is in house 5, which means Green must be in house 2.

**Step 2: Place the White house.**
* Clue 1 states that the green house is immediately to the right of the white house (meaning they are a pair: White, Green).
* In **Scenario A** (Green in 4), White must be in house 3. 
* In **Scenario B** (Green in 2), White must be in house 1.

**Step 3: Place the Red and Blue houses.**
* Clue 5 states that the blue house is not at either end, meaning it cannot be in house 1 or house 5.

Let's test **Scenario A**:
* Houses: 1: Yellow, 2: ?, 3: White, 4: Green, 5: ?
* The remaining colors for houses 2 and 5 are Red and Blue. 
* Since Blue cannot be at an end (house 5), Blue must be in house 2, leaving Red in house 5.
* However, Clue 2 says the red house is to the left of the blue house. Here, Red (5) is to the right of Blue (2), which violates the clue. 
* Therefore, Scenario A is invalid.

Let's test **Scenario B**:
* Houses: 1: White, 2: Green, 3: ?, 4: ?, 5: Yellow
* The remaining colors for houses 3 and 4 are Red and Blue. 
* Clue 2 says Red is to the left of Blue. Therefore, Red must be in house 3 and Blue must be in house 4.
* Let's check Clue 5: Blue is in house 4, which is not an end. This fits perfectly.

The only valid arrangement is:
House 1: White
House 2: Green
House 3: Red
House 4: Blue
House 5: Yellow

1
Agent grade — 98/100. Correct arrangement and count via clean step-by-step deduction. Slightly lighter on explicit verification than Opus, but fully sound and the cheapest correct answer here.
Verbatim output (180 in / 518 out tokens, 22828 ms, $0.006576)
To find the valid color arrangements, we can deduce the positions of the houses step by step (numbered 1 to 5 from left to right):

1. **Analyze Yellow and Green's positions:**
Clue 3 states the yellow house is at one of the two ends (Position 1 or Position 5). 
Clue 4 states there are exactly two houses between the green house and the yellow house. 
- *Case A:* If the yellow house is at Position 1, the green house must be at Position 4.
- *Case B:* If the yellow house is at Position 5, the green house must be at Position 2.

2. **Analyze White's position:**
Clue 1 states the green house is immediately to the right of the white house. This means the white house is exactly one spot to the left of the green house.
- *Case A:* If green is at 4, white must be at 3. (Arrangement so far: 1:Yellow, 2:Empty, 3:White, 4:Green, 5:Empty)
- *Case B:* If green is at 2, white must be at 1. (Arrangement so far: 1:White, 2:Green, 3:Empty, 4:Empty, 5:Yellow)

3. **Analyze Red and Blue's positions:**
The remaining colors to place are red and blue. Clue 2 states the red house is somewhere to the left of the blue house.
- *Case A:* The empty spots are 2 and 5. For red to be to the left of blue, red must be at 2 and blue must be at 5. However, Clue 5 states the blue house cannot be at either end. Since Position 5 is an end, **Case A is invalid.**
- *Case B:* The empty spots are 3 and 4. For red to be to the left of blue, red must be at 3 and blue must be at 4. Let's check Clue 5: Blue is at Position 4, which is not an end. This works perfectly!

This leaves us with exactly one valid arrangement that satisfies all the clues.

**Valid Arrangement:**
House 1: White, House 2: Green, House 3: Red, House 4: Blue, House 5: Yellow

1

Verdict

On this complex reasoning task, Claude Opus 4.8 offered the best accuracy-for-money (100/100). The fastest answer came from Claude Opus 4.8 at 97.3 tokens/sec, while Gemini 3.1 Pro was cheapest to run — the priciest run here (GPT-5.4 Pro) cost roughly 23× as much for a comparable answer. When every model is this capable, the real question stops being “can it do it?” and becomes “how much time and money did the answer cost?” — expand the rows above to judge for yourself.

More premium-model tests

Advanced Coding
Median of Two Sorted Arrays in O(log n)
View results →
On a budget?
Cheap-model tests (under $3/M)
View results →

Test it with your own prompt

Run all these flagship models side by side on the hard problem that actually matters to you.

Open the live playground →