External Exam Download Resources Web Applications Games Recycle Bin

Exercises F

I.py

Stairs: 3
-
 |
  -
   |
    -
     |

Stairs: 1
-
 |

Stairs: 2
-
 |
  -
   |

# can you scale this to n stairs (n positive integer)

II.py

Digits to display: 0123456789
Bars scale factor: 1
 -      -   -       -   -   -   -   - 
| |  |   |   | | | |   |     | | | | |
        -   -   -   -   -       -   - 
| |  | |     |   |   | | |   | | |   |
 -      -   -       -   -       -   - 

Digits to display: 81253
Bars scale factor: 2
 --        --   --   -- 
|  |    |    | |       |
|  |    |    | |       |
 --        --   --   -- 
|  |    | |       |    |
|  |    | |       |    |
 --        --   --   -- 

Digits to display: 731
Bars scale factor: 3
 ---   ---       
    |     |     |
    |     |     |
    |     |     |
       ---       
    |     |     |
    |     |     |
    |     |     |
       ---

# can you scale this to n bars per digit? (n positive integer)

III. Implement 3 sorts from the Algorithms sorts link above

IV. Create this program:

1. Initialise a full deck (52) of cards (choose an appropriate representation data structure)

repeat:

2. shuffle
3. simulate game of snap by drawing 2 cards off top at once
  3.1 snap on two of same title ("Ace" == "Ace" etc.)
  3.2 when end of deck reached, go back to shuffle

until a match made 

V. Create this program:

P = player
G = goal
. = empty grid placeholder
x = obstacle

1. ensure path exists between P & G
2. generate terrain randomly
3. scale to n size (n positive integer)
4. clump x together (hard)

examples:

#####
#P..#
#...#
#.xG#
#####

######
#P...#
#xx..#
#x...#
#...G#
######

#######
#P..xx#
#..xxx#
#...xx#
#xx...#
#xx..G#
#######