Word game

Word game

Find the longest word.

A popular word game has sixteen six-sided dice. Each dice is unique with a single letter of the alphabet on each face. The dice are rolled and arranged in a 4x4 grid. The players try to create valid words using the dice. Any dice can be chosen as a starting letter, but subsequent letters must adjacent horizontally, vertically or diagonally to the previous dice. The object of the game is to find a valid word with the most letters.

The six faces of the sixteen dice can be seen in the `dice.txt` file below. It is important that the grid is stored in a 2D array for each dice position to be processed easily. The program does not need to determine who wins.

R,I,F,O,B,X

I,F,E,H,E,Y

D,E,N,O,W,S

U,T,O,K,N,D

H,M,S,R,A,O

L,U,P,E,T,S

A,C,I,T,O,A

Y,L,G,K,U,E

Qu,B,M,J,O,A

E,H,I,S,P,N

V,E,T,I,G,N

B,A,L,I,Y,T

E,Z,A,V,N,D

R,A,L,E,S,C

U,W,I,L,R,G

P,A,C,E,M,D

Make


Write a program that reads in the faces of the sixteen dice, picks a random face from each die and outputs the letter from the face in a 4x4 grid.

Use this boilerplate code as a starting point:

Success Criteria

Remember to add a comment before a subprogram, selection or iteration statement to explain its purpose.

Complete the subprogram called `shuffle_letters` that:

  1. Defines a 2D array of 4x4 strings representing the grid of letters.
  2. Reads the dice faces from the `dice.txt` file.
  3. Assigns a letter in the grid to be one of the faces from each dice.
  4. Returns the grid of letters.

Complete the subprogram called `show_letters` that:

  1. Outputs the 4x4 grid of letters.

Typical inputs and outputs from the program would be:

BISN

ASCY

ASIT

NEUA

Knowledge Organiser

Use these resources as a reference to help you meet the success criteria.

Programming guide:

Evaluate


Run the program several times to check that your program has met the success criteria.

Check that you have:

  • Used comments within the code to describe the purpose of subprograms, conditions and iterations.
  • Used meaningful identifier names. That means the names of subprograms and variables indicate what they are for.

Registered in England and Wales: 10442992

VAT Number: 290 9845 58

Telephone: 01452 947500

Email: admin@craigndave.co.uk

Craig'n'Dave logo

Craig 'n' Dave

Bett Awards 2024 Finalist