# Count the score of a Code Golf code [duplicate]

This question already has an answer here:

My challenge is to make a Java method(s) that is given a String (another code in Java), removes any unnecessary characters, counts and returns the score, and displays the cleaned-up code in a way that can be copied/pasted.

It should ignore spaces, line breaks, etc. unless they are necessary to the code.

For example, if the space in the string int number=3; was removed to make it intnumber=3; (and remove a bit), there would be a compiler error if the counted program were run. However,

int
number   =

3           ;


would return 13, the same as the previous two examples.

The program with the least characters as calculated by the program you write (note - this does not mean you can just make it return 0; or something like that) wins!

Note - the code must be in Java. This Java code cannot call code of another language. If there is a loophole, please ask in a comment before posting an answer!

Note: there are a few key differences between this challenge and the other one:

• You have use Java
• You must return the number of characters after having removed spaces, etc.
• You leave the variable names, etc. as are. For this, the score should ignore line breaks, spaces, and other characters skipped over by the compiler when counting. The other program required you to reduce variable names, remove comments, etc.

To be clear, this is primarily a score checker. The code reducing in this program is to help the user get a lower score without substantially changing their program.

## marked as duplicate by xnor, Sparr, Jo King code-golf StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Nov 26 '18 at 21:48

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

• I'm voting to close this question as off-topic because it's basically just asking for a minifier – Sparr Nov 26 '18 at 21:28
• So this program should just remove unneeded whitespace and count the length of the result? – Poke Nov 26 '18 at 22:21
• If it's more complicated than that I fear something something halting problem – Poke Nov 26 '18 at 22:23
• Note that restricting a challenge to a single language usually isn't seen as a good thing, especially if the challenge is a subset of an already existing challenge, like this one. If this question is re-opened, I would expect it to get downvoted. – Jo King Nov 27 '18 at 3:17
• I would suggest leaving this closed and try posting future challenges in the Sandbox to try to get feedback and gauge whether the question will be well-received. – Jo King Nov 27 '18 at 3:23