Hacker Newsnew | past | comments | ask | show | jobs | submit | billforsternz's commentslogin

No one serious ever talks about "upgrading" to Tahoe without the quotes. I hope Apple are seriously embarrassed about this and determined to mend their ways.

The only reason people get confused about the Monty Hall problem is that the problem description rarely if ever makes it clear that the host knows where the car is and deliberately chooses a different door.

It's inconceivable (for example) that Paul Erdos, a world class mathematician, would fail to solve this problem if it were actually communicated clearly.


It is incredibly annoying that in the case where the host doesn't know where the car is but opens a goat door anyway, the probability goes back to 50-50

Eh, when you think about it, it makes sense.

Original rules (host knows where car is and always opens a door with a goat):

- 1/3 of the time your original choice is the car, and you should stick

- 2/3 of the time your original choice is a goat, and you should switch

Alternative rules (host doesn't know where car is, and may open either the door with the car or a door with a goat)

- 1/3 of the time your original choice is the car, the host opens a door with a goat, and you should stick

- 1/3 of the time your original choice is a goat, the host opens a door with a goat, and you should switch

- 1/3 of the time your original choice is a goat, the host opens the door with the car, and you're going to lose whether you stick or switch

So even under the new rules, you still only win 1/3 of the time by consistently sticking. You're just no longer guaranteed that you can win in any given game.


We are conditioning out the case where the host picks the door with a car, so there's only two scenarios of equal probability left. Hence 50-50.

Well yes, if you throw out half of the instances where your original choice was wrong, then the chance your original choice was correct will inevitably go up.

But if he doesn't know where the car is, how can he be sure that the door he opens is going to have a goat?

Nobody said he can be sure.

The scenario is the host doesn't know which door has the car, opens some random door, and that door happens to have a goat behind it.

If you were in this scenario, your odds of getting the car doesn't change whether you switch or not


That would indeed be annoying, but I doubt it is the case. If you only consider this scenario, it cannot be distinguished by conditional probability from the case that the host knows, and so the math should stay the same.

As usual, the problem is not an incredibly difficult problem, but just a failure to state the problem clearly and correctly.

Try to write a computer program that approximates the probability, and you'll see what I mean.


https://github.com/yen223/monty_fall/blob/master/Monty%20Hal...

The math is contingent on whether you know the host knows or doesn't know where the door with the car is. This is the counterintuitive bit.


Your program shows exactly what I mean: "Impossible" cannot be non-zero, your modified question is not well-defined.

Yes, of course it depends on the host knowing where the goat is, because if he doesn't, the scenario is not well-defined anymore. This is not annoying, this is to be expected (pun intended).


The scenario is well-defined. There's nothing logically impossible about the host not knowing which door has the car, and still opening the goat door.

"Impossible" in the program just refers to cases where the host picks the car door, i.e. the path that we are not on, by the nature of the statement. Feel free to replace the word "impossible" with "ignored" or "conditioned out". The math remains the same.


I know of two distinct methods of encoding any legal chess position into 24 bytes worst case. In both cases, you get the full position, plus who to move, plus full information on future castling and en-passant possibilities. This is the FEN state of the board, minus the two counts. It's more than the information you get from a published chess diagram in a book or magazine. Although in a book or magazine inevitably "who to move" is represented somehow, castling and en-passant possibilities are not usually.

Method 1: Lichess method; 64 bit header, 1 bit per square indicating occupied squares, then (up to) 32 4 bit codes for the 32 occupied squares. So 24 bytes worst case!

Method 2: My own method a list of 2 bit codes, one of the 4 codes indicates empty square, the other three codes are prefixes for a second 2 bit code. Three prefixes applied to one of 4 code values gives a total of 12 possibilities corresponding to any possible chess piece. Worst case 32x2 bits plus 32x4 bits = 24 bytes.

In each case there is sufficient entropy to create tricks to add the supplementary information (who to move etc.), similar tricks are in the original article.

I mention my own method from my Tarrasch Chess GUI https://github.com/billforsternz/tarrasch-chess-gui only for completeness. If I had known about method 1 I would have used that, it is simpler and better and there is much more entropy available making the tricks easier.

I would urge commentators to keep clear the difference between compressing a chess position (this challenge), a chess move and a chess game. A chess move needs far less bits of course. A complete chess game is always encoded as a list of moves, not positions, for this reason.

Edit: I should have mentioned that the chief advantage of method 1 over method 2 is average bits required. An empty board is 64x1 bits = 8 bytes for method 1 and 64x2 bits = 16 bytes for method 2.

Edit 2: I am going to describe my tricks, just because they are fun. Two kings the same colour means Black to move. Two White kings means the first king is white, two black kings means the first king is black. Otherwise White to move. A friendly pawn on the first rank means an enpassant vulnerable pawn. Swap it with the 4th rank square to get the actual contents of both squares. A hostile pawn on the first rank is an unmoved rook or king, establishing all castling rights. The castling and en-passant tricks can be combined in a pleasant and harmonious way.


I recall idly looking through the manual of our Bosch dishwasher when it was delivered and seeing that they offered to share GPL'ed source code from the machine's embedded guts. I thought to myself, "that's kind of interesting, I'll take them up on that". So I emailed the address they provided for this purpose. I got an auto email back saying, effectively, "No. You're not an authorised person, we don't recognise your email address, we don't know who you are, we're not going to talk to you."

Oh well. Big Corp doing what Big Corps do. Paying lip service to legal requirements, but reluctantly and with barriers that would no doubt take a lot of time and money to even try and break down.


I was troubled by my own comment. How exactly did Bosch handle this? I went back and checked and in fact the rejection email came from their email server, it was an "access denied" type email that I originally misinterpreted as a "you don't have access" type message leaving me annoyed but really I took away and remembered a wrong impression. Looking more carefully, the message doesn't mean anything subtle, it just means the email address (oss-request@bshg.com for the record) doesn't exist. Which is bad, but not nearly as bad as I portrayed it above. Apologies (for the record) to Bosch.


This is very interesting, very refreshing, very simple and clever, very well done, very everything good. Bravo and thank you.


A few too many 9s there I think. You're estimating that only 1 person in every 10 million could care less. So less than 50 such people in the USA for example


For a fun project; rejuvenating a 1978 Chess Engine https://github.com/billforsternz/zargon. It's the second time I've worked on the same engine. The first time I got it working nicely on modern machines, running four orders of magnitude faster than in in 1978. This time I hope to get it running much faster than that. I found a bug in the 1978 Z80 assembly the other day. A blog post "Fixing a 50 year old bug..." or similar suggests itself.


I know it's silly, but I just want to fix his first version with the minimum possible changes;

  /* Copyright 2023. All unauthorized distribution of this source code
     will be persecuted to the fullest extent of the law*/
  #include <stdio.h>
  #include <stdint.h>
  #include <string.h>
  int main(int argc, char* argv[])
  {
      uint8_t number = argc>1 ? argv[1][strlen(argv[1])-1]-'0' : printf("Usage: odd-or-even number\n");
      if (number == 0)
          printf("even\n");
      if (number == 1)
          printf("odd\n");
      if (number == 2)
          printf("even\n");
      if (number == 3)
          printf("odd\n");
      if (number == 4)
          printf("even\n");
      if (number == 5)
          printf("odd\n");
      if (number == 6)
          printf("even\n");
      if (number == 7)
          printf("odd\n");
      if (number == 8)
          printf("even\n");
      if (number == 9)
          printf("odd\n");
      if (number == 10)
          printf("even\n");
  }
This way it basically works. It's a shame that it doesn't call out a non numeric argument but that's about the only problem. It relies on a trick, printf() returns the number of characters printed, so the error message string needs to be longer than 10.


Wouldn't using elif for all comparisons after the first improve performance?

Or is the performance considered worse because it becomes O(n) (where n < MAX_UINT) vs. constant time ( O(MAX_UINT) )


It certainly would be normal to use else if (or switch) if you wanted to be picky but really such changes are inconsequential here. And I was trying to change just one line. Sadly I also had to quietly change stdlib.h to string.h as well.


If you wanted to avoid <string.h>, you could use the poor man's strlen(), snprintf(0,0,"%s",argv[1]). For full input validation without adding any more statements, the best I can get (in ISO C) is

      uint8_t number = (argc<2||sscanf(*++argv,"%*[0123456789]%n",&argc)||argc--[*argv]?printf("bad\n"):argc[*argv])-'0'; // No problems here
Though with either function you may run into issues if the OS allows arguments longer than INT_MAX. To be defensive, you could use "%32767s" or "%*32767[0123456789]%n" instead, at the cost of failing inputs longer than 32KiB.


Marvellous, love it. Thank you.


Semi serious idea: A lot of people (including me) write C++ but it's basically C plus a small set of really ergonomic and useful C++ features (eg references). This should be standardised as a new language called C+


That probably would see more success than the monster they've created. I've been out of the C++ world for a while, but I hardly recognize the language anymore.


I agree, I had the same problem.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: