Storage Technologies – Tic-Tac-Toe (Python Challenge)

For this challenge, we are putting a tech twist on the classic Tic-Tac-Toe game. Instead of Xs and Os, you will be working with a 3×3 grid filled with various computer storage devices. Your task is to write a Python program that not only generates this grid but also analyses it to detect if three devices of the same technology are aligned horizontally, vertically, or diagonally. Your program will give a score to the randomly generated grid where each alignment will add 10 points to the grid score.

Learning Objectives

The aim of this challenge is to work with different data structures in Python. The code provided below will use:

  • A 2D-array to store the tic-tac-toe grid (3×3 grid)
  • A list of storage devices
  • A dictionary of storage devices to store the technologies of each storage device

Your Challenge

Step 1:

Generate a 3×3 grid filled with random storage devices from the following list:

  • CD
  • DVD
  • BluRay
  • HDD
  • Floppy Disk
  • Magnetic Tape
  • USB Key
  • SD Card
  • SSD

Step 2:

Analyse the grid to check for any horizontal, vertical, or diagonal alignments of three devices from the same technology category:

  • Optical: CD, DVD, BluRay
  • Magnetic: HDD, Floppy Disk, Magnetic Tape
  • Solid State: USB Key, SD Card, SSD

Step 3:

Score points: For every alignment of three devices from the same technology, increase the score by 10.

Python Code

The code is already started for you. The code generates the random 3×3 grid of storage devices (step 1). But step 2 and 3 are incomplete. A this stage the code only checks the first row of the grid. You will need to complete this code t check all three rows as well as all thre columns and the two diagonales.

unlock-access

Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area

Did you like this challenge?

Click on a star to rate it!

Average rating 3.7 / 5. Vote count: 3

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!