Show more

@Absinthe
This was a lot of fun decided to do the problem by hand using non brute Force techniques. Attached are all the steps I used to solve the problem including the final solution on the last page.

Total number of coconuts is 3,121 at the start. The number of coconuts they ended up with was the following: 828, 703, 603, 523, 459

If your following the pages I attached the order in which you follow them is "knowns/reduce" then "All valid values" then "final solution"

++

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.

For 1 year now I don't use any file explorers.
I only use tools like cd, ls, etc. to get along.
I tried a lot of GUI/CLI file explorers but never stuck with them for some reason :thinkhappy:

A comparison of the flex / style across 3 of my flex pens. The first I made myself from a 120 year old Waterman nib. The second is a stock falcon pilot, the last one is my hand customized Custom 912 (With Motishaw Spencerian modification)

#python #toyprogrammingchallenge

It doesn't have to be Python, but I am doing it in python. I would appreciate any feedback on my solutions, and encourage everyone interested to submit their solutions.

I will try to post one each week. But I make no promises.

So far there is one to generate the the lyrics of Ninety-nine Bottles of beer (without numerals and with correct pluralization of the word bottle(s) ).

This is coming from @Absinthe So either follow that account, or the hashtag

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 #

care to play with some programming languages:

Here is a web page that lets you have a compillation environment for a whole bunch of them without having to install anything. Pick your language from the drop down.

rextester.com/

@Absinthe

Haha, yeah, yeah :)

Heck, with support for Windows 7 and 8 ending soon, there'll soon enough come a time when *I* won't be able to run it either. [stage whisper] "that's why I'm learning python..."

But VFP served my career well for twenty-some years, and it does still run on a lot of machines.

It's the language & dev environment I'm still most familiar with, though I hadn't touched it in a while, so I saw this as an opportunity to fire up the ol' IDE again.

"I am so tired of people thinking they can just waltz into my room when I'm clearly listening to music in 4/4 time."

@Absinthe

Here's mine. I ended up adapting your solution for converting numbers to words, because it's more lightweight than the known solutions in my language of choice. Cheers.

github.com/patchcali/toy-progr

#toyprogrammingchallenge

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 think this whole Richard Stallman thing violates freedom of speech. I'm not defending what he said. I'm also not saying other people should say offensive things, I'm merely saying it's their right to do so. Just as it is the right of every one else who says at least as bad of stuff back. Any law that makes what he says illegal, makes much of what people that are against him say illegal.

@Absinthe

Lisp FORMAT's "~r" option makes the problem much easier than in most languages, since it converts 99 to "ninety-nine" in one line of code. The code would have been 2 or 3 times as long, had I had to do that myself.

I used LispWorks to test it, but it should work in clisp.

@Absinthe

Common Lisp. 14 minutes.

(defun beer (&optional (start 99)) (loop for num = start then next-num for next-num = (1- num) for numstr = (if (eql 0 num) "no" (format nil "~r" num)) then next-numstr for next-numstr = (if (eql 0 next-num) "no" (format nil "~r" next-num)) for bottles = (format nil "bottle~p" num) for next-bottles = (format nil "bottle~p" next-num) while (> num 0) do (unless (eql num start) (terpri)) (format t "~@(~a~) ~a of beer on the wall,~%~ ~a ~a of beer. Take one down,~%~ pass it around... ~@(~a~) ~a of beer.~%" numstr bottles numstr bottles next-numstr next-bottles)))

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

Show more
Qoto Mastodon

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