The assignments will be graded out of 100 points. Create a text document entitled answers.xxx (where you replace xxx with whatever extension is appropriate, depending on the file format you use). Acceptable file formats are plain text, Word document, OpenOffice document, and PDF. Put your name and UTA ID at the top. Your answers that are not part of a program will be added to this file. Each task below will instruct you where to put your answers.
You are going to design and program the game, Tic-Tac-Toe. Tic-Tac-Toe is a two-player game played on a 3x3 grid in which the players alternate turns and select a grid square in which to place one of their pieces. One player uses the letter X for pieces, and the other uses the letter O. A player wins the game by placing three of his pieces in a row, either vertically, diagonally or horizontally. For example, X wins the following game:
X X X O O X X O O
You are free to make any design decisions you see fit. For example, which data structure you choose to represent the playing board. This is what you must complete (anything additional is up to you):
It should be stressed that you will receive partial credit if you design and implement some useful functions for the game, even if you can't finish everything.
In answers.xxx document, describe the design of your program. What functions are you creating, and what are their arguments and returns? What functions you deem necessary is entirely up to you. Just be sure to discuss each one you create.
Implement the code for your functions and save them in a file named tic_tac_toe_functions.py.
Write a main program that tests the functions you implemented for Tic-Tac-Toe as described above, and save it as tic_tac_toe.py. You will have to import your functions into this file. In grading this task, the important criterion will be the inclusion of good test cases for testing your functions.
The file system on a computer can be represented as a tree. The directories are connected with branches and the files are the leaves on the tree. Consider the following directory structure:
___________[C:]___________________ | | | __[dir1]____________ file6 [dir5] | | | | file1 [dir2] __[dir4]_____ file7 | | | | [dir3] file3 file4 file5 | file2
This directory structure can be represented by nested lists in which each directory is a list containing files and/or other directories (also represented as lists). For example, the above directory structure could be represented as:
C = [ ['file1', [ ['file2'] ], ['file3', 'file4', 'file5'] ], 'file6', ['file7'] ] # | | | |_______| | |_________________________| | |_______| | # | | | dir3 | dir4 | dir5 | # | | |___________| | | # | | dir2 | | # | |____________________________________________________| | # | dir1 | # |____________________________________________________________________________| C:
The C directory is the external list. Inside the C list is another list representing dir1, file6, and another list representing dir5. Each of those directories contains either more lists representing subdirectories, files, or both. Write a function that traverses a tree structure represented by such nested lists and prints the filenames one per line. The tree can be arbitrarily deep and each directory may or may not contain files or other directories. Here are a few example lists and their respective output:
# Input 1 C = [['file1', [['file2']], ['file3', 'file4', 'file5']], 'file6', ['file7']] # Output 1 file1 file2 file3 file4 file5 file6 file7 # Input 2 C = [[['answers.txt'], 'task12.py', [['hello.txt'], 'pagefile.sys']], 'explorer.exe'] # Output 2 answers.txt task12.py hello.txt pagefile.sys explorer.exe # Input 3 C = ['a.txt', 'file.txt', [[[[['hello.txt', 'bye.txt'], 'b.txt']]], 'last.txt']] # Output 3 a.txt file.txt hello.txt bye.txt b.txt last.txt # Input 4 C = [[[[[[[[[[[[[[[[[[['my_file.txt']]]]]]]]]]]]]]]]]]] # Output 4 my_file.txt
If your output is in a different order, that is fine, as long as it is all there. Save your function in task4_functions.py. Save your main program in task4_main.py. Your main program should contain your selection of good test cases.
Mr. Style is needing a program to help him get dressed in the morning. He needs a function, dress_me, that:
For example, if he ran:
shirts = ['white', 'blue'] ties = ['purple', 'yellow'] suits = ['grey', 'blue'] combinations = dress_me(shirts, ties, suits) for combo in combinations: print combo
It would print something like:
('white', 'purple', 'grey') ('white', 'purple', 'blue') ('white', 'yellow', 'grey') ('white', 'yellow', 'blue') ('blue', 'purple', 'grey') ('blue', 'purple', 'blue') ('blue', 'yellow', 'grey') ('blue', 'yellow', 'blue')
Write a function that meets Mr. Style's requirements. The lists can be
arbitrarily long, and your function must make use of nested for
loops. Save your function as
task5_functions.py. Save your main program (that contains your tests) as task5_main.py. Your main program
should contain your selection of good test cases.
Pay close attention to all specifications on this page, including file names and submission format. Even in cases where the program works correctly, points will be taken off for non-compliance with the instructions given on this page (such as wrong file names, wrong compression format for the submitted code, and so on). The reason is that non-compliance with the instructions makes the grading process significantly (and unnecessarily) more time consuming. Contact the instructor or TA if you have any questions.
The assignment should be submitted via Blackboard. Submit a ZIPPED directory called assignment6.zip (no other forms of compression accepted, contact the instructor or TA if you do not know how to produce .zip files). The zipped directory should contain your answers.xxx document and all the Python code files (task5.py, task6.py, etc).