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.
I really enjoyed this kata, but i would suggest improving the sample tests to include decoding a factorial base number that has a letter in it. With the current sample tests I could completely ignore the letters and still pass the samples but fail the full tests.
you're not checking the structure of the
tree
, there. Only the structure of a Node. I mean: the only reason why my solution got invalidated is the very first line of your new function. Otherwise, since you just check that the root node is compliant with the structure of a bst, but without checking that the BST itself actually holds the values he's supposed to hold... Well, my code returning an empty root still satisfiies the other tests.Note: you're making the things far worse, since you introduces now
Node.val
without saying anything in the description... And while you STILL didn't tell anything about the contract for the Node class.....No, you have to build a reference tree, and check whether the user's tree is identical. But this will require enforcing an exactly same approach as you use which sounds bad for a purely algorithmic kata. Alternatively, you could turn the task into "implement a BST", and check that an in-order traversal results in a correct sorted list, but this may lead to people imitating a BST just good enough to pass the tests.
I think whoever upvoted this kata should have let it die, because this is likely to turn into a huge mess, and still none of the issues raised earlier have been addressed...
okay, now i check the structure of the tree along with the result of the traverse method. This is still not perfect but is it better?
na, you're trying to go the wrong way around. What you should do is to avoid totally any list-like approach. Your class methods are the weak points, here. What you shoul do is actually to test the structure of the tree, NOT the result of it. You're currently testing that the user is going from Berlin to LA hoping he'll go by sea, except only a very strong checking would forbid him to use a plane. Meaning you're "attacking" the problem neither from the correct side nor with the correct tools.
for example this kata prevents users from using any
eval
related functions and I want to do the same with mine but with any sorting related functionThanks for the feedback, i am trying to prevent users from extending lists and from using any built in sorting functions but im still learning so this will be improved. I know there is way to test if a certain function is used i just don't know exactly how, I am still trying to figure it out.
Hi,
Sorry to say so, but... your requirements are just like your tests: full of holes x)
This should never pass the tests. You're trying to do too much things at the same time while not testing any behavior properly.
You can access the source code at
/home/codewarrior/solution.txt
.You check its existance, but not behavior.
The description says nothing about the requirement of
left
,right
, orval
.Now I test that the BST has a left, a right, and all the necessary methods
The "sorting" is the same as in-order traversal, so this part is a duplicate. Idk if there're katas about implementing a BST (I think I saw one in Beta, but not sure whether an approved one exists), so this kata could be a duplicate overall.
I want to prevent uses from using the sorted() method but I don't know how
you're right, i just noticed that, i'll fix it
Loading more items...