5 kyu
The Bee
152 of 274EgorArh
Loading description...
Algorithms
Mathematics
Matrix
Puzzles
Performance
Dynamic Programming
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
that moment when you dont know how to solve it ,look at solutions and still dont know how to solve it .. gotta love programming
This comment has been hidden.
A hint would be nice. I managed to calculate the number of fields but the number of moves grows astronomically so its hard to see any pettern.
difficult to understand, please help me. what is N here it is side of haxagonal? and how to calculate cells for N side?
should be clear now that the picture is put back in place
The picture in the description is gone
I found it at https://0tvet.com/tpl/images/4396/6778/bfc08.jpg
I used the above image to build an SVG and inline it in the description. See fork
äpproɛved
Hmm, my Haskell solution computes all [2..200] values in 3.8 sec at my i5 core ThinkPad, but when I run tests only (5 values) here, it exceeds the time limit 12 sec. I wish I could see what happens at the CodeWars host machine! I use GHC 9.6.1 at my laptop, here is 9.2.5, but it's unlikely the cause. I also used Template Haskell in the solution and it could take more time to compile. Is compilation time included into the whole time limit 12 sec?
Your algorithm is likely not scaling well in terms of performance for bigger n. My first algorithm would get the 12 sec limit when attempting this kata. Turns out I had to take a completely different approach for it to scale better. My submitted solution on my i9 takes almost 5 seconds to compute "theBee 1000". I benchmarked other solutions on the site, and they took between half the time, to double the time of mine.
This is theBee 1000 at my Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz. The problem seems to arise from failure of memoization at the CodeWars host. I use somewhat tricky memoization mechanism which allows pure code (in the sense of FP and Haskell) avoiding mutation of the underlying data structure (I use vector) on the surface. This type of memoization has robust support in GHC since very early releases, but this can be easily broken, for instance, by lack of laziness in the underlying vector. This is why I wonder how the program gets built at CodeWars including GHC options, vector version etc.
To answer one of your questions: Compile time is included in the time limit.
It is the case when you have to disassemble the picture extremely thoroughly. Just play with it and everything will become clear. I really appreciated the idea of this kata. Thanks, Egor!
This is absolutely beautiful! Thank you.
I have seen 4 kyu katas way easier than this.
Java translation
thank you very much for your translation
This sequence is not currently in the OEIS. Even though it would spoil the kata a bit, I think it is worthy of inclusion.
Author, how did you come up with the sequence? Is there someplace on the web that would deserve attribution?
@mods
, are there reasons not to submit this sequence to the OEIS? ( I personally would not consider spoiling the kata enough reason not to submit it. Other opinions may be available. )Don't ruin my kata :(
And I took the idea of kata, from a math exam, you can definitely find mathematical analogues of this problem on the Internet
My intention is not to ruin the kata; my intention is to improve OEIS ( which comes with fame, fortune and bragging rights for you. Just different bragging rights than having an unspoilt kata ).
This comment has been hidden.
I don't see how it would ruin the kata. There is no simple solution to this problem, is there?
This comment has been hidden.
difficult :(
This comment has been hidden.
Factor translation
thank you so much!!!
theBee 1 == 1
is totally valid ( andtheBee 1 == 0
is totally wrong ).A case can even be made that
theBee 0 == 0
( though I can understandundefined
orNone
).IMO the
theBee 1
case should be added to the kata.how can you imagine a 1x1 honeycomb where there is point A and point B
I think that would be unnecessary.
Haskell translation
this translation modifies the description: it adds the code length limit ( and minor other edits )
Thank you so much for your translation
Needs
performance
tag ( in addition todynamic programming
).I did it, thanks for your advice
both these tags aren't added yet
I've just added them
Oh, thank you then, apparently I wrote what I did and just forgot to add, my apologies
( JS, possibly others )
This is unspecified.
( I'll add that to a Haskell translation. I suppose it's the same for all languages? )
ETA: It isn't. Python deviates. :[
In fact, it was added to the tests so that people could not solve the problem using a list with all the answers
I did it, thanks for your advice
no reason to deviate, why does Python have other limit?
Great one!
which language?
Fixed that for you ;)
Maybe it was a pun? The kata's name is
The Bee
after all ;)Could use tag:
dynamic programming
added by the Hive Queen
C# Translation
Man, thank you so much.
.
Javascript translation
approved by authör
Wow, very cool thanks a lot!!!
This comment has been hidden.
Yeah, Number input would have been better as you don't need the input in any calculations (unless you come up with an O(1) solution). All current solutions transform it in the first lines.
I changed it, only invalidated one solution. Input is Number now, as it's used as an ordinal number, not part of any calculattions.
Can anyone help me translate the task in Js here's what I have done, and then tight, and maybe I'm not a lot of mistakes, do not judge severely
This comment has been hidden.
This comment has been hidden.
Don't try JS, let a seasoned JS translator handle this please :)
I really want to learn this language, I have plans to start learning it as soon as I finish learning Python
Since the input scope is small
(1 < n <= 200)
, I suggest you use the entire input range in random tests, and shuffle tests.That is, if I understand you correctly, I need to remove random tests and write tests for each number
no keep the random tests, but do something like this in pseudo code:
for n in shuffle(range(2,201)): runtest(n)
Thanks for the advice, that's what I did.
some solutions time out now, this is due to the fact you are still using your own solution inside the 'random' tests. please change your solution with that lambda you posted as spoiler below. This gives the user solution more time to run.
Okay, I'll do that now.
I did it all, Thank you so much, thanks to you my kata is so much better
Current kata votes:
5 seems fair
I'm very glad you think so.
approved
Anyone can tell me how to spell the condition in the tests so that decisions of this type are not made, if someone can help me will be immensely grateful to him
I have implemented the code in your test suite. I set the limit to 1,000 characters which gives a lot of room for creativity, but there's no chance of hardcoding all the answers now.
(so my solution and one other have now already been invalidated)
Thank you so much, now I will know how to do it, you are very helpful
You should use that lambda as reference solution
mine_solution
inside random tests, rather than your own solution.The Python code length limit is
< 1000
. In all other languages, it is<= 1000
( and that's what I wrote in the description update with the Haskell translation ).I'd suggest to give Python solvers that one extra char. It's the simplest solution. ( Yes, people will raise issues for that one character. )
Hello all, if anyone has a desire to refine, fix, translate the task, or otherwise contribute to the improvement of this kata, I would be very grateful to him
how is Python integer precision with these huge numbers?
So it seems we can not get in the answer is not an integer, as we only work with integers, perhaps I misunderstood you again, but I hope right :D