6 kyu
How many pages in a book?
1,632 of 4,690alexbur
Loading description...
Puzzles
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.
Ruby version kumited
This comment has been hidden.
41 should equal 17 (test case 25)
this is the answer i get and it is correct, WHY 17?? 12345678910111213141516171819202122232425 how come this has 17 digits??
i still didnt get it(
Read the task carefully. What are you asked to do?
python new test framework is required. updated in this fork
Approved
there is a bug in the random test for go, the values are off
With summary = 43451 Expected : 10912 to equal : 10911
With Python the tests behave differently.
Same: With summary = 53961 Expected : 13014 to equal : 13013
Confirm
Why is my solution not listed?
It should be visible now.
This comment has been hidden.
This comment has been hidden.
D: issue (verified with JS)
Fixed
Go translation
approved
D translation
Tried with maths for about an hour, but gave up... ;(
Maths behind this problem is very interesting. Cool Kata!
thank you
can u give me a hint of how to solve this ,i had done but test returned it took more time
There is no coincidence for 1095 or 185 however the test has a solution of 401 and 97 respectively. If someone can help, I would appreciate it a lot. Programming in JavaScript.
Both tests are fine, maybe you misunderstood the task. Not a kata issue.
You were right, I had not understood the task well. So I read it more careful and solved it. I apologize and thank you very much
Completed all sample tests but the random test sends out a timeout error
Your code being too slow to pass the kata is not an issue. An issue is a bug in the kata. Please refer to the documentation: https://docs.codewars.com/training/troubleshooting/
easy to understand have a nice day
This comment has been hidden.
Please use spoiler flag when you post code (I put it for you this time).
Sample and final tests are missing the test framework import in Python.
Fixed in latest fork
I misread the condition and did the exact opposite. (Input: 17 output: 25)
C++ fork to correct random tests, please check carefully, thanks.
thank you
COBOL translation fork, fixing incorrect values generated by tests + maximum edge case (requiring a change of result's format).
.
This comment has been hidden.
test cases cannot be changed for python and js
Why??
It's not changing testcases, it's just fixing the reference solution that fails on one (unlikely but possible) case. That would not invalidate any solution if that's your reason.
It's written when i edit tests in kata editer. I guess some kind of feature of the site
Ok :/ I didn't know this could happen... I'm going to ask to understand what's happening and let you know.
Thank you a lot for your valuable contribution
I could publish a new fork, see if you can approve it: https://www.codewars.com/kumite/6249e154a8fca9004a478649?sel=6249e154a8fca9004a478649
i did, thanks
.
Can't pass random tests in Rust. Tried my approved C code and didn't work either (summary = 58385)
There's already an issue opened about bad tests in C++ and Rust.
It has just been fixed.
Thanks.
This is a great kata! Really enjoyed solving this one.
thank you
Hello, everyone. I can't pass random test on C++. Values are same like other test. Where is my mistake? Thanks a lot.
i think we got a problem with C++ tests, can't resolve it. My bad
There is an opened issue about tests being bad in this language.
fun task, enjoyed it! Thanks
Bruh I found the "more complex" version a lot easier...
Great task, man! Thanks
C Translation kumited, thanks
thanks
COBOL translation.
.
Thank you
C++ translation has the same issue as Rust: There are invalid
summary
values given in random tests. ExampleShould be fixed above
Fixed C++ sample tests
thank you, sir :)
All sample test (Python) is passed but random not work (most of the time)
This is most likely not an issue of the kata but of your solution, so you'll need to fix that. 486 people were able to solve the kata in Python so far.
Your solution only works for page numbers up to three digits. Additionally it is too slow to handle the 200 random test cases, it manages to only calculate about 70 tests before the 12 second limit is reached.
I tried doing this code on c++, however it gave me some errors that didn't appear to be related to my code, so to make sure I wasn't doing something wrong I ran the code in the terminal, and it worked just fine. I may have done something wrong, but as I said, it doesn't look that way to me.
This was the error (part of it, at least): In file included from main.cpp:7: ./tests.cpp:5:8: error: constructor cannot have a return type It(test) ./tests.cpp:5:8: error: qualified reference to 'test' is a constructor name rather than a type in this context ./tests.cpp:5:5: error: expected '(' for function-style cast or type construction It(test)
I had the same issue with C++.
In C++, the "TEST" case does not work. But, the "ATTEMPT" case works!
Fixed.
hi
Rust random tests don't work, because (most of the time) they will produce an impossible summary number. For example you cannot have n = 3542, as page numbers for n = 3541 is 1162 and next page is 1163, making n = 3545, thus assering that the set [0,1,2,3,4,5,6,7,8,9] contains 1163 as a member.
These random tests cannot be completely random, to adhere to the requirements.
Fixed.
For the java version, when you return the wrong value for a test you're given the error: "expected: <X> but was: <Y>". The issue is that X seems to be set to the user's return value and Y is the expected result for the given test. Wouldn't it make more sense to have "expected: <Y> but was: <X>" instead?
TLDR: the variables for expected and actual seem to be opposite for what they actually are in the java error message "expected: <X> but was: <Y>".
Thanks, I will fix this asap.
I cannot confirm this issue. Either lazyvinh already fixed it or it worked as expected.
Yes, fixed already, thanks everyone.
This comment has been hidden.
This comment has been hidden.
I have the code but I cant submit it!
While using console log, I hit the max-buffer limit (1.5MB) during the random tests. Removing the log allowed me to complete the task, but its worth noting for anything who is close to completing the task.
Dear WingItMan, why do you believe this is a kata issue?
Not an issue.
i made algorithm and i pass the first 5 tests. But why i try to attempt it gives me an error. Test Results: Execution Timed Out STDERR Execution Timed Out (12000 ms) Why did my code time out? Our servers are configured to only allow a certain amount of time for your code to execute. In rare cases the server may be taking on too much work and simply wasn't able to run your code efficiently enough. Most of the time though this issue is caused by inefficient algorithms. If you see this error multiple times you should try to optimize your code further.
The description says: 'Be aware that you'll get enormous books having up to 100.000 pages.'
Your solution looks extremely ineffcient to me. Maybe add some
print
commands and check the sample tests.This comment has been hidden.
Hello! I have similar problem. Have you already solve this problem? I can't solve.
Java translation
Rust: the issue below isn't fixed yet.
Fixed, thank you
Rust random tests:
There's no
n
matching81493
.Thank you, sir. Corrected
This comment has been hidden.
you tried to convert it to int?