SpiralFlex
Well-Known Member
- Joined
- Dec 18, 2010
- Messages
- 6,960
- Gender
- Female
- HSC
- N/A
Due to the lack of reception with my previous thread, hopefully more people will contribute as more SDD students join the forum. Year 12s and Year 11s and anything below and beyond feel free to participate.
I shall start,
An algorithm is required to fill an n by n two-dimensional array of Boolean values so that the diagonals each contain True and all other array elements remain False. It is known that all elements are initially false. The required result when n=6 (ie. a 6 by 6 array) is reproduced below.
Write an algorithm that will efficiently achieve this requirement.
Note: To type code in psuedo, the preferred method when using a forum is to use [code.] at the beginning of your code and [/code.] at the end of your code. No full stops.
I shall start,
An algorithm is required to fill an n by n two-dimensional array of Boolean values so that the diagonals each contain True and all other array elements remain False. It is known that all elements are initially false. The required result when n=6 (ie. a 6 by 6 array) is reproduced below.
n=6 | 0 | 1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|---|---|
0 | True | False | False | False | False | True |
1 | False | True | False | False | True | False |
2 | False | False | True | True | False | False |
3 | False | False | True | True | False | False |
4 | False | True | False | False | True | False |
5 | True | False | False | False | False | True |
Write an algorithm that will efficiently achieve this requirement.
Note: To type code in psuedo, the preferred method when using a forum is to use [code.] at the beginning of your code and [/code.] at the end of your code. No full stops.
Code:
BEGIN Spiralsays
PRINT Like this kekeke
END Spiralsays