Show newer

@serra it can be. But TDD is about development rather than testing.

On another note have you participated the in my ?

@11112011 @p and heroin is so 1970's get withe the program. I think it is Oxy to an 8 y/o now. What will a five y/o pay with? Boogers and bubblegum?

@serra only a unit test suite. If you buy into the whole concept it will cause you to create that kind of code. Don't forget the refactor step.

@zingbretsen I like the list slicing it just isn't a first class tool for me yet. Sure if I use it a few more times it will stick

@zingbretsen it is the direction I was trying to get to, because I don't think I need to check any one I have already visited a second time. Those list semantics with the : throw me, I am still getting to know them, but that feels right, I will try it when I get home.

@zingbretsen care to take a shot at a fix for my one-line solution in this one?

Show thread

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

@Absinthe That sounds very fair. I'll submit am example using a `deque` later today!

Finished answer (Python) 

@masterofthetiger@theres.life @zingbretsen

That works. Simpler and much more elegant looking code than my craziness. I am not sure about the relative efficiency between yours and mine, I think you might have more multiplications but you also solve the side case of "don't use division"

@zingbretsen personally, I don't care. The "freebies" are ones I have found that were given as job interview exercises (so far).

Personally, I am working on buffing up my personal python skills, so I am trying to import as little as possible. So far I have needed only the random import for setting up data.

But you need to decide what you want to get out of these challenges. If importing libraries works for you I don't see anything much wrong with it. Unless the challenge is about the functionality that you want to import. For example. if the challenge was to write a bubblesort, obviously importing someone else's bubblesort library would be pretty much cheating.

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.

@namark

I just found an error in my implementation, I wonder if you might want to test yours.

Here is the issue. Let's say your list of numbers is [2, 5, 8, 3, 7, 9] and your K=4 So, in my case I take K-2 to get 2 and search for it in the list and find it. But it is not a second 2 just the only 2. I believe I would return True, and it should be false. No one ever said the numbers in the table were unique, so in theory there could be 2 2's or just one.

I will be able to fix one way that I did it, but I am not sure I will still be able to pull off the 1 line solution :)

@namark that's pretty cool. But without understanding all the predicates and such it was hard to follow what the code was doing. But it seemed that when you did A + B = K that it didn't know anything about the list, so when it went through the member call, I was wondering what it might be trying to test

@namark maybe i will try it from sources this weekend.

Show older
Qoto Mastodon

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