Advertisement
dimoBs

Untitled

Oct 23rd, 2020
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. function solve(input){
  2. let index = 0;
  3. let title = input[index];
  4. index++;
  5. let allSeats = Number(input[index]);
  6. index++;
  7. let biletType = input[index];
  8. index++;
  9. let countStudents = 0;
  10. let countStandart = 0;
  11. let countKid = 0;
  12. let boughtBillets = 0;
  13.  
  14. while(title !== "Finish"){
  15. let bilets = 0;
  16.  
  17. while(biletType !== "End"){
  18. if(biletType === "student"){
  19. countStudents++;
  20. }else if(biletType === "standard"){
  21. countStandart++;
  22. }else if(biletType === "kid"){
  23. countKid++;
  24. }
  25. boughtBillets++;
  26. bilets++;
  27. if(bilets >= allSeats){
  28. break;
  29. }
  30. biletType = input[index];
  31. index++;
  32.  
  33.  
  34. }
  35. console.log(`${title} - ${(bilets / allSeats * 100).toFixed(2)}% full.`);
  36.  
  37. title = input[index];
  38. index++;
  39. allSeats = Number(input[index]);
  40. index++;
  41. biletType = input[index];
  42. index++;
  43. }
  44. console.log(`Total tickets: ${boughtBillets}`);
  45. console.log(`${(countStudents / boughtBillets * 100).toFixed(2)}% student tickets.`);
  46. console.log(`${(countStandart / boughtBillets * 100).toFixed(2)}% standard tickets.`);
  47. console.log(`${(countKid / boughtBillets * 100).toFixed(2)}% kids tickets.`);
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement