7 kyu
[Code Golf] Number Pyramid Series 1 - Sum of Corners
242LanXnHn
Loading description...
Mathematics
Restricted
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.
It looks easy when it's solved, but I've spent quite some time stuck at 36-37 chars solutions. With <36 chars it's probably a 6kyu
Am I correct in assuming that the code needs to start "def sum_corners(n):return " leaving just 9 characters for the code or the formula?
No, this is not correct. You can squeeze out 4 characters more.
This is one of the basic Python golfing trick, you can find it on Internet quite easily.
Thanks for the Kata, finally got it. I didn't realize that we are allowed to alter the function definitions here at Codewars. I also think that this was a bit tough for 7 kyu, needed pen and paper + needed to learn new ways of writing python for this one, usually 7 kyu are pretty much tutorial stuff.
This comment has been hidden.
You are close to the answer, you can observe the conner cases, and search for
Python boolean
.i should learn that lambda thing
Well, you can definitely google and learn it.
You can found many websites about it, then come back to continue golfing!
Enjoy your learning.
good kata ,I enjoyed. thx
Thank you for the feedback.
Welcome to do other kata of this series.
I would strongly suggest having a one character function name. Every additional character comes off the code size limit, so the limit could be 30 instead of 40 without changing the difficulty of the task. The golfing task ( generous as 40 is! ) is not a 40, it's a 30.
A long method name adds something special (sadistic) to a code golfing exercise. I would keep it. I would like to see the limit lowered to 35 though. Makes it hard enough, but still allows for a varity of solutions.
Length limit was changed to
35
as mentioned below.Regarding the name of the function, I will leave this suggestion open and see if there is an agreement to change the name.
Will change/remain it accordingly.
Cool kata, fellow code golf fan :) by the way I think the accepted title format is to include [Code Golf] - I get dozens of hits when I search with that title tag, whereas I get 0 when I search for [Golfing]
Also - I'm not sure what the Codewars consensus is because I'm waiting for my first golf kata to get approved - maybe the char limit is currently a bit generous at 40? My first unoptimized solution passed with 36 - I guess it depends what difficulty you are aiming for?
I agree, my very first attempt was easily short enough. I would suggest bringing it down to at least 35.
I think that now when kata tags are finally getting cleaned up, tags in titles become redundant (unless it's a golfed version of another kata).
Just search for
restricted
and you should find only code golf and similar.If even I can solve it, it's probably too easy.
Figuring out the formula is harder than golfing it right now.
With the suggestion, I updated it to
35
.If there is something still need to be improved, please let me know.
.
35 is too hard for 7 kyu. It took quite some time to figure out the shortest formula and then I can't get below 36 :-/
This comment has been hidden.
There is one quite easy way for you to get down to 35, one of your math operations can be slightly rewritten.
Haha ok thank you I got it. But still it's quite hard for 7 kyu. I'm excited to see the other solutions. /edit Ok if you got some experience in code golfing it looks much easier.
@Fuzzi - now try the other ones in @LanXnHn 's Number Pyramid series, they are all great!
Well, I will get more opinion before changing the length limit.
This was approved Kata and I want to have the minimum amount of modifying.
restrictions
tag should be added.It is added. Thank you for your reminding.
Description: "The lenght of your code should be less or equal to 40."
Sample tests:
Thank you for the reply, I forgot to update the sample tests.
Now it's fixed.