Warning
This page is located in archive. Go to the latest version of this course pages. Go the latest version of this page.

01 Intro

We log on, discuss the rules, answer first questions, create first simple Python program.

Read about computer labs how to set-up initial password, access home directory, links to other university services, …

Reading about Python and programming essentials from the Programming Essentials course. Tutorials help with setting Python, discuss how to upload homework correctly, and add some class examples and some most frequent Python modules.

After solving the logging issues we will go into Objective Python. We will program the NPuzzle class that would represent the classical n-1 puzzle. Necessary basis will be explained at the first lecture. Python is well on-line documented/discussed, in case of problems, google is your friend.

NPuzzle class

Besides the constructor __init__ we will need a few basic method, namely reset, visualise, read_tile. You can create some auxiliary methods/function as it suits to you

class NPuzzle:
    '''
    sliding puzzle class of a general size
    https://en.wikipedia.org/wiki/15_puzzle
    '''
    def __init__(self,size):
        '''
        create the list of symbols, typically from 1 to 8 or 15. Empty tile
        is represented by None
        :param size: the board will be size x size,
                     size=3 - 8-puzzle; 4 - 15 puzzle
        '''
 
    def reset(self):
        '''
        initialize the board by a random shuffle of symbols
        :return: None
        '''
 
    def visualise(self):
        '''
        just print itself to the standard output
        :return: None
        '''
 
    def read_tile(self, row, col):
        '''
        returns a symbol on row, col position
        :param row: index of the row
        :param column: index of the column
        :return: value of the tile - int 1 to size^2-1, None for empty tile
        The function raises IndexError exception if outside the board
        '''

courses/be5b33kui/labs/weekly/week_01.txt · Last modified: 2018/02/18 16:14 by svarnpet