Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

146
Views
El tiempo necesario para destruir un edificio en el juego de navegador se calcula incorrectamente
// Number of rockets launched per second. const rocketSpeed = 1; // The amount of damage dealt by rocket. const attackDamage = 60; // The amount of hit points of the building. const buildingHitPoints = 1000; // The number of rockets required to destroy the building. const numberOfRockets = Math.ceil(buildingHitPoints / attackDamage); // The time it takes to destroy the building. const requiredTime = numberOfRockets * rocketSpeed;

Si la velocidad del rocketSpeed es más de un segundo, obtengo el valor correcto.

Por ejemplo: const requiredTime = 17 * 1 ;

Pero si especifica una velocidad de rocketSpeed inferior a 1 segundo, entonces el valor es incorrecto:

Por ejemplo: const requiredTime = 17 * 0.625; // 10.625

0,625 es el número de cohetes disparados por segundo. Es decir, se lanzará 1 cohete en aproximadamente ~ 1,2 segundos.

He probado diferentes opciones por tipo: const requiredTime = 17 + (17 - 37.5%); (37,5% porque: 1000 - 625 = 375. 375 es el 37,5% de 1000), pero no funciona.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

El número de cohetes lanzados por segundo se considera mejor como una frecuencia que como una "velocidad".

La frecuencia f es f = 1/T donde el tiempo es T , entonces T = 1/f

Tal vez cambie el nombre de RocketSpeed a RocketFrequency y haga una nueva variable timeBetweenRockets con
const timeBetweenRockets = 1 / rocketFrequency .

Entonces la última línea de código será más autoexplicativa.

const requiredTime = numberOfRockets * timeBetweenRockets

about 4 years ago · Juan Pablo Isaza Report

0

Tienes el cálculo al revés. Si prueba valores superiores a 1, verá que tarda más: 1 cohete por segundo (r/s) da como resultado 17 segundos. 2 r/s da como resultado 34 segundos y 0,5 r/s da 10,625 segundos.

 const calculate = rocketSpeed => { // The amount of damage dealt by rocket. const attackDamage = 60; // The amount of hit points of the building. const buildingHitPoints = 1000; // The number of rockets required to destroy the building. const numberOfRockets = Math.ceil(buildingHitPoints / attackDamage); // The time it takes to destroy the building. const requiredTime = numberOfRockets * rocketSpeed; return requiredTime; } console.log(`Time for 1 rocket/s: ${calculate(1)}`); console.log(`Time for 2 rocket/s: ${calculate(2)}`); console.log(`Time for 0.625 rocket/s: ${calculate(0.625)}`);

Si, en cambio, divide número de numberOfRockets por velocidad de rocketSpeed , obtendrá las respuestas correctas.

 const calculate2 = rocketSpeed => { // The amount of damage dealt by rocket. const attackDamage = 60; // The amount of hit points of the building. const buildingHitPoints = 1000; // The number of rockets required to destroy the building. const numberOfRockets = Math.ceil(buildingHitPoints / attackDamage); // The time it takes to destroy the building. const requiredTime = numberOfRockets / rocketSpeed; return requiredTime; } console.log(`Time for 1 rocket/s: ${calculate2(1)}`); console.log(`Time for 2 rocket/s: ${calculate2(2)}`); console.log(`Time for 0.625 rocket/s: ${calculate2(0.625)}`);

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!