7 kyu
Calculate mean and concatenate string
1,405 of 4,319user8476848
Loading description...
Fundamentals
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.
JavaScript fork (author gone)
Approved
In javascript the float "1.0" will be printed as just 1, the last test case never will be achieved
39 => 3.9
9 => 0.9
10 => 1 XXXX
Not quite sure where to start with this one.
Not a kata issue, closing - and please double-check your issues before you raise them :)
TypeScript:
Fixed some time ago.
random tests are attackable.
fixed in OP's fork
python new test framework is required. updated in this fork
Approved
This comment has been hidden.
Fixed in this fork
Dear all, I am trying this Kata in Python. I may have missed something. But all the samples for testing have an average of "0.0". Is there something wrong? Thank you
You mean like the first sample test?
Which has 3.6, not 0.0?
Yes, you have missed something.
Can you explain yourself again, please? There's no
issue
with the Python kata, by the way. If you're not certain of something, please just post as aquestion
.There is definitely something wrong, but not with the kata. The sample tests have varied averages, and none of them are 0.0. Not sure what the issue could be unless you post your code as a spoiler. It's possible that hitting the "reset" button at the bottom of the screen will help you out? It will set everything to how it's supposed to be when you open the problem for the first time (including deleting any solution you may have programmed).
This comment has been hidden.
When you use the expression "samples for testing" I look at the sample tests. Now I see you are really talking about the random tests!
My bad. Sorry for the misunderstanding. I should have been clearer.
Yes, that's odd. It doesn't do that for me. I have no idea what might be causing that.
Nevermind, I figured it out. I think you're mutating the input. Try solving this without changing the elements in the input.
Thanks for the reply. Just solved this without changing the input. Anyway, I think this should be added to the description of the kata (or implied).
Ruby 3.0 should be enabled.
Fixed in this fork
PHP
In PHP version Random test violates the descriptoin "
There will always be 10 integers and 10 characters.
".Some times there is an array comprises only numbers. And need to multiply mean value by two, or use hardcoded divident 10, not a real ammount of numbers in this array.
found the bug in the random tests -- it now spits correct arrays
For the PHP version, it looks to me like the main tests still test against 2 * the mean while the "sample" tests are still correct. Am I missing something?
resolved
Why didn't any of the php errors reported raise an issue? The random tests are wrong.
found the bug in the random tests -- it now spits correct arrays
This comment has been hidden.
my sample test is passing but random test isnt..
i used 10 as the divisor for the mean and its bringing error..
Can you help pls
resolved
For PHP the random tests always expect the mean * 2, fixed tests do not. I see this was brought up a few months ago, it is still an issue.
In TypeScript, best practice might return a tuple instead of an array.
I'm unable to pass the testRandom with PHP. The average is always twice what I calculated, and the string is empty, since it's 20 numbers and no strings.
Hello @mdfleury I did not create the PHP translation it was done by @donaldsebleung. That being said I do not see any issue with the randoms and 54 other guys have passed it. Will you please post your code and mark spoiler so I can take a look?
This comment has been hidden.
I finally gave up and looked at solutions, and they're wrong.
The tests in the PHP version are not correct. It generates randomly arrays of numbers without strings.
resolved
Apparently the tests for Java have an issue. When I run them I get errors......
Test Results: /KataTests.java:13: error: illegal start of type Log @Test ^ /KataTests.java:13: error: expected @Test ^ /KataTests.java:14: error: ';' expected public void mean_BasicTest2() { ^ /KataTests.java:14: error: invalid method declaration; return type required public void mean_BasicTest2() { ^ 4 errors
Hi @Doug, I am not sure why you are having this issue I just ran the tests with my default solution and they passed fine. There are also 76 solutions in Java that also passed. Do you want to post your code and mark it spoiler and I can take a look? Thanks
C#: The description is imprecise. Not any floating point number will do, but only 'double'
This comment has been hidden.
I think that always having 10 integers and 10 characters in the passed in array makes this exercise simplier, but it could be made more difficult and more realistic by passing in a random amount of integers and characters.
This comment has been hidden.
I really liked this exercise, thank you for making it!
public static Object[] mean(char[] lst)
this means that there an array called Object ? or can someone explain this object[] mean part
Hello ~ It means you are returning an array of objects. This allows for the mixing of types since one is a string and another double.
so the name of this array is mean ?
no the name of the method is mean
so the Object [] just represents a mixed type array ah gotcha ty:)
Haskell translation kumited. Please review and approve. Thanks, suic
Approved ! Thanks Suic!
Thanks, that was quick! :)
FYI - (
Java
version)import java.util.*
is not neededstring[]
instead ofString[]
char[]
is more appropriate thanString[]
given the kind of inputThis comment has been hidden.
This comment has been hidden.
PHP Translation Kumited - please accept :D
Accepted with thanks :)!
Nice work
You're welcome, and thanks for the compliment :D
C#-Translation kumited!
https://www.codewars.com/kumite/57c3ea91e2ddc374620001fc
Please check and approve it! :-)
Approved Thanks Steffen!
You will be given a list of strings which will include both numbers and characters. There will always be 10 numbers and 10 characters.
Return a list where the first element is the mean of the numbers (rounded to one decimal place) and the second element is a single string of the characters in their original order.
###Example
This comment has been hidden.