Show more


Here's another freebie, I assume it is python specific because they start with a base of python code. But if it makes sense, try it in whatever language you like:

This problem was asked by Google.

Given the root to a binary tree, implement serialize(root), which serializes the tree into a string, and deserialize(s), which deserializes the string back into the tree.

For example, given the following Node class

class Node:
def __init__(self, val, left=None, right=None):
self.val = val
self.left = left
self.right = right
The following test should pass:

node = Node('root', Node('left', Node('left.left')), Node('right'))
assert deserialize(serialize(node)).left.left.val == 'left.left'


Here's a Freebie!

This problem was asked by Stripe.

Given an array of integers, find the first missing positive integer in linear time and constant space. In other words, find the lowest positive integer that does not exist in the array. The array can contain duplicates and negative numbers as well.

For example, the input [3, 4, -1, 1] should give 2. The input [1, 2, 0] should give 3.

You can modify the input array in-place.

Good morning and here comes the latest challenge.

git.qoto.org/Absinthe/onetonin

The numbers 1 2 3 4 5 6 7 8 9 can have either the operator "+" or "-" placed between them.
As well, if no operator is placed, then the adjoining numbers go together such as 1 2 would
become "12" or 1 2 3 would become "123" and so forth.

The goal is to find the combinations that would make the line calculate up to 100 exactly.

Here is an example: 12 + 3 - 4 + 5 + 67 + 8 + 9 = 100

Would like maybe something other than eval().

I found a corner case on the find sum in list that I overlooked. If the list is [1,2,5] and the number is 4 I will return true because I am looking through the whole list for K-element and will of course find element. I was so happy to get a single line that worked, I am wondering if I can fix it and still keep it one line?

git.qoto.org/Absinthe/sum-of-n

I know count may work better than any, or some other logic to handle the special case of K-element == element

Okay, here is another freebie :) I will put in a real one before the end of the weekend.

Basically, you are given a list from which you need to create a new list where each element is the product of all the "OTHER" elements.

I found a few interesting corner cases.

I challenge you to give it a try!

Read the challenge here:

git.qoto.org/Absinthe/productn

My attempt is checked into that repo as well.

Here's another freebie!! I signed up for a programming problem of the day. I got my first one today, rated "easy".

Here's the description of the problem.

git.qoto.org/Absinthe/sum-of-n

My code to solve it, though not clean and delicious, is in that same repo, but certainly give it a crack before peeking. :)

How about a guessing game? Or job interview type programming tasks?

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.

++

Ready for the next challenge?

"5 Guys and a Bunch of Coconuts"

Here is a link to the text description of the problem.

git.qoto.org/Absinthe/coconuts

That link is to the repo, and my solution is in it as well.

Here is a freebie, but I encourage you to give it a try.

I remember back to first year college. Prof said, some day your boss will come to you at 3:15 and ask you to write a sort module and he will need it by 3:30. The answer to this was the bubble sort. the idea being that it might not be the most efficient or elegant sort module, but sure enough it is easy to write. I have been working in the industry since 1989 and to date, no one has ever asked me to write a sort routine. :)

That said, I challenged myself to write one in 15 minutes, in python because I am trying to relearn python. It took a little longer than 15 minutes, but I did comment it, comply with pylint3 and pycodestyle. And I refactored it for modularity.

Give it a shot, see if you can do it without looking it up. It is an awesome feeling when it works.

If you want, here is my results :

git.qoto.org/Absinthe/bubbleso

I promise a full one is coming before the weekend is over. Still watching for anyone with one for the Ninety-nine Bottles challenge.

@bii @paleBlue @billstclair

Is anyone else interested in the current challenge, before I get ready to drop the next one?

I have shared the first one with some friends outside the fediverse and got some good reaction from them as well.

If you have some friends that might be interested please pass it along. I am not sure how well the tag federates so as I see that people have responded I will try to keep a list and keep you in the loop. If anyone is just interested in watching, either follow the or submit your attempt, or constructive coding recommendations and so forth.

Remember to use the #

Unfortunately, I see no way to follow a tag, but as long as you remember to include the tag in your post all that gets posted against it will be searchable at least.

I am still looking to see more languages, and/or feedback on the entries we have so far. Also, anyone you know that is interested feel free to share it with them.

By the way, I updated my attempt to have a cleaner output by building up a tuple to pass to the print statement so I didn't need multiple output lines.

And thanks @freemo for the gitlab space.

git.qoto.org/Absinthe/ninety_n

I want to propose a programming challenge. This could be fun for beginners and experienced programmers as well. It is language agnostic. It might even be more about community than the programming part itself. The challenge itself should not take more than an hour. But it shouldn't be so simple that you don't have to put in a little effort. I will propose the first one, and those who participate are welcome to propose the next and as we can agree on it we can go off and knock it out.

Once you see other people's results you can modify your own, or even propose something to make someone else's better or faster or fix a bug that you find.

These can become toy programs for you to have around for testing concepts, and helping to try out other languages.

If you are interested or know someone else who might want to play too share this with them.

I guess we can use this thread to get started, and I guess i am supposed to use a hashtag for something like this so how about

I will try to work in Python at least in the beginning but you are welcome to work in whatever you are comfortable with.


First challenge:

"Ninety-nine bottles of beer on the wall"

Generate the whole song from "Ninety-nine" to "No". The output should look like :

Ninety-nine bottles of beer on the wall.
Ninety-nine bottles of beer. Take one down,
pass it around... Ninety-eight bottles of beer.

(You know what the middle looks like)

Two bottles of beer on the wall.
Two bottles of beer. Take one down,
pass it around... one bottle of beer.

One bottle of beer on the wall.
One bottle of beer. Take one down,
pass it around... No bottles of beer.

I won't put too many specifics on how you get there, but the output should be words, not numerals :) Try to write clean, maintainable and visually understandable code.

Let see if I am alone or anyone wants to play along. :)

Here is my first attempt total time 48 minutes.

git.qoto.org/Absinthe/ninety_n

Qoto Mastodon

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