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.2 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
68b1f72371a5ac895ac70a02 Challenge 40: Photo Storage 28 challenge-40

--description--

Given a photo size in megabytes (MB), and hard drive capacity in gigabytes (GB), return the number of photos the hard drive can store using the following constraints:

  • 1 gigabyte equals 1000 megabytes.
  • Return the number of whole photos the drive can store.

--hints--

numberOfPhotos(1, 1) should return 1000.

assert.equal(numberOfPhotos(1, 1), 1000);

numberOfPhotos(2, 1) should return 500.

assert.equal(numberOfPhotos(2, 1), 500);

numberOfPhotos(4, 256) should return 64000.

assert.equal(numberOfPhotos(4, 256), 64000);

numberOfPhotos(3.5, 750) should return 214285.

assert.equal(numberOfPhotos(3.5, 750), 214285);

numberOfPhotos(3.5, 5.5) should return 1571.

assert.equal(numberOfPhotos(3.5, 5.5), 1571);

--seed--

--seed-contents--

function numberOfPhotos(photoSizeMb, hardDriveSizeGb) {

  return photoSizeMb;
}

--solutions--

function numberOfPhotos(photoSizeMb, driveSizeGb) {
  const driveSizeMb = driveSizeGb * 1000;
  return Math.floor(driveSizeMb / photoSizeMb);
}