4 kyu
One Line Task: Squirrel And Tree
859 of 2,319myjinxin2015
Loading description...
Puzzles
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.
This comment has been hidden.
Hi! I have not been able to get past 53 char on python, can i get some guidance? :D
This comment has been hidden.
I can't get past 52 :(
JavaScript: 54 chars it is the best return my fo
two things:
This comment has been hidden.
My code so far is 53 characters long and i was wondering if anyone can point me in the direction to shorten it ?
This comment has been hidden.
To write MY code I've got only 24 characters(Python)
Hi Alexey - I don't know how you are currently counting your characters to reach 24 - are you only including the Latin letters in your code in this total, ignoring the punctuation etc? - but to me your answer appears as 54 characters in total.
The Python limit for this kata challenge is 52 so you need to reduce a bit more.
To be clear - if you take your solution (all of it, not just the part after the function definition) into your standard text editor and select it as a block, it should say 54 characters selected.
oof, stuck at 55 characters
nvm I'm just a dumbass
Lua translation!
This comment has been hidden.
Thanks for this interesting kata.
I can feel some of my long-gone mathematical neuron dendrites regrow back.
This comment has been hidden.
You can squeeze them into a single line.
Hint: Define a function without using "def".
Ahhhh thanks a lot for this kata @myjinxin2015 ! It's my first attempt at these kind of problems and I learnt a lot this evening, what a cool aspect of programming!
Can't stop laughing😂: "your code length = 52: expected 'code length >= 52' to equal 'code length < 52'"
Code length = 57: False should equal True :(((
This is tricky! I like being forced to practice concise coding, despite the frustrations!
nice kata!
how do you forbid exec??
your code length = 52 - Expected: 'code length < 52' omg
One of the best kata I did, 10/10
This was an excellent challenge.
It really challenges you to come up with compact code.
You will master arrow functions and converting a string to a number.
god damit. Im stuck at 60 charachters. Its a fun experiment to keep finding ways to get it down to 52 but honestly the code wont be readable at that point.....
A lot of neat, shorter answers left out of the solution pool since some of the answers expected integers and not floats.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
the
return
is taking a lot of chars, imo... Far too much... => ? ;oSo, a way to return the value without using the return keyword ? :/
This comment has been hidden.
Yup, got it. Thank you guys so much !
Code length = 188: False should equal True Can anyone explain this? I was coding using Python and finished it, then this happened.
read the constraints: your code must be shorter than 52 characters, in python (hence the title: "one line task". Sort of...)
This kata has already given me heart attack.
your code length = 52 - Expected: 'code length < 52' fuck
This problem is amazing. I don't think I'll ever be writing functions the same way again.
This comment has been hidden.
There's a different way to define the function that would bring your code well within the limit
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
Very interesting and enjoyable. I already had the knowledge I needed, but some "outside the box" thinking about boilerplate code did it for me.
First question... because I think I was not fully understanding the description...
Will I need to calculate that "constant angle to the ground"?
The answer is: no Sorry for late ;-)
Then I truly do not understand the question.
If circumference (a loop around the trunk of the tree), S=3, each loop climbs the tree h=4 and height of tree H=16, then my understanding is that it will take 4 loops to reach the top because 4x4=16. So total travelled is 4x3=12 but yet expected output is 20.
Description said:
to figure out how many meters the path length of squirrel climbed when it reached the tree top.
Note,the path length of squirrel climbed
, S isthe length of its circumference
, notthe path length of squirrel climbed in a loop
. Is this clear?EDIT: You can flatten the tree like a paper, in your imagination. Then rethink this problem.
I have to agree with dafuloth, the description is very difficult to understand and even after forfeiting to see the solution I don't understand the math behind.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
It's cool that you're steadily cheating your way to the top of the leaderboard, but it doesn't mean that you can simply tell other people how to solve the kata (moreover, it seems you don't even know what you're talking about).
This comment has been hidden.
@___i thanks, you tip help me, I've solved it.
@Maxitenia : Congrats
This comment has been hidden.
I love this kata so much.
This comment has been hidden.
This comment has been hidden.
You might also try googling something like "shorter python functions"
There is a good starting point on Stack Exchange.
dang it, I can only get to 65 characters with python, I'm using round() also
Can you post your current solution here and mark as having spoiler?
Current Python and Ruby code length requirement is too lenient. It should be at around
46
and40
(the current limit) because of tricks these two language includes.That would be too much IMO. Now there're at least
3
possible solutions in JS while you want Python and Ruby version to have only1
. Looking for the only possible solution is more annoying than interesting, moreover with the unobvious approach you used. I wouldn't change it to anything lower than<= 48
as it could seriously increase the difficulty, even beyond the original version which was fairly easy to do.Well, then the question is: Why is there a translation in the first place?
Also, the thing that was done in Python and Ruby version are not even as advanced as JS version. That makes their difficulty more along with
6/5kyu
instead of4kyu
.I agree, currently, the python version is at most 7 kyu (basic geometry)
46 seems appropriate for python, yes
This comment has been hidden.
then the overall rank of the kata should be modified, I guess...
This comment has been hidden.
This comment has been hidden.
Got it running in 48 characters but now I see 46 is possible? aaaah
Python anti-cheat tests in Preloaded are leaking global variables to the user solution. Especially there are very ambiguous ones like
b
ands
, which is almost an conflict toS
in initial code arguments.Could you explain what do you mean? How can text parsing anti-cheat leak variables from the test suite before actually reaching it (I've already translated/authored a few katas and no one ever raised this issue or mentioned such a possibility)? The only variables used in test suite are
randint
generators (not so ambigous now), BUT there's no variable "s" used, so idk what do you mean here.In Preloaded. I can see
s
,file
,b
and probably more things in user solution byprint(globals())
.Got it now. This is what you're seeing.
Yup. You should probably wrap them inside a function, execute it, then delete the function.
Python test for code length should also tell what's the code length requirement when it fails, like in Ruby (
code should <= 47 chars
) and JS.Damn, forgot to mention it. The current limit in Python is
51
characters (not52
). Unfortunately, I can't fix it anymore, only @myjinxin2015 can.After translation is approved I think you should be able to edit the kata directly (though maybe it needs 6k honor? I don't really know about this).
Probably 6k needed as I can't edit it.
Yeah I've never been able to edit kata after I've translated it. Guess we'll see soon enough if that changes >_>
This comment has been hidden.
By shortening your code so your code length is less than the limit (
52
chars, see descriptions) ;-)This comment has been hidden.
I don't think you're ready for Code Golfing if you're asking such questions ;)
You don't technically need any of those things, but the first thing you asked about is useful.
This comment has been hidden.
This comment has been hidden.
I've done some golfing kata not long ago and the initial solution actually used
def
- a very vile method to trick newbies ;)Translation got approved while it was night for me, and I couldn't see your message/change anything :|
Added a Ruby translation if you like :)
Approved. Thanks ;-)
43 in Ruby, 50 in JS :D Thanks for the Ruby translation!
Oof.. if you did it in 43 I guess I made a pretty bad oversight ha. Edit: Ah interesting. I didn't know about that trick. :)
Can cut down 1 more byte
Edit: cut it down to 40: https://www.codewars.com/kata/reviews/5ac96b8b7245a19f7f00317c/groups/5ad02055d33826e277000236
Edit: the same trick in Python cut the byte count to 46: https://www.codewars.com/kata/reviews/5ad003ebe975198746000f05/groups/5ad021dad3382616c8000258
Shrug I dunno. It seems pretty obscure to me.. never seen it before. But either way, it's an outlier, right? It's not like there are a multitude of solutions in between 48 and 40... so is it really a problem?
Your squirrel and my camel might be cousins
:-)
https://www.codewars.com/kata/zig-zag-camel
This comment has been hidden.
OK..OK..You win. With a magic spell, the kata's limit was changed. ;-)
Ahh, but 51 made it too easy ;-)
And what was the limit before 52 chars? Thanks!
This comment has been hidden.
Only two pairs of
()
should be used in the right side ;-)Got it. Sad part is that I had it written down on paper a couple days ago. I could have sworn I tried it before but I guess I didn't. :|
Well done ;-)
This comment has been hidden.
This comment has been hidden.
The h means height in one loop,not distance in one loop. Maybe you can make it more clearly.
in one loop the squirrel climbes
hmeters(vertical height)
is this OK?That's better. :)
This comment has been hidden.
π is not necessary.
This comment has been hidden.
good, this makes it clear :)
noooo not another one! I'm stuck at 54 :(
The squirrel climbed
H
meters. But that's not the answer you want. I think you want the length of its path.Yes, you are right.
Please help me to correct it, I don't know how to do that :]