In Santa's workshop, the elves are storing gifts ๐ in a vertical warehouse. The gifts are dropped one by one through a column and start stacking up.
The warehouse is a matrix with # gifts and . empty spaces. You must create a dropGiftsdrop_gifts function that receives the warehouse state and an array with the columns where the gifts are dropped.
Falling rules:
.) of that column.dropGifts(
[
['.', '.', '.'],
['.', '#', '.'],
['#', '#', '.']
],
[0]
)
/*
[
['.', '.', '.'],
['#', '#', '.'],
['#', '#', '.']
]
*/
dropGifts(
[
['.', '.', '.'],
['#', '#', '.'],
['#', '#', '#']
],
[0, 2]
)
/*
[
['#', '.', '.'],
['#', '#', '#'],
['#', '#', '#']
]
*/
dropGifts(
[
['.', '.', '.'],
['.', '.', '.'],
['.', '.', '.']
],
[0, 1, 2]
)
/*
[
['.', '.', '.'],
['.', '.', '.'],
['#', '#', '#']
]
*/
dropGifts(
[
['#', '#'],
['#', '#']
],
[0, 0]
)
/*
[
['#', '#'],
['#', '#']
]
*/drop_gifts(
[
['.', '.', '.'],
['.', '#', '.'],
['#', '#', '.']
],
[0]
)
# [
# ['.', '.', '.'],
# ['#', '#', '.'],
# ['#', '#', '.']
# ]
drop_gifts(
[
['.', '.', '.'],
['#', '#', '.'],
['#', '#', '#']
],
[0, 2]
)
# [
# ['#', '.', '.'],
# ['#', '#', '#'],
# ['#', '#', '#']
# ]
drop_gifts(
[
['.', '.', '.'],
['.', '.', '.'],
['.', '.', '.']
],
[0, 1, 2]
)
# [
# ['.', '.', '.'],
# ['.', '.', '.'],
# ['#', '#', '#']
# ]
drop_gifts(
[
['#', '#'],
['#', '#']
],
[0, 0]
)
# [
# ['#', '#'],
# ['#', '#']
# ]