Advertisement
Spocoman

Spaceship

Feb 13th, 2022 (edited)
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function spaceShip(input) {
  2.     let s = Number(input[0]);
  3.     let d = Number(input[1]);
  4.     let v = Number(input[2]);
  5.     let sv = Number(input[3]);
  6.    
  7.     let ship = s * d * v;
  8.     let astronaut = (sv + 0.4) * 2 * 2;
  9.     let team = Math.floor(ship / astronaut);
  10.    
  11.     if (team < 3){
  12.         console.log("The spacecraft is too small.");
  13.     } else if (team > 10){
  14.         console.log("The spacecraft is too big.")
  15.     } else {
  16.         console.log(`The spacecraft holds ${team} astronauts.`);
  17.     }
  18. }
  19.  
  20. Тарикатско решение:)
  21.  
  22. function spaceShip(input) {
  23.     let team = Math.floor((Number(input[0]) * Number(input[1]) * Number(input[2])) /((Number(input[3]) + 0.4) * 2 * 2));
  24.     console.log(team < 3 ? "The spacecraft is too small." : team > 10 ? "The spacecraft is too big." : `The spacecraft holds ${team} astronauts.`);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement