27
$\begingroup$

The main() method in the following Java program is a text rebus. What does it represent?

import java.util.*;
import java.awt.geom.*;

public class WhatDoesMainRepresent {
    private static HashSet<Obj> hashSet = new HashSet<Obj>();
    private static AffineTransform e = new AffineTransform();

    static {
        hashSet.add(new Obj());
    }

    public static void main(String[] args) {
        hashSet.add(new Obj());
        e.rotate(Math.PI);
        {}
    }

    private static class Obj {
        public int hashCode() {
            return 1;
        }
    }
}

Hints:

1. The AffineTransform object is named e for a reason.
2. The hashSet.add(new Obj()) line in the main() method represents a single word that is a verb. (So far that word has not been mentioned.)

$\endgroup$
  • 14
    $\begingroup$ That hash method might have just made be cry... $\endgroup$ – Going hamateur Jul 27 '15 at 15:24
  • $\begingroup$ I am now tempted to do a near identical puzzle where a string object "u" is placed with an object with a hashCode of 2. And getting rid of the affine transform. $\endgroup$ – Going hamateur Jul 27 '15 at 15:32
  • $\begingroup$ @pacoverflow does it have something to do with Coffee and Pie? Like dipping Cracked Coffee Cake in Coffee at Starbucks? $\endgroup$ – kanchirk Jul 27 '15 at 18:36
  • $\begingroup$ @kanchirk Nothing to do with coffee and pie. $\endgroup$ – pacoverflow Jul 27 '15 at 18:37
  • $\begingroup$ Is that verb 'spin'? $\endgroup$ – CodeNewbie Jul 30 '15 at 5:35
22
$\begingroup$

It represents

Kaleidoscope

Reasoning:

The second add will have the object "collide" with the first on the hashset since they have the same hash code. e rotated 180 degees is "a". The empty curly braces are a new "scope". Collide+a+scope = kaleidoscope.

$\endgroup$
  • $\begingroup$ I think you got it one note, the e rotated is definitely intended to be a schwa. But I like it. $\endgroup$ – Going hamateur Jul 30 '15 at 14:53
  • $\begingroup$ Good job. I was definitely thinking of a schwa for the rotated e (it was another puzzle on this site). The a works almost as well, although it's dependent on the font. $\endgroup$ – pacoverflow Jul 30 '15 at 15:57
14
$\begingroup$

I shame myself with this guess if it turns out to be wrong, but I suspect the text is the idiom

been around the block once or twice

The reasoning being:

Every key/value pair in a hash map is stored in a bin determined by its hash code. In this case the hashcode for all objects of the Obj class is identical, meaning such objects are stored in the same bin.

The e.rotate(Math.PI) statement performs a useless 180° inversion. The transform will therefore turn its operand around. The {} represents an empty block.

The static statement and initial statement in main adds an object to the same bin once and then twice.

Hence: bin around the block once or twice.

After typing this out, I realize how indescribably bad this pun is. I truly hope this isn't the correct answer. :P

$\endgroup$
  • 1
    $\begingroup$ No need to worry, that's not the correct answer. :) +1 for a nice explanation though. $\endgroup$ – pacoverflow Jul 27 '15 at 19:16
  • 1
    $\begingroup$ After reading that explanation, it's kinda hard to believe this isn't correct. +1 $\endgroup$ – Set Big O Jul 27 '15 at 19:38
  • 2
    $\begingroup$ If the static statement isn't part of the answer, what is its purpose? The code will function the same without it. $\endgroup$ – Ian MacDonald Jul 27 '15 at 20:15
  • 3
    $\begingroup$ @IanMacDonald As I understand it, the hashCode is used for performance, to find the item in the HashMap's internal buckets, not to identify an individual key within those buckets. As a quick test I just pasted the code to an editor, printed the size of the map and after the second put there are two items in it. $\endgroup$ – Kevin Rubin Jul 28 '15 at 18:04
  • 1
    $\begingroup$ @pacoverflow: I overlooked the fact that you hadn't overridden equals. So possibly "two in a bucket", "twice in the bucket", "toss in the bucket", then possibly "turns over", "around", "dumps out", "overturns", then possibly "block", "empty", "nothing", "empty-handed". And because it's a rebus, "over", "under", "with", etc. can always play a part. A-aaaand... I've still got nothing. :P $\endgroup$ – COTO Jul 28 '15 at 20:18
4
$\begingroup$

I think the answer is:

Love story

Reasoning:

hashSet.add(new Obj());

Here an object is being stored in a hash set [STORE]

e.rotate(Math.PI);

Here the object e is having a 180 degree rotation applied [E ABOUT]

{}

This is an empty block, so this code does nothing, or love as nothing can be termed in tennis for example [LOVE]

So putting it together we have:

STORE E ABOUT LOVE i.e. STORY ABOUT LOVE or LOVE STORY

$\endgroup$
  • $\begingroup$ +1 for a nice try, but if this is the correct answer, then the static initialization block is completely unnecessary. $\endgroup$ – pacoverflow Jul 30 '15 at 13:23
  • $\begingroup$ @pacoverflow Hmm yes good point $\endgroup$ – Pete Jul 30 '15 at 13:51
3
$\begingroup$

Is it

Much Ado About Nothing

Building quite heavily COTO's answer:

There's much code before the main(), but then it adds (sounds vaguely like "Ado") one more element, a new Obj object, to the collection, so it doesn't have none or one, but rather, much content.

The e.rotate(Math.PI) being "about".

And the empty code block {} being "Nothing".

$\endgroup$
  • 1
    $\begingroup$ Sorry that's not it. If I were going for "ado", I would have put in a do-while statement. :) $\endgroup$ – pacoverflow Jul 28 '15 at 20:04
  • $\begingroup$ Ah well... That was much ado about nothing, then... $\endgroup$ – Kevin Rubin Jul 28 '15 at 20:14
0
$\begingroup$

I don't think this is what you're after, but it could look like part of one school of thought for the perfect barbecue:

add another one (second distinct Obj object: 'another', hashCode: 'one') to the block (static initialiser: 'block', also HashSet: reference to barbecue grids or the deliberate style of burn marks on the meat after cooking), turn it over once at the natural point, i.e. half way through cooking (e: base of natural logs, rotate by $\pi$: turn around), then just let it sit i.e. do nothing until it is done (empty brace = nop: do nothing , end of main(): 'done').

$\endgroup$
  • 3
    $\begingroup$ But is this answer well done? $\endgroup$ – Mark N Jul 29 '15 at 14:52
  • 1
    $\begingroup$ @MarkN Compared to the other answers so far, perhaps rare. $\endgroup$ – Lawrence Jul 30 '15 at 2:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.