Competition : Win a ticket to GeeCON Prague 2014
-
3 -
-
Number of slices to send:Optional 'thank-you' note:
-
The event boasts Java and JVM based technologies, dynamic languages, enterprise architectures, patterns, distributed computing, software craftsmanship, mobile and much more...
To stand a chance of winning the ticket, all you have to do is enter our fun programming competition, posting your solutions in this very thread. You can even post more than once. The solution that we, the CodeRanch staff, think is the best will win the ticket to GeeCON Prague 2014. Also, as an added bonus, the winner will have the opportunity to meet one of our esteemed Marshal's Ulf Dittmer who will be attending the conference too.
The contest ends Friday 10th October, with the winner announced by Saturday 11th October. Good luck, and have fun!!
The Competition: Java obfuscated word occurrence counter
The Problem
The Criteria
The Rules
For example
The sentence (String) "I really REALLY love CodeRanch" returns the occurrence (Map) {i=1, really=2, love=1, coderanch=1}
A test harness to get you started
Provided is a simple Java class with the skeleton method signature and a couple of tests that you can use to verify the correct functionality. For writing your solution you are only interested in the method skeleton on lines 6 - 9, this is where you complete the method with your solution to make it function correctly.
How to run the test harness
Take a copy of this code and paste it into a file called GeeConComp.java.
Compile it
javac GeeConComp.java
Run it
java GeeConComp
Initially the output will report test failures, which is expected as the solution has not been written yet.
CodeRanch GeeCON Prague 2014 competition
========================================
Test FAIL :(
Expected: {love=1, coderanch=1, i=1, really=2}
Actual : null
Test FAIL :(
Expected: {better=3, never=1, rest=1, may=1, and=1, i=1, best=2, until=1, is=1, my=2, good=2}
Actual : null
What you want to see is passing tests
CodeRanch GeeCON Prague 2014 competition
========================================
Test PASS :)
Test PASS :)
That's it! Enjoy.
Tim Driven Development | Test until the fear goes away
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
or using grouping
-
-
Number of slices to send:Optional 'thank-you' note:
-
Three attempts so far - two from newly registered people and one that's a first post from someone who registered two and a half years ago.
Joanne
-
-
Number of slices to send:Optional 'thank-you' note:
-
Joanne Neal wrote:one that's a first post from someone who registered two and a half years ago.
Yea who does that! (ActiveStaff#timcooke)
Tim Cooke wrote:Tim joined CodeRanch in 2008 but didn't post a single thing until early 2013. Nobody knows why
Remember, obfuscation is the name of the game in this competition. We're looking for the most unreadable code you can muster while being functionally correct.
Tim Driven Development | Test until the fear goes away
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
all of you.
-
-
Number of slices to send:Optional 'thank-you' note:
-
I like the idea of the "golf rule" as concise code can be still comprehensible. But "unreadable" code by its nature will not.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
-
-
Number of slices to send:Optional 'thank-you' note:
-
That means no Scala. Sorry Joe.
Tim Driven Development | Test until the fear goes away
-
-
Number of slices to send:Optional 'thank-you' note:
-
SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
Pawel Szulc wrote:I've entered the competition but I still am amazed that you promote "unreadable" code.
Hi Pawel. None of us here at the Ranch would ever promote that you write unreadable code in the real world. But for this competition we wanted to make it fun and interesting by getting you thinking a little differently and have you write the most obscure code you can come up with that still solves a simple problem.
@Joe Harry, You can enter as many times as you like, so go nuts.
Tim Driven Development | Test until the fear goes away
-
-
Number of slices to send:Optional 'thank-you' note:
-
SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
-
-
Number of slices to send:Optional 'thank-you' note:
-
Of course, I can obfuscate it further and fix it. Is it necessary?
SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
If you want to discuss what happens if you post "Campbell Ritchie is a dreadful nuisance" please go to one of the Java fora.
Don't copy‑and‑paste this post.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
2 -
-
Number of slices to send:Optional 'thank-you' note:
-
Joe Harry wrote:I can already see that my obfuscated version fails the test for a String input
Of course, I can obfuscate it further and fix it. Is it necessary?
No.
The Rules wrote:The sentence is a String delimited by single whitespace characters. Assume no punctuation.
That means you don't have to handle multiple whitespace. You can assume it never happens.
As a general note to all. Please don't forget to UseCodeTags when posting code. Omitting their use does not qualify as a valid obfuscation technique.
Tim Driven Development | Test until the fear goes away
-
-
Number of slices to send:Optional 'thank-you' note:
-
If the code fulfils the rules of the contest compiles and produces a PASS result from Tim's test harness, each would count as a separate entry. Multiple entries are welcomedAdalberto Toledo wrote: . . . which one match the best with the criteria...

-
-
Number of slices to send:Optional 'thank-you' note:
-
This does not comply with the rules that only standard JavaSE classes may be used. I suggest you resubmit with that import removed. Consider StringJoiner instead.Adalberto Toledo wrote:
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
Campbell Ritchie wrote:
This does not comply with the rules that only standard JavaSE classes may be used. I suggest you resubmit with that import removed. Consider StringJoiner instead.Adalberto Toledo wrote:
You are right however, my solution is only the wordOccurrence method, that library is only used in the Main method, just for running the program and convert the arguments passed by the Command Line Interface (CLI), to a String delimited by a single whitespace.
Anyway, I appreciate your suggestion and I will consider the StringJoiner Class instead of the StringUtils Class.
Please, try to evaluate only my wordOccurrence method because that is my solution.
Before that solution, I submitted a solution without the Main method and it doesn't have that library imported, do you want me to submit it again?
Thanks a lot
Best Regards
-
-
Number of slices to send:Optional 'thank-you' note:
-
Adalberto Toledo wrote:that library is only used in the Main method
Noted. Solution accepted.
Tim Driven Development | Test until the fear goes away
-
3 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
subh kumar wrote://soln by [email protected]
-
-
Number of slices to send:Optional 'thank-you' note:
-
subh kumar wrote:
subh kumar wrote://soln by [email protected]
-
-
Number of slices to send:Optional 'thank-you' note:
-
subh kumar wrote:
subh kumar wrote:
subh kumar wrote://soln by [email protected]
-
-
Number of slices to send:Optional 'thank-you' note:
-
subh kumar wrote:
subh kumar wrote:
subh kumar wrote:
subh kumar wrote://soln by [email protected]
| There is no "i" in denial. Tiny ad: The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |








