I made a Java test. Can you beat it? Also can you hack it?

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

benkapparate
Posts: 7
Joined: Fri Oct 11, 2013 5:05 am UTC

I made a Java test. Can you beat it? Also can you hack it?

Postby benkapparate » Fri Oct 11, 2013 9:05 pm UTC

I'm trying to make this a good free learning tool: http://www.kittybyte.com/challenge . I also wrote the free textbook that goes with it.

I know Java gets a bad rep, but it's still the language used in schools (e.g. AP Computer Science). What are some ways I could improve this website?

lgw
Posts: 437
Joined: Mon Apr 12, 2010 10:52 pm UTC

Re: I made a Java test. Can you beat it? Also can you hack i

Postby lgw » Fri Oct 11, 2013 10:28 pm UTC

My work filter is sure that's a pron site. Either way this seems a bit spammy.
"In no set of physics laws do you get two cats." - doogly

benkapparate
Posts: 7
Joined: Fri Oct 11, 2013 5:05 am UTC

Re: I made a Java test. Can you beat it? Also can you hack i

Postby benkapparate » Sat Oct 12, 2013 12:00 am UTC

truth be told, I think the domain once upon a time was a porn site, but it is not now. The site is also #3 today on reddit /r/programming

User avatar
Jplus
Posts: 1721
Joined: Wed Apr 21, 2010 12:29 pm UTC
Location: Netherlands

Re: I made a Java test. Can you beat it? Also can you hack i

Postby Jplus » Sat Oct 12, 2013 11:45 am UTC

benkapparate wrote:What are some ways I could improve this website?

I think you'll be inspired if you read this and this and ideally also this book.
"There are only two hard problems in computer science: cache coherence, naming things, and off-by-one errors." (Phil Karlton and Leon Bambrick)

coding and xkcd combined

(Julian/Julian's)

Story
Posts: 78
Joined: Wed Aug 26, 2009 9:03 pm UTC

Re: I made a Java test. Can you beat it? Also can you hack i

Postby Story » Mon Oct 14, 2013 5:56 am UTC

Can I hack it? Probably not without the source code. I didn't see any obvious weaknesses after poking around for an hour, but I wouldn't be confident in its security either.

It certainly is interesting though. How on earth did you manage to make java.lang.Class throw a NoClassDefFoundError?

jareds
Posts: 436
Joined: Wed Jan 03, 2007 3:56 pm UTC

Re: I made a Java test. Can you beat it? Also can you hack i

Postby jareds » Mon Oct 14, 2013 8:23 pm UTC

Well, here's some free bug testing:

Numbers 26-28 (recurse) Combos, Variations, Permute; fail to run even with an empty function (so no recursion):

Code: Select all

Runtime error
At line -47, the submission threw the exception: java.lang.ClassNotFoundException: not in allowed classes: java.lang.StackOverflowError

Number 31 (dijkstra) Diameter expects wrongs answers. For example:

Code: Select all

dijkstra you gave 5 wanted 2 graph: a=0 b=1 w=2;a=0 b=0 w=4;a=0 b=2 w=8;a=1 b=0 w=2;a=1 b=2 w=3;a=2 b=1 w=3;a=2 b=0 w=8;a=2 b=2 w=3

What path of length <= 2 exists from node 0 to node 2? For that matter, what path of length <= 2 exists from node 1 to node 2? I suspect your canonical answer is running Dijkstra's on different source nodes without clearing the dist fields in between.

Your random test cases sometimes include disconnected graphs, but your problem description doesn't say what to return in that case.

Code: Select all

dijkstra you gave 2147483647 wanted 0 graph: a=0 b=2 w=6;a=1 b=1 w=2;a=2 b=0 w=6

And -1 would make more sense than 0 as the return value for a disconnected graph, since 0 is possible diameter. (On second thought, I think 0 is not the deliberate return value for a disconnected graph, but rather the result of the previous bug.)

BTW, the best way to compute the diameter of a graph is probably Floyd-Warshall, not Dijkstra's, but it makes sense as a pedagogical matter since Dijkstra's was the previous problem. What doesn't make sense as a pedagogical matter is telling the student to run Dijkstra's between every pair of nodes. If you're going to teach Dijkstra's, you should want the student to understand that they can run Dijkstra's once on a source node and find the maximum distance of any node from that source node (or find that not all nodes are reachable from that source), so they just need to run Dijkstra's once per node.

Angle brackets

Your description of 31 (dijkstra) Diameter is messed up where it includes angle brackets for the generics. Your description of 30 (dijkstra) Dijkstra should specify the specific type of the Map and HashMap in the Node (I assume the failure to do so is an angle bracket issue).

Syntax errors with generics mildly screw up the angle brackets. For example, if I do the Map.Entry backwards one of the left angle brackets is replaced by a dot (and one of the commas is replaced by a dot):

Code: Select all

Compilation error
At line 7, the submission failed to compile with the error: error: incompatible types for (Map.Entry<Integer,Node<T>> e : graph.get(i).neighbors.entrySet()) { ^ required: java.util.Map.Entry<java.lang.Integer.Node<T>> found: java.util.Map.Entry.Node<T>,java.lang.Integer>

Also, you might consider formatting compilation errors with multiple lines and fixed-width so as not to mess up the compiler's alignment of the caret.

ArnavKumar
Posts: 8
Joined: Mon Oct 28, 2013 10:08 am UTC

Re: I made a Java test. Can you beat it? Also can you hack i

Postby ArnavKumar » Mon Oct 28, 2013 10:19 am UTC

It may be spam. So i am not going to do anything with it.


Return to “Coding”

Who is online

Users browsing this forum: No registered users and 7 guests