Okay, I thought I came up with some good challenges and a fun freebie to go with them. I seem to be getting some followers, but not a lot of people trying them.

What kinds of things are you all interested in? I can find all sorts of things, many of them are math-y (statistics and things like that), or string management and still others require you be willing to handle things like differential equations.

If you mention what you might like I can either find some or make some up.

@Absinthe I think it's better to keep them simple and accessible. That way almost anyone can give it a try, and those who want more challenge can generalize and optimize to no end.

For example, I skipped the bubble sort, because I have no idea what the term means (I forgot everything sort). If you could frame that in some kind of a easy to grasp story, like the coconuts, the generalization of which would be bubble sort, that would be "next level".

Follow

@namark
Imagine a deck of cards numbered from 1 to some number. They are dealt out
one after the other in a straight line down the street. You grab the first card that is at the top of the road and if it is the same of less than the next you put it back down and grab the next one. If it is more than the next one you make them switch places. Then from that position, you continue
the same way until you get to the end of the street. If you have done no changing of places your deck is sorted. If you have done even 1 changing of places you start over from the top. Keep doing this until you make no
changes.

It is called a bubble sort, because it looks like values bubble up through the list until they come to rest at their respective positions. It is the simplest sort to write. And it works great for things that are almost sorted. Not quite as well for things that are in the completely reversed order. There are some things you can do to make it more efficient.

@Absinthe I guess it could be framed it as some sort of evil genie appearing in someone's home, putting some cards on the table in some specific order and telling them that every day if they find two adjacent cards where left is greater than right, they must swap them but only once per day, or great misfortune will befell them.

The question would be if this person can ever stop worrying about the curse. If yes in how many days and what would be the arrangement of cards at that point.

@Absinthe that's a pretty lazy story though, as it is in no way integral to the problem, the genie could have asked to solve an any sort of puzzle there, but just to give you an idea of what I meant.

Bubble sort specifically might not be the best problem for this purpose.

@namark

I get you. Remember that was a freebie :) I do like to frame them in interesting story lines if possible. However, it is a base algorithm that one should be able to pull out of one's head. Not sure a great reason to write one, other than the exercise itself. Watching something you knock out in 10 minutes be able to sort the heck out of stuff is kind of cool. And as you print out the passes it is cool to see the values bubble through.

@Absinthe Sounds neat and quick to implement indeed. I don't think I would be able to come up with that though. If I was to sort something, I would have probably went with the dumbest way imaginable - find smallest -> set it aside -> repeat. Unless it was an interview question, in which case I'd try to do the smartest thing I ever heard of and totally fail.

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.