The Vampire Hunt

HardAcc. 70.1%
+45 XP 25

Siphoning Digits

A Vampire Number is a composite natural number with an even number of digits, that can be factored into two integers (fangs) such that:

  1. Both fangs have exactly half as many digits as the original.
  2. The fangs contain all the original digits in any order.
  3. Both fangs cannot end in zero simultaneously. Example: 1260 = 21 * 60.

The Assignment

Your function receives a 4-digit parameter target.

  1. Use nested loops to find all pairs of 2-digit factors (x, y).
  2. Verify if x * y === target.
  3. Use a logic check to ensure the digits of (x and y) are a permutation of the digits of target.
  4. Print "true" if at least one such pair exists, else "false".

01EXAMPLE 1

Inputtarget = 1260
Outputtrue

Explanation: 21 * 60 = 1260. Digits match.

Constraints

  • Only check 4-digit numbers.
  • Digit comparison must be precise.
MathLoopsLogic
JavaScript
Loading...
3 Hidden

Input Arguments

target1260

Expected Output

true

Click RUN to test your solution