I would be grateful for any help provided.
I have 7 separate arrays with approx. 90,000 numbers in each array (let's call them arrays1-arrays7). There are no duplicate numbers in each array. BUT, there may be duplicates between arrays. for example, array 2 has no duplicates, but you can have common numbers with arrays3 and arrays4.
Problem: I am trying to identify all numbers that are duplicated 3 times when all 7 arrays are combined.
I have to do this calculation 1000 times, and it takes 15 minutes, but this is not normal, because I have to run it 40 times - Code:
if you know another language that is best suited for this type of computation, please let me know. any additional suggestions like redis or gearman are helpful.
for($kj=1; $kj<=1000; $kj++)
{
$result=array_merge($files_array1,$files_array2,$files_array3,$files_array4,$files_array5,$files_array6,$files_array7);
$result=array_count_values($result);
$fp_lines = fopen("equalTo3.txt", "w");
foreach($result as $key => $val)
{
if($result[$key]==3)
{
fwrite($fp_lines, $key."\r\n");
}
}
fclose($fp_lines);
}
, array_map array_count 17 :
for($kj=1; $kj<=1000; $kj++)
{
$result='';
for ($ii = 0; $ii< 7; $ii++) {
$result .= $files_array[$hello_won[$ii]].'\r\n';
}
$result2=explode("\n",$result);
$result2=array_map("trim",$result2);
$result2=array_count_values($result2);
$fp_lines = fopen("equalTo3.txt", "w");
foreach($result2 as $key => $val)
{
if($result2[$key]==3)
{
fwrite($fp_lines, $key."\r\n");
}
}
fclose($fp_lines);
unset($result2);
///////////////////////////////////////////////////
@ziumin @ailvenge @scunliffe @this.lau_ @monocell , ! , . !