subject

Uluthando needs your help to plant some trees. He can give you three parameters of the land: - width of the land w
- length of the land l
- gap between the trees g
You have to create an algorithm to return the number of trees which can be planted on the edges of the given land in a symmetrical layout shown below (unsymmetrical gap = x, tree = o, gap = -):

w=3, l=3, g=1
plantTrees(w, l, g) ➞ 4

o - o
- -
o - o

// Uluthando can plant 4 trees.
w=3, l=3, g=3
plantTrees(w, l, g) ➞ 2

o - -
- -
- - o

// Uluthando can plant 2 trees.
If the layout is not symmetrical, you have to return 0:

w=3, l=3, g=2
plantTrees(w, l, g) ➞ 0

o - -
x o
x x x

// Planting 2 trees mean the gap of two trees will be greater than 2.

o - -
x o
o - -

// Planting 3 trees mean the gap of two trees will be less than 2.
Another Example for better understanding:

w=3, l=3, g=0
plantTrees(w, l, g) ➞ 8

o o o
o o
o o o

// Uluthando can plant 8 trees.
(10 Points)

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 15:30
Brian wants to conduct an online search with a certain phrase. he intends to use the words books that belong to the 1800s in his search. how should he use the word that in his search?
Answers: 1
question
Computers and Technology, 23.06.2019 21:30
Examine the list below. which factors positively affect lifetime income? check all that apply.
Answers: 1
question
Computers and Technology, 23.06.2019 22:00
Take a critical look at three gui applications you have usedβ€”for example, a spreadsheet, a word-processing program, and a game. describe how well each conforms to the gui design guidelines listed in this chapter.
Answers: 3
question
Computers and Technology, 24.06.2019 00:00
Visualizing a game of β€œtag” to remember the meaning of contagious
Answers: 3
You know the right answer?
Uluthando needs your help to plant some trees. He can give you three parameters of the land: - widt...
Questions
question
History, 06.07.2019 00:00
Questions on the website: 13722367