nPhoenix

Script de Calcular Número de Sistemas

Jul 4th, 2019
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var file = require("fs").readFileSync("C:/nodejs/MonsterValleNew/documentacao/sistemas pre-alpha.txt", "utf8");
  2.  
  3. var statistics = {
  4.     total: (file.match(new RegExp("{", "g")) || []).length,
  5.     ready1_4: (file.match(new RegExp("{1/4}", "g")) || []).length,
  6.     ready1_2: (file.match(new RegExp("{1/2}", "g")) || []).length,
  7.     ready3_4: (file.match(new RegExp("{3/4}", "g")) || []).length,
  8.     ready: (file.match(new RegExp("{x}", "g")) || []).length,
  9.     notready: (file.match(new RegExp("{-}", "g")) || []).length,
  10. };
  11.  
  12. statistics.ready1_4 *= 0.25;
  13. statistics.ready1_2 *= 0.5;
  14. statistics.ready1_4 *= 0.75;
  15.  
  16. console.log(
  17.     "\x1b[37m",
  18.     "Numero total de sistemas:", statistics.total + "\n",
  19.     "Sistemas completos:", statistics.ready + "\n",
  20.     "Sistemas 1/4 completos:", statistics.ready1_4 + "\n",
  21.     "Sistemas 1/2 completos:", statistics.ready1_2 + "\n",
  22.     "Sistemas 3/4 completos:", statistics.ready3_4 + "\n",
  23.     "Soma dos sistemas completos:", (statistics.ready + statistics.ready1_4 + statistics.ready1_2 + statistics.ready1_4) + "\n",
  24.     "Sistemas que não estão prontos:", statistics.notready + "\n",
  25.     "\x1b[41m",
  26.     "Porcentagem aproximada de sistemas completos:",
  27.     "\x1b[33m",
  28.     Math.round(((statistics.ready + statistics.ready1_4 + statistics.ready1_2 + statistics.ready1_4) / statistics.total) * 100) + "%",
  29.     "\x1b[0m"
  30. );
Advertisement
Add Comment
Please, Sign In to add comment