7 kyu
Categorize New Member
78,433 of 174,678Brynx
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.
This comment has been hidden.
Your solution has a bug and does not handle some inputs correctly. If you take a look at results of failed tets you will see that it fails "Edge cases" section. What edge cases did you test in console?
Buggy solutions are not a kata issue.
I had no idea, how to know the "Edges conditions" and that it was necessery check if input array is empty. Thank You!
Is there a way we can see the edgecase testing and random tests? My code passes the normal tests but I cannot begin to debug why it is failing the edge cases. This is in the TS version.
Lua translation!
Approved
Is there a reason why I'm failing the tests despite the expected solution being ok? Maybe I am missing something.
Usually when tests fail it means that the expected solution is not OK.
Your answer is different from the expected one:
there is a space before Senior
This comment has been hidden.
Array<number>
andnumber[]
mean the same thing.Sorry I meant
number[][]
/[number, number][]
. I changed the type to use shorthand syntax rather than generic typesThis comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
A problem with your code is not a kata issue. Use question label next time.
Also use markdown formatting and mark your post as having spoiler content.
Thanks!
I am ajust a beginner and i didnot understand anything so can one of u guys can make it breif to me
The instrunctions were kinda confusing for me. At first I understood that in order to be senior, the handicap would have to be lower than 7. Made sense in my mind, because I thought to be a senior you would have to have a good handicap. Only after the first test I understood that it is meant to be the other way around. Might help to adjust the instructions a bit, so it becomes clearer. Or it's just me, not having the slightest idea about croquet clubs and handicaps ¯_(ツ)_/¯
I agree, absolutely no point mentioning that a lower handicap is better, that's what makes this confusing.
im having an issue where my test cases seem to be giving the opposite results of what they should be, for example one test case was [[83,-2],[29,5],[15,22],[23,12]]
and all of my results were open, however the test results said that none of them should equal open.
all of those cases should be open, correct?
Yes, all those cases should be open, your current code has a bug, it's printing the result, instead of returning it.
that was it, thank you! i knew i was at the point in the rabbit hole where i was overlooking something silly.
This comment has been hidden.
Please flag dicussions of the solution as having spoilers.
Hello everyone, a question, after solving the code that I can do, will I gain any experience to increase my level or something like that? Is the solution saved or do we post it somewhere?
After solving it, you hit "attempt". If it's successful then you hit "submit". Saves your code to your profile and grants points to raise rank, etc.
I passed the kata and my code works when i attemped and submited it, but while testing it i get this error:
Traceback (most recent call last): File "/workspace/default/.venv/lib/python3.11/site-packages/codewars_test/test_framework.py", line 112, in wrapper func() File "/workspace/default/tests.py", line 8, in basic_test_cases test.assert_equals(open_or_senior(),['Open', 'Senior', 'Open', 'Senior']) ^^^^^^^^^^^^^^^^ TypeError: open_or_senior() missing 1 required positional argument: 'data'
if needed i can also show the code.
Click reset, you edited sample tests and hence the error you get. Not a kata issue.
yeah, you rigth, my mistake, sorry!
This comment has been hidden.
There is no issue:
Your answer is wrong.
I realized immediately after posting, but thank you 👍
This comment has been hidden.
No, they're not the same.
Would you please explain? Thanks.
This comment has been hidden.
This comment has been hidden.
Those are the first two examples I wrote there, the conditions are opposite. Like p and not p in my examples.
This comment has been hidden.
Yes, as you can see from those Truth tables, both conditions being True and both being False lead to the same result, the difference is when only one of them is True and the other one is False.
Why is (255,1) a senior? Should it not be open? since the handicap is less than 7 and if (255,1) is senior then why is (73,1) considered open?
There is just a misunderstanding in description I think. There is "the better the player the LOWER the handicap." It should be HIGHER. With that thinking my coding start working :D
Bad test case?
One test case sets the age to 45 and the handicap to 12. The rules clearly state that the age must be at least 55 and the handicap be over 7, but this person is apparently a senior, anyway.
why is my test working but my attempt is failing??
Your current code works.
Is the "handicap greater than 7" line meaning they are better (lower handicap) or worse (bigger handicap)? The tests kinda make it clear, but I think that can be confusing
It says greater, not better. It's clear imo.
There's a bug in test, for this input [ [ 45, 12 ], [ 55, 21 ], [ 19, -2 ], [ 104, 20 ] ], we got
expected [ 'Open', 'Open', 'Open', 'Open' ] to deeply equal [ 'Open', 'Senior', 'Open', 'Senior' ] But [55,21] and [104,20] for Senior.
There is no bug in the tests, there is one in your code though.
Why (73,1) = 'Open'?
Because handicap isn't greater than 7.
It raised an error, but in VSC it works fine
STDERR: Traceback (most recent call last): File "/workspace/default/tests.py", line 2, in from solution import open_or_senior ImportError: cannot import name 'open_or_senior' from 'solution' (/workspace/default/solution.py)
When I [ATTEMPT] it then it returns this:
STDERR: Traceback (most recent call last): File "/workspace/default/tests.py", line 4, in from solution import openOrSenior as open_or_senior ImportError: cannot import name 'openOrSenior' from 'solution' (/workspace/default/solution.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/workspace/default/tests.py", line 6, in from solution import open_or_senior ImportError: cannot import name 'open_or_senior' from 'solution' (/workspace/default/solution.py)
It works fine for me, maybe you renamed the function? Closing because it works with your current code.
for age = 75 and handicap = 7, expected OPEN
what? isnt that suppose to be senior? age is atleast above 55, and handicap is equal to 7, therefore; the member meets the requirements for the senior label, what am i doing wrong here.
greater than 7, not equal buddy.
This comment has been hidden.
Please, don't post solutions in Discourse. This is the second time I warn you.
This comment has been hidden.
Nice additional info, but not a kata suggestion :-)
Why is the example input a list of lists, and the test cases are lists of tuples?
I use python. I Pasted the code into pycharm and it worked fine! But here it is saying some random bullcrap. Just why???
It's not random, and it's not fecal matter, it's called receiving error messages.
For your code submitted to the sample tests:
End of File
error and it shows you which line of your code causes that (line 2)age
and ahandicap
(you need to calculate an outcome for each tuple)Age
uppercase, and thenage
lowercasesenior
Here is more on troubleshooting.
This comment has been hidden.
data
is an array of tuples, not a tuple itself, not a kata issueThis comment has been hidden.
this site is broken bro; i wrote a simple solution but its saying some nonsense about ">= not supported between instances of tuple and int"
so i copied&pasted into vscode my solution, gave it one of the basic test cases and IT WORKED, you dont understand how unbelievably angry i am right now
p.s. i used python
Your code is wrong. See the input format:
It is a list of tuples. So, data[0] is a tuple, and you can't use
>=
as the error says. And the output should be a list of strings. The kata is fine, your code is not. Please read this: https://docs.codewars.com/training/troubleshootingScala translation
how can i contact u
LGTM, Approved!!!
Hello! I simply want to ask people who has been programming for awhile (preferably with work experience) wether they find Linq to be a best practice or not? I'm a C++ programmer so boiler code and complexity is nothing new to me. Which is also why I prefer to write function bodies with regular loops/recursion. But linq has the advantage of one liners and looking amazing, but often suffer in performance and at time clearity for larger queries. So I'm asking the precent Linq spokes-ppl and us performance maniacs to endulge in a conversation of pros and cons :)
I'll Start:
I find Linq to be an amazing tool, providing both clarity (more often then not), one line syntax, easier querries and easier maintanability. But at the same time it suffers greatly in performance, and as a C++ developer in his Core, I enjoy performance and cache locality. Which Is why I often prefer the use of regular iterations through loops and recursion (call me conservative if you like). But Linq is something I still enjoy using for fetching data especially collections since those add operations tend to be nasty.
Man, you wrote that the better the skill, the lower the rank => rank -2 - 7 the better players(Seniors). But in output you expect completely different result.
Senior in this case means the restricted division for people who are old and bad. If an old person has a good handicap they play in the Open division.
This comment has been hidden.
This comment has been hidden.
Factor translation
Approved
the output is below,still dont know whats different.
Basic Test Cases
Log ['Open', 'Senior', 'Open', 'Senior']
None should equal ['Open', 'Senior', 'Open', 'Senior']
Log ['Open', 'Open', 'Senior', 'Open']
None should equal ['Open', 'Open', 'Senior', 'Open']
Completed in 0.04ms
Read this: https://docs.codewars.com/training/troubleshooting/#.print-vs-return
Not a kata issue.
Solved~ thanks
For C# I have 'Expected: "null"' for the Random Test Cases and there are no indications as to where there are "null" results, just "Senior" and "Open".
I have seen that for some Python users there was a limit of 25 for the age. I tried if the age was under 18 then the result is "null" as opposed to the expected strings. Somehow Codewars just made all my results "null" not just the true tests. I verified it in Visual Studio and it worked but not here.
Regardless, I think you should at least mention the expected null test cases if not remove it entirely.
There are no expected "null" results or inputs, just arrays. What's obvious is that there's some problem with your code, not tests. Please see https://docs.codewars.com/training/troubleshooting for some tips or post your code here (or on discord) using the format shown here: https://docs.codewars.com/references/markdown/#code-block
Then why does my code work in Visual Studio and not here and why does Codewars say Expected: 'null' received 'Open'?
How can my "bad" code get Codewars to say it expected a null result? Do you realize what you are saying?
Here, since there are no expected null results, please explain this:
Test Failed Expected and actual are both <System.String[10]> Values differ at index [3] Expected: null But was: "Open"
Because actual and expected are flipped in random tests, your code is generating those nulls.
Fixed that, check your code and fix it.
Ok, now I can tell if something is wrong from my side. Thanks! L.E.: There, now I fixed it! Easier when the error message points the right way!
Nice kata description! :0)
Java translation is ready for review! (Author inactive)
C translation (author inactive)
Approved :)
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
If it works in a version greater than 3.8, you'll have to wait for it to be available in CW. Please mark your post as having spoiler content next time.
This comment has been hidden.
Thanks for the reply Chrono79. The refactor looks great. Sorry for not marking my post as spoiler; I am new here and didn't have enough honor to mark it as spoiler.
how does it work? How does the assignment happen?
Hi! For JS, in the Kata Description you made the pairs in (), however in the test cases each pair is an array []. This causes an issue where the code is right, but you need to make sure the function is looking for an array. A simple correction to the Description should fix this issue, thanks!
Well, description is shared amongst all languages and it's not that easy to match them all, you could look at the sample tests to see what the input format is and what your code should return. Changed it for javascript anyway.
Oh didn't think of that! Thanks anyway!
My code works fine until i attempt it and it fails sometimes 3 or 10 times. When i input the data for one of the failed scenarios, it returns the correct answer. Not sure what the issue is here
Read this: https://docs.codewars.com/training/troubleshooting
It's a problem with your code, not a kata issue. Check "How to post code in Discourse" if you can't find the problem in your code.
Ok i will take a look. thanks
This comment has been hidden.
This comment has been hidden.
Does your code work in other environments with exactly the same data samples which make you fail tests on Codewars?
Potentially helpful reading: https://docs.codewars.com/training/troubleshooting#print-input
for the millionth time, my code works fine in pycharm .........why does not it work on codewars. what do i have to do ....
This comment has been hidden.
Your condition for age is wrong.
hi i have finished the kata and when i am testing on my Vscode it works ok and returns exactly what is expected to return but when ia pres attempt it fails on 3 tests and it says seniop or open not defined by the context i can not figure out can somebody help please thanks
It's a problem with your code:
Not a kata issue. Read this: https://docs.codewars.com/training/troubleshooting/
HI i just fixed it and submitted all is ok. the name of my function was not right it must be open or senior as it is named in the tests the name i used was categorizeNewMember and that is why i was getting seniorOrOpen undefined. Thanks for the quick responce
may I see your code?
in this kata. I finished the challenge and when i clicked test button its print out You passed all tests :).but, when I clicked attempt for trying to submit its print out "Passed: 2 Failed: 1 Exit Code: 1" Please, Can anyone told me what is the issue?
It's a problem with your code:
Not a kata issue. Read this: https://docs.codewars.com/training/troubleshooting/
This comment has been hidden.
you use the value
17
for the handicap threshold instead of7
, not a kata issueThe example data in the instructions had a list of lists, but the data actually received was a list of tuples. This should be fixed in the instructions
In JS we call it list not tuple but in python it's tuple so maybe the instructions are going to vary a bit according to language.
Duplicate issue.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
Hi. Please use the
spoiler
flag when posting code in the discourse.In Python, logical
AND
is written asand
, not&
.&
is bitwiseAND
. You do not need parentheses()
around your conditional statements. Again, this is Python, everything is a lot simpler than in other languages. You can write:if <condition> and <condition>:
Ok now I get the idea! Thank you very much and sorry for the missing spoiler flag
For some reason I can't edit my initial message so if maybe an admin can simply delete my message to avoid spoiling other users
I already marked it as a spoiler for you
Cheers.
This comment has been hidden.
Don't use
input
, your function is called in the tests part. You use a loop and access the elements of the inner lists like you do with a single list. Read this: https://docs.codewars.com/training/troubleshooting/ a problem with your code is not a kata issue.JS if i console.log(data) i get empty array in random tests: [[], [], [], [], [], [], [], [], [], []]
And i fail the test because : Expected: '['Open', 'Senior', 'Open', 'Senior', 'Open', 'Senior', 'Senior', 'Open', 'Senior', 'Open']', instead got: '['Open', 'Open', 'Open', 'Open', 'Open', 'Open', 'Open', 'Open', 'Open', 'Open']'
That's because you were mutating the input, anyway, that shouldn't matter anymore.
My solution is correct in 98 of 105 cases and i cant find the issue :C. Any tip?
Please see if you can find anything helpful in this paragraph: https://docs.codewars.com/training/troubleshooting#works-but-no
thx i did it
Nice kata, but in Python, I believe the function should be called open_or_senior, not openOrSenior.
Already fixed.
At some point (probably when the kata was modified to conform to PEP-8), the input data on Python 3.8 was changed from lists within lists to tuples. This means none of the upvoted solutions work as-written anymore.
This is still probably a 7 kyu since the problem can be fixed within the solution, but the instructions are no longer accurate.
Tricky wording with lower handicap meaning a better score, but they ask for a handicap greater than 7, where in golf I'd say greater than 7 indicates less than by the rules of how handicaps are applied value;.
Hi, my answer is the correct but the output say: Expected: '['Open', 'Senior', 'Open', 'Senior']', instead got: 'undefined' and my output is [ 'Open', 'Senior', 'Open', 'Senior' ]
Are you returning the result?
Thanks, I wrote console.log jajjaja thanks
This comment has been hidden.
I really don't know what to return. have never worked with "IEnumerable" or pretty much anything like it. I was using an ArrayList to save the categories and if i try to return it i get an error "Cannot implicitly convert type 'System.Collections.ArrayList' to 'System.Collections.Generic.IEnumerable'"
I don't understand wheather I should give importance to age or handicap value whilst categorising
Both!,use and operator of your language:- JS - && python-and other languages you would have to look up.
This comment has been hidden.
Thanks!
In my opinion isntruction should mention that there are tuples in the list, not lists inside the list.
True
Made description language-independent.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
est.assert_equals(open_or_senior([(16, 23),(73,1),(56, 20),(1, -1)]) these should be list nested in list, not set nested in list
yes input_list=[[16,23],[73,1],[56,20],[1,-1]]
The 2nd sample test for Python appears to have an error. The 73-year-old should be in 'Senior' category.
test.assert_equals(open_or_senior([(16, 23),(73,1),(56, 20),(1, -1)]),['Open', 'Open', 'Senior', 'Open'])
Both conditions must be fulfilled.
Sorry my bad!
This comment has been hidden.
OP solved it, closing
In Rust, the return type really should be
Vec<&str>
. This is considered more idiomatic sinceString
dereferences to&str
.This turns the function signature into:
This comment has been hidden.
This comment has been hidden.
No, there's no list with any certain name. Your solution should return new, filled list, and not use any existing list to fill it in.
Thank you so much, returning the list made it work.
it was not clear how invalid data should be handled.
This comment has been hidden.
This comment has been hidden.
You need to return dataLog as a result from that function
Why is the handicap range from -2 to +26 and the test values exceed +25. Wasted so much time to just change handicap >=8 from handicap >= 8 and handicap <= 26
What language has this problem? Help us help you!
Just had this issue with Python.
For instance random test #2 is: Log [(24, 27), (64, 17), (69, 14), (49, 8)] ['error', 'Senior', 'Senior', 'Open'] ['error', 'Senior', 'Senior', 'Open'] should equal ['Open', 'Senior', 'Senior', 'Open']
Fixed it.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
Hey guys, My code is completely right and so is the answer, but the interpreter keeps saying that my log is wrong. I don't get this "Expected menssage". Can anyone help me ?
Log: [ 'Open', 'Senior', 'Open', 'Senior' ] Expected: '['Open', 'Senior', 'Open', 'Senior']', instead got: 'undefined'
This comment has been hidden.
Check the last bullet point in this point of FAQ. Your code is not right, if it were right, it would pass :)
First, I'd like to thank you for replying. I "debugged" the problem haha. My results were matching the test results but the way my results are being printed out not, then i realised that I was using the console.log() function to print them out. This was my first Kata I'm still acostumed to the console way. Thanks again ! :)
'looks like you solved it'
This comment has been hidden.
Please, don't post solutions in Discourse, it's forbidden. If you want to discuss your solution use Solutions section and remember to use spoiler flag there too.
Sorry was looknig for a solutions section but couldn't find it.
This comment has been hidden.
Why are you mutating the array in place? Don't do it.
But why not, it works 🤷 I pass the basic tests
What would you suggest instead?
Using
map
instead ofmap!
, and about why is that a bad idea, it's simple: you don't know if the data passed to your function is used later in another place, so, mutating or destroying it is always a bad idea. In this case, the control function uses the same data after it passed for your function and because the content has changed, you see that error.ok that's fair enough yes. I still don't understand the ArgumentError though! 🤷
You had an array of arrays with numbers and mutated it to an array of strings:
So, following the example in the description, you're comparing
"O"
to55
sure, but why did the methods .to_i .to_int and Integer(data_item[0])
not work?
also, how is it that that basic tests raked green? 🤷 also, why did I get an ArgumentError only for the comparison with 55 and not the one with 7?
Thank you 😊
Because the control function (not your function, remember yours received good input values) doesn't use any of them
Because they expect a hardcoded result, they don't use a control function.
Because it's the first thing the control function checks and it throws the error and halts execution
In python the tests were expecting the function to be named open_or_senior but the provided code template names the function "openOrSenior".
Fixed.
This comment has been hidden.
There is a bug in your solution, please follow this FAQ to find it.
The user can mutate the input in Python (at least). The expected result should be obtained first.
This comment has been hidden.
This comment has been hidden.
Fixed in Python.
FArekkusu: You also changed the function name, but forgot to change the initial code, could you fix that too?
It seems this happens in Ruby too.
fixed for ruby
Fixed in JS, assume case closed ^^
This comment has been hidden.
You're probably mutating the input.
Can you explain why mutating the input causes problems?
In this case, because the expected value is calculated after you calculated yours and the function tries to access a two elements list inside the original list.
Understood, thank you so much.
Python: Function name should use snake_case as per PEP8.
Fixed.
This comment has been hidden.
No. A Senior is an older player, normally they become worse, not better with the age.
I have an issue related this ['Open', 'Open', 'Open', 'Open', 'Senior', 'Open', 'Open', 'Open', 'Open', 'Open', 'Senior', 'Open'] it is printing this many timees what should I do
Just try to debug your loops and consider and consider inner list as a single node
This comment has been hidden.
Spoiler flag!
Flatmap only works on node v11+, while only node 8 is available for this kata.
Oh, i see, thanks
This comment has been hidden.
This comment has been hidden.
Not only you are modifying the original array which is bad practice, but also your conditional check is wrong. (Re-read the description)
This comment has been hidden.
hi,
it seems like you are returning just a string, but it requires an array of data like
["Senior", "Open"]
.Awesome, thank you. I had a feeling it was something obvious like that.
There is an issue in Ruby. Tests are : Test.assert_equals(openOrSenior([[45, 12],[55,21],[19, -2],[104, 20]]),['Open', 'Senior', 'Open', 'Senior']) Test.assert_equals(openOrSenior([[3, 12],[55,1],[91, -2],[54, 23]]),['Open', 'Open', 'Open', 'Open']) Test.assert_equals(openOrSenior([[59, 12],[55,-1],[12, -2],[12, 12]]),['Senior', 'Open', 'Open', 'Open']) Test.assert_equals(openOrSenior([[16, 23],[73,1],[56, 20],[1, -1]]),['Open', 'Open', 'Senior', 'Open'])
But for the number 3 : Test.assert_equals(openOrSenior([[59, 12],[55,-1],[12, -2],/!\issue => [12, 12]]),['Senior', 'Open', 'Open', 'Open']) data[3][0] return 68 instead of 12 data[3][1] return 7 instead of 12
There is no issue, you're confusing the log you see, it is the input of the next test. The log appears above the test result.
Oh ok, my bad, I understand my mistake ! Thanks for your help
So my output is: ['Open', 'Senior', 'Open', 'Senior'] And the error is: <class 'list'> should equal ['Open', 'Senior', 'Open', 'Senior'] Whoever tells me why this fails gets a coffee on me...
Try with this line:
Tell me what you got.
Log ['Open', 'Open', 'Open', 'Open', 'Open'] It should work for random tests too: None should equal ['Open', 'Open', 'Open', 'Open', 'Open']
Your function is printing instead of returning the result.
There is a mistake in Instructions
"To be a senior, a member must be at least 55 years old and have a handicap greater than 7. In this croquet club, handicaps range from -2 to +26; the better the player the lower the handicap. "
Following this logic - if lower handicap is better, then handicap greater than 7, should be < 7, not > 7
Not an issue, normally when you get old, you become worse, not better, so handicap grows.
Ah, "Senior" here means retired "too old" player, not high-class ? I thought it means high-class player, no issue then. You are right.
This comment has been hidden.
nope.
Agree
Swift translation added.
PHP translation added
This comment has been hidden.
Could you provide a little more information about your problem? Also double check that you are returning the result and not just printing it to console.
This comment has been hidden.
Don't post solutions, it's forbidden.
Ouch. There is no 'delete' button. Hopefuly 'Spoiler' button does the job. Thanks!
My JS code is working on the first one but not on the second and the third. Can anyone help me what could be the problem? It is just weird that it passes once and then it gives me "TypeError: Cannot read property '0' of undefined"...
I think you'd have to have someone see your code to help you debug it in this case. If you do post your code, don't forget to tag it as a spoiler comment. Then, someone may come along and explain your problem.
This comment has been hidden.
return the answer, do not print it. (and never post code without the spoiler flag, plz)
Groovy translation kumited. Please review and approve. Thanks, suic
Already aproved
F# translation:
updated to F# 6.0 + NUnit, using tuples
There are several translations waiting to be approved or rejected:
C++ CoffeeScript TypeScript Java
I didn't make them, but I noticed them in there. Some have been there for 3 years, and are just sitting there. What's goin'on?
java translation needs rejected, see my comment on it
@anter69 can you approve or reject some of these
This comment has been hidden.
Is this your whole solution? Because in that case the code structure is fundamentally wrong.
Is it? But if I put the example input inside the 'member' variable and run the program I got the right output. I think the problem is that I didn't make a function, am I right?
In all katas the tests are performed by calling/analyzing the function(s)/class(es)/variable(s) defined by user. So yes, your solution should be a function.
This comment has been hidden.
Your functions should return in Codewars and next time mark your post as having spoiler content please.
Sorry, I am new. Thanks for the tip, going to see if it works. :)
Testing for [[59, 26], [68, 4], [72, 1], [44, 21], [66, 14], [31, 5], [28, 0], [59, 21]] ['Senior', 'Open', 'Open', 'Open', 'Senior', 'Open', 'Open', 'Senior'] should equal ['Senior', 'Senior', 'Senior', 'Senior', 'Senior', 'Senior', 'Senior', 'Senior'] the random test is wrong it only returns senior in all list?????
oh i solved it, just create a new list and append the outputs there
I'm a brand new user and this is extremely difficult, if anyone could help point me in the right direction, that would be great
loop throught the list given, apply the conditions if conditions were met create a new list and add the output there. hope this helped you
This comment has been hidden.
Please mark your post as having spoiler content next time.
Thanks for the reminder! I will remeber to mark my post as having spoiler content next time!
Brand new user and so confused. I don't even know what the requirement is. Just write the function definition? Write the whole program including sample data? I don't understand at all. How to get help?
you need to learn about loops and data structures first then hopefully you can solve this kata......
This comment has been hidden.
Use the correct capitalization.
:facepalm:
thanks for your time!
capitalization of senior and open
This comment has been hidden.
Next time mark your post as having spoiler content and use proper markdown when posting code in discussion. The input is passed to the function as arguments, you don't need to read them from the keyboard and also your function should return (and it should be a list as the description says), not print.
Thank you! And sorry for the oversight on the 'spoiler' . Won't happen again.
This comment has been hidden.
and have a handicap greater than 7
your code shouldx >= 55 and y > 7
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
In python I am getting a SyntaxError: File "main.py", line 3 test.assert_equals(openOrSenior(return),['Open', 'Senior', 'Open', 'Senior']) ^ SyntaxError: invalid syntax Code works when I run it somewhere else.
There's no issue with the Python version. Something in your solution must be causing it.
The description says to be a senior, you must have a handicap greater than 7. Not 7, but strictly greater. It only took my solution when I allowed handicp to be 7. Need to fix tests or description.
This comment has been hidden.
Not true for me. Worked fine with > 7
I tried to do ipnut checking based on
In this croquet club, handicaps range from -2 to +26
to ensure that we had valid handicaps (as well as an age above 0). But in the random tests I got bad handicaps and was told it failed when I raised an exception. Is this expected behaviour?It seems babies are welcome in this croquet club. Don't do input validation here, not needed.
Looks like it's a bad constraint. Should NOT be explained, since it leads to incorrect solutions.
Every time I submit an attempt the random test returns
Expected and actual are both <System.String[10]> Values differ at index [2] Expected: null But was: "Open"
I am not sure why the random test would return a null, does anyone have suggestions?
This comment has been hidden.
I think that you should add "Don't mutate the input!" to the description.
Ruby conventions use snake_case. Please use snake_case.
Hi Everyone, new to Codewars (liking it!), may Iask for your input?
so when I run the tests for my solution, the Log says.. ['Open', 'Senior', 'Open', 'Senior'] and the warning says None should equal ['Open', 'Senior', 'Open', 'Senior'], which is right?
My results match the output for the tests, but the tests are failing? I am not sure why..? (this is with version 2.7.6 and 3.4.3)
Thanks!
None
is the value that's returned by your function, the expected value was['Open', 'Senior', 'Open', 'Senior']
. Make sure your function actually returns the value, maybe you're printing it.Ah! thank you.
please return the result
This comment has been hidden.
Your function should
return
the array,console.log()
is not the same.It says "the better the player the LOWER the handicap" which actually in mathematical terms would state that it must be < 8 and not > 7 !
This comment has been hidden.
The test does not work for Python 3 at all and for Python 2 random test outcome is always like ['Senior', 'Senior' ... 'Senior'] and the Kata cannot be completed.
Both python versions work fine. Don't mutate the input.
Yup, it works fine for Python 3 when new list is created instead of mutating the input. Thanks a lot!
Hello, the tests seem to be broken for Ruby. My code works fine in repl.it and passes all the sample tests, but when I submit I get the following message:
Expected: ["Senior", "Open", "Open", "Open"], instead got: ["Senior", "Open", "Open", "Senior"]
hi im new can maybe somone help me a little bit im tryin to elarn this programming to start a career when i graduate high school
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
Because this is a two-dimensional array! example: data=[[45, 12],[55,21],[19, -2],[104, 20]] data[0][1]=12 data[1][0]=55
HELP
hey guys! i can't get the final output in one list of strings: this is my output:
['Open'] ['Open'] ['Senior'] ['Open']
it should look like that ['Open', 'Open','Senior','Open']
thanks!
your output seems currently to be a list of lists of strings:
instead of the list of strings you pasted at the end of your message.
hey! thanks!! I'm still getting an error not sure why!!
can i share my function here?
Maybe compile all of your answers into a list in the beginning, and then move it into an array using .ToArray()
list.append() #append object to end
I have a translation for you in F#
Why Senior needs more handicap ?
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This is my first try of CodeWar, when I complete my test function, I cannot find where to test it , when I click "Attempt" button below ,it will pop up a message says "Failed to communicate to code execution service." I am totally new to this tool, so could someone kindly tell me what is wrong. Thanks a lot!
This comment has been hidden.
Correct answer need a list
This comment has been hidden.
for(member in data)
only gives the index of the item in the array, not the item itself. This is shown by printing member (using console.log(data)).To reference the actual item, you must do
data[member]
.To fix this, do something like the code listed below:
Thanks so much for the detailed explanation! I appreciate.
This comment has been hidden.
Update: You have to return the output list instead of printing it.
This comment has been hidden.
I had the same problem. I think you have to do return(answers_list) rather than print(answers_list).
Yep, you are correct. I changed my output list to return and it passed. Thank you.
Mess with your if statement
I am getting the output in the correct format, still it is unacceptable. I don't understand why.
You have to return the output list instead of printing it.
This is my first Kata, so being a beginner Codewars user could have something to do with my difficulty. I welcome your feedback.
When I print the contents (with console.log) of my array of 'Open' or 'Senior' members, I get the correct output. But the Test Results from 'Run Examples' fails. Instead of the 'Expected' output, the Test Results outputs 'undefined.' That's not my goal. Obviously.
What are your suggestions? Thanks!
This comment has been hidden.
This is called a conditional operator. It's basically shortened syntax of an if-statement.
Here's a link to the devdocs explanation http://devdocs.io/javascript/operators/conditional_operator.
In this situation the expression "(member[0] >= 55 && member[1] > 7)" returns a boolean, depending on the value of the boolean the conditional will return 'Senior' if it's true, and 'Open' if it's false.
Hope that helped :)
Yes it does! Thanks especially for the link to the docs!
Random tests are broken in Python 3.4.3
Testing for [[49, 16], [60, 21], [61, 3], [62, 19], [64, 18], [42, 18], [69, 1], [66, 21]]
Every test got TypeError: unorderable types: str() >= int()
This comment has been hidden.
Do not change original input list. Worked for me when i fixed that.
Hey, I'm getting an error when I solve this challenges. I get a message that says 'There was a server issue while sending the request. Please try again'. This is also happening in other challenges. I can't work like this. Any suggestions?
This isn't a Kata issue, but instead a CW issue.
TypeScript translation
The initial tests pass, but are the extended test suite broken for this question?
Testing for [[44, -2], [61, 15], [27, 20], [44, 8], [40, -1], [43, 24], [44, 18]] Log ["Open", "Senior", "Open", "Open", "Open", "Open", "Open"] #<ArgumentError: comparison of String with 55 failed>
>='
block in solOOS'each'
solOOS'block (3 levels) in <main>'
block (2 levels) inI have the same issue. Not sure what I'm missing... the code works perfectly for basic tests but fails all the random tests... from the looks of things there is nothing wrong with my code.
I have exactly the same. My basis tests are passing but then when i try the random tests it gives me that too.. Don't know what to do now..
Have the same issue. Help! I need somebody help!
Ruby version is working correctly.
[[], [], [], [], [], [], [], [], [], []] ? ✘ Expected: '['Senior', 'Open', 'Open', 'Open', 'Senior', 'Open', 'Senior', 'Open', 'Senior', 'Senior']', instead got: '['Open', 'Open', 'Open', 'Open', 'Open', 'Open', 'Open', 'Open', 'Open', 'Open']'
random test cases seem to be wrong
Random testing seems to be broken. Says that it should return an empty list.
me: 86ms Passed: 3 Failed: 1 Test Results: Basic tests Log [45, 12] [55, 21] 55 [55, 21] [19, -2] [104, 20] 104 [104, 20] ✔ Test Passed
Log [3, 12] [55, 1] [91, -2] [54, 23] ✔ Test Passed
Log [59, 12] 59 [59, 12] [55, -1] [12, -2] [12, 12] ✔ Test Passed
Log [74, 10] 74 [74, 10] [55, 6] [12, -2] [68, 7] 68 [68, 7] ✘ ['Senior', 'Open', 'Open', 'Senior'] should equal ['Senior', 'Open', 'Open', 'Open']
whats up with the last part of the test? did you guys have to do this as well? I dont understand the extra number????
your probably doing a comparison wrong. its >7 not =7
This comment has been hidden.
Not an issue ;-)
Ruby translation:
openOrSenior
is a bad method name. Rename it to:open_or_senior
fixed
Tests are broken in Python3 (3.4.3).
Everything is working correctly.
No matter what case in random test, every member is regarded as 'Senior', please help to fix the problem.
Testing for [[27, 20], [81, 0], [42, 27], [46, 4], [46, -1], [61, 9], [65, 26]] It should work for random tests too: ['Open', 'Open', 'Open', 'Open', 'Senior', 'Senior'] should equal ['Open', 'Open', 'Open', 'Open', 'Open', 'Senior', 'Senior']
Why [42, 27] is defined as 'Open' if there only max 26 handicap? Maybe it should be neither Open nor Senior?
Solution is wrong.
I have all the correct answers but it says it "instead got nil"...
It's very helpful to get to know so many implementation. But i will suggest you should also say that the best practice to solve this is using the map function of the array instead of another functions like for and foreach
This code is not working. I HAD the same exact answer as one of the answers and it said it was wrong...
This comment has been hidden.
This comment has been hidden.
The better the player the lower the handicap. So if you are 55 years old and are a very good player with a handicap of 5, you can't be Senior, but if you aren't so good and have a handicap of 10 then you can. Don't you should change it, so a senior must have a handicap of 7 at most? - Regards
If tests didn't be written in the window below my code, i would never guess that THE BAD HANDICAP IS GOOD, THE GOOD IS BAD!
Testing for [[53, 21], [56, 19], [46, 24]] It should work for random tests too: ['Open', 'Senior', 'Open'] should equal ['Senior', 'Senior', 'Senior']
The random tests seem to be wrong. First and last person are < 55 years old and shouldn't be Senior. (Python) In fact, in the random tests, it seems to expect every single person to be a Senior.
Python version is working correctly.
This comment has been hidden.
should a Senior really have a handicap "worse" than 8 ? that is, if he becomes better, he won't be a Senior anymore?
The random tests in the Javascript kata seem to think that >8 is the correct result, as noted by the expected [90, 8] being listed as Open, instead of the Actual case of Senior.
I think I fixed it, but I haven't tried. Could you have a look at the JavaScript tests and resolve the issue if they're fine?
Yep! It's working fine now. Thanks!
I think that one of your edge cases is wrong. In the spec it says that they must have a handicap greater than 7, but when I ran the edge case tests it said that the handicap must be greater than 8.
I assume you were talking about the JS version: if so, it was a leftover from previous versions, now I should have if fixed (the kata author can confirm I am right or not, in case) :)
Yep, it was the JS version! Thanks very much!
Haskell translation kumited. I used the handicap
>7
condition, as stated in the description, not the one in the current JavaScript variant (>8
).As stated by the author in reply to my comment, >7 is now the right version; I'll fix it all within the day adding also edge cases and random tests, so your version is ok as it is :)
A test case and the description conflict:
This is in the JavaScript variant. The random tests also contain one wrong pair:
[90,8]
.Problem has been solved. Thanks.
This comment has been hidden.
I've made an adjustment to the problem stating >7 rather than >8. Thanks
This comment has been hidden.
Too few test cases for now: if you wish I can easily add a good load of random tests to complete the kata.
Also, your solution is probably wrong if you meant literally "greater than 8", as you put >7.
That would be awesome if you could. Also I've edited the details to specify that a Senior handicap is >7 rather than the original >8. My bad.
Give me 24 hours top and I'll fix JS and Python version adding edge and random tests and possibly will also submit a Ruby version.
Ruby translation submitted, Python random tests added and I assume you did yourself the random tests on JS; let me know if you need anything else :)
Just as a friendly reminder, but my translation and bkaes-senpai's are still awaiting validation, provided they are ok with you.
"To be a senior, a member must be at least 55 years old and must have a handicap of greater than 8" should be changed to "To be a senior, a member must be at least 55 years old and have a handicap greater than 8"
Edited. Cheers.
JS translation kumited.
Thanks for that Zozo. Just approved the kumit.