Skip to content

Instantly share code, notes, and snippets.

@codepo8
Last active February 2, 2024 13:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codepo8/458953213aae249cdcd4b073e522b4cf to your computer and use it in GitHub Desktop.
Save codepo8/458953213aae249cdcd4b073e522b4cf to your computer and use it in GitHub Desktop.
The CODE 100 xxx-challenge

The CODE100 XXX challenge

It's not what you think… On the 29th of January CODE100 is coming to Amsterdam - you can get a ticket here to join the party and network or you can go the whole hog and apply as a challenger - remember, the winners get to the finals in July and last year's winner went home with 10,000 Euro prize money.

In any case, this time the puzzle is to celebrate Amsterdam and it's flag:

Flag of Amsterdam, two red bars with a black bar containing three white X

The challenge is to take a collection of 292 games of noughts and crosses (or Tic Tac Toe) and to find out how many were won by the player using the X like shown in this animation:

Animation of 292 games of Tic Tac Toe and the result of how many were won by the player x

You can use this text file of all the games as the source. The file consist of played games separated by a blank line. For example:

 O │ O │ O 
───┼───┼───
 X │   │   
───┼───┼───
 X │ X │   

 O │ X │ X 
───┼───┼───
 O │ O │ X 
───┼───┼───
 X │ O │ X 

   │ O │ X 
───┼───┼───
 X │ X │ O 
───┼───┼───
 X │   │ O 

In this case, the first game was won by O and the second and third by X. The rules are the ones of the game, in order to win, three Xes must be either in horizontal, vertical or diagonal order.

How many games were won by X?

@gpetrioli
Copy link

The games.txt file points to the wrong place. Use https://puzzles.code100.dev/code100/puzzles/xxx/games.txt for the link.

@codepo8
Copy link
Author

codepo8 commented Feb 2, 2024

Well spotted, fixed :)

@gpetrioli
Copy link

And it looks like results are

{ X: 183, O: 88, tie: 21 }

running code at https://stackblitz.com/edit/stackblitz-starters-mz5umb

@codepo8
Copy link
Author

codepo8 commented Feb 2, 2024

Yep, well done! That's one solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment