Skip to content
Tactiverge

◇ Sensors · loops and conditions

Find the spikes

Scan a vibration log and report the positions of readings above a safe limit.

  • Level 1 · Explorer
  • 5 tests
  • technically checked

Your task

A vibration sensor on a pump logs one value per second. Maintenance wants to know when the vibration went over the safe limit, not just whether it did.

Write spikes(readings, limit) that returns an array of the indices (positions, starting at 0) of readings that are strictly greater than limit. A reading equal to the limit is still safe.

Hints (0 of 3 shown)

    What gets checked

    • spikes([1, 9, 2, 10], 5) → [1, 3]
    • spikes([1, 2, 3], 5) → []

    Plus 3 hidden tests for edge cases. They run in the sandbox like the others; only the result is shown.

    Tab indents · Esc then Tab leaves the editor · Ctrl/⌘ Enter runs · Ctrl/⌘ Shift Enter checks · Ctrl/⌘ / comments

    Starting the sandbox…

    Press Run to see what your program prints.

    Your code runs only in this browser, inside an isolated sandbox with no network access, and stops after 3 s. Nothing you type is sent to Tactiverge; drafts and progress are saved in this browser only.