First line run, minimum of arr is 1, arr.index() returns the first index (searching from the left) of an occurrence of 1, which happens to be 0. m gets 0.
Next, sorted() is called on arr and returns a new sorted array, [1,1,2,3,4]. On the other side, arr[m:] with m=0 becomes arr[0:] gives [1,2,3,4,1]. arr[:m] with m=0 becomes arr[:0] gives []. [1,2,3,4,1]+[] gives [1,2,3,4,1]. [1,1,2,3,4] == [1,2,3,4,1] evaluates to False.
Also, I forgot to add: there is a #help-author channel on the Codewars Discord when you can ask for help/advice, or get people to review your draft katas before publishing them; this can help you iron-out any early problems (and also determine if your idea is judged "interesting" enough before you spend hours working on it).
Note also that you can read the Test Cases of any kata you have solved - recently approved katas, or ones with high approval ratings can be a good source of inspiration if you want to get a feel for the Codewars test suite, and good practices (it's how I figured this stuff out myself).
Best wishes for your kata authoring in future, I hope you stick with it!
this is a HUGE help, obviously for this Kata but also to understand for future Katas. If I can get this process down I think I'll really enjoy writing them :)
hello sir-- I wrote random tests but not sure about the syntax to execute-- would you help me please? It's my first Kata and I can't find the syntax in docs/Google...
Many thanks in advance!
The python code works fine, but the test execution syntax is throwing an error:
File "/workspace/default/tests.py", line 45
test.assert_equals(matt(test_list[0]), solution(test_list[0])
^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: invalid syntax.
@test.describe('Random Tests')
defrnd_tests():
test_list= []
lotsofcharacters='1234567890!@#$%^&*()abcdefghijklmnopqrstuvwxzyABCDEFGHIJKLMNOPQRSTUVWXYZmattMATTmattMATT'defgenerate_some_test_strings():
# our new stringnew_string=""# picks a random length for stringlength_of_string=randint(2, 10)
# picks random characters according to the length of the stringforiinrange(0, length_of_string):
new_string+=lotsofcharacters[randint(0, 71)]
test_list.append(new_string)
# generate 10 random string to test againstforiinrange(10):
generate_some_test_strings()
test.assert_equals(matt(test_list[0]), solution(test_list[0])
test.assert_equals(matt(test_list[1]), solution(test_list[1])
test.assert_equals(matt(test_list[2]), solution(test_list[2])
test.assert_equals(matt(test_list[3]), solution(test_list[3])
test.assert_equals(matt(test_list[4]), solution(test_list[4])
test.assert_equals(matt(test_list[5]), solution(test_list[5])
test.assert_equals(matt(test_list[6]), solution(test_list[6])
test.assert_equals(matt(test_list[7]), solution(test_list[7])
test.assert_equals(matt(test_list[8]), solution(test_list[8])
test.assert_equals(matt(test_list[9]), solution(test_list[9])
not so much guessing, but perhaps extrapolating or deducing...
but anyway, if you've learned about numbers a bit, and you stare at the sample tests critically enough, the formula just leaps out at you
Reraised as issue with more detail
Fixed by last python update.
finally approved :)
First line run, minimum of arr is 1, arr.index() returns the first index (searching from the left) of an occurrence of 1, which happens to be 0. m gets 0.
Next, sorted() is called on arr and returns a new sorted array, [1,1,2,3,4]. On the other side, arr[m:] with m=0 becomes arr[0:] gives [1,2,3,4,1]. arr[:m] with m=0 becomes arr[:0] gives []. [1,2,3,4,1]+[] gives [1,2,3,4,1]. [1,1,2,3,4] == [1,2,3,4,1] evaluates to False.
.
A bit late but i have now approved it!
oh hell yeah, I'll join it, that sounds like a much better workflow
Also, I forgot to add: there is a #help-author channel on the Codewars Discord when you can ask for help/advice, or get people to review your draft katas before publishing them; this can help you iron-out any early problems (and also determine if your idea is judged "interesting" enough before you spend hours working on it).
You're welcome, glad it was useful;
Note also that you can read the Test Cases of any kata you have solved - recently approved katas, or ones with high approval ratings can be a good source of inspiration if you want to get a feel for the Codewars test suite, and good practices (it's how I figured this stuff out myself).
Best wishes for your kata authoring in future, I hope you stick with it!
this is a HUGE help, obviously for this Kata but also to understand for future Katas. If I can get this process down I think I'll really enjoy writing them :)
This comment is hidden because it contains spoiler information about the solution
hello sir-- I wrote random tests but not sure about the syntax to execute-- would you help me please? It's my first Kata and I can't find the syntax in docs/Google...
Many thanks in advance!
The python code works fine, but the test execution syntax is throwing an error:
thank you! I'll fix it up :)
Loading more items...