This week's giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Production-Ready Serverless (Operational Best Practices) and have Yan Cui on-line!
See this thread for details.
Win a copy of Production-Ready Serverless (Operational Best Practices) this week in the Cloud/Virtualization forum!

D.J. Quavern

Ranch Hand
+ Follow
since Feb 19, 2019
D.J. likes ...
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt Green check

Recent posts by D.J. Quavern

It's an honor that you thought small pieces of my code were good enough to borrow

I did not write a test: my bad. In the end, I lost more time copy-pasting tests than if I had taken 5 minutes to write a decent test. My bad.

I'll post another code shortly on which I would really appreciate some insights
Thanks to everyone.
I reduced it to one loop with a period instead, and a string builder.
I am down to 0.19 s now.

Do you mind checking another problem ?
And Junilu, can I please see your solution?
Yes, this solution passes but I have 0.78 secs, which is long.
@Junilu: I'll try with your hints.
Hello Ranchers!
I need some help to speed up this code.
The problem is as follow:

This code works but it's very slow!
Junilu said once "main is a pain", is it why? Should I made helper functions? How can I make it faster or more efficient?

Thanks to everyone who read and respond.
4 days ago
Yes. It is easier to see. But i wonder if it can't be made in a more straightforward way?
1 week ago
But it still calls the method with return??
1 week ago
Yes, very much m'y faut indeed.

I still don't get why the partition_random returns a method if it should return a split index?
1 week ago
Hello Ranchers!

I am working on my old assignment and cannot remember why I wrote things the way I did (I hear you Junilu, this is my fault for not commenting !, and I agree).

This part of the code is written for a quicksort choosing a random pivot. But why does the partition_random returns the partition? Wouldn't it be easier for the partition_random to return an index (index of the new random pivot) and send it to quicksort?
I tried of course and I get a wrong assertion.

Can someone please help me to cast a light on that?

1 week ago
Hello again!

I don't get how map get information about the array. In this code, there is no connection between the two data structures.

1 month ago
Good morning Rangers!

I read this blog post and I do not understand when do the variables corresponding to x and y are passed to the function. I feel really lost.

I tried to pass arguments in the main

and of course I got some uncomprehensible go error.

1 month ago
Thank you a lot. I get it now!
1 month ago

Stephan van Hulst wrote:
Because mergesort is a stable sorting algorithm it is guaranteed that after sorting the array, aliceOne must come before aliceTwo, and therefore changing the name of aliceOne will result in [Eve, Alice, Bob, Carol, Dave]. With quicksort you don't have this guarantee, so it's not used for arrays of objects.

You write that I don't have this guarantee, but it's still possible?
1 month ago

Stephan van Hulst wrote:

D.J. Quavern wrote:If aliceOne is in the right position in the array

What's the right position of aliceOne in the array after sorting?

I would have said first but I suspect that I am supposed -since you are asking- to reply second since quicksort works with swaps?
1 month ago
Thank you!
Even though it was very clear, I don't get why you did not have this garantee for quicksort? If aliceOne is in the right position in the array, the name should be changed easily to Eve even with quicksort?
1 month ago

Campbell Ritchie wrote:

Michael Krimgen wrote:Java uses TimSort for Objects: . . .

I presume you know why? That is the same as the modified merge sort Stephan mentioned.

No, I don't know anything except the the information from Wikipedia. Is there a special reason except it's more efficient?
1 month ago