5 kyu
One Line Task: Integer Average
270myjinxin2015
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 is what they mean when they say "Think Differently."
This comment has been hidden.
I am stucked at 46 char, test case need me to be less than that any hints?
Sorry, my mistake. Thus, I remove my previous post. My apology sensei.
46 chars, my brain is about to explode! Need a hint, please :)
After read the discourse,i find the way to solve it.
This was absolutely brutal, yet absolutely worth spending an evening on. Thank you!
I decided in 44 characters. It was a cruel kata)
It was painful, but interesting :)
This comment has been hidden.
I have 52 chars while using reduce. Can you provide any hints?
Hmm.. reduce is too long, try other shorter method like
j...
? ;-)That is insane evil! 1 char left :)
Continue your hard work, or, have some coffee and try again ;-)
I am completly stocked :(
Can I get property
length
somehow shorter than 7 bytes?Or force
/
operator to be more important than!
operator?% operator will be better.
yup, but its still not enough.
I can of course
%
bya.length
and compare it to0
or just make logical negation!
which needs brackets. Or I can divide/
sum than% 0
modulo it with zero and than do logical operator. First approach looks shorther, but it requires 47 anyway.ok I got it :)
Happy coding
^_^
Haha these are my issues as well. Oh how I long for Ruby...
a.reduce(:+)/a.size%1==0
;)Why not C#:
a.Average()
? ;-)This comment has been hidden.
check how to invoke functions without parantheses and you're good to go.
Thanks a lot! It was really helpful! I have learned a new thing again.
Can someone give a small hint on how to remove %1 or ==0? I'm stuck at 47 characters and this is getting frustraiting. Thanks!
What can I do? Will I be getting through? Now that I must try To leave it all behind..
Reduce only to 50 characters. Where i can bye more powefull evil? And how it smoke ))?
This comment has been hidden.
https://www.codewars.com/kata/beginner-reduce-but-grow To solve this kata, and then to see my "clever" solution. Perhaps you can find some new way for this kata ;-)
Ok, thanks - I get it. I have never heard about that "bad". What we need is just turn the page in learning book.
This comment has been hidden.
Now I think you need Voile's hint: there is a way to invoke functions without using parenthesis. Or my hint: sometimes ==0 equals to <1 (only sometimes) and hope you never used %1 in your code ;-)
This comment has been hidden.
The hints below are barely subtle at all, but just in case: ==0 cannot save you 3 bytes (from 49 to 46), so you shouldn't worry about that yet.
The first trick involved would be what I'd imagine a script kiddie who self-learns only JS and knows nothing about "best practices" or C syntax would do :P And the second one is very obscure. You'll need the second when you reach 47.
well im taking js and c/c++ classes at my high school and im still kinda iffy on the emca6 arrow notation, but i am stuck at 47 characters, im not really sure im a script kiddie, but everyone starts somewhere right?
Okay, so you're probably stuck at the last part.
Hint: there is a way to invoke functions without using parenthesis.
sometimes ==0 equals to <1 (only sometimes) and hope you never used %1 in your code ;-) is this helpful?
This comment has been hidden.
This comment has been hidden.
Thanks. Happy coding
^_^
Enjoyed this kata. The difficulty for me was my unfamiliarity with ES6, but at least I knew that was where to look to reach the final solution.
This comment has been hidden.
Lots of the things you see in the JS test code is just the standard myjinxin kata test code suite (they exist in every kata he created), so probably most of them are unused. You can just refactor out all the things irrelevant to the test itself.
This comment has been hidden.
This is hard ... I got my solution down to
51
characters after a few tries but can't currently think of a way to further shorten it ...This comment has been hidden.
Unbelievable... You post that without spoiler.... !? Lame...
Thanks @RustedMemory for the hint (read the full comment in my email inbox); no wonder @myjinxin2015 kept saying that
only evil can pass ;-)
:p I'll try the Kata again sometime :)Just managed to cut it down to
49
characters with evil (tehehehe ...) but apparently still not evil enough :pAnd now
47
- what am I missing? ;)there are different modes to do this... (might help a bit... maybe... If I guess right where you're stuck now... ;) )
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.
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.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
Great kata, but I think it is a litte bit to hard... maybe allow 1-3 letters more. Otherwise it is only one way to solve it and the good ideas are useless. But it was fun. ;-) Thanks! Upvote! :-)
Yeah, so far I have thought of two ways to do it with 47 characters, oops!
Ha, I suddenly noticed I was doing an unnecessary step, and got it down to 45. :-)
only evil can pass ;-) a hint to 10XL :]
This comment has been hidden.
This comment has been hidden.
is there a shorter way to check for int?
This comment has been hidden.
Wow, I can't believe I didn't think of that... thanks.
This comment has been hidden.
be evil ; ) )