saveThePrisoner.js

    0

    0

    The saveThePrisoner function will save the prisoner at index n with value s + m - 1.

    function saveThePrisoner(n, m, s) {
      let value = s + m - 1;
    
      return (value > n)
        ? (!(value % n) ? n : value % n)
        : value;
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.