Ad

A wayward human has entered the Forest of the Lost- a forest renowned for having monsters of the worst variety.

Given the coordinates of the human, the coordinates of a monster, and the monster's attack span return whether the human is deciminated or if he lives to see another day.

ex. DeadOrAlive([3, 4], [3, 6], 1) == 'Alive!';

ex. DeadOrAlive([7, 6], [3, 6], 5) == 'Dead!';

Things to keep in mind:

  • The span will always be a whole number
  • Human and monster can have the same coordinates
String DeadOrAlive(List<int> human, List<int> monster, int span) {
  return ((monster[0] - human[0]).abs() <= span && (monster[1] - human[1]).abs() <= span) ? 'Dead!' : 'Alive!';
}
Arrays
Data Types
Control Flow
Basic Language Features
Fundamentals

Palindrome:

A palindrome is a word that when reversed reads the same. An example is "evil rats star live."

Valid palindromes should output 'TRUE' while invalid ones should output 'FALSE'.

function palindrome (x) {
  let s = x.split('').reverse().join('')
  return x == s ? "TRUE" : "FALSE"
}