6 kyu
[Code Golf] Optional Walrus?
424Chris_Rands
Loading description...
Restricted
Puzzles
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.
stuck at 33 with that greek function already 😫
Crazy kata indeed 😵 I also tried and failed - so far.
The test framework and solution should be imported explicitly.
oh, I forgot it -- fixed
Sample tests should have the correct
describe
/it
structure.fixed
BTW, is the
it
block mandatory? It works pretty fine without...It's not mandatory from technical point of view, but the fact that it works is only a quirk of Codewars Python testing framework and how CW runner interprets its output. Assertions located anywhere outside of an
@it
block are not something what "sane" testing frameworks support and such test suites might hinder future updates of Python versions or testing frameworks.Please refer to explanation on this list: https://github.com/codewars/content-issues/wiki/List-of-Python-Kata-to-Update#test-framework
Also from kazk:
It's at least strongly recommended to switch existing kata to proper describe/it/assert levels, and it's a requirement for new kata as the "it works" is considered a legacy behavior.
8 months ago you were claiming that having
it
blocks withoutdescribe
is enough here (which hobovsky explained to be wrong), now you're claiming that havingdescribe
blocks withoutit
is enough (which again hobovsky had to explain to be wrong). Are you serious?8 months is a lot of time. Maybe things changed in the meantime. Maybe I changed in the meantime. Anyway, as all required details are there, we should be all fine now ;-)
New test framework should be used.
fixed
Thanks anter69!
are we allowed to rename the variable into something shorter?
does the caller need to know what your parameter names are?
You can and should rename the variables
This was one of the most satisfying katas to solve
I'm slapping myself in the face right now. But yeah, overall good kata.
YEEEES :D Congrats to the other Warriors
Stuck at 34...
mention code golf in the title
AND
allow a few more characters to allow some variation
First part is accepted, the second not. Let's call it a day and close the suggestion ;-)
I have 34 characters without 'return' in one line. can somebody help me?
How do you do it without return statement?
There are different types of functions. Try searching for it online.
Even the spaces count, try to reduce every unnecessary spaces. Also search code golfing. That gave me the final push :)
Think about a certain greek symbol...
Now I have 35 characters. Was used python golfing and walrus. Can somoeone help me? I think, the trouble in return statement.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
The indentation is 4 characters lost so everything needs to be in one line, isn't it?
Yes.
The return plus the whitespace are 7 characters, the definition header takes 11 characters. The len call is 6 characters and the Walus Operator plus parentheses are 4 characters. So that's 31-7-11-6-4 = 3 characters for the computation. Among which a multiply sign, the integer variable and the assigned length variable so 0 characters are left for the comparison operator... Did I miss something?
indent can be 1 space too. but for this to works, you need one line!
There must be a Pythonic trick I've missed
35 characters min, here too... Walrus didn't helped too much... :)
@sinisake apparently the return statement is eating the extra characters
At 34 without the whitespace after the return statement
This comment has been hidden.
It's possible to solve, you just need to think outside the box a bit. I laughed myself silly when I realized how I overlooked the first solution listed.
I managed to use the Walrus Operator in the if statement, but thats not nearly enough...
And finally!
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
there's lots of ways you can reduce boolean expressions in python try looking up "python golf"
Thank you. Your comment helped me find the last bit that I was missing :)
Okey the "python golf" and Walrus got me down to 35, its not like some short form of return or some stupid stuff
You can omit return at all. Search about it on google.