Skip to content

Add ScalesFitness method for Scales problem - #1

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1777826877-scales-fitness
Open

devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1777826877-scales-fitness

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented May 3, 2026

Copy link
Copy Markdown

Summary

Implements the ScalesFitness method in Labs/ScalesProblem/ScalesSolver.java for the Scales problem.

Test #1 — Invalid input handling (returns -100):

  • rep or weights is null
  • rep or weights has size zero
  • rep.size() is greater than weights.size()

Test NABBrunel#2 — Penalty regime (0, 0, 10, 20, ... %):
When rep.size() < weights.size(), unassigned weights incur a penalty:

  • 0 unassigned → 0% penalty
  • 1 unassigned → 0% penalty
  • 2 unassigned → 10% penalty
  • 3 unassigned → 20% penalty
  • n unassigned (n ≥ 2) → (n−1) × 10% penalty, applied as a percentage of total weight added to the base fitness

Base fitness = |leftSum − rightSum| where true = left side, false = right side.

Review & Testing Checklist for Human

  • Verify ScalesFitness returns -100 for null, empty, and oversized rep inputs
  • Verify penalty regime matches the expected pattern (0, 0, 10, 20, ... %)
  • Compile and run: javac ScalesSolver.java && java ScalesSolver

Notes

  • A main method is included for quick manual testing of the function.

Link to Devin session: https://app.devin.ai/sessions/c5fd40e46d1f4ddba06784e61733b818
Requested by: @2431250


Open in Devin Review

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant