Skip to main content
added 34 characters in body
Source Link
Quinn
  • 1.4k
  • 5
  • 4

Auto Tic Tac Toe

Okay, so after thinking about the comment I think I thought of a way to make it more interesting.


Challenge

Given no input, write a program or function which outputs an entire game of Tic-Tac-Toe where X always wins, or the game ends in a tie.

Requirements

  • X goes first
  • O must make moves at random
  • X must make smart moves such that it always wins the game, or the game ends in a tie

Example

Here's what I would expect a game to look like:

X--
---
---

XO-
---
---

XO-
-X-
---

XOO
-X-
---

XOO
-X-
--X

Notes:

  • X does not need to win in the fewest moves, it is enough to just make it always block O from winning
  • You can output the game in whatever form you like, as long as it is easily conveys every turn of the game. For example you could output a string like above, or a list of lists of ints like below, where 0 is an empty space and 1, 2 are X, O respectively:
[
  [1,0,0, 0,0,0, 0,0,0], 
  [1,2,0, 0,0,0, 0,0,0], 
  [1,2,0, 0,1,0, 0,0,0],
  [1,2,2, 0,1,0, 0,0,0], 
  [1,2,2, 0,1,0, 0,0,1]
]

This is code golf, answer in the fewest bytes wins. Standard rules apply.


Is this a better challenge? I'd love to know what people think


Working example of ungolfed code: Try it online!Try it online!

Auto Tic Tac Toe

Okay, so after thinking about the comment I think I thought of a way to make it more interesting.


Challenge

Given no input, write a program or function which outputs an entire game of Tic-Tac-Toe where X always wins, or the game ends in a tie.

Requirements

  • X goes first
  • O must make moves at random
  • X must make smart moves such that it always wins the game, or the game ends in a tie

Example

Here's what I would expect a game to look like:

X--
---
---

XO-
---
---

XO-
-X-
---

XOO
-X-
---

XOO
-X-
--X

Notes:

  • X does not need to win in the fewest moves, it is enough to just make it always block O from winning
  • You can output the game in whatever form you like, as long as it is easily conveys every turn of the game. For example you could output a string like above, or a list of lists of ints like below, where 0 is an empty space and 1, 2 are X, O respectively:
[
  [1,0,0, 0,0,0, 0,0,0], 
  [1,2,0, 0,0,0, 0,0,0], 
  [1,2,0, 0,1,0, 0,0,0],
  [1,2,2, 0,1,0, 0,0,0], 
  [1,2,2, 0,1,0, 0,0,1]
]

This is code golf, answer in the fewest bytes wins. Standard rules apply.


Is this a better challenge? I'd love to know what people think


Working example of ungolfed code: Try it online!

Auto Tic Tac Toe

Okay, so after thinking about the comment I think I thought of a way to make it more interesting.


Challenge

Given no input, write a program or function which outputs an entire game of Tic-Tac-Toe where X always wins, or the game ends in a tie.

Requirements

  • X goes first
  • O must make moves at random
  • X must make smart moves such that it always wins the game, or the game ends in a tie

Example

Here's what I would expect a game to look like:

X--
---
---

XO-
---
---

XO-
-X-
---

XOO
-X-
---

XOO
-X-
--X

Notes:

  • X does not need to win in the fewest moves, it is enough to just make it always block O from winning
  • You can output the game in whatever form you like, as long as it is easily conveys every turn of the game. For example you could output a string like above, or a list of lists of ints like below, where 0 is an empty space and 1, 2 are X, O respectively:
[
  [1,0,0, 0,0,0, 0,0,0], 
  [1,2,0, 0,0,0, 0,0,0], 
  [1,2,0, 0,1,0, 0,0,0],
  [1,2,2, 0,1,0, 0,0,0], 
  [1,2,2, 0,1,0, 0,0,1]
]

This is code golf, answer in the fewest bytes wins. Standard rules apply.


Is this a better challenge? I'd love to know what people think


Working example of ungolfed code: Try it online!

deleted 931 characters in body
Source Link
Quinn
  • 1.4k
  • 5
  • 4

Auto Tic Tac Toe

Okay, so after thinking about the comment I think I thought of a way to make it more interesting.


Challenge

Given no input, write a program or function which outputs an entire game of Tic-Tac-Toe where X always wins, or the game ends in a tie.

Requirements

  • X goes first
  • O must make moves at random
  • X must make smart moves such that it always wins the game, or the game ends in a tie

Example

Here's what I would expect a game to look like:

X--
---
---

XO-
---
---

XO-
-X-
---

XOO
-X-
---

XOO
-X-
--X

Notes:

  • X does not need to win in the fewest moves, it is enough to just make it always block O from winning
  • You can output the game in whatever form you like, as long as it is easily conveys every turn of the game. For example you could output a string like above, or a list of lists of ints like below, where 0 is an empty space and 1, 2 are X, O respectively:
[
  [1,0,0, 0,0,0, 0,0,0], 
  [1,2,0, 0,0,0, 0,0,0], 
  [1,2,0, 0,1,0, 0,0,0],
  [1,2,2, 0,1,0, 0,0,0], 
  [1,2,2, 0,1,0, 0,0,1]
]

This is code golf, answer in the fewest bytes wins. Standard rules apply.


Is this a better challenge? I'd love to know what people think


Here is a ungolfed versionWorking example of an acceptable answerungolfed code: Try it online! Try it online!

Auto Tic Tac Toe

Okay, so after thinking about the comment I think I thought of a way to make it more interesting.


Challenge

Given no input, write a program or function which outputs an entire game of Tic-Tac-Toe where X always wins, or the game ends in a tie.

Requirements

  • X goes first
  • O must make moves at random
  • X must make smart moves such that it always wins the game, or the game ends in a tie

Example

Here's what I would expect a game to look like:

X--
---
---

XO-
---
---

XO-
-X-
---

XOO
-X-
---

XOO
-X-
--X

Notes:

  • X does not need to win in the fewest moves, it is enough to just make it always block O from winning
  • You can output the game in whatever form you like, as long as it is easily conveys every turn of the game. For example you could output a string like above, or a list of lists of ints like below, where 0 is an empty space and 1, 2 are X, O respectively:
[
  [1,0,0, 0,0,0, 0,0,0], 
  [1,2,0, 0,0,0, 0,0,0], 
  [1,2,0, 0,1,0, 0,0,0],
  [1,2,2, 0,1,0, 0,0,0], 
  [1,2,2, 0,1,0, 0,0,1]
]

This is code golf, answer in the fewest bytes wins. Standard rules apply.


Is this a better challenge? I'd love to know what people think


Here is a ungolfed version of an acceptable answer: Try it online!

Auto Tic Tac Toe

Okay, so after thinking about the comment I think I thought of a way to make it more interesting.


Challenge

Given no input, write a program or function which outputs an entire game of Tic-Tac-Toe where X always wins, or the game ends in a tie.

Requirements

  • X goes first
  • O must make moves at random
  • X must make smart moves such that it always wins the game, or the game ends in a tie

Example

Here's what I would expect a game to look like:

X--
---
---

XO-
---
---

XO-
-X-
---

XOO
-X-
---

XOO
-X-
--X

Notes:

  • X does not need to win in the fewest moves, it is enough to just make it always block O from winning
  • You can output the game in whatever form you like, as long as it is easily conveys every turn of the game. For example you could output a string like above, or a list of lists of ints like below, where 0 is an empty space and 1, 2 are X, O respectively:
[
  [1,0,0, 0,0,0, 0,0,0], 
  [1,2,0, 0,0,0, 0,0,0], 
  [1,2,0, 0,1,0, 0,0,0],
  [1,2,2, 0,1,0, 0,0,0], 
  [1,2,2, 0,1,0, 0,0,1]
]

This is code golf, answer in the fewest bytes wins. Standard rules apply.


Is this a better challenge? I'd love to know what people think


Working example of ungolfed code: Try it online!

Added example solution, made it easier
Source Link
Quinn
  • 1.4k
  • 5
  • 4

Auto Tic Tac Toe

Okay, so after thinking about the comment I think I thought of a way to make it more interesting.


Challenge

Given no input, write a program or function which outputs an entire game of Tic-Tac-Toe where X always wins, or the game ends in a tie.

Requirements

  • The player who takes theX goes first turn should be random
  • O must make moves at random
  • X must make smart moves such that it always wins the game, or the game ends in a tie

Example

Here's what I would expect a game to look like:

X--
---
---

XO-
---
---

XO-
-X-
---

XOO
-X-
---

XOO
-X-
--X

Notes:

  • X does not need to win in the fewest moves, it is enough to just make it always block O from winning
  • You can output the game in whatever form you like, as long as it is easily conveys every turn of the game. For example you could output a string like above, or a list of lists of ints like below, where 0 is an empty space and 1, 2 are X, O respectively:
[
  [1,0,0, 0,0,0, 0,0,0], 
  [1,2,0, 0,0,0, 0,0,0], 
  [1,2,0, 0,1,0, 0,0,0],
  [1,2,2, 0,1,0, 0,0,0], 
  [1,2,2, 0,1,0, 0,0,1]
]

This is code golf, answer in the fewest bytes wins. Standard rules apply.


Is this a better challenge? I'd love to know what people think


Here is a ungolfed version of an acceptable answer: Try it online!

Auto Tic Tac Toe

Okay, so after thinking about the comment I think I thought of a way to make it more interesting.


Challenge

Given no input, write a program or function which outputs an entire game of Tic-Tac-Toe where X always wins, or the game ends in a tie.

Requirements

  • The player who takes the first turn should be random
  • O must make moves at random
  • X must make smart moves such that it always wins the game, or the game ends in a tie

Example

Here's what I would expect a game to look like:

X--
---
---

XO-
---
---

XO-
-X-
---

XOO
-X-
---

XOO
-X-
--X

Notes:

  • X does not need to win in the fewest moves, it is enough to just make it always block O from winning
  • You can output the game in whatever form you like, as long as it is easily conveys every turn of the game. For example you could output a string like above, or a list of lists of ints like below, where 0 is an empty space and 1, 2 are X, O respectively:
[
  [1,0,0, 0,0,0, 0,0,0], 
  [1,2,0, 0,0,0, 0,0,0], 
  [1,2,0, 0,1,0, 0,0,0],
  [1,2,2, 0,1,0, 0,0,0], 
  [1,2,2, 0,1,0, 0,0,1]
]

This is code golf, answer in the fewest bytes wins. Standard rules apply.


Is this a better challenge? I'd love to know what people think

Auto Tic Tac Toe

Okay, so after thinking about the comment I think I thought of a way to make it more interesting.


Challenge

Given no input, write a program or function which outputs an entire game of Tic-Tac-Toe where X always wins, or the game ends in a tie.

Requirements

  • X goes first
  • O must make moves at random
  • X must make smart moves such that it always wins the game, or the game ends in a tie

Example

Here's what I would expect a game to look like:

X--
---
---

XO-
---
---

XO-
-X-
---

XOO
-X-
---

XOO
-X-
--X

Notes:

  • X does not need to win in the fewest moves, it is enough to just make it always block O from winning
  • You can output the game in whatever form you like, as long as it is easily conveys every turn of the game. For example you could output a string like above, or a list of lists of ints like below, where 0 is an empty space and 1, 2 are X, O respectively:
[
  [1,0,0, 0,0,0, 0,0,0], 
  [1,2,0, 0,0,0, 0,0,0], 
  [1,2,0, 0,1,0, 0,0,0],
  [1,2,2, 0,1,0, 0,0,0], 
  [1,2,2, 0,1,0, 0,0,1]
]

This is code golf, answer in the fewest bytes wins. Standard rules apply.


Is this a better challenge? I'd love to know what people think


Here is a ungolfed version of an acceptable answer: Try it online!

changed the whole challenge basically
Source Link
Quinn
  • 1.4k
  • 5
  • 4
Loading
added 112 characters in body
Source Link
Quinn
  • 1.4k
  • 5
  • 4
Loading
Source Link
Quinn
  • 1.4k
  • 5
  • 4
Loading