Advertisement
Spocoman

01. SoftUni Reception

Nov 8th, 2023 (edited)
573
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function softUniReception(input) {
  2.     let first = Number(input[0]);
  3.     let second = Number(input[1]);
  4.     let third = Number(input[2]);
  5.     let students = Number(input[3]);
  6.  
  7.     let counter = 1, hours = 0;
  8.  
  9.     while (students > 0) {
  10.         students -= first + second + third;
  11.         hours += counter % 3 == 0 && students > 0 ? 2 : 1;
  12.         counter += 1;
  13.     }
  14.  
  15.     console.log(`Time needed: ${hours}h.`);
  16.     return;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement