I feel like the string e = 1, w = -1, likewise n = 1, s = -1 in description is pretty weird, maybe this should be slightly better (prob needs to be corrected as well):
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:
deffoobar(): pass
The variable created is foobar, the proof, you can do that:
deffoobar(): passfoobar=1234
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:
# Common accepted solutiondefcheck(s, e): returneins# Another solutiondefsingleton(c): returnc()
@singletonclasscheck:
def__call__(self, s, e):
returneins
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.
nice use of capitalize(), gotta use it in my code next time
Approved.
Hotfix on the issue below: https://www.codewars.com/kumite/6738311be9617f5edd152e28?sel=6738311be9617f5edd152e28
hotfix: https://www.codewars.com/kumite/6738311be9617f5edd152e28?sel=6738311be9617f5edd152e28
oops, thought the grid is x-positive and y-negative based D:
hotfix: https://www.codewars.com/kumite/6738311be9617f5edd152e28?sel=6738311be9617f5edd152e28
Check the issue above.
it's n = y+1, s = y-1 instead of n = y-1, s = y+1 in test.
done
I feel like the string
e = 1, w = -1, likewise n = 1, s = -1
in description is pretty weird, maybe this should be slightly better (prob needs to be corrected as well):Otherwise, not bad
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
Loading more items...