rotated games

Toggle class name on click in jQuery

by oktaviardi pratama

HTML

<div id="banner-message">
 <h1>
 rotated games
 </h1>
</div>

CSS

body {
  background: #20262E;
  padding: 20px;
  font-family: Helvetica;
}

#banner-message {
  background: #fff;
  border-radius: 4px;
  padding: 20px;
  font-size: 25px;
  text-align: center;
  transition: all 0.2s;
  margin: 0 auto;
  width: 300px;
}

button {
  background: #0084ff;
  border: none;
  border-radius: 5px;
  padding: 8px 14px;
  font-size: 15px;
  color: #fff;
}

#banner-message.alt {
  background: #0084ff;
  color: #fff;
  margin-top: 40px;
  width: 200px;
}

#banner-message.alt button {
  background: #fff;
  color: #000;
}

JavaScript

function rotated(arr, n) {
    let rotated = arr.slice(n).concat(arr.slice(0,n))
    return rotated
}
function highvalue(arr){
    return arr.indexOf(Math.max(...arr))
}
function getMaxElementIndexes(a, rotate) {
let arr = []
for(let i = 0; i < rotate.length; i++){
    let rotateArr = rotated(a, rotate[i]);
    let high = highvalue(rotateArr)
    arr.push(high)
}
   return arr;
}

function main() {
    const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

    const aCount = parseInt(readLine().trim(), 10);

    let a = [];

    for (let i = 0; i < aCount; i++) {
        const aItem = parseInt(readLine().trim(), 10);
        a.push(aItem);
    }

    const rotateCount = parseInt(readLine().trim(), 10);

    let rotate = [];

    for (let i = 0; i < rotateCount; i++) {
        const rotateItem = parseInt(readLine().trim(), 10);
        rotate.push(rotateItem);````````
    }

    const result = getMaxElementIndexes(a, rotate);

    ws.write(result.join('\n') + '\n');

    ws.end();
}