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.
python new test framework is required. updated in this fork
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Hi @Rockkley.
Lambdas are anonymous callable objects. If you want call it later, you must use a variable, no other choice to do that. And here (in codewars) if there no name, unit test cannot check the solution.
For your information, in python, a
def
(and so, a fonction) defined like that create a variable:The variable created is
foobar
, the proof, you can do that:It's the aim of the mechanism under the concept of decorators.
If you prefer i can use these solutions instead of lambda, the solution will be acepted:
I know that lambda is anonymous function, and there's no need to create variable for lambda, but here we need to meet the interface requirements. Requirement here is that
check
is callable.In real world I would not create function for this one liner, that's why I'm showing solution with
lambda
.variable "check" holds the function. and ambda describes the oneliner function.
mult = lambda a,b:a*b
is the same as
def mult(a,b):
return a*b
What do you mean? Do you know how lambdas work? Do you know you can copy the code and make trials on your own to understand how it works? On your own computer, or just here, by clicking on
Fork
just below any solution.Why creating a variable for lambda?
Good Kata for what it wants to do. Minor suggestions for the description:
Just write 'Walker', maybe emphasize it.
"This class should have two methods:". This is a specification, let's be precise :)
The following list could use some clean-up: Why precede each method with a number? There should be 2 list items, one for each method, with the description below at matching indentation.
walk(string):
a method that takes a string of directions for Mr. Strolly to walk as input (this hasn't happened yet, why past tense?)
coords():
a method that returns Mr. Strolly's position relative to his house*
* Instead of pre-populating the __init__ method, you could specify that Mr. Strolly's initial position is his house at (0,0).
Please use new python test framework.
A class keeps state between walks. If there is only one walk, a function is better than a class.
Using a class only to split a function into three is bad practice.
Agreed. Doing it in
C
is actually not that easy, too. The string handling isn't super involved but definitely worth more than 8 kyu. It is so unfortunate that it isn't possible to have different difficulty rankings for different languages. Sometimes the tooling makes all the difference between a Kata being super easy or actually quite hard.Except that this is a ver bad example. If you want to make a kata about how to write classes (which, btw, there are always many such katas so your would be a duplicate) you need a better situation where doing so would make sense. As it currently stands it really doesn't.
Matrices don't have up and down. There are all kinds of coordinate systems in programming. Downwards Y is used in 2D quite often, but for instance PDF has Y pointing upwards. In 3D graphics Y seems to point upwards in most cases both in right- and left-handed coordinate systems. In math right-handed systems are usually used, although it looks like left-handed systems are used in other areas too.
Note that downwards Y in 2D probably comes from analog TV scanning direction or from writing direction, so it's mostly associated with screen coordinates.
That depends on the coordinate system orientation, although
Y
axis is generally facing downwards in programming (row number in matrices, offset in GUI etc.).Loading more items...