β back to unit
Challenge
# puzzle gauntlet advanced
The Final Door
The last door of the Puzzle Workshop has a three-part combination lock β one part per skill you've mastered. πͺβ¨
You get the nums and a target (present in the list). The three codes:
- SEARCH: the position of the target in the SORTED version of the list (binary search encouraged!).
- COUNT: how many even numbers the list holds.
- BEST: the biggest sum of two neighboring numbers in the ORIGINAL order.
Print the combination as <code1>-<code2>-<code3>.
Example:
Input: nums = [7, 2, 9, 4, 6], target = 9
Output: 4-3-13
Sorted gives [2, 4, 6, 7, 9], where 9 sits at position 4 (SEARCH). The evens are 2, 4, 6 β 3 of them (COUNT). Neighboring sums in the original order are 7+2=9, 2+9=11, 9+4=13, 4+6=10 β the biggest is 13 (BEST).
π‘ need a hint?
pg-final-door.pyπ given lines are locked β write your code in between
loading...