Commit b578fb68 authored by Ilya Prokhorov's avatar Ilya Prokhorov

Errors fixed

parent 788c1cb8
......@@ -5,23 +5,22 @@ process.stdin.on('data', function(data) {
});
function filterInputs(inputs) {
var whitelist = ["[email protected]", "[email protected]", "[email protected]", "[email protected]"];
var sortedWhitelist = [...whitelist].sort()
var sortedWhitelist =
["[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]"];
inputs.forEach(input => {
search(input, sortedWhitelist, 0, sortedWhitelist.length)
search(input, sortedWhitelist, 0, sortedWhitelist.length - 1)
})
}
function search(word, sortedWhitelist, lowIndex, highIndex) {
if (highIndex <= lowIndex) {
console.log("-No Match-")
return;
}
var middleIndex = lowIndex + (highIndex - lowIndex) / 2;
var middleWhitelistedWord = sortedWhitelist[middleIndex];
if (middleWhitelistedWord.hasOwnProperty("localeCompare") == false) {
return;
}
var middleIndex = Math.floor(lowIndex + (highIndex - lowIndex) / 2);
var middleWhitelistedWord = sortedWhitelist[middleIndex];
var compareResult = middleWhitelistedWord.localeCompare(word);
if (compareResult > 0) {
......@@ -33,5 +32,6 @@ function search(word, sortedWhitelist, lowIndex, highIndex) {
else {
console.log("Found");
console.log(word);
}
}
}
scalac ../Generator/Generator.scala
trap times EXIT;
scala -J-Xmx2g GeneratorApp 10 10 | node binarySearch.js
scala -J-Xmx2g GeneratorApp 100 200 | node binarySearch.js
......@@ -11,7 +11,9 @@ class Generator {
wordsList += "[email protected]"
return wordsList.toArray
val shuffled = Random.shuffle(wordsList)
return shuffled.toArray
}
}
......
scalac ../Generator/Generator.scala
trap times EXIT;
scala -J-Xmx2g GeneratorApp 10 10 | node naiveSearch.js
scala -J-Xmx2g GeneratorApp 100 200 | node naiveSearch.js
......@@ -11,7 +11,137 @@ function filterInputs(inputs) {
}
function search(word) {
var whitelist = ["[email protected]", "[email protected]", "[email protected]", "[email protected]"];
var whitelist = [ '[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]ahoo.com",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected].ca",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]"
];
whitelist.forEach(whitelistWord => {
if (whitelistWord === word) {
console.log("Found")
......@@ -19,4 +149,5 @@ function search(word) {
return;
}
})
}
echo "Naive Search"
cd NaiveSearch
start=`date +%s`
for i in {1..10}
do
./buildAndRunWithGenerator.sh
done
end=`date +%s`
runtime=$((end-start))
echo $runtime
cd ..
echo "---"
echo "Binary Search"
cd BinarySearch
start=`date +%s`
for i in {1..10}
do
./buildAndRunWithGenerator.sh
done
end=`date +%s`
runtime=$((end-start))
echo $runtime
cd ..
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment