Sample

MBJP/22

Human rating uses the original dataset scale.

DatasetMBJP
Human5
Lines25

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett0.4740–1; higher is more readable
87.5Δ 6.2
Scalabrino0.9090–1; higher is more readable
75.0Δ 18.8
Dorn0.6890–1; higher is more readable
56.2Δ 37.5
Mi0.8620–1; higher is more readable
100.0Δ 6.2
LLOC7Logical lines; fewer is more readable
81.2Δ 12.5
DeepSeek V4 Pro19.330–20; mean of three runs
100.0Δ 6.2
GPT-6.1 Sol190–20; mean of three runs
93.8Δ 0.0
BTTF0.7540–1; higher is more readable
93.8Δ 0.0
Human51–5; original rating
93.8

Views

Source code

import java.util.*; class FindFirstDuplicate { /** * * Write a function to find the first duplicate element in a given array of integers. * * > findFirstDuplicate([1, 2, 3, 4, 4, 5]) * 4 * > findFirstDuplicate([1, 2, 3, 4]) * -1 * > findFirstDuplicate([1, 1, 2, 3, 3, 2, 2]) * 1 */ public static int findFirstDuplicate(List<Integer> nums) { Set<Integer> seen = new HashSet<>(); for (Integer num : nums) { if (seen.contains(num)) { return num; } else { seen.add(num); } } return -1; } }

Loading feature diagnosis…

Source regions

Feature contributions

Feature contributions

FeatureValueContribution
(log-odds)
Halstead volumeHow much symbolic information the code contains. It combines the total number of operators and values with the number of distinct ones.382.574−12.625
Source linesThe number of non-empty source lines.25+10
Byte entropyHow varied the bytes in the source text are. Repeated bytes give a lower value; a more even mixture gives a higher value.4.232−6.348

Intercept 8.87 + feature contributions = -0.103 (log-odds).
Score = sigmoid(-0.103) = 0.474.

Score0.909

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.90.88+0.662
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.065+0.308
Identifier layout (horizontal)How rapidly the visual pattern of identifier characters changes from left to right. It measures spatial frequency, not the meaning of the names.91−0.189
Indentation frequencyHow rapidly indentation changes from line to line.16−0.184
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.25+0.151
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.23.783−0.077
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.16+0.054

Intercept 0.07 + feature contributions = 0.794 (log-odds).
Score = sigmoid(0.794) = 0.689.

Score0.862
Score7
Run 1

The code is well-structured, clear, and easy to read. It uses a simple for-each loop and a HashSet to track seen elements. The logic is flat with only one level of nesting. Each action is on its own line, and the purpose is immediately clear from the method name and documentation. The code is concise, avoids unnecessary complexity, and follows natural reading flow from left to right, top to bottom.

Run 2

The code is highly readable. It uses a clear, flat structure with a single method and a straightforward for-loop. The logic is immediately obvious: iterate through the list, track seen numbers in a HashSet, and return the first duplicate encountered. There is minimal nesting (one level inside the loop), clear intent, and concise length. Each action is on its own line, and the reading flow is natural. Although the else block could be omitted for brevity, its presence is not harmful and arguably improves clarity. Documentation with examples is included, enhancing understandability.

Run 3

The code is highly readable. It has a clear class and method name, a concise docstring with illustrative examples, and a flat control flow with minimal nesting. The logic is straightforward: use a HashSet to track seen numbers and return the first repeated element. Each iteration performs a single logical check, and the early return avoids unnecessary processing. The code is concise, uses standard Java idioms, and follows a natural reading flow from problem description to implementation.

Run 1

Code Structure: The method is logically organized around tracking seen values and returning the first repeated value. Nesting: Only a loop and a simple conditional are nested; the else is unnecessary after an early return. Clarity of intent: Descriptive class, method, and variable names, plus examples, make the purpose clear, although the documentation says array while the parameter is a List. Code length: Short and focused, with no substantial redundancy. Action granularity: Each statement performs one clear action. Reading flow: Initialization, sequential scanning, duplicate detection, and the fallback return follow a natural order. Minor distractions include the wildcard import and the stray asterisk in the documentation.

Run 2

Code Structure: Logically organized into a single focused method with a set tracking previously encountered values. Nesting: Shallow loop-and-conditional nesting is easy to follow, though the else is unnecessary after an early return. Clarity of intent: Descriptive names and illustrative examples clearly communicate the purpose; the documentation slightly mismatches the List parameter by calling it an array. Code length: Concise, with no substantial redundancy. Action granularity: Each statement performs one clear action. Reading flow: Natural progression from initialization through iteration, duplicate detection, and the fallback return. Minor distractions include the wildcard import and stray asterisk in the documentation.

Run 3

Code Structure: Imports, class, documentation, and method are logically organized. Nesting: A single loop with one conditional keeps nesting shallow; the else is unnecessary after an early return. Clarity of intent: Descriptive names and examples clearly explain finding the first repeated value encountered. Code length: The implementation is concise, though the documentation has minor formatting clutter. Action granularity: Each statement performs one clear action on its own line. Reading flow: Initialization, iteration, duplicate detection, tracking, and fallback return follow a natural sequence.