Files
freecodecamp--freecodecamp/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/68c1a929005bf54d342aa8d3.md
T
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

2.0 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
68c1a929005bf54d342aa8d3 Challenge 56: Space Week Day 2: Exoplanet Search 28 challenge-56

--description--

For the second day of Space Week, you are given a string where each character represents the luminosity reading of a star. Determine if the readings have detected an exoplanet using the transit method. The transit method is when a planet passes in front of a star, reducing its observed luminosity.

  • Luminosity readings only comprise of characters 0-9 and A-Z where each reading corresponds to the following numerical values:
  • Characters 0-9 correspond to luminosity levels 0-9.
  • Characters A-Z correspond to luminosity levels 10-35.

A star is considered to have an exoplanet if any single reading is less than or equal to 80% of the average of all readings. For example, if the average luminosity of a star is 10, it would be considered to have a exoplanet if any single reading is 8 or less.

--hints--

hasExoplanet("665544554") should return false.

assert.isFalse(hasExoplanet("665544554"));

hasExoplanet("FGFFCFFGG") should return true.

assert.isTrue(hasExoplanet("FGFFCFFGG"));

hasExoplanet("MONOPLONOMONPLNOMPNOMP") should return false.

assert.isFalse(hasExoplanet("MONOPLONOMONPLNOMPNOMP"));

hasExoplanet("FREECODECAMP") should return true.

assert.isTrue(hasExoplanet("FREECODECAMP"));

hasExoplanet("9AB98AB9BC98A") should return false.

assert.isFalse(hasExoplanet("9AB98AB9BC98A"));

hasExoplanet("ZXXWYZXYWYXZEGZXWYZXYGEE") should return true.

assert.isTrue(hasExoplanet("ZXXWYZXYWYXZEGZXWYZXYGEE"));

--seed--

--seed-contents--

function hasExoplanet(readings) {

  return readings;
}

--solutions--

function hasExoplanet(readings) {
  let total = 0;
  const values = readings.split('').map(c => parseInt(c, 36));
  
  total = values.reduce((sum, v) => sum + v, 0);
  const average = total / values.length;
  const threshold = average * 0.8;

  return values.some(v => v <= threshold);
}