2023-01-09 15:12:34 +00:00
|
|
|
const fs = require('fs');
|
|
|
|
let PrankData = JSON.parse(fs.readFileSync("prankdata.txt"));
|
|
|
|
|
2023-01-09 15:17:01 +00:00
|
|
|
let nbPrank = 0;
|
|
|
|
let nbCrepe = 0;
|
|
|
|
let meanCrepe = 0;
|
2023-01-17 12:14:03 +00:00
|
|
|
let userPrank = {};
|
2023-01-09 15:12:34 +00:00
|
|
|
|
|
|
|
for (var uid in PrankData) {
|
|
|
|
if (PrankData[uid].type == "crêpe") {
|
|
|
|
if (PrankData[uid].state == "Done") {
|
|
|
|
nbPrank ++;
|
2023-01-09 15:13:33 +00:00
|
|
|
nbCrepe += parseInt(PrankData[uid].amount)
|
2023-01-17 12:16:58 +00:00
|
|
|
if (!userPrank[PrankData[uid].creator]) {
|
|
|
|
userPrank[PrankData[uid].creator] = 0;
|
2023-01-17 12:05:55 +00:00
|
|
|
}
|
2023-01-17 12:16:58 +00:00
|
|
|
userPrank[PrankData[uid].creator] += parseInt(PrankData[uid].amount);
|
2023-01-09 15:12:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
meanCrepe = nbCrepe / nbPrank;
|
|
|
|
|
|
|
|
console.log("Nombre de mission mission achevé: " + nbPrank)
|
|
|
|
console.log("Nombre de crêpe servis: " + nbCrepe)
|
2023-01-17 12:05:55 +00:00
|
|
|
console.log("Nombre moyen de crêpe par demande: " + meanCrepe + "\n")
|
|
|
|
for (var user in userPrank) {
|
2023-01-17 12:15:33 +00:00
|
|
|
console.log(user + " a commandé " + userPrank[user] + " crêpe")
|
2023-01-17 12:05:55 +00:00
|
|
|
}
|