Coding Game - The Descent

Posted GoldenaArcher

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Coding Game - The Descent相关的知识,希望对你有一定的参考价值。

The Descent

问题原地址: The Descent

问题大意:

其实就是用 for 循环检查当前循环体内的最大值,然后输出该最大值。

说的很花里胡哨的,意思就这么简单

解题方案:

/**
 * The while loop represents the game.
 * Each iteration represents a turn of the game
 * where you are given inputs (the heights of the mountains)
 * and where you have to print an output (the index of the mountain to fire on)
 * The inputs you are given are automatically updated according to your last actions.
 **/

// game loop
while (true) 
  // 需要在日志台输出 index,以及找到当前循环体内最高的 山脉 去攻击
  let index = 0,
    mountainHeight = 0;
  for (let i = 0; i < 8; i++) 
    const mountainH = parseInt(readline()); // represents the height of one mountain.
    if (mountainH > mountainHeight) 
      mountainHeight = mountainH;
      index = i;
    
  

  // Write an action using console.log()
  // To debug: console.error('Debug messages...');

  console.log(index); // The index of the mountain to fire on.

以上是关于Coding Game - The Descent的主要内容,如果未能解决你的问题,请参考以下文章

learn python the hard way_make a game

Logistic Regression Using Gradient Descent -- Binary Classification 代码实现

The Imitation Game

POJ 1970 The Game

The Rotation Game

Assignment #4: The Tile Game