Micro Challenge #16 – Finding systematic solutions (to help you win at Battleship)

11 May 2020 - 3 minute read

Welcome to the Sixteenth of Altitude Foundation’s #MicroChallenges2020 

Today we’re exploring ‘best possible solutions’ using Battleship!

What’s a Micro Challenge?

These challenges are short activities to help you develop, revise or refresh your coding skills, posted every Monday, Wednesday and Friday.

Micro Challenge #16

This week, we are exploring ‘best possible solutions’ – finding different solutions to issues and determining which is the best. For our Monday challenge, we are looking at the game Battleship – a classic board game. 

It uses a 10 x 10 grid like this:

0123456789
0
1
2
3
4
5
6
7
8
9

 You will then place your five ships onto the grid. The five different ships can be represented like this (one X represents one set of grid coordinates):

X X X X X

X X X X 

X X X 

X X X

X X

Your opponent will do the same. The aim of the game is to sink their ships before they sink yours. What system can you use to ensure success most of the time?

The Challenge:

Can you create a system which will allow you to identify and sink your opponent’s ships as fast and reliably as possible?

Consider:

  • The size of the ships
  • The size of the grid
  • What to prioritise: speed or reliability? 

How can you prove the effectiveness of your strategy on the grid?

Review it:

Try it out on this online version of Battleship. This is a larger grid and the ships have a slightly different breakdown – how might that change your strategy? 

Advanced:

How might your strategy have to change when you hit a ship? Why? 

Could you design a search algorithm which reflects your strategy? (See Challenge 13 and Challenge 14 on searches)

Share it

We would love to see what you have created! Please send any pictures, videos, or files of your activities to us – either via Facebook, Twitter or Instagram  using #MicroChallenges2020 or to challenges@altitudefoundation.org. If you are emailing them to us, please let us know if you are happy for us to share your stuff on our social media platforms (with credit, of course). 

Sign-up here to receive a weekly email with Micro Challenges top tips and solutions:



Leave a comment

Leave a Reply