Sample

JetBrains/i2

Human rating uses the original dataset scale.

DatasetJetBrains
Human0.65
Lines29

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
50.8Δ 15.3
Scalabrino0.8810–1; higher is more readable
88.1Δ 52.5
Dorn0.5750–1; higher is more readable
64.4Δ 28.8
Mi0.5450–1; higher is more readable
61.9Δ 26.3
LLOC18Logical lines; fewer is more readable
29.7Δ 5.9
DeepSeek V4 Pro17.330–20; mean of three runs
78.8Δ 43.2
GPT-6.1 Sol180–20; mean of three runs
77.5Δ 41.9
BTTF0.5660–1; higher is more readable
83.1Δ 47.5
Human0.650–1; original rating
35.6

Views

Source code

public class HappyNumbers { public static boolean isHappy(int n) { int slow = n, fast = n; do { slow = digitSquareSum(slow); fast = digitSquareSum(digitSquareSum(fast)); } while (slow != fast); return slow == 1; } public static int digitSquareSum(int n) { int sum = 0, tmp; while (n > 0) { tmp = n % 10; sum += tmp * tmp; n /= 10; } return sum; } public static void main(String[] args) { for (int i = 1; i <= 1000; i++) { if (isHappy(i)) { System.out.println(i); } } } }

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.819.748−27.052
Source linesThe number of non-empty source lines.29+11.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.566−5.349

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

Score0.881

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.59.966+1.125
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.29−0.245
Indentation frequencyHow rapidly indentation changes from line to line.27+0.197
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.108−0.103
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.27+0.08
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.27.902−0.02

Intercept 0.07 + feature contributions = 0.3 (log-odds).
Score = sigmoid(0.3) = 0.575.

Score0.545
Score18
Run 1

The code is highly readable. The structure is clean with logical separation of concerns: `isHappy` handles cycle detection, `digitSquareSum` isolates the calculation, and `main` handles output. Nesting is minimal and control flow is straightforward. Intent is clear from method and variable names like `slow`, `fast`, and `digitSquareSum`. The code is concise, using the Floyd cycle-detection algorithm efficiently without unnecessary comments. Most lines perform one logical action, though `fast = digitSquareSum(digitSquareSum(fast));` combines two operations but remains understandable in context. Reading flow is natural, especially for those familiar with linked-list or number theory patterns. Minor deductions: the variable name `tmp` is slightly vague compared to something like `digit`, and the cycle-detection logic assumes familiarity with the algorithm—less obvious to a novice reader.

Run 2

The code is clean, well-structured, and concise. Each method has a single clear purpose: isHappy uses Floyd's cycle detection, digitSquareSum computes the required sum, and main prints happy numbers. Nesting is minimal—only one level in the loop and while. Variable names like slow, fast, and sum clearly convey intent. Lines mostly perform one action, and the reading flow is natural: helper method before main, clear algorithm implementation. The digitSquareSum method is compact without sacrificing clarity. Overall, highly readable with a minor note that the algorithm's use of cycle detection could be commented for readers unfamiliar with the technique.

Run 3

The code is concise and logically organized, separating concerns into helper methods. The Floyd cycle detection approach is cleanly implemented with clear variable names (slow/fast). Nesting is minimal, and each line generally performs a single action. The digitSquareSum method is readable but slightly compressed by declaring `sum` and `tmp` on one line. The main loop is straightforward. Overall, the intent is clear, and the code follows natural reading flow, with only minor room for improvement in variable declaration spacing.

Run 1

Code Structure: Well organized into separate methods for happy-number detection, digit-square summation, and output. Nesting: Shallow and easy to follow; only the main loop contains a nested conditional. Clarity of intent: Class and method names clearly communicate purpose, though Floyd’s cycle-detection technique could benefit from a brief comment, and tmp is a generic variable name. Code length: Concise without unnecessary repetition. Action granularity: Operations generally occupy separate lines, although combined variable declarations and the nested digitSquareSum call slightly reduce explicitness. Reading flow: Natural progression from the core algorithm to its helper and demonstration, with consistent formatting.

Run 2

Code Structure: Well-organized methods separate happy-number detection, digit-square summation, and output. Nesting: Shallow, with only a simple loop and conditional in main. Clarity of intent: Class and method names communicate purpose clearly, though Floyd’s cycle-detection technique is not explained and tmp is a generic name. Code length: Concise without unnecessary repetition. Action granularity: Most lines perform one action; combined variable declarations and the nested digitSquareSum call slightly reduce step-by-step clarity. Reading flow: Natural progression from detection to helper to demonstration, with consistent formatting and straightforward control flow.

Run 3

Code Structure: Well organized into separate methods for happiness testing, digit-square summation, and output. Nesting: Shallow overall, with only a simple conditional inside the main loop. Clarity of intent: Class and method names clearly communicate purpose; however, the slow/fast cycle-detection technique would benefit from a brief explanatory comment, and tmp is a generic name. Code length: Concise without unnecessary logic or repetition. Action granularity: Most lines perform one action, though combined variable declarations and nested digitSquareSum calls slightly reduce clarity. Reading flow: Natural and consistent, progressing from the core test to its helper and then the demonstration.