7 kyu
Rotate for a Max
2,955 of 11,106g964
Loading description...
Algorithms
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.
in the future, please do not use the
issue
tag to ask for help and use markdown to post your code (see there).Debug your code. I added this line to your code, and this is what I see for
n = 56789
:whereas the proper rotations of
56789
as shown in the description are:description is a bit wonky but was a neat problem
racket is cool yall
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
pefrect presentation of the bubble sort in some kind. but first i was very frustrated.
i dont get it... the instruction quite clear for the first example "56789". but how "max_rot(38458215) should return 85821534"? isn't it suppose to be:
38458215
84582153 (rotate left)
85821534 (hold first number) --> this is the answer, so i should stop here?
85215348
85253481
85254813
85254138
85254183
The description says that you have to return the largest of all the generated numbers after doing all the rotations. As 85821534 is the largest number, that is the one that you return.
I think this question is resolved since OP didn't reply
based Shiroko pfp btw
nn
nice kata,It was difficult for me but I learned a lot. One question: Does Codewars accept or recognizes js method toSpliced()? I needed to change it on other one...
check the Node version in the language version dropdown for JavaScript, then check the compatibility status on MDN
After a lot of attempts, i returned to this kata and solved, im glad.
Nice kata. Advice for warriors: you should be attentionally with reading description =)
Good one, but def harder than 7 kyu.
I am getting this error For n = 38458215: 84582153 should equal 85821534 For n = 195881031: 958810311 should equal 988103115
for first 2 test cases that next two test cases are passed my logic was to store each rotation in the rotations list to keep track of all the numbers generated.
You should read the description again on how the rotations should be applied. Your algorithm rotates the whole number and that is not what is asked for here.
Thank You
always tend to get stuck on katas by g964 so much so that everytime i see their question , I go - 'argh, here we go again' . great exercise for the gray matter :D
feels like 6kyu to me. I am noob tho
This comment has been hidden.
This kata is a good one, you just need to focus, at first you will think that the kata is wrong, but after careful consideration, you will know how to solve. The random test cases are near perfect.
Test shows that 99249557 should equal 507992495, really?
Your code returns a wrong result,
99249557 < 507992495
Thanks, im got my mistake!
Chrono79, a thanks from me too.
Good kata, beginners might struggle with this one since they may not understand what "rotating" the number means. But once you understand the rotating factor, the kata becomes particularly easy.
This comment has been hidden.
A problem with your code is not a kata issue. Print the input to debug your code.
Nice kata. Maybe a bit difficult for beginners though.
Nice kata, it's easy, just look carefully at the description!
Thanks!
For all the whiners, yes it's a bit challenging, but over all it does fit 7kyu lvl, so keep your mind sharp and attention to details even sharper. It's easier than some of the 7kyu katas' i've seen. All good, and may the force be with you.
Very satisfiying once you solve it. I finally solved something with recursion and it was this problem :)
The description of this problem is really bad
Sincerely, everyone.
I've seen worse. Besides test cases are there, so you could derive from those.
This comment has been hidden.
Your code already gets IndexOutOfBoundsException. When I fix this it fails for two-digit numbers.
This comment has been hidden.
Asking for help is not a kata issue. Notice at the top of the page how many people passed the Kotlin kata.
That's not Rotate means......
This comment has been hidden.
Take the number of the example, pass it to your function, see the numbers you get, find what you're doing wrong.
.
I actually solved the test cases before posting this question. So I am not asking about how to solve the prolem. My question simply is: "why does the second sequence you gave not fit the description of the kata?" but not "how do I write a function to get like that sequence?" In other words, I am asking why does the first sequence you gave fit the description, forget about the code.
I put a question instead of an issue, out of respect, in hope to get an answer. But the question was not answered, and was marked resolved. At this point, I lost every hope to question the descritpion and get a fruitful result. Never mind.
To answer: "why does the second sequence you gave not fit the description of the kata?"
The sequence consists of repeatedly performing the given operation on the result of the previous operation, whereas you are performing some kind of string slicing with
i
on the same, initial strings
.e.g., using the Description example:
It Rust tests generate a warning:
Modified though not being the Rust translator who has left CW. Please could you give it a try?
I suppose the issue resolved.
missing a lot from the description!!!
overcomplicated
Description should have been better, I thought the original number shouldn't be considered while calculating the max number. This should be a 5 or 6 kyu!
The original number is in the sequence in the description, isn't it? Why did you think it should be excluded?
It is present in your example, but it is not part of a rotation, i mean we are not doing any rotation to find that number, but it was just my assumption and I realized it. why don't you add an another example that replicates the scenario we discussed, I mean it makes things clear!, Anyways Good challenge, I liked it
Not my kata, but maybe adding an example where the original number is the greatest could help clarify that.
@balu9: "Identity" is a rotation in the same way that "Identity" is a permutation, etc... You can find this example on the Internet:
Interesting but for me it was quite difficult and I think it's closer to a 5kyu or 6kyu.
so bad desc
true and real
Fixed.
I have an issue with tests in java. The function's input type is long, but the test's input is represented by java compiller as integer. Could you please do soomething with tests for java?
16130873362142 cannot be represented as a 32-bit integer (type int). It can be represented as a 64-bit integer (type long). long literals in Java end with an "L": 16130873362142L
There is nothing to do; the test is with 16130873362142L. Note at the top of the page that Java is passed by 1338 people.
Thanks, i've found my mistake! ;)
Getting the following error. Why max_rot(rnd) should return "r"? n should be a positive digit.
Traceback (most recent call last): File "/workspace/default/tests.py", line 62, in randomTests() File "/workspace/default/tests.py", line 60, in randomTests testing(max_rot(rnd), r) File "/workspace/default/solution.py", line 8, in max_rot str_n += str(n)[i] IndexError: string index out of range
r
is a var that contains the expected value, the problem is in your code, in this line to be exact:Not a kata issue.
I'd like to have more tests because my code works well on tests but when I try to attempt it fails, it would be nice if I could see a default number and not just what the result should be
https://docs.codewars.com/training/troubleshooting/
Print the input.
my absolutely wrong PHP solution (its not even a solution, i was just testing functions) somehow pass all cases
This comment has been hidden.
Tests modified. Your solution is invalidated. Thanks for your post.
This comment has been hidden.
Banning specific operations, changing ranks and changing solution setups are too late as it will invalidate all solutions & require change in all languages
good kata
Thanks!
This comment has been hidden.
Good observation!
Cool kata with Strange description))) Thank You!
Node 12 should be enabled (Refer this and this for more info)
Python new test framework should be used (Refer this & this for more detail)
Ruby 3.0 should be enabled (Refer this & this for more detail)
Typescript 3.3 or above should be enabled, refer this for more info
.
This is not a 7kyu kata. 6kyu min
This kata has greatly improved my knowledge 💪. I am very happy! Thanks to the author 👍!
Issue was marked as resolved by author without any change to the description.
Here's a suggestion to improve the description:
An example is not a spec. "Doing rotations similar to the above example" is too vague. "the maximum number you got doing rotations"; how do I "get" a number "doing rotations"?
Are you kidding?
Part of my description:
Your proposition: (Here's a suggestion to improve the description:)
Moreover you quote "the maximum number you got doing rotations" is wrong.
Did you intentionally forgot to read what I wrote below the literal quote from your description on how to improve that part of the description? Or are you just creating a pretext to ridicule me and avoid improving the description?
I'm done with this.
Absolutely not! I am sorry if I gave you that feeling. I have carefully read all your post. When authoring the kata I thought that for a simple kata an example was better than a purely mathematical description that would have been cumbersome to write and to read.
This kata's description is not even close to a proper spec. The number of people that already solved the kata does not change that fact. Please put at least some effort into it. For a 7 kyu kata, it's not fun trying to discover by trial and error what exactly is asked for.
It is your point of view, not mine.
Until now and as far as I know nobody complained about the description.
Instead of complaining it would be more interesting if you had proposed something better from your point of view.
A lot of people complained about the description, just scroll down. I must admit, it is indeed rather confusing. What would "rotate left" mean if there was no example? IDK, there are a lot of ways to interpret the word "rotate".
I can propose. Just change the number in the description to something which is easier to follow.
123456
for example.123456 -> 612345 -> 6 51234 -> 65 4123 -> 654 312 -> 6543 21
You can't be serious, or you've "forgotten" that already multiple people complained about the description. And you quickly mark it as resolved without changing anything.
As an author it's your responsibility to write a proper description, not mine. I can't figure out in a reasonable amount of time what the requirements are, how am I supposed to suggest an improvement then? I will make a new issue with a suggestion.
@MikChan
I had scrolled down and I have seen some people complaining e.g "WHAT IN THE WORLD IS THIS DESCRIPTION"... I know that my English is not of first quality (which is saying little) but this kind of critics doesn't bring much.
First: the description begins with "Let us begin with an example:" and the example follows where we rotate left. Second: when reading a book if I don't understand a word I take a dictionary or I google the word ("rotate left" 183 000 000 results, yes it'a bit long...)
My example was with "56789"; I don't see a big difference with "123456" except your presentation
123456 -> 612345 -> 6 51234 -> 65 4123 -> 654 312 -> 6543 21
. Interesting but I would be afraid that in6 51234
some well intentioned people see two numbers6
and51234
...Nevertheless thanks for your contribution and best regards.
Nevertheless, a lot of people do complain, that's just a fact.
Well, nothing stops you from removing spaces or adding the remark that they're there only for better visualization. The main point of confusion is there because the description completely relies on the example, and the example is very difficult to follow. I know that because I faced this problem myself while solving this kata. Of course, it's solely up to you, but I don't think adding more clarity in the description would hurt. At the very least, it would prevent the creation of issues like this one.
Your example is totally different from the one in description and it follows a different rotation pattern!
This comment has been hidden.
Not a kata issue, you have to use the CW version, sorry. You can ask CW to give the PS 7 version.
Okay. Is it possible to provide a more descriptive error message then? I mean, "Error occurred in test script './test.ps1'" is not particularly helpful.
It's not kata fault. In such a case it's the output of CW PowerShell runner. Try to use your code online and see if you have a more explicit message. I think you should replace "&&" by "-and".
Thanks for replying. I already solved the kata. It turns out PS 6 didn't have logical && and ternary operators which I used. I understand that kata itself has nothing to do with it. It's the random tests. I was under the impression that kata's author verifies or at least can view those.
No, your kata failed even with "Sample tests" (I tried it; when changing "&&" to "-and" there was no more "Error occurred in test script './test.ps1'").
Yes I can see the random tests but I have no power or what the CW PS runner returns when your code is executed.
Edit: you can report a bug and ask for the last version of PS at https://www.codewars.com/topics/bug-reports.
Thank you. I'd also appreciate if you can help me figure out which of the tests fails for me on your other kata called "All inclusive?" https://www.codewars.com/kata/5700c9acc1555755be00027e
Bad description... But then again, I don't expect anything more from g964....
Not an issue of the kata (passed by more than 6000 people).
This comment has been hidden.
In Instructions nothing, what should i do with zero. If 0 is first, then delete?
If 0 is first, like in '10' and '01', which one is greater?
Rust translation
Approved, thanks for all your work:
Where's the love for Prolog ? ;-)
In pause for now. Kata approved.Thanks for the post.
Fun kata :-)
Thanks! Maybe you can translate it to Rust?
Sure thing :-)
This comment has been hidden.
I have the same problem. In case you haven't figure it out, you have to pass the inital number in to the array.
Cheers.
This is not for help solving the probem. My function is correct.
The issues are in randomized tests: My value is greater than the expected value, as seen below:
Expected: {4635994101} But was: {6359411940}
Expected: {962193428} But was: {994286132}
Without the input, how can we (or you) know your results are ok? Print the input: https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution
Please help!
I have passed the test case but stuck on random test. Please see the output of the random tests below:
Time: 6080msPassed: 0Failed: 2Exit Code: 1 Test Results: max-rot Fixed Tests Should Pass Fixed Tests
Expected: {962193428} But was: {994286132}
Stack Trace Completed in 686ms Completed in 686ms Random Tests Should pass Random Tests
Expected: {4635994101} But was: {6359411940}
Stack Trace Completed in 198ms Completed in 198ms Completed in 884ms
Language is PowerShell.
Asking for help is not an issue, sorry.
This is not for help solving the probem. My function is correct.
The issues are in randomized tests: My value is greater than the expected value, as seen below:
Expected: {4635994101} But was: {6359411940}
Expected: {962193428} But was: {994286132}
testing(max_rot(38458215), 85821534) testing(max_rot(195881031), 988103115) testing(max_rot(896219342), 962193428) testing(max_rot(69418307), 94183076)
These test cases make no sense... the bottom 2 only move the number once and the first two moves twice
921934286 should equal 962193428 91830764 should equal 94183076 511728027 should equal 571172802 452257820 should equal 452782025 665682451 should equal 666824515
While these dont even move the first number to the end. What is it that youre asking for????????
You're not rotating in the general sense that all positions keep their same place beside each other when rotating. The example shows that you move the first number by index to the back (store this number), then move the second number by index to the back (store this number), then move the third number by index (store this number),etc. Take the max of the stored values.
Yeah that didnt explain it at all lol
Read the instructions again, apply the steps listed there:
You have to pick the maximum number between all those.
In all your error messages:
Print the input, see what your code is doing wrong.
WHAT IN THE WORLD IS THIS DESCRIPTION
What is it that I'm not getting? I passed the Test but he Attempt fails (with 100+ successses and 100+ fails)
I inserted a code to see which number is the input and sometimes the programs expect to have the input as the solution. For example one of my fails had an input number of 62383480048545 and the result was saying "28480048545633 should equal 62383480048545"
What am I not getting there?
What language?
Python
EDIT: I actually found what I was doing wrong. I didn't include the initial input as a possible return value.
This comment has been hidden.
You do all steps listed in the instructions and return the greatest of those numbers.
greatest in value?
Yes.
please stop allowing rubbish katas like this one on the platform rubbish description as many people have pointed out ruins the experience
gold!
Very enjoyable, i don't know why people complain...
This comment has been hidden.
If I change my loops to while loops, since it seems to not be adding all the number options, it throws an error saying there is no length method for an integer, but I check the m variable, it shows it to be an array and I don't do anything to it to make it not an array, so I'm not sure why it isn't working? Thanks for any insight.
Elixir verion at this moment is broken. When I run
Attempt
tests I get:That error came from module prepared by author.
(=> code issue.)
Are you returning the wrong type? Post your code for help.
I'm not sure how
to_charlist/1
defined in Kernel can be undefined :/ I took a look at the tests, but didn't see anything obvious. I wasn't able to reproduce the error using your solution either.I also cleaned up the test output so try again and report back if still happens.
This comment has been hidden.
I just tried your solution and couldn't reproduce it.
It's just failing tests like:
Do you see output like this or is it always
CompileError
? Maybe try resetting (after saving your code somewhere)?@kazk: I get the same kind of ouput with Koziolek's code.
That's really weird :/ I just reformatted the test code to get the exact line number. Can you try again and see if the line number in the compile error changes?
Also, can you use the browser's dev tools to see which language version is sent? It might be related to https://github.com/Codewars/codewars.com/issues/1909
@Koziolek
I found the cause.
Can you try again after reselecting the language version? (just select the language version again even it says 1.9 already or try resetting) Your solution is executed using Elixir 1.2 because of https://github.com/Codewars/codewars.com/issues/1909
@kazk ok – now it works fine.
Description is a little vague, though difficult to succinctly describe the question. Maybe update to say something along the lines of: Given a number, rotate the first digit left to the end of the number (12345 becomes 23451). Continuing rotating the first digit left for the length of the number up until the second to last digit (1234 eventually becomes to 45123). Given the new numbers (12345, 23451, 34512, and 45123), determine the largest value.
That was not the task. You have to keep one more number at the front after every rotation.
Are these test cases wrong?
Shouldn't the output for the first one be something like 85254183? The second one 981318105??
I am able to get these solutions if I set the rotate limit to 2 instead of length(n)-1, but that is not what the description says
I just saw that a few other people posted the same comment earlier. It looks like you have to return the greatest number out of all of them. The example should be modified so that the LAST rotation isn't coincidentally the answer, as it can be read interpreted that the last iteration is the answer instead of the greatest number.
Unacceptable bad description...
really bad description
I'm getting a Java 43 error stating that there's a possible lossy conversion from Long to Int. The description is pretty clear that the input will be an int, yet the tests accept Long inputs. I can change all of my types in my internal methods and then cast to an Int in the end, but that seems silly. Is this by design or something that made it's way into the Java version by mistake?
The description says that n is an integer. Long are integers and the given signature of the function is
Cheers;
Thanks for the quick reply. I haven't the foggiest why I would do this, but I must have changed the return and parameter types immediately once I got them into my IDE.
The kata statement says nothing about integer overflows.
I.e. an input like '8999999999999999999' which fits int64 (golang user here) after the first rotation becomes '9999999999999999998' which overflows and now is -8446744073709551618.
Depending on how we treat the overflow 9999999999999999998 is either the answer (it is a clear max) or not (it is now negative).
Good point but you can't have input as
8999999999999999999
neither in fixed tests as you can verify nor in random tests since then
value in random tests comes fromint64(random(100000, 100000000000000))
. I can be wrong but I think there never is overflow. Thank for your post and cheers!rotate for max... again the objective was not clear... i thought it meant rotate digits through the terminating digit. in fact it means you collect ALL of the intermediate numbers too, and then among them (AND the original n) return the maximum.
Did you read the example given in the description?
I just re-read it, and it seems clear enough.
But I had read it before doing it. Maybe I didn't read the digits correctly.
Dont solve this kata, in my case i used pop and append, and digits magically increase in the test cases -- also, on some of them which digits do not magically occurr, I test them locally and they work fine.
i can't understand, what's problem. "String index out of range: -1". Can someone help me?
The description only says to rotate four times, it doesn't say to continue the pattern over the lenght of the number no matter how long. Please consider updating the instructions for those of us that take insturctions very literally. :) Other than that, nice kata.
Rotate four times is only for the given example. Please can you say what I should add.
Something like:
"The number of rotations required is one less than the length of the given number. The example above is five digits long, so it requires four roatations. 1234567 is seven digits long, so it would require six rotations."
Thanks again for your commitment to creating and improving katas.
Slightly modified the description. Thanks for your posts.
Can someone help me in this Error. Expected 452782025 but got 405225782 What is the starting number for which i am getting this error so i may exactly know the bug in my code.
Print the input.
thanks new to this site, so didnt knwow about this. Well i got it, and problem solved.
The condition should be explained more specifically. Why in example 5 and 9 swapped?!?!
Hi, the sample test works fine for my solution -> nevertheless 1 of 22 test crashes whenever I try to attempt the code. Because there is no usefull log of the test result, I can't see which test fails and why. Is it possible to get more information about the crashed test?
Which language? If it is C (I looked at your languages) you usually have something like
Error. Expected ... but got ...
. Anyway you could print the input.Hello, for input containing many zeros like 1020 you could have two possible ways of dealing with it: (1) 1020 -> 0102 -> 0210 -> 0201 or (2) 1020 -> 102 -> 120. You chose the case (1) but it doesn't have to be obvious. Maybe consider adding a second example to the kata's description to leave no space for doubts. Regards
why 38458215 equals to 85821534 after maxRot? I cant understand the task. if we move one position to the left we will have: 8 4582153->85 821534->852 15348->8525 3481->85254 813->852541 38->85254183
It requires the max number during all these steps instead of the final result.
I saw my mistake
Thanks paradox, i need to read the description slower xD
for c language; I passed all the test case, however, when I attemp it, there is one test case case I can't passed it. It's said: "Excepted 6387336214110 but got 1817467955"
How should I slove this problem?
This comment has been hidden.
Not a suggestion, one can consider it logically regardless of number of iterations
This comment has been hidden.
I am worried but 5 guys passed the kata, it's not that much (but for Ocaml not that bad since not many guys practice Ocaml at CW). I tried several solutions and all worked fine. The Ocaml translation was validated without any problem.
Nevertheless I slightly modified the "Submit" tests and your solution should pass now. Please tell me if it works now.
Thanks so much for the help! My solution passes now. I appreciate it.
The description is pretty difficult to get through as non-visualizer since 'rotate left' actually means moving a particular digit to the end, the right. But easy to implement once understood.
The description only says you should rotate three times, it doesn't say rotate over all the digits. Nor does it state bounds such as being >= 0. And it doesn't mention that the original number should be part of the maximum.
Thank you for explaining! I was able to figure it out once I read your comment.
Thank you! I didnt include the original number !!! Excellent.
This is pretty difficult for a 7 kyu kata.
Thanks but as you know I am not the one who gives the kyu...
Yeah, I know there's not much you can do about it. I was leaving a note for others who find that this is harder than they might have expected. So they know it's not just them.
I concur. I've been scratching my head for hours. I'd rate this 6 or a 5 honestly. Good challenge, though.
This comment has been hidden.
Hi, does anyone know how to print debug output for the C++ interface? cout << "test" << endl; is giving me a JSON error ... I'm just starting on testing C++ 14 on this site and I'm sorta helpless :)
Thanks mate for your reply! I was: using namespace std; so namespace resolution shouldn't have caused problems, I guess it was just some bug in the interface at that time, it worked ok in the days later. And I know that "using namespace" is frowned upon by some, but I'm here just for fun, not production code ;)
This comment has been hidden.
The tests are the same in all languages and 1594 guys passed the kata (52 with C) as you can see at the top of the page.
.
Needs fixed checks for edge cases like ints of "size" 2. My first solution was wrong for such ints but was able to pass the tests!
99249557 should equal 507992495 This was a pain. The details could be more clear on including the original number, and no it does not say that. It's frustraint when original tests pass and it fails due to a random test not outlined originally when you submit it. I see many opthers had a hard tiem with this too. Just a lttle clearer on using the original number as well.
Seems like there's something wrong with the test. maxRot(441142049) should return the value 414204941 as the answer -- and it does but I still continue to get this error. "Failed asserting that 414204941 matches expected 441142049."
There are no errors in the tests. 122 guys passed the PHP kata. Do you think that 414204941 is greater than 441142049?
When I execute the random tests every 32nd test case run will fail. "Time: 17ms Passed: 31 Failed: 1". I have printed out the input value in these cases, added it to manually executed tests, and each time was able to to run the test succesfully. I'm wondering why it's always 32nd executed test case which fails... I wrote the code in C.
I tried a few solutions and saw no problem. What are the input and the output for this failing test?
****************** Random Tests **** maxRot input: 376550431 ✘ Test Crashed Exit code: 0 Signal code: 11
If I execute the test manually it will succeed dotest(376550431, 765504313);
It doesn't seem to matter what is the input on every 32nd random test, it will always fail.
This comment has been hidden.
Typescript compiler can't compile anything because of the following error:
It doesn't even compile a blank function that's there by default..
Maybe it was a CW problem, I just tried and it worked fine. Could you try again?
Still not working, same error
solution.ts
is your code.In my case it helped to just write
public static maxRot(n) {
instead ofpublic static solution.G964.maxRot(n) {
.Hi.
Does anyone have a clue, how I could debug exceptions?
It just says this:
Fixed__Tests ✘ Caught unknown exception Random_maxRot Log
Locally, I compiled the code, it runs fine even with big numbers.
Thanks!
Don't post an issue, it's not a problem of the kata, 120 guys passet it in C++. You could have a problem with your code. Try to print the input to see where that happens.
This comment has been hidden.
Python
Does "99249557 should equal 507992495" in the test output mean max_rot(507992495) should output 99249557?
max_rot(507992495) = 99249557 when I run my function locally, but errors in the test case. Could there be an issue in the test case due to the leading 0?
226 guys passed the Python kata and 1074 all languages where the tests are all the same so I think there are no errors in the tests. "99249557 should equal 507992495" means that your result is "99249557" instead of a correct result of "507992495".
I have the same problem, I have written cata in C.
I used C++ to accomplish the function. There is a problem when input is '099249557' . When the input save as 'long long' type , the first alpha '0' will lost. Is there are any other solution ? Or it just the bug of test examples?
There is no bug, the'0' is lost...
What do you mean about 'There'. Is my function or the test example?
There is no bug in the tests. As you could have seen at the top of the page 114 guys passed the C++ kata and 1057 in all languages; the tests are the same in all languages.
Ok,Thanks! I'll try to solve it
This comment has been hidden.
This comment has been hidden.
I am having this same issue, I think there is some bug with this KATA, How can you return 507992495 when input is 99249557 ? It passes 12 test cases but fails in 1 and say expected 507992495 for 99249557 ?? they dont even have same length
I suppose your language here is Python... Could you post exactly the failed tests (lines between 3 backticks at the beginning and at the end)? When input is
99249557
Python reference solution outputs99249557
. Moreover as you could have seen at the top of the page 250 guys (out of 1217) passed the Python kata; the fixed tests are the same in all languages.Hello, can you please fix test cases.
Wrong : testing(MaxRotate.maxRot(38458215), 85821534);
Right answer is - 85254183
There are no error in the tests, sorry. How do you have negative numbers?
Sorry for misunderstanding. I've missed the word "greatest". Thank you.
In the future, look at the top of the page where you can see that more than 900 guys passed the kata. If a test was wrong somebody would have seen that, no?-)
Having the same problem, can you help me out? what do you mean by that?
This comment has been hidden.
Print the input.
I think the description should changed to explicitly state that your code should consider "n" itself when returning the largest number. It's very frustrating to write a solution that passes all of the initial tests, and then fails on some of the random tests - especially for newer programmers.
Look at the example in the description:
You clearly see that the initial number
56789
is considered.Sure, it's there, but it's very easy to miss. No harm in making it more clear, right?
This tripped me up too. While it's true the initial number was considered in the description, I also didn't interpret it that way. No worries.
I keep getting "Caught unknown exception". Anybody? No idea. It compiles and runs when I compile it in DEV-c++
Visual Studio 2015 also works flawless. Admin, help!
I tried a few solutions and had no problem.
This comment has been hidden.
What's more tests work flawlessy, this issue happen when I try to submit.
The Typescript version of this test has errors; the "reference" syntax at the top is wrong. It should be
not
I can fix it in the visible test cases, but when I go to submit, I'm hosed.
I know that and told the bug to the staff. CW adds this stuff which it is not in the kata! I just corrected it. Hope everything is fine now, please tell me if it works!Thanks for your post!
wow, worked fairly hard for this one and test cases have errors... now what? that kinda sucks.
I was thinking the same thing then I realized I wasn't storing ALL the values to compare. Make sure you're looking at ALL possible combinations in order to come up with the answer.
may want to give a bit of context because I had no idea what rotating left for numbers was until I looked it up: https://en.wikipedia.org/wiki/Bitwise_operation
Just learned clojure, any longtime clojurist that can check my style? :)
http://www.codewars.com/kata/reviews/56a48bc7272cb4e0f000003c/groups/56d7041c3e818628fd000c87
I like
rot
androtn
, but I'm looking for a more elegant cycle in theall-rot
function.I get in random tests (python): 99249557 should equal 507992495 99249557 has 8 digits 507992495 has 9 digits
my code claims that max is 94955792
All other random tests did pass. Is there a problem with this specific test?
Please could you post exactly the output of the test?
99249557
gives the following sequence:[99249557, 92495579, 94955792, 94557929, 94579295, 94572959, 94572599, 94572599]
so your answer is not the good one which in this case is the number itself. Lots of guys (and a few of them excellent programmers) passed the kata without problem. I think you forgot to consider the number itself. As for the answer507992495
I can't understand where it comes from. Tell me please if you succeed with the small modification.This comment has been hidden.
Thanks for your answer!
Same problem :/
Same problem :c
in typescript I have the same problem: Fixed Tests: expected 99249557 to equal 507992495 Random Tests: expected 277415286 to equal 826774152 277415286 gives the following sequence: [277415286, 774152862, 741528627, 745286271, 745862712, 745827126, 745821267, 745821672, 745821627, 745821627]
GUIg: you're confusing the error message meaning and without the input value there isn't much we can do to help you. Starting with 507992495, all rotations are these
You can see 507992495 itself is the max value there.
The first value in the error message is what your function returned, not the input value, to see that value, you should print it yourself.
I think default test case for java in case
is invalid.
for input
869219342
expected is962193428
but the most of result of maxRot should be start with6xxxxxxxx
I can't see where you found this test case:
MaxRotate.maxRot(869219342)
Sorry, may be is my fault keyboard typing.
This comment has been hidden.
Sorry for that, it is my mistake with a bad copy and paste. Hope it's fixed now, please could you try again and tell me if it works? As a side note, Clojure is not much practiced here so if I make mistake! Thanks for your post (the first line would have been enough:-)
Fixed! Thanks a lot!
This really doesn't seem kyu7 difficulty to me. At least not for JavaScript. kyu7 is a beginner tier. This is deceptively complex and requires caching results, type conversion, custom value based sorting, and a decent amount of manipulation. Add in the fact that the description is implicit instead of explicit for things like including the original value in the sort options and you are just going to frustrate someone who is at a kyu 7 skill level currently. This should be at least a 6.
This comment has been hidden.
You don't need to convert numbers. You can also do it with integer modulo and division (although that's a bit more tedious to write). And you don't need to keep any lists, sorting, etc. Just keep track of the largest number as you do each rotation step.
I have had one too many sleepless nights trying to solve g964's various mathematical riddles. When you start one of his challenges, you'd better have lots of free time in your disposal. Having said that, I tend to agree that this kata is just a bit too much for a 7kyu.
Complete agreement. I decided. Using the debug all turns out, but tests are not the same. And I do not understand the example in the description. Why did you move 5 and 9?
passing 150 tests but failing on some number. "2642376522401 should equal 2642765224013" ??? That's obviously wrong!
So now I'm printing the input number with my result so I can compare when I get these errors and it appears there is something wrong with the test case:
My output: 36191144385332 and the max is 69144385332311
Error: 69144385332311 should equal 69148533231143
The one consistent thing about this error is that my max result matches the begininng number in the error message. It's very random so I'm passing anywhere from 44 -150 tests before this comes up.
563692037 563692037 and the max is 669203753 Test Passed
159043701 159043701 and the max is 590437011 Test Passed
896304934 896304934 and the max is 963049348 Test Passed
273293210 273293210 and the max is 732932102 Test Passed
451496516 451496516 and the max is 549651641 Test Passed
88700243816673 88700243816673 and the max is 88700243816673 Test Passed
65879065959482 65879065959482 and the max is 65879065959482 Test Passed
88361793184682 88361793184682 and the max is 88361793184682 Test Passed
91556298303742 91556298303742 and the max is 91556298303742 Test Passed
Random tests ****************** 86924138583362 86924138583362 and the max is 86924138583362 Test Passed
77490520118683 77490520118683 and the max is 79520118683740 Test Passed
99069689298951 99069689298951 and the max is 99069689298951 Test Passed
55180712498677 55180712498677 and the max is 58724986775101 58724986775101 should equal 58729867751014
I think you don't understand what the following mean:
It doesn't mean that you should have:
2642376522401 == 2642765224013
but that you got2642376522401
instead of having2642765224013
. Did you read some of the CW docs? (http://www.codewars.com/docs)ok, looks like I didn't understand the error code. Sorry about that! I am still passing lots of tests but always failing randomly. Can you explain why this is failing here:
24195535165786 and the max is 49553516578621 [24195535165786, 41955351657862, 49553516578621, 49535165786215, 49551657862153] 49553516578621 should equal 49556786215315
After running more tests it appears that I can get the correct number by continuing the pattern (ie. freeze the first 4, then the first 5...)
24195535165786 41955351657862 49553516578621 49535165786215 49551657862153 49556578621531 49556786215315 <--- correct answer
Any ideas? Am I supposed to continue the pattern depending on the length of the number?
You have to go on until there are nothing more to move.
g964 plz look into this pls....
I don't understand! Which language? Console.log or print if you want to see the input. I am sure (99.99%) that there are no errors in the tests.
i use python.... and this is what i did on my notebook which exactly matches my code in python...but the test case doesnt match :(
In your results
which number is the max?
for eg: max_rot(38458215),85821534 should be according to test case but here is it done on paper: 84582153 85821534 85215348 85253481 85254813 85254138 85254183 which should be the answer but you can see what test case is .....
i think test cases have errors...i mean i can do it in copy and test cases still dont match....i think test cases should be checked again
Agreed! I got an error saying "2642376522401 should equal 2642765224013" ??? That's obviously wrong!
See my answer above.
I think perhaps one of the test cases is incorrect. I keep failing the 13th test after submitting, but I can't figure out how; and since this is a new Kata, perhaps it's just messed up. If it's my mistake, could somebody give me a hint? Here's what I have:
The tests are the same in all languages and I'm sure (99.99%) that there are no errors.
OK. I must be missing something then, but for the life of me I can't figure it out!
This comment has been hidden.
70 guys passed the tests so I'm 100% sure:-) Did you console.log the input?
I'm an idiot. Sorry for bothering you. :o)
No problem! You are welcome.
It's tricky, but fun!
Thanks for your feedback!
There are defineilty errors in the test cases. "2642376522401 should equal 2642765224013" ??? That's obviously wrong!
No need to post everywhere and be careful wit the word "obvious" :-)