From 2703ed41cc212967be130b80c0ce2398d6dd0c8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Holp?= Date: Wed, 8 Apr 2020 16:31:07 +0000 Subject: [PATCH] Upload files to 'pages/students/2016/jan_holp/dp2021/zdrojove_subory' --- .../jan_holp/dp2021/zdrojove_subory/answer.js | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 pages/students/2016/jan_holp/dp2021/zdrojove_subory/answer.js diff --git a/pages/students/2016/jan_holp/dp2021/zdrojove_subory/answer.js b/pages/students/2016/jan_holp/dp2021/zdrojove_subory/answer.js new file mode 100644 index 0000000000..89acc47be7 --- /dev/null +++ b/pages/students/2016/jan_holp/dp2021/zdrojove_subory/answer.js @@ -0,0 +1,44 @@ + +const fs = require('fs'); +const readline = require('readline'); + + +var result = []; + + + +const readInterface = readline.createInterface({ + input : fs.createReadStream('/home/elastic/BP/skweb/server/scnc2/answers'), + console : false +}); + + +readInterface.on('line', function(line){ + var tokens = line.split(" "); + var id_query = parseInt(tokens[0]); + var id_document = parseInt(tokens[1]); +// console.log([id_query]); + + if (!(id_query in result)){ + result[id_query]=[id_document]; + } + else { + result[id_query].push(id_document); + } + + + +// console.log(result); +}); + + +readInterface.on('close', function() { + for (let i = 0 ; i < result.length; i++){ + + console.log(i); + console.log(result[i]); + } + console.log("koniec"); +}); + +