In this challenge, you will be given the source code of a Java program. Your task is to write a function or full program that will remove the whitespace from this program. The whitespace-removed program should work exactly the same as the original program. Your program can be in any language. In this challenge, every space, tab, and newline will be considered whitespace.
Summary
Input can be through command-line arguments, function parameters, or STDIN/equivalent.
Output will be the input program without whitespace through STDOUT/equivalent, along with an integer representing the amount of whitespace removed. Your score will be determined by (number of bytes) - (whitespace removed in sample program)
Sample Program (You can remove 104 whitespace characters from this)
class Condition {
public static void main(String[] args) {
boolean learning = true;
if (learning == true) {
System.out.println("Java programmer");
}
else {
System.out.println("What are you doing here?");
}
}
}
Whitespace-free version: class Condition{public static void main(String[]args){boolean learning=true;if(learning==true){System.out.println("Java programmer");}else{System.out.println("What are you doing here?");}}}
Clarifications from Comments (see below)
- The programs passed as input will be at the same whitespace complexity as the sample program.
- The programs will not contain comments.
Closing question
Due to the amount of confusion involved with the question, I have decided to close the competition and accept @MartinBüttner's answer. Sorry for any misunderstanding. However, I would believe the answers to be good as a tool for java golfers, which is why I did not delete the question.
int\nfoo=5;
? – Martin Büttner♦ yesterday