Sample

JetBrains/b2

Human rating uses the original dataset scale.

DatasetJetBrains
Human0.53
Lines24

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
66.1Δ 46.2
Scalabrino0.9180–1; higher is more readable
90.7Δ 70.8
Dorn0.4630–1; higher is more readable
38.1Δ 18.2
Mi0.6920–1; higher is more readable
96.6Δ 76.7
LLOC15Logical lines; fewer is more readable
43.6Δ 23.7
DeepSeek V4 Pro17.330–20; mean of three runs
78.8Δ 58.9
GPT-6.1 Sol17.670–20; mean of three runs
63.1Δ 43.2
BTTF0.4290–1; higher is more readable
34.7Δ 14.8
Human0.530–1; original rating
19.9

Views

Source code

public class HappyNumbers { public static void main(String[] args) { for (int i = 1; i <= 1000; i++) { if (isHappy(i)) { System.out.println(i); } } } public static boolean isHappy(int n) { int sum = 0; while (n != 1 && n != 4) { while (n > 0) { int d = n % 10; sum += d * d; n /= 10; } n = sum; sum = 0; } return n == 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.640.733−21.144
Source linesThe number of non-empty source lines.24+9.6
Byte entropyHow varied the bytes in the source text are. Repeated bytes give a lower value; a more even mixture gives a higher value.3.595−5.393

Intercept 8.87 + feature contributions = -8.067 (log-odds).
Score = sigmoid(-8.067) = 0.

Score0.918

Feature contributions

FeatureValueContribution
(log-odds)
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.45.75+1.727
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
Indentation frequencyHow rapidly indentation changes from line to line.1−0.703
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.138−0.404
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.24+0.187
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.24−0.13
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.22.872−0.09

Intercept 0.07 + feature contributions = -0.147 (log-odds).
Score = sigmoid(-0.147) = 0.463.

Score0.692
Score15
Run 1

The code is well-structured with a clear separation between the main loop and the happiness-checking logic. The isHappy method uses a concise mathematical approach and avoids unnecessary recursion. Nesting is minimal, with only one inner while loop for digit processing. Variable names are straightforward and intent is clear. Code length is compact without sacrificing readability. Each line performs a single action, contributing to easy scanning. The reading flow is natural, from the main loop to the helper method. Minor improvements could include a comment explaining why '4' is used as a termination condition, but overall the code is highly readable.

Run 2

The code is well-structured and readable. The main loop is clear and the isHappy method is logically separated. Nesting depth is minimal, with only two levels inside isHappy. Intent is clear: find happy numbers between 1 and 1000, though the `n != 4` condition could use a comment to explain its purpose. Code length is concise without being cryptic. Each statement performs one logical action, and reading flow is natural, following the algorithm's order. Minor improvements could include a constant for the unhappy cycle and a brief comment on the algorithm.

Run 3

The code is highly readable. It has a clear structure with a main method iterating up to a defined value and a well-named isHappy helper method. Nesting is minimal and logical. Intent is clear from method and variable names. Code is concise, with action granularity mostly one operation per meaningful step (loop, sum update, digit extraction). The reading flow is natural: digits are squared, summed, and the process repeats until a known terminal state. The only slight readability gap is the use of the 'magic number' 4 as a termination condition without a brief comment, but this is a well-known property of unhappy numbers and does not significantly impact clarity.

Run 1

Code Structure: Clean separation between printing results and checking whether a number is happy. Nesting: Modest, with an if inside a for loop and two nested while loops that fit the algorithm. Clarity of intent: Class and method names clearly convey purpose, though the unexplained cycle-detection constant 4 and abbreviated variables n and d require some familiarity. Code length: Concise without unnecessary logic. Action granularity: Each statement performs one clear operation; conventional for-loop syntax remains easy to read. Reading flow: Consistent formatting and sequential digit processing make execution straightforward to follow. A brief explanation of why reaching 4 terminates the check would improve readability.

Run 2

Code Structure: Clean separation between printing happy numbers and checking them. Nesting: Moderate, with straightforward nested loops and a simple conditional. Clarity of intent: Class and method names convey the purpose, but terse variables and the unexplained cycle-detection constant 4 require familiarity with the algorithm. Code length: Concise without unnecessary statements. Action granularity: Each line performs one clear operation. Reading flow: Natural progression from iteration to digit processing and result checking; resetting sum outside the inner loop slightly increases the effort needed to track state.

Run 3

Code Structure: Clean separation between printing results and checking happiness. Nesting: Modest nesting; the inner digit-processing loop naturally fits within the transformation loop. Clarity of intent: Class and method names convey the purpose, but the unexplained sentinel 4 and abbreviated variable d require some domain knowledge. Code length: Concise without unnecessary boilerplate or repetition. Action granularity: Each statement performs a single clear action on its own line. Reading flow: Execution proceeds naturally from iteration to checking to output, and the happiness calculation is easy to follow. A comment explaining why reaching 4 indicates an unhappy number would improve readability.