Skip to content
DeepForgeby svx
All problems
EasyComputer Visioncv-374

Occupied Voxel Count

Problem

Count the distinct voxels occupied by a point cloud.

Map every point to (floor(x / size), floor(y / size), floor(z / size)) and return the number of unique integer cells. An empty cloud returns 0.

Hint

floor maps both -0.5 and 0.5 into different bins, while 1.0 lands one cell further.

Test cases

case 1
in: [[[0.1,0.1,0.1],[0.2,0.3,0.2],[1.5,1.5,1.5]],1]
expected: 2
case 2
in: [[[1,1,1],[1.2,1.4,1.6],[1.9,1.1,1.3]],2]
expected: 1
case 3
in: [[],1]
expected: 0
case 4
in: [[[-0.5,-0.5,-0.5],[0.5,0.5,0.5],[1,0,0]],1]
expected: 3
Starter codePython
def occupied_voxel_count(points, size):
    # Your code here
    pass

4 test cases · run your code against them in the editor