Files
wehub-resource-sync dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

1.5 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
68ee9e3066cfd4eb2328e8a6 Challenge 87: Matrix Builder 29 challenge-87

--description--

Given two integers (a number of rows and a number of columns), return a matrix (an array of arrays) filled with zeros (0) of the given size.

For example, given 2 and 3, return:

[
  [0, 0, 0],
  [0, 0, 0]
]

--hints--

build_matrix(2, 3) should return [[0, 0, 0], [0, 0, 0]].

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(build_matrix(2, 3), [[0, 0, 0], [0, 0, 0]])`)
}})

build_matrix(3, 2) should return [[0, 0], [0, 0], [0, 0]].

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(build_matrix(3, 2), [[0, 0], [0, 0], [0, 0]])`)
}})

build_matrix(4, 3) should return [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]].

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(build_matrix(4, 3), [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]])`)
}})

build_matrix(9, 1) should return [[0], [0], [0], [0], [0], [0], [0], [0], [0]].

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(build_matrix(9, 1), [[0], [0], [0], [0], [0], [0], [0], [0], [0]])`)
}})

--seed--

--seed-contents--

def build_matrix(rows, cols):

    return rows

--solutions--

def build_matrix(rows, cols):

    return [[0 for _ in range(cols)] for _ in range(rows)]