Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
For starters: I don't find it more readable. Additionally: code formatted like that cannot be formatted easily using an IDE. When I would refactor the name of the remove char function to RemoveCharAt, I'd have to manually reformat that code to get everything aligned. No problem for a tiny kata, but bound to result in very ugly code in big projects.
Heh, I think you're right about that. The second part of the concatenation is incorrect. good catch!
thank you 😁
Thanks for your comment.
Really cool to read that the code sparked an idea for you.
Have a merry, code-y Christmas!
A blind guess would be that the error stems from the use of Seq.reduce, which needs to start out with the zero-value of the type at hand. For an integer, that would be 0. However, because of the code before the reduce call, the type might only be known as IComparable, and the zero value cannot be derived from that.
That's what I think when I see the error message. I only did F# during a holiday a while back, so it's not up front knowledge to me, but I hope this helped in some way.
Like it says right at the start of my comments: "It was a fun journey, even though it feels like I took the long way."
Believe me, I had a big laugh at myself after solving the puzzle using this route. I decided to type out the scribbles that I had on paper into the comments, just in case it might put a smile on other peoples faces too ;-)
Thanks! :)
Yes, I agree on that. I opt for staying close to intent and optimize when needed. But as long as you know the function exists, I'm happy ;)
Cheers!
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Yes, you're absolutely right! My code is wrong.
I remember being a bit annoyed by the opinionated tests, so I might have taken a shortcut there.
That's a sin of course, sorry for that ;-)
At a glance, the two things that might be the issue here are:
Thanks for your comment, much appreciated!
Though this is a sensible and elegant algorithm, I would not qualify it as especially fast, as the title suggests.
It definitely is fast enough for small primes, but try running this one for example:
Here an output of the timing for this test on my machine:
I wrote up an alternative version, which is able to produce output pretty fast for larger numbers as well.
Here the timing of an example run using this code:
So let's say that there is room for improvement ;-)
Kind regards,
Maurice
Ah, I forgot to remove firstUnsolvedFieldOf(), that one wasn't needed anymore.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Loading more items...