Skip to content

Latest commit

 

History

History
29 lines (17 loc) · 953 Bytes

File metadata and controls

29 lines (17 loc) · 953 Bytes

Back

Box Blur

https://app.codesignal.com/arcade/intro/level-5/5xPitc3yT3dqS7XkP

Challenge description

Last night you partied a little too hard. Now there's a black and white photo of you that's about to go viral! You can't let this ruin your reputation, so you want to apply the box blur algorithm to the photo to hide its content.

The pixels in the input image are represented as integers. The algorithm distorts the input image in the following way: Every pixel x in the output image has a value equal to the average value of the pixel values from the 3 × 3 square that has its center at x, including x itself. All the pixels on the border of x are then removed.

Return the blurred image as an integer, with the fractions rounded down.

Example

For

image = [[1, 1, 1], 
         [1, 7, 1], 
         [1, 1, 1]]

the output should be solution(image) = [[1]].

Solution

Solved with Rust