Aliens are attacking our hometown! It is up to you as the commander to protect your home from being destroyed by the alien invasion.
Technical Specification Our intelligence agencies have been able to identify the key characteristics of the impending aliens and have relayed them to you.
ALIEN is a JSON Object with HP and ATK.
INVASION is a JSON ARRAY of ALIEN.
POWER is the sum of the ALIEN remaining HP and ATK.
EDIT: When sorting the aliens POWER, if two aliens have the same power then sort by whichever alien has the SMALLER HP. That is for example given an array of aliens like this:
// Given these aliens {Hp: 3, Atk: 3}, // 6 Power {Hp: 2, Atk: 3}, // 5 Power {Hp: 3, Atk: 2}, // 5 Power {Hp: 2, Atk: 3}, // 5 Power {Hp: 3, Atk: 1}, // 4 Power {Hp: 3, Atk: 1}, // 4 Power {Hp: 1, Atk: 3}, // 4 Power {Hp: 3, Atk: 1}, // 4 Power {Hp: 2, Atk: 2}, // 4 Power {Hp: 1, Atk: 3}, // 4 Power {Hp: 1, Atk: 3}, // 4 Power {Hp: 1, Atk: 2}, // 3 Power {Hp: 1, Atk: 2}, // 3 Power {Hp: 2, Atk: 1}, // 3 Power {Hp: 2, Atk: 1}, // 3 Power
// This is the proper sorting {Hp: 3, Atk: 3}, // 6 Power {Hp: 2, Atk: 3}, // 5 Power {Hp: 2, Atk: 3}, // 5 Power {Hp: 3, Atk: 2}, // 5 Power {Hp: 1, Atk: 3}, // 4 Power {Hp: 1, Atk: 3}, // 4 Power {Hp: 1, Atk: 3}, // 4 Power {Hp: 2, Atk: 2}, // 4 Power {Hp: 3, Atk: 1}, // 4 Power {Hp: 3, Atk: 1}, // 4 Power {Hp: 3, Atk: 1}, // 4 Power {Hp: 1, Atk: 2}, // 3 Power {Hp: 1, Atk: 2}, // 3 Power {Hp: 2, Atk: 1}, // 3 Power {Hp: 2, Atk: 1} // 3 Power The formal API specification may be used to view these definitions in greater detail.
A Command is one of "volley" - Targets the number of aliens sorted by descending POWER decided by taking your remaining HP modulo the remaining number of aliens, dealing 1 HP.
"focusedVolley" - Targets half of the remaining aliens, rounded up and sorted by descending POWER, dealing 2 HP.
"focusedShot" - Targets the alien with the highest POWER, killing them instantly.
Additional Specifications EDIT: The sequence of events must follow in this order, first you the commander will attack the aliens, then the surviving aliens will attack your remaining HP with each alien dealing damage equal to their ATK power.
An Invasion is over if and only if your remaining HP ≤ 0 or there are no more invading aliens left.
The testing oracle will prioritize states in this order: 1, the least remaining aliens left, 2. the highest remaining hp left over, and 3. the least number of commands used.
Given an array of distinct alien invasions from our challenge server and given the commands available to you, find a state in which maximizes the aliens killed, maximizes the remaining hp left over, and minimizes the commands provided. (In this order)
NOTE: The challenge server will send multiple invasions, you are expected to return each solved invasion with the corresponding challenge ID, in any order. Your scores will be averaged and returned to you by the oracle.