baxy77bax has asked for the wisdom of the Perl Monks concerning the following question:
I'm in a need for some assistance. The thing is, I would need to write a counter that works in the same way as this one:
and figure out which of the numbers in the array appear only one time, but i cannot use the built-in hash data structure.my %hash; my @array = qw(1 3 4 55 4 3 4 22 1 3 4 3 2 2 3 34); foreach (@array){ $hash{$_}++; }
Oh, yes and i have to stick to only basic conditionals and iterators, meaning no greping or mapping. however sorting is allowed. I was thinking of just sreating an array and then using indexes as hash keys but then a lot of positions would not be initialized(using space for nothing) and I would need to make 55 instead of 16 steps to get to my result.55,22,34 are the numbers that appear only once
Can anyone make a creative suggestion on how to do this in more effective and economic way ?
Thank you
baxy
|
|---|