Hello! For each Java conference we come up with a game so that anyone can have fun at our booth. At the Joker 2018 conference, we suggested that participants take Duke out of the labyrinth, a detailed article about the game from last year
can be found here This year we continued the tradition and made the game, where answering questions on Java, we need to help Duke to find the hidden way out.
The point is to wander around a closed playing field with questions about Java, for each game session a unique grid of questions is generated. The player’s task to answer questions is to take Duke out of the maze through the door, the location of which is new every time, so it’s impossible to work out a strategy in advance and stick to it, there is always a chance to go in the wrong direction and be far from the exit. At the same time, answering different categories of questions, the player opens a different number of closed cells around him, when answering a simple question, 1 cell opens, the average 2, and the complicated 3. For the correct answer to simple questions, 1 point is awarded, the average - 2 , and for the most difficult - 5, and if the player was able to bring Duke out of the maze, then he will receive an additional 20 points. But not everything is so simple! If a player answers the questions incorrectly, the points burn out in proportion to the accrual system, answered the simple answer incorrectly, lost 1 point, medium - 2, difficult - 5. Therefore, 0 points is not the worst result, because you can go deep into the minus. The one who wins the most points in 180 seconds wins.
The most difficult, for the participants, was this question (by the way, from the category of simple ones):
What will the code print?
')
BigInteger big = BigInteger.valueOf(Long.MAX_VALUE); System.out.println(big.add(big).longValue());
- -2
- 4294967294
- 18446744073709551614
- throw an
ArithmeticException
Correct answerIt is necessary to recall the basics of bit arithmetic and not to forget that
longValue()
implements a narrowing primitive conversion:
jshell> BigInteger big = BigInteger.valueOf(Long.MAX_VALUE) big ==> 9223372036854775807 jshell> big.toString(16) $2 ==> "7fffffffffffffff" jshell> big.add(big).toString(16) $3 ==> "fffffffffffffffe" jshell> big.add(big).longValue() $4 ==> -2
Some game statistics:
- the number of gaming sessions was 1123;
- maximum score 252;
- for an average of 1 game session, the player answered 15 questions correctly.
Paradoxically, but in fact, this year the simple questions were answered worse than the difficult ones.
This time we decided not to publish the correct answers to the questions, but to give you the opportunity to get as close as possible to the conditions of the Odnoklassniki stand at the JPoint 2019 conference and laid out the game in open access for everyone.
You can play the game and test your strength here:
javagame.odkl.ru