📜 ⬆️ ⬇️

Remember the real world

Hello, I want to talk about the problem that our team recently faced and how we had to participate in the fraud of the lottery results.

So, in the very first week of the new year, we were given a simple but urgent task. A certain foreign company engaged in film distribution decided to attract people to the new inconspicuous filmmaker, playing tickets to it among its visitors. To do this, a batch of fresh tickets (1 million pieces) was supposed to inflict unique alphabetic codes of sufficient length to ensure compatibility. Buyers must enter them on a special page of the site (along with a zip code to send a person to the nearest cinema, if he won). Our foreign colleagues gave us a file with a list of codes and told us to take the first 500 and use them as winning ones (4 winning places were assigned to 1 winning code in the cinema). Since we were not interested in non-winning tickets, and the client didn’t care who won, we put 500 lines with codes in our database and wrote the necessary logic to check the codes and distribute prizes - letters with invitations to the nearest available cinema. A week after the launch, the site went live, tickets went to the ticket office, and on the first evening 2 people became happy winners.

However, a week passed and the customer began to write alarming letters - nobody else won! The next testing and revision of the code yielded nothing - everything worked perfectly, you enter a good code - you won, a bad one - you will get lucky another time. Of course, the probability of a correct code is small - about 0.0005, and not all people like to play the lottery, but it was embarrassing that someone won on the first day.

As a result, the film distributor made a decision to fill the cinema at any cost. We rewrote all the logic to manipulate the results ... and it was only here that we understood the problem. The customer received the same list of codes as we did and sent it to the printing house. Naturally, the codes were printed on successive tickets. Then, of course, the tickets were sent in batches to the cinemas, and there they were distributed in batches at the box office. And most likely, the very “first available, no matter what” 500 codes, which we took from the 500 first lines of the file, got everything for 1 movie session. The only consolation is that only 2 out of 500 viewers decided to check their tickets.
')
And the moral is all in the title - remember the pieces of paper on which your data will be printed, remember the “limitations” of the real world.

Source: https://habr.com/ru/post/167061/


All Articles