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.
Here: https://en.wikipedia.org/wiki/Go_(game) it says:
However, I do believe this must not be missing in the description of course!!!
The desc just says it implicitly & partly/poorly "not completely with no regard to handicaps or when the game is replayed/rolledback or some other actions maybe" within the reset section:
reset
Whose turn is it first and does placing handicap stones whose turn it is?
It cannot be split into "cats and dog", because there is only one "d", it could have been split into "cats an dog"
Yep!
The additional tests are no longer additional, and the description is no longer incorrect in the description of the number and datatype of possible function arguments. Also, don't use flawed logic. :P
I'm not explaining "side effects"; you can ( now ) read the test and you can Google it ( Wikipedia has a useful article ).
The side effect test, of course, is the test against
! cache[hash]
instead ofhash in cache
. But I won't be suggesting that in the error message.Solved?
That was indeed the problem with your code BTW. I would have expected that problem to surface earlier in testing already, but it didn't. I may write some tests particularly for that bug, apart from moving the side effect test up and copying it to the example tests. I've written some memoisation code over the years that suffered from the same bug; it should be caught explicitly.
I can't work with that fork. Did you publish it? Or just save it?
Have you tried logging only if
fn.length===0
?Answers to lots of kata can be googled of course. If I invented something truly unique, I wouldn't be making a kata out of it, I'd be writing a paper or getting a patent. :P
Difficulty on here is odd sometimes, I'll give you that. But it often depends on prior knowledge also: if you already know the solution, the problem seems a lot easier. I wrote the solutions years before I created the kata and wrote all the testing. Difficulty is set by everybody but the author BTW, but most everybody that solved the kata of course also already knew memoisation.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Could you fork your solution, change it to your not-working solution, and publish that, failed tests and all, so I can see what was actually happening to you? Please?
a) did throw me off, but only a little; I suspected as much, but I couldn't be sure.
b) "single" is intended as opposed to "more than one" earlier. I could rephrase that as "every argument, singly" ? You're not supposed to do things in a loop; you're supposed to memoise independently for every argument, one at a time. I'm also open for other suggestions to improve the description ( preferably no less concise than it is now though ).
c) last test section actually breaks the description. ( sorry 'bout that! :o ) It effectively passes you
undefined
( this is normal JavaScript semantics, and I consider that to be expected ), which is not aNumber
,String
orObject
. Having to acceptObject
means you have to be flexible anyway. I'm thinking to change it to something less defined, which would includeundefined
. Again, open to suggestions.d) the last test will always have that problem of course, and submit testing will also always have that problem. You could maybe have logged only for
function.length===0
, if you knew the last test was unique in that way, but that's not a general solution. It's, however, not intended as a surprise, so I could include it in the example tests ( that's an honest thing to do anyway ). Also, having that particular test be covered by the description should help ( a bit ). But whatever is the last test will always be difficult to debug. Hmmm .. should at least be the umpteenth test of the same kind then, not any kind of new test. Simply reordering the current tests may also help.e) the kata asks for a generalised implementation of memoisation. That is of course easier to do if you have some experience with specific use cases of it, and can abstract and generalise from there. Kata also assumes some knowledge of functional programming, where "side effect" is ( or should be ) a well-know concept, entirely separate from memoisation. It's not "at least once" BTW; it's "exactly once".
f) I am unconvinced that you, with your limited experience, being unable to solve the kata means it has flaws. No offense. There are flaws, definitely, but if this were easy, it would have been 8 kyu and the description would have been a oneliner. Some background knowledge is assumed implicitly, and that could and maybe should be made explicit, but the other extreme is spelling out what you have to do to the point where there's no challenge at all. This kata is not intended to be ( and I don't think it presents itself as ) an introduction to memoisation ( that would be "memoise this particular function". there's other kata that do that. I could probably find some if you want ), so I don't think it should be held to that standard.
Memoisation itself does ( should, must ) not have side effects; it can ( does ) affect the side effects of its argument function. "Side effects" appears on the Wikipedia page of "pure function". ( Recommended reading! I think functional, pure programming is fun, and educational. )
OK, so: what should I do about that "single" in the description? what should I do about that last test? ( I can change it to
(x) => v++
, but that feels a bit like cheating. ) I definitely should move that to earlier in the submit tests, and copy it to the example tests, I think. and the big question: what is the intended audience for this kata, are you in it, and how much should I accomodate you? quite willing to do that, just unsure of how much is appropriate. ( and you may actually not be the best person to ask that question of. what to do, what to do? )Couple final things: I did not set the difficulty for this kata, and the set difficulty of 6 kyu does not mean every 6 kyu solver should be able to solve it. I think. Also, I'm only trying to make some things explicit; I do not mean to insult you in any way. You have limited experience; I did as well when I was on here for a month and 26 kata. It also seems 6 kyu kata were easier then ( ranking by the community has changed over time ). Also, this is too long. :P
I am sorry if I came across as being rude, but I was a bit angry about how much time I've spend trying to pass those side effects tests. I have several points I want to tell you:
a) I've ment
(hash in cache)
intead, sorry if it mislead you.b) This may be a problem of how I understand Details text, but for me it seems that words "...and memoising it for every single argument." indicate some kind of action that I would need to perform in a loop for every argument this function would recieve, which is not what you need to do. So, basically, it trew me off.
c) Details indicate that this function would recieve either one argument ("...given a function of one argument, returns a memoised function of one argument."), or several ("Functions of more than one argument can...") but last test section (about side effects) gives you 0 arguments, which was not indicated in Details, or visible tests.
d) Moreover, only those test would pass for me, and I couldn't debug them because logging would produce millions of other logs (in previous tests), and I can't see code of those tests to copy into my IDE.
e) While I've used recursion and been aware of memoization, I've never actually used it, so this kata was introductory to the concept for me in particular.
f) As result of (c-e), in my opinion, this kata has flaws in design, as I needed to try and guess what was wrong in my code, and it was not shown to me clear enough by words "should have at least one side effect".
In fact, I'm still not sure I know what "side effects" of memoization are exactly, and those words don't appear on for example, wikipedia Memoization page.
Could you please explain to me exactly what, and why, the problem is?
I'd like to understand why you use such big words ( "lie" ). I am not doing that intentionally, but of course I am testing for certain effects. Memoisation should affect side effects, and it's not like I'm doing it quietly.
Please consider that
!cache[hash]
may not do what you think it does if a function value is falsy, and / or you may wanthash[cache]
instead ofcache[hash]
if you wantedcache in hash
.This comment is hidden because it contains spoiler information about the solution