alexmojaki / alexmojaki/futurecoder

Finishing the course

Open
#345 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1.5k
Forks
183
PR merge metrics
No merged PRs in 30d

Description

**User Issue**
Email: (not given)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Safari/605.1.15

Thanks for the congratulations! Now that I've completed the tic tac toe game, I would like to see some kind of recap of everything I've learned and some suggestions of what to do next please.

Redux state

```json
{"book":{"error":null,"route":"main","previousRoute":"toc","pageSlugsList":["IntroducingTheShell","NavigatingShellHistory","IntroducingStrings","AddingStrings","IntroducingVariables","UsingVariables","WritingPrograms","StoringCalculationsInVariables","IntroducingForLoops","Indentation","BasicForLoopExercises","BuildingUpStrings","BuildingUpStringsExercises","BasicTerminology","IntroducingIfStatements","CombiningCompoundStatements","UnderstandingProgramsWithSnoop","IfAndElse","TheEqualityOperator","IntroducingElif","OtherComparisonOperators","IntroducingLists","BuildingNewLists","UsingBreak","GettingElementsAtPosition","GettingElementsAtPositionExercises","CallingFunctionsTerminology","FunctionsAndMethodsForLists","MoreListFunctionsAndMethods","StringMethodsUnderstandingMutation","HowToFindInformationWithGoogleAndMore","UnderstandingProgramsWithPythonTutor","EqualsVsIs","ModifyingWhileIterating","SingleAndDoubleQuotesInStrings","IntroducingFstrings","IntroducingNestedLoops","IntroducingBirdseye","IntroducingNestedLists","LoopingOverNestedLists","DefiningFunctions","CallingFunctionsWithinFunctions","ReturningValuesFromFunctions","TestingFunctions","MoreOnReturn","IntroducingOr","IntroducingAnd","MultiLineExpressions","CombiningAndAndOr","IntroducingNotPage","IntroducingTicTacToe","NewlinesAndFormatBoard","Types","InteractiveProgramsWithInput","NestedListAssignment","MakingTheBoard","TheFullTicTacToeGame"],"user":{"uid":"JKsT9oAPxWXzffUIGq0vV2CRbWE3","email":null,"developerMode":false,"pageSlug":"TheFullTicTacToeGame","pagesProgress":{"BasicForLoopExercises":{"step_name":"final_text"},"BuildingNewLists":{"step_name":"final_text"},"BuildingUpStrings":{"step_name":"final_text"},"BuildingUpStringsExercises":{"step_name":"final_text"},"CallingFunctionsTerminology":{"step_name":"final_text"},"CallingFunctionsWithinFunctions":{"step_name":"final_text"},"CombiningAndAndOr":{"step_name":"final_text"},"CombiningCompoundStatements":{"step_name":"final_text"},"DefiningFunctions":{"step_name":"final_text"},"EqualsVsIs":{"step_name":"final_text"},"FunctionsAndMethodsForLists":{"step_name":"final_text"},"GettingElementsAtPosition":{"step_name":"final_text"},"GettingElementsAtPositionExercises":{"step_name":"final_text"},"HowToFindInformationWithGoogleAndMore":{"step_name":"final_text"},"IfAndElse":{"step_name":"final_text"},"Indentation":{"step_name":"final_text"},"IntroducingAnd":{"step_name":"final_text"},"IntroducingElif":{"step_name":"final_text"},"IntroducingForLoops":{"step_name":"final_text"},"IntroducingFstrings":{"step_name":"final_text"},"IntroducingIfStatements":{"step_name":"final_text"},"IntroducingLists":{"step_name":"final_text"},"IntroducingNestedLists":{"step_name":"final_text"},"IntroducingNotPage":{"step_name":"final_text"},"IntroducingOr":{"step_name":"final_text"},"IntroducingTicTacToe":{"step_name":"final_text"},"LoopingOverNestedLists":{"step_name":"final_text"},"ModifyingWhileIterating":{"step_name":"final_text"},"MoreListFunctionsAndMethods":{"step_name":"final_text"},"MoreOnReturn":{"step_name":"final_text"},"MultiLineExpressions":{"step_name":"final_text"},"OtherComparisonOperators":{"step_name":"final_text"},"ReturningValuesFromFunctions":{"step_name":"final_text"},"SingleAndDoubleQuotesInStrings":{"step_name":"final_text"},"StringMethodsUnderstandingMutation":{"step_name":"final_text"},"TestingFunctions":{"step_name":"final_text"},"TheEqualityOperator":{"step_name":"final_text"},"UnderstandingProgramsWithPythonTutor":{"step_name":"final_text"},"UnderstandingProgramsWithSnoop":{"step_name":"final_text"},"UsingBreak":{"step_name":"final_text"},"IntroducingTheShell":{"step_name":"first_expression"},"NavigatingShellHistory":{"step_name":"final_text"},"IntroducingStrings":{"step_name":"hello_string"},"AddingStrings":{"step_name":"hello_world_concat"},"IntroducingVariables":{"step_name":"word_assign"},"UsingVariables":{"step_name":"name_assign"},"WritingPrograms":{"step_name":"editor_hello_world"},"StoringCalculationsInVariables":{"step_name":"sentence_equals_word_plus_name"},"BasicTerminology":{"step_name":"final_text"},"IntroducingNestedLoops":{"step_name":"first_nested_loop"},"IntroducingBirdseye":{"step_name":"first_birdseye_example"},"NewlinesAndFormatBoard":{"step_name":"final_text"},"Types":{"step_name":"final_text"},"InteractiveProgramsWithInput":{"step_name":"final_text"},"NestedListAssignment":{"step_name":"final_text"},"MakingTheBoard":{"step_name":"final_text"},"TheFullTicTacToeGame":{"step_name":"final_text"}}},"processing":false,"running":false,"numHints":0,"editorContent":"def winning_line(strings):\n strings = set(strings)\n return len(strings) == 1 and ' ' not in strings\n\ndef row_winner(board):\n return any(winning_line(row) for row in board)\n\ndef column_winner(board):\n return row_winner(zip(*board))\n\ndef main_diagonal_winner(board):\n return winning_line(row[i] for i, row in enumerate(board))\n\ndef diagonal_winner(board):\n return main_diagonal_winner(board) or main_diagonal_winner(reversed(board))\n\ndef winner(board):\n return row_winner(board) or column_winner(board) or diagonal_winner(board)\n\ndef format_board(board):\n size = len(board)\n line = f'\\n {\"+\".join(\"-\" * size)}\\n'\n rows = [f'{i + 1} {\"|\".join(row)}' for i, row in enumerate(board)]\n return f' {\" \".join(str(i + 1) for i in range(size))}\\n{line.join(rows)}'\n\ndef play_move(board, player):\n print(f'{player} to play:')\n row = int(input()) - 1\n col = int(input()) - 1\n board[row][col] = player\n print(format_board(board))\n\ndef make_board(size):\n return [[' '] * size for _ in range(size)]\n\ndef print_winner(player):\n print(f'{player} wins!')\n\ndef print_draw():\n print(\"It's a draw!\")\n\ndef play_game(board_size, player1, player2):\n board = make_board(board_size)\n print(format_board(board))\n \n player = player1\n for i in range(board_size * board_size):\n play_move(board, player)\n if winner(board):\n print_winner(player)\n return\n if player == player1:\n player = player2\n else:\n player = player1\n \n print_draw() \n \nplay_game(3, 'X', 'O')","messages":[],"pastMessages":["

You must define a function format_board

","

Given these values:

\n
board = [[' ', ' ', ' '], ['X', 'X', 'O'], ['O', 'O', 'X']]\n
\n

your code outputs:

\n
['O', 'O', 'X']\n
\n

when it should output:

\n
XXO\nOOX\n
","

Given these values:

\n
board = [[' ', ' ', ' '], ['X', 'X', 'O'], ['O', 'O', 'X']]\n
\n

your code outputs:

\n
None\n
\n

when it should output:

\n
XXO\nOOX\n
","

Given these values:

\n
board = [[' ', ' ', ' '], ['X', 'X', 'O'], ['O', 'O', 'X']]\n
\n

your code outputs:

\n
NameError: name 'join' is not defined\n
\n

when it should output:

\n
XXO\nOOX\n
","

Given these values:

\n
board = [[' ', ' ', ' '], ['X', 'X', 'O'], ['O', 'O', 'X']]\n
\n

your code outputs:

\n
NameError: name 'x' is not defined\n
\n

when it should output:

\n
XXO\nOOX\n
","

Given these values:

\n
board = [[' ', ' ', ' '], ['X', 'X', 'O'], ['O', 'O', 'X']]\n
\n

your code outputs:

\n
X\nX\nO\n
\n

when it should output:

\n
XXO\nOOX\n
","

Given these values:

\n
board = [[' ', ' ', ' '], ['X', 'X', 'O'], ['O', 'O', 'X']]\n
\n

your code outputs:

\n
XXO\nOOX\n
\n

when it should output:

\n
 | |\n-+-+-\nX|X|O\n-+-+-\nO|O|X\n
","

STOP!

\n

Try to avoid copy pasting code. You will learn, absorb, and remember better if you type in the code yourself.

\n

When copying is appropriate, there will be a button to click to make it easy. If there's no button, try typing.

\n

Having said that, we're not going to force you. Copy if you really want to.

","

Given these values:

\n
board = [[' ', ' ', ' '], ['X', 'X', 'O'], ['O', 'O', 'X']]\n
\n

your code outputs:

\n
   f'\n -+-+-\n'XXOf'\n -+-+-\n'OOX\n
\n

when it should output:

\n
 | |\n-+-+-\nX|X|O\n-+-+-\nO|O|X\n
","

Given these values:

\n
board = [[' ', ' ', ' '], ['X', 'X', 'O'], ['O', 'O', 'X']]\n
\n

your code outputs:

\n
 -+-+-\n'XXO\n -+-+-\n'OOX\n
\n

when it should output:

\n
 | |\n-+-+-\nX|X|O\n-+-+-\nO|O|X\n
","

Unused variable lines

\n

You defined a variable lines but never used it. Did you forget to use it?\nMaybe you used the wrong variable in its place? If you don't need it, just remove it entirely.

","

Given these values:

\n
board = [[' ', ' ', ' '], ['X', 'X', 'O'], ['O', 'O', 'X']]\n
\n

your code outputs:

\n
None\n
\n

when it should output:

\n
 | |\n-+-+-\nX|X|O\n-+-+-\nO|O|X\n
","

Unused variable line

\n

You defined a variable line but never used it. Did you forget to use it?\nMaybe you used the wrong variable in its place? If you don't need it, just remove it entirely.

","

Given these values:

\n
board = [[' ', ' ', ' '], ['X', 'X', 'O'], ['O', 'O', 'X']]\n
\n

your code outputs:

\n
 | |\n\nX|X|O\n\nO|O|X\n
\n

when it should output:

\n
 | |\n-+-+-\nX|X|O\n-+-+-\nO|O|X\n
","

Given these values:

\n
board = [[' ', ' ', ' '], ['X', 'X', 'O'], ['O', 'O', 'X']]\n
\n

your code outputs:

\n
O|O|X\n\nO|O|X\n\nO|O|X\n
\n

when it should output:

\n
 | |\n-+-+-\nX|X|O\n-+-+-\nO|O|X\n
","

Given these values:

\n
board = [[' ', ' ', ' '], ['X', 'X', 'O'], ['O', 'O', 'X']]\n
\n

your code outputs:

\n
NameError: name 'i' is not defined\n
\n

when it should output:

\n
 123\n1\n2XXO\n3OOX\n
","

Given these values:

\n
board = [[' ', ' ', ' '], ['X', 'X', 'O'], ['O', 'O', 'X']]\n
\n

your code outputs:

\n
 1 1\nX1X1O\nO1O1X\n
\n

when it should output:

\n
 123\n1\n2XXO\n3OOX\n
","

Given these values:

\n
board = [[' ', ' ', ' '], ['X', 'X', 'O'], ['O', 'O', 'X']]\n
\n

your code outputs:

\n
 1XXO\n 1OOX\n
\n

when it should output:

\n
 123\n1\n2XXO\n3OOX\n
","

Given these values:

\n
board = [[' ', ' ', ' '], ['X', 'X', 'O'], ['O', 'O', 'X']]\n
\n

your code outputs:

\n
 str(row)XXO\n str(row)OOX\n
\n

when it should output:

\n
 123\n1\n2XXO\n3OOX\n
","

Given these values:

\n
board = [[' ', ' ', ' '], ['X', 'X', 'O'], ['O', 'O', 'X']]\n
\n

your code outputs:

\n
   ['O', 'O', 'X']XXO['O', 'O', 'X']OOX\n
\n

when it should output:

\n
 123\n1\n2XXO\n3OOX\n
","

Given these values:

\n
board = [[' ', ' ', ' '], ['X', 'X', 'O'], ['O', 'O', 'X']]\n
\n

your code outputs:

\n
 [' ', ' ', ' '] [' ', ' ', ' ']\nX['X', 'X', 'O']X['X', 'X', 'O']O\nO['O', 'O', 'X']O['O', 'O', 'X']X\n
\n

when it should output:

\n
 123\n1\n2XXO\n3OOX\n
","

Given these values:

\n
board = [[' ', ' ', ' '], ['X', 'X', 'O'], ['O', 'O', 'X']]\n
\n

your code outputs:

\n
None\n
\n

when it should output:

\n
 123\n1\n2XXO\n3OOX\n
","

Given these values:

\n
board = [[' ', ' ', ' '], ['X', 'X', 'O'], ['O', 'O', 'X']]\n
\n

your code outputs:

\n
3\nO\nO\nX\n
\n

when it should output:

\n
 123\n1\n2XXO\n3OOX\n
","

Given these values:

\n
board = [[' ', ' ', ' '], [' ', ' ', ' '], [' ', ' ', ' ']]\nplayer = 'X'\n
\n

your code outputs:

\n
 123\n1\n2X\n3\n
\n

when it should output:

\n
<input: 2>\n<input: 1>\n 123\n1\n2X\n3\n
","

Given these values:

\n
board = [[' ', ' ', ' '], [' ', ' ', ' '], [' ', ' ', ' ']]\nplayer = 'X'\n
\n

your code outputs:

\n
 123\n1\n2\n3\n
\n

when it should output:

\n
<input: 2>\n<input: 1>\n 123\n1\n2X\n3\n
","

Given these values:

\n
board = [[' ', ' ', ' '], [' ', ' ', ' '], [' ', ' ', ' ']]\nplayer = 'X'\n
\n

your code outputs:

\n
TypeError: can only concatenate str (not \"int\") to str\n
\n

when it should output:

\n
<input: 2>\n<input: 1>\n 123\n1\n2X\n3\n
","

Given these values:

\n
board = [[' ', ' ', ' '], [' ', ' ', ' '], [' ', ' ', ' ']]\nplayer = 'X'\n
\n

your code outputs:

\n
 123\n1 X\n2\n3\n
\n

when it should output:

\n
<input: 2>\n<input: 1>\n 123\n1\n2X\n3\n
","

You must define a function play_move

","

The sublists in the result are not all separate objects.

","

Given these values:

\n
size = 2\n
\n

your code outputs:

\n
[' ', ' ', ' ', ' ']\n
\n

when it should output:

\n
[[' ', ' '], [' ', ' ']]\n
","

Given these values:

\n
size = 2\n
\n

your code outputs:

\n
[<built-in method copy of list object at 0x19364d0>, <built-in method copy of list object at 0x19364d0>]\n
\n

when it should output:

\n
[[' ', ' '], [' ', ' ']]\n
","

Given these values:

\n
size = 2\n
\n

your code outputs:

\n
AttributeError: 'builtin_function_or_method' object has no attribute 'append'\n
\n

when it should output:

\n
[[' ', ' '], [' ', ' ']]\n
","

Given these values:

\n
size = 2\n
\n

your code outputs:

\n
[[<built-in method copy of list object at 0x17610b0>, <built-in method copy of list object at 0x17610b0>], [<built-in method copy of list object at 0x17610b0>, <built-in method copy of list object at 0x17610b0>]]\n
\n

when it should output:

\n
[[' ', ' '], [' ', ' ']]\n
","

Given these values:

\n
size = 2\n
\n

your code outputs:

\n
UnboundLocalError: local variable 'row' referenced before assignment\n
\n

when it should output:

\n
[[' ', ' '], [' ', ' ']]\n
","

You must define a function make_board

","

Given these values:

\n
board_size = 2\nplayer1 = 'A'\nplayer2 = 'B'\n
\n

your code outputs:

\n
ValueError: No more test inputs - solution should have finished by now\n
\n

when it should output:

\n
  1 2\n1  |\n  -+-\n2  |\nA to play:\n<input: 1>\n<input: 1>\n  1 2\n1 A|\n  -+-\n2  |\nB to play:\n<input: 1>\n<input: 2>\n  1 2\n1 A|B\n  -+-\n2  |\nA to play:\n<input: 2>\n<input: 1>\n  1 2\n1 A|B\n  -+-\n2 A|\nA wins!\n
","

You must define a function play_game

","

Given these values:

\n
board_size = 2\nplayer1 = 'A'\nplayer2 = 'B'\n
\n

your code outputs:

\n
TypeError: object of type 'int' has no len()\n
\n

when it should output:

\n
  1 2\n1  |\n  -+-\n2  |\nA to play:\n<input: 1>\n<input: 1>\n  1 2\n1 A|\n  -+-\n2  |\nB to play:\n<input: 1>\n<input: 2>\n  1 2\n1 A|B\n  -+-\n2  |\nA to play:\n<input: 2>\n<input: 1>\n  1 2\n1 A|B\n  -+-\n2 A|\nA wins!\n
","

Given these values:

\n
board_size = 2\nplayer1 = 'A'\nplayer2 = 'B'\n
\n

your code outputs:

\n
NameError: name 'plater2' is not defined\n
\n

when it should output:

\n
  1 2\n1  |\n  -+-\n2  |\nA to play:\n<input: 1>\n<input: 1>\n  1 2\n1 A|\n  -+-\n2  |\nB to play:\n<input: 1>\n<input: 2>\n  1 2\n1 A|B\n  -+-\n2  |\nA to play:\n<input: 2>\n<input: 1>\n  1 2\n1 A|B\n  -+-\n2 A|\nA wins!\n
","

Given these values:

\n
board_size = 3\nplayer1 = 'X'\nplayer2 = 'O'\n
\n

your code outputs:

\n
ValueError: No more test inputs - solution should have finished by now\n
\n

when it should output:

\n
  1 2 3\n1  | |\n  -+-+-\n2  | |\n  -+-+-\n3  | |\nX to play:\n<input: 1>\n<input: 1>\n  1 2 3\n1 X| |\n  -+-+-\n2  | |\n  -+-+-\n3  | |\nO to play:\n<input: 1>\n<input: 2>\n  1 2 3\n1 X|O|\n  -+-+-\n2  | |\n  -+-+-\n3  | |\nX to play:\n<input: 1>\n<input: 3>\n  1 2 3\n1 X|O|X\n  -+-+-\n2  | |\n  -+-+-\n3  | |\nO to play:\n<input: 2>\n<input: 1>\n  1 2 3\n1 X|O|X\n  -+-+-\n2 O| |\n  -+-+-\n3  | |\nX to play:\n<input: 2>\n<input: 3>\n  1 2 3\n1 X|O|X\n  -+-+-\n2 O| |X\n  -+-+-\n3  | |\nO to play:\n<input: 3>\n<input: 3>\n  1 2 3\n1 X|O|X\n  -+-+-\n2 O| |X\n  -+-+-\n3  | |O\nX to play:\n<input: 3>\n<input: 1>\n  1 2 3\n1 X|O|X\n  -+-+-\n2 O| |X\n  -+-+-\n3 X| |O\nO to play:\n<input: 2>\n<input: 2>\n  1 2 3\n1 X|O|X\n  -+-+-\n2 O|O|X\n  -+-+-\n3 X| |O\nX to play:\n<input: 3>\n<input: 2>\n  1 2 3\n1 X|O|X\n  -+-+-\n2 O|O|X\n  -+-+-\n3 X|X|O\nIt's a draw!\n
"],"requestingSolution":0,"prediction":{"choices":null,"answer":null,"userChoice":"","wrongAnswers":[],"state":"hidden","codeResult":{"passed":true,"messages":[],"output":" 1 2 3\n1 | | \n -+-+-\n2 | | \n -+-+-\n3 | | \nX to play:\n 1 2 3\n1 X| | \n -+-+-\n2 | | \n -+-+-\n3 | | \nO to play:\n 1 2 3\n1 X|O| \n -+-+-\n2 | | \n -+-+-\n3 | | \nX to play:\n 1 2 3\n1 X|O| \n -+-+-\n2 |X| \n -+-+-\n3 | | \nO to play:\n 1 2 3\n1 X|O| \n -+-+-\n2 |X| \n -+-+-\n3 | |O\nX to play:\n 1 2 3\n1 X|O| \n -+-+-\n2 |X| \n -+-+-\n3 X| |O\nO to play:\n 1 2 3\n1 X|O| \n -+-+-\n2 O|X| \n -+-+-\n3 X| |O\nX to play:\n 1 2 3\n1 X|O| \n -+-+-\n2 O|X| \n -+-+-\n3 X|X|O\nO to play:\n 1 2 3\n1 X|O|O\n -+-+-\n2 O|X| \n -+-+-\n3 X|X|O\nX to play:\n 1 2 3\n1 X|O|O\n -+-+-\n2 O|X|X\n -+-+-\n3 X|X|O\nIt's a draw!\n"}},"questionWizard":{"messages":[],"requestExpectedOutput":false,"expectedOutput":""}}}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.