Write pseudocode that will print out an image like this. It should have an outline of black squares with an island of black squares in the middle. The input will be 2 numbers, giving the length and width of the rectangle you will need to print (both numbers are guaranteed to be 5 or greater). Your program will be able to output 3 different things, a black square, a white square, and a line break. Use these 3 "characters" to print out the entire image.

The white "fringe" inside the rectangle should be equally wide in all parts of the image. In this example, the fringe is 2 squares wide at every location. It should also be as large as possible while still remaining equal, and while keeping at least some black squares in the middle island (ie: a white fringe that is only 1 square wide would not be valid, nor would a fringe that takes up the entire rectangle, with no middle island). This also means that the island should be as small as possible, but not 0.

This was a long explanation so if you have any questions feel free to email me. Good luck!

do we write this in python or java?

you write it in pseudocode

ok

let “r” be the # of black tiles in each row

r = 7

let “c” be the # of black tiles in each column

c = 9

let “a1” be the midpoint of the vertical lines

let “a2” be the midpoint of the horizontal lines

make a single row of 9 black tiles

on 9th tile, place down (r-1) black tiles vertically downwards

on lowest vertical tile, make a row of (c-1) black tiles

on leftmost tile of the lowest horizontal line, place down (r-2) black tiles upwards

find a1 and a2

for leftmost vertical line, move the midpoint a2 / 2 units to the right

for rightmost vertical line, move the midpoint a2 / 2 units to the left

for the uppermost horizontal line, move the midpoint a1 / 2 units down

for the bottommost horizontal line, move the midpoint a1 / 2 units up

find the point where all 4 midpoints overlap into a single midpoint

Let "a" equal the number of black tiles in each row

let "c" equal the number of black tiles in each column

make one vertical row of 9 black tiles going down

On the ninth tile place 7 tiles horizontally

On the seventh tile place another row of nine black tiles going up.

Then on the ninth tile place another 7 tiles horizontally.

Go 4 tiles to the right and 3 tiles down and place one tile.

Then from tile 4,3 place 2 tiles going to the right.

Print

Let r = # of rows

Let c = # of columns

Let a = midpoint

While r < 7

If r = 0 or r = 6

Print 9 black lines

Else if r = 3

Print c = |a - 1|, print c = a

Else print one black square at c=7

this probably isnt the correct answer but hey i tried

l = length, w = width

1) Find midpoints of both sides:

l_mid = (l - 1)/2

w_mid = (w - 1)/2

2) Find the fringe gap on each side

row_fringe = w_mid - 1

col_fringe = l_mid - 1

3) Find the difference of fringe gaps

4) Make loops

for each row:

for each column:

if it's the first or last row, first or last column, or midpoint:

print black square

elif col_fringe is greater and it is the middle row:

if the column number is abs(difference of fringe gaps)

away from midpoint:

print black square

elif row_fringe is greater and it is the middle column:

if row number is abs(difference of fringe gaps) away

from midpoint:

print black square

else: print white square

print line break

I'm not sure what I did but I think it sort of works