
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Compare the 2 code variants on the same ToR:
и:
Could this have been written by the same person with a little over an hour apart? The handwriting is questionable )Alexei, you're killing young talent...
This marketer hasn't been able to start selling for 5 years...and you're saying he's even worse as a programmer
Sorry, I didn't mean to kill you.
:-) if you don't try to keep the order, the time isO(1), the total number of steps of all the loops= array size
too lazy to code :-)
1. Search for first 3 from left to right.
2. if found, then look for a non-triple from right to left, copy it to the place of the 3.
continue until 1,2 have intersected, trim the array by the number of copies.
Ideally, it is exactly 1/2 of "bubble sorting" :-) If instead of copying, you make a swap, the output will be a partially ordered array (all 3-thirds moved to the right)
Total number of steps of all loops=array size is O(n) complexity.
If the input array is sorted, the given problem is solved through binary search.
The complexity is O(log(n)) in the average case and O(n) in the worst case.
Still got the hang of Peter's version.
It's quite compact and even works properly. Kudos to Peter.
But in terms of speed it comes second from the end. Or first place from the end, if you don't count the original, completely unusable by speed variant of the owner of this thread.
How did you test it?
How have you been testing?
Study the code.
It's bad when you're too lazy to code.
It's not that I'm lazy at all, but MT is only on VDSs and you don't experiment on them.
about that :
+- 1 :-) I'll be back from summer camp in a couple of days, I'll check it out...
ps. in addition, in the code, there is an extra loop entry on termination... a trifle, but it can be removed
It's not that I'm lazy at all, but MT is only on VDSs and you don't experiment on them.
about that :
+- 1 :-) I'll be back from the countryside in a couple of days, I'll check it out...
ps. in addition, in the code extra input to the loop at the end...a trifle, but can be removed
Bravo! After correcting a couple of errors you may have knocked me off the pedestal even without using ArrayCopy. Checkmate. :))
Bravo! After correcting a couple of errors, you've knocked me off the pedestal even without using ArrayCopy. Checkmate. :))
Although not exactly so, because the output array is quite different - already mixed. But it's cool anyway!
Of course, if we are dealing with quotes, this will not work. I'm on the podium again. ))
I've changed the way of calculating the checksum. No longer the simple sum of all elements, but the sum is (element value)/(element number).
And this is what I got: