5

I need your help. I think my computer is gaining sentience. I went to a play, but when I got back this file was saved on my desktop:

#!/usr/bin/env python3
# -*- coding: latin8 -*-
i = input("Please enter a character: ")
print((i == "Ä" or i == ";"))

(note: The original riddle had a colon : instead of a semicolon ;. This was my fault, the correct character is a semicolon)

It was saved as question.py. I know I didn't write this! I think my computer is trying to ask me a question, but I can't tell what the question is.

What question is my computer asking me?


To avoid confusing people, this is not a unicode trick. The "Ä" character is encoded as a single byte, 0xC4.

Hint:

The question is a famous line

DJMcMayhem
  • 382
  • 3
  • 14
  • Also, I'm really new to puzzling.se, so if there's anything I should do differently, let me know. – DJMcMayhem May 19 '16 at 04:36
  • 3
    Well, technically, it's asking you to 'Please enter a character'. I think you're looking for something less obvious though. – Tim Couwelier May 19 '16 at 05:54
  • To make it clearer: the program, when launched, will request a text input from the user, and respond True for Ä or : and False otherwise. – fffred May 19 '16 at 08:12
  • Sounds more like a programming-related question than a puzzle. This prints True if what you enter is either a colon or a dotted A, and False otherwise. Or is there something more to it? – Aiman Al-Eryani May 19 '16 at 08:14
  • Is your file actually encoded in Latin-8? Because it makes a huge difference in how it works (saved in UTF-8, it doesn't recognize the Ä unless you remove the second line). – BaSzAt May 19 '16 at 08:18
  • 1
    @AimanAl-Eryani Yes there is more to it. It's supposed to be a riddle similar to this one: http://puzzling.stackexchange.com/q/30064/11338 – DJMcMayhem May 19 '16 at 08:21
  • 4
    @BaSzAt Yes, it actually is saved in Latin8, and that is important and relevant. – DJMcMayhem May 19 '16 at 08:22
  • 2
    https://en.m.wikipedia.org/wiki/ISO/IEC_8859-14 link to the codepahe – Robert Fraser May 19 '16 at 10:27
  • 5
    Those are characters 0xC4 and 0x3A in the Latin-8 encoding. (In particular, they are regrettably not 0x2B and ~0x2B.) In decimal, 196 and 58. – Gareth McCaughan May 19 '16 at 10:40
  • 4
    "Give me plastic explosives or give me emergency roadside service" – question_asker May 19 '16 at 11:53
  • Slightly oddly, 0xC4 and 0x3A are pretty close to being complements like 0x2B and ~0x2B. And for that matter 0x2B and 0x3A aren't so very different: just let one nybble lend 1 to the other. I expect this is all just coincidence, but maybe there's some clever thing I'm missing. – Gareth McCaughan May 19 '16 at 13:15
  • @DJ McMayhem, when you read that file and see e.g. "Ä" are you doing so in the Latin-8 encoding? Or might we e.g. be treating it as UTF-8? – Gareth McCaughan May 19 '16 at 13:17
  • If the file looks like that when treated as UTF-8, then that "Ä" string is actually 0xC3 0x84. In Latin-8 the first of those is a capital A with tilde and the second is left undefined by ISO-8859-8 and typical Microsoft conventions would make it a "lower" European double-quotation-mark. None of that seems likely to be helpful. – Gareth McCaughan May 19 '16 at 13:21
  • @GarethMcCaughan That's already been addressed here, It's Latin-8 – question_asker May 19 '16 at 13:49
  • 2
    No, what's been established here is that the file is Latin-8, not that the text we see above is the result of treating it as Latin-8. If your text editor doesn't understand the "-*- coding: -*-" convention then it might pick a different encoding, in which case what we're seeing as "Ä" might be interpreted as something else by the Python interpreter. – Gareth McCaughan May 19 '16 at 13:52
  • For that matter, if you run that program in a context where whatever's supplying input to the Python interpreter (e.g., a terminal emulator running under X on Linux, etc.) isn't using the Latin-8 encoding, then what you need to type to get something that reaches the Python interpreter as the Latin-8 encoding of "Ä" may be something entirely other than "Ä". – Gareth McCaughan May 19 '16 at 13:55
  • I should add that I don't actually think this sort of trickery is likely to be the point of the question, and I rather hope it isn't. – Gareth McCaughan May 19 '16 at 13:56
  • 1
    @GarethMcCaughan Yes, you've spent a lot of time and effort going after something that is most certainly not part of the puzzle – question_asker May 19 '16 at 14:39
  • A couple of minutes only, actually. – Gareth McCaughan May 19 '16 at 14:55
  • ... As you will see from the original questioner's comments on Caelan O'Toole's answer, it turns out it wasn't coincidence that 0xC4 and 0x3A are almost complements, and they were actually intended to be exactly complements :-). – Gareth McCaughan May 19 '16 at 15:02

3 Answers3

6

Just a guess:

Could your computer be asking the question: "To be or not to be?" from Shakespeare's Hamlet? My reasoning was simmilar to Caelan's, except I expected to get the Hex value 0x2B from ord('Ä'), but it was giving me 196 (0xC4), and I didn't think to divide by two. If I did so, I would have found that the unicode encoding was 'b', chr(196/2) == 'b', but I just didn't have time to think through my answer, and posted this guess on a hunch. However, looking back If you take unichr(59) which is the ~ (binary NOT) operation of the hex value '0xc4' (~196 is negative).

micsthepick
  • 3,731
  • 1
  • 18
  • 33
6

To be or not to be? (Well, more "2b or not 2b")

My reasoning:

The unicode code for Ä is U+00C4. The key part here is C4.
If we translate C4 from hexadecimal to decimal, we get the number 196. Half of 196 is 98.
Let's now translate 98 from decimal to hexadecimal to get 62, and look for unicode code U+0062.
The letter that comes out is b. Note that 196 being 2 times 98 is where the two comes from. Whatever you do for the colon, you will come to something that is not 2b.

Klyzx
  • 534
  • 5
  • 12
  • 1
    Your last line makes no sense though because anything you type will be 'not' (answer) but only a colon is accepted as 'true' – SlashmanX May 19 '16 at 14:30
  • Oh, wait, I didn't read the comments on the question correctly. Ä and : are true, nothing else. – Klyzx May 19 '16 at 14:33
  • 1
    Your reasoning for the first part makes sense though, whether it's right or not, good stuff – SlashmanX May 19 '16 at 14:35
  • 2
    You're trying to make your explanation adapt to an answer, while it should be vice versa. – Aiman Al-Eryani May 19 '16 at 14:42
  • Well, this is embarrassing. This is spot on except for the part about the colon. However, (and this is completely my fault) I messed up the riddle. It should be a semicolon ; instead or a colon :. I'm not really sure what I should do. Should I update the riddle and wait for somebody to explain the semicolon also, or should I explain my mistake and accept this one (since the only part it's missing is my fault)? – DJMcMayhem May 19 '16 at 14:55
  • I think you should accept this and explain that ';' = ~'Ä' more explicitly in comments. – Gareth McCaughan May 19 '16 at 14:58
  • ; is 3B in Unicode, so I guess that explains it? – SlashmanX May 19 '16 at 14:58
  • SlashmanX, the point is that 0x3B = ~0xC4. (And 0xC4 = 20x62 = 2'b', which is the actual key point of the question.) [note: when I wrote this, SlashmanX's comment said something a bit different from what it says now.] – Gareth McCaughan May 19 '16 at 14:59
  • Yeah makes sense. Just a coincidence I guess (or just completely irrelevant). I edited my comment cos there was possibly a spoiler in it – SlashmanX May 19 '16 at 15:00
  • @DJ McMayhem, to clarify my comment ("I think you should ...") above: I think you should also update the riddle, but leave a note in there saying what it originally said and that this is why lots of the discussion talks about ':' rather than ';'. – Gareth McCaughan May 19 '16 at 15:01
  • @GarethMcCaughan Done. Sorry about that, I feel really bad now. – DJMcMayhem May 19 '16 at 15:05
  • @CaelanO'Toole I'm accepting this answer because "2b or not 2b. Yes, that is the question." – DJMcMayhem May 19 '16 at 15:06
  • I already thought it was meant to be semicolon. That was 3b. I couldn't figure out how 3a related to the question. – Klyzx May 19 '16 at 15:11
  • Really disappointed to see this being marked as the answer. Take half? I can't find any hint in the puzzle that tells you to do this. To leave out the ":"? Meh. Basically, this puzzle wouldn't have been solved without making a blind guess about what the answer would be and going towards that. – Aiman Al-Eryani May 19 '16 at 15:14
  • 6
    but the semicolon is 59, which is ~196 - it's not just that 3B is "not 2B" – question_asker May 19 '16 at 15:19
  • Yes, the second half of the explanation is very wrong. I don't know if I should unaccept this since I've already screwed this up so much. – DJMcMayhem May 19 '16 at 15:55
  • Add your own explanation to the answer then, as I couldn't think of much better. – Klyzx May 19 '16 at 17:44
  • 1
    @DJMcMayhem Unaccept my answer and instead accept micsthepick answer instead. It is more complete than mine. – Klyzx May 20 '16 at 13:06
1

Your computer is developing emotions. The question is 'Do you love me?', and it is offering two choices; A (grade A YES) or a colon (taken to be NO)

JMP
  • 35,612
  • 7
  • 78
  • 151