35

I'm a CS student enrolled in a class about a certain programming language. Recently, I discovered a trick that is pretty useless in actual production code and doesn't seem to be known by many. The trick results in a program not outputting the expected result. The program is less than 5 lines long.

I am curious as to whether my professor would be able to uncover the solution and would like to ask him during his consultation time. My concern that I do not want the professor to think I am trying to be rude, disrespectful, or anything negative to him.

Would it be appropriate for me to go see my professor during his consultation hours and ask him why my program is not outputting the correct output?

  • 6
    Why are you curious as to whether your professor is able to uncover the solution? How long did it take you? Are you certain that this trick is in fact all that novel? First do some digging or even ask a question at Stack Overflow. – Greg Bacon Sep 4 '17 at 19:49
  • 23
    For fun, can you post the puzzle? – Guido Sep 4 '17 at 21:37
  • 16
    Asking programming questions of a CS professor? What would be the fun in that? Ask professional programmers. – Raphael Sep 5 '17 at 7:47
  • 3
    When I was in elementary school I asked my French teacher whether one was supposed to say "Je déteste tu" or "Je te déteste". The moment she replied "Je te déteste," I broke in, "You hate me?!" with an exaggerated groan of lamentation. The cheap trick got a laugh but I can't say it was my proudest interaction with a teacher. Perhaps best to leave the whole approach by the wayside... – Luke Sawczak Sep 5 '17 at 14:39
  • 5
    How would you feel about being asked 'trick' questions on a test? – Jon Custer Sep 5 '17 at 19:07

10 Answers 10

122

Asking it as a "trick", where you pretend it is a real question and you don't know the answer, could certainly be annoying depending on the professor's mood. So don't try to be tricky.

Hi Professor, if you have a few minutes, I came across an interesting puzzle that I thought you might appreciate. I thought the answer was pretty surprising. [if invited to continue:] Look at this program; can you guess what it would output?

You should make it clear that this is a "riddle" to which you already know the answer. If the professor isn't interested in spending time thinking about it, he can always ask you to tell him the answer, or just say he is too busy right now.

Also, you know your professor better than we do; use your own judgment as to whether he is someone that would find this sort of thing interesting.


Some commenters have raised the question of whether this is an appropriate use of office hours at all. My view is that it is, since it is at least somewhat related to the content of the course (same programming language). It also has the potential to lead to a technical discussion in which you might learn something. I personally would be happy to have this kind of conversation with a student during my office hours.

Of course, it should be low priority. If there are other students waiting with questions that are directly about the course (homework, lecture, etc), then this is not a good time to ask your puzzle; go away and come back another time.


I am assuming that your honest goal in all this is simply to share something that you think the professor will find technically interesting, and/or to learn more about it yourself. If your intention is actually to "test" the professor, or to impress him with your obscure technical knowledge, or make him think you are smart so that you get a better grade, then please don't; that would be rude and disrespectful, and professors tend to be pretty good at seeing through things like that.

  • 67
    I don't really understand the purpose of asking the professor to solve a puzzle, especially if you already know the answer and particularly if you aren't close. The OP has learned something on their own. That's great. They can ask the professor for more information about their finding if it's relevant to their field and they have a question. But if the entire purpose of the exchange is just to test the professor, that's just performing an experiment on someone else and doesn't seem at all relevant to advancing one's own learning. – Zach Lipton Sep 2 '17 at 6:55
  • 100
    @ZachLipton: if the idea is to test the professor, then it’s awkward and immature. But if the idea is to share something fun and interesting, that can be fine. I’ve had a couple of good students whom I got to know partly in this sort of way — i.e. while chatting after class they said “By the way, I came across this interesting somewhat-class-related thing the other day, which you might enjoy if you haven’t already seen.” – PLL Sep 2 '17 at 8:21
  • 50
    @PLL I agree that the distinction between sharing something interesting you just learned vs. testing the professor is critical here. – Zach Lipton Sep 2 '17 at 9:06
  • 14
    More importantly, any such trick almost certainly depends on specific knowledge of the language involved. If the professor is known to be familiar with the language, he might appreciate the cleverness behind the trick. Otherwise, it's just going to look like you are trying to show him up. – chepner Sep 2 '17 at 13:23
  • 14
    And don't assume he has the knowledge just because he is teaching a class on the language. – chepner Sep 2 '17 at 13:24
61

No, do not do this. It is a complete waste of everybody's time. Office hours are there to help students learn, not for playing pranks.

If there are other students who wish to use office hours to learn, you are denying them the support they need by wasting your professor's time. If there aren't other students using the time, you are denying your professor the chance to spend the time doing something productive.

However, if you don't understand how the code works yourself, you could ask this as a non-trick question. Since it's rather tangential to the course, I wouldn't recommend that if there are other students wanting to use the time.

  • Agreed on all points here. If there's a purpose to your coming to your instructor with it (like you really, really don't understand how this could possibly work) then do so, with that explicitly stated as a lead-in. Doing it just to prove how smart you are would be inappropriate and a waste of everyone's time. – Joe McMahon Sep 5 '17 at 20:42
  • Sorry, disagree. A prof who knows the material well enough should be able to take this as an opportunity to teach or learn regardless - teach why tricks are annoying, or learn something new about language X. Yes, if there is a long line of students obviously not - but again, hopefully prof P can realize this isn't as productive as soon as it is asked in this case. – kcrisman Sep 6 '17 at 1:20
  • 1
    @kcrisman Almost any dumb thing a student could do could be turned into a teaching opportunity. That doesn't mean it's a good idea to do the dumb thing. – David Richerby Sep 6 '17 at 7:28
  • True, but the student could turn the dumb thing into something not dumb, and that isn't wasting time. Agreed that the snotty "trick" way of doing it is dumb. – kcrisman Sep 6 '17 at 19:08
24

The answer by Nate suggests a nice and respectful way to discuss this problem. You could even prefix that by "when researching about [the language] I came across [..]" to show that you found it by genuinly being interested in the subject as opposed to be the bravest and challenge him with a trick question circulating the class.

I decided to write an answer not only to agree with another answer, but to explain why you shouldn't lie like you intend to. I think that it IS (contrary to your intentions) disrespectful to pretend that this question is a genuine one that you have problem with.

If the professor tries to seriously help you and tries to imagine what were you thinking, it might just mislead him in an unfair way. If he asks you "what did you want to accomplish by this code" or "why did you write these lines like that" what will you answer? Going to lie with "I don't know, did I go wrong there?" again?

Even stupider case:

-- Hey, professor, I'm having some trouble, can you give me a hand? I can't understand why is this code not outputing [x].

-- What the hell, moron? Did you find this trick problem on [y] and are trying to fool me now?

-- Oh, I didn't know you read the site...

-- I published this problem on that forum, couldn't you read neither my username nor signature?

Besides, I'd like to challenge your reasons for asking. You haven't told us - is the professor considered (or considers himself) a guru on this language? Or maybe (as usually is the case) his research is somewhat related to programming languages and someone has to introduce you to that language? And is the course actually about the language or does it use the language to teach some programming concept?

Just because the professor seems to know a lot more on the language than most of the students, it doesn't mean that professor is or should be a specialist in the language. Or that he even is/should be interested in the language that much. Maybe he is just using the language as a tool to teach a concept? Often it is the case that subjects like functional programming are taught in a functional programming language like Haskell, but the course is not actually about the language.

Of course, the professor should know the language enough to use it, show it and understand students code, but there is no reason to expect him knowing implementation details or other particularities that your trick might depend on. So just tell him up straight and honest - "I found this trick question". If he has the time and enthusiasm, he might enjoy it and you might have a discussion that benefits both of you. Or maybe he just tells you to not waste the consultation time and f.. off write your thing in an email.

17

At best, you might amuse them, but there is significant risk that you'll annoy them if they don't think that the subject "is just a game". That is, they may not think that contemplation of a trick question is a good investment of resources. Or, if they are very quick/savvy, they'll see through it right away and wonder why you are wasting your time this way...

15

It sounds to me like you are trying to profit from your clever discovery (which is a common enough thing for someone to do when they've discovered something cool) but are looking for the wrong sort of profit. Namely, you are looking for a cheap emotional thrill that you would get from being able to demonstrate to yourself that your professor would fail the little "test" you have devised for him, and which you yourself passed (although under different and perhaps incomparable circumstances).

However, this thrill (assuming it materializes) would not actually bring you any tangible benefit, and on the other hand it may have a significant cost in annoying the professor and having him form a poor opinion of you as an immature jerk. Seeking an emotional thrill that comes at a cost of actual, real world harm is precisely one of the hallmarks of immature behavior.

So here's a suggestion. If you want to actually benefit from your cute discovery, by all means share it with your professor (and with us, and with your friends, Facebook contacts etc), in the way Nate Eldredge suggested or in some other friendly way that doesn't involve trickery. Professors love to have conversations with smart students (during office hours or at other times) and learning from them just as much as they love teaching them. I'm sure your professor would enjoy the discussion and be suitably impressed (to an extent proportional to how clever the discovery is -- keep in mind you haven't exactly reinvented relativity theory here, so I wouldn't expect too many accolades...). This could translate later on to him giving you advice, mentorship, a letter of recommendation etc.

Another suggestion is to simply enjoy for now the satisfaction of doing something creative and learning something interesting. The pursuit of knowledge has many rewards, but not all of them involve instant gratification. Some day in the future you might use this tidbit or other bits of knowledge you pick up in a job interview or some other useful occasion, but until then, isn't it fun just knowing you are learning cool things and becoming smarter?

8

I think that trying to trick someone this way is fairly unethical behavior. And for this particular kind of situation I find being honest is usually the best way to do it.

"Hey, I found a cool trick I thought you might like."

Your professor then gets to decide how much interest he has in it, and enjoys being part of your friendly interest instead of forming a 'this kid's a dick' opinion of you.

  • 1
    Unethical? Seriously? Today nothing sells below unethical. – usr1234567 Sep 3 '17 at 21:16
  • 1
    @usr1234567 It's an act of deception, so ethics seems relevant. But I agree that the term is massively over-used on this site. – David Richerby Sep 5 '17 at 12:23
  • @DavidRicherby agreed. The people who misuse this term are seriously unethical. ;-) – Dan Romik Sep 9 '17 at 18:01
6

Post it to StackOverflow. If the trick is nice, you'll get tons of upvotes and you will make a bunch of people smile.

Wasting the time of a professor might be a bad idea. Showing an interesting result would be ok. It depends on: How cool is your discovered trick? And how is your professors mood? The StackOver test might help to figure out the first question.

And share the StackOverflow link here for us curious people.

  • "And share the StackOverflow link here for us curious people." - Definitely! I'm curious to see this trick myself. – DavidB Sep 5 '17 at 1:48
5

I've been in programmimg since 1980s and, among other things, I held computer classes even for high school professors. In my opinion, no professor should be offended by your question, be it a trick question or not. If the professor is really good, s(he) can see what's the point in your trick question. If it happens that the professor doesn't get it, even s(he) can learn something new. If the question is really cool you both may have a good laugh.

So, if the professor is offended by your question or thinks that a student's question is a waste of time - it's shame that such a person works in education. I spent countless hours sharing my knowledge with my students and I think the most dangerous situation is to create the atmosphere in which students are afraid to ask.

  • 1
    For me, the issue isn't whether or not the professor is offended (I agree they shouldn't be) but whether or not it's a productive use of the finite time they have available to help students. Students' questions can be a waste of time, especially questions whose goal isn't to help the student understand the material better. – David Richerby Sep 4 '17 at 15:34
  • First paragraph is great. Second paragraph ... I think that in some cases it is appropriate to be offended if it's truly showing a lack of respect. It's not about the content, but attitude. If I have someone showing up for office hours who doesn't come to class, doesn't read the book, is failing, and then says "did I miss anything important", the person is likely still offensive and is indeed wasting my time. My institution and I both value the student above the content, so I will personally strive to show grace, but that is not inconsistent with the student's actions being disrespectful. – kcrisman Sep 6 '17 at 1:26
4

This really depends on how busy the office hours are.

At my university the office hours lines are often 30 minutes to 1 hour long, so you do your fellow classmates a disservice by taking up the professor's time with something that doesn't actually help you.

But if nobody comes to the professor's office hours, then sure, you might as well. Professors are used to not knowing things (they do research, after all), so it's unlikely that you would bruise their ego. You don't get to be a professor without being repeatedly humbled by your experiences.

  • 2
    I agree that it wouldn't hurt their ego. But the professor being annoyed because of the time wasted is quite likely. – zipirovich Sep 2 '17 at 4:10
  • 15
    Professors don't just sit staring at the ceiling if nobody comes to office hours. They'll be working on something else and you're still wasting their time. – David Richerby Sep 2 '17 at 9:18
4

Depends. Is there any didactic purpose to the gotcha? (Java has tons, and Python has quite a few). Some of these are very instructive (e.g. the mutability, shallow copy-related ones), and some are just annoyances or mistakes in the standard.

Anyway, I'd phrase it as a comment: "There's an obfuscation/gotcha revolving around X" and see if they're actually interested in knowing about it, rather than a riddle or trick question. Unless the prof's personality is ok with the latter - you know better than us.

protected by ff524 Sep 3 '17 at 21:43

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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