6 kyu
#1 Sequences: Pure Even Digit Perfect Squares (P.E.D.P.S)
273 of 493raulbc777
Loading description...
Mathematics
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.
Nice mathematical kata.
The problem states that the first integer that fullfills the conditions is 64, but what about 4 or 0?
My codes are passing all the tests, and i already changed my approach 4 times, it says always that it timed out, also it says that the code takes more than 12 seconds to solve a problem, i ran all the codes on my machine and they all take less then 2 seconds for the same tests, Begining to quit in this platform
How long does your solution run on your machine for
even_digit_squares(0, 1_000_000_000_000)
?Your solution is simply too slow. Your solution being too slow is not a kata issue.
Please note that the description specifies bounds of inputs. Largest test is
even_digit_squares(10000000000, 100000000000)
.My code passed everything until it timed out, must i take a different aproach?
I am using math.sqrt to check for perfect squares. Is there a less time consuming approach? I have passed all the tests but not the attempt session.
I can't see your current algorithms, but if you are taking
n = b-a
square roots, then, yes, there is a faster way. In that case, if you think more carefully about what is needed to solve the problem, you can probably find a simple way to speed things up without changing your algo very much.This comment has been hidden.
Just for the description... isn't
4
the first number that satisfies the conditions?@raulbc777 check this ^
What about
0
? 😏True, either way, 64 is not the first one ;) Unless you exclude single digits numbers, but that's not currently in the description.
Julia translation
Approved +1
Cheers! I hope you've been well!
thanks for your message. I'm well. Many new things. Trying to give my best.
Python fork - test framework fix
Approved +1
I felt soo good after solving this kata @raulbc777 thank you!
Glad you liked it!
https://www.codewars.com/kata/59290e641a640c53d000002c/typescript
Typescript version
It has been approved +1. Great job! We'll be waiting for users that solve the kata in this language and see if everything's ok. Cheers!
I love this kind of Kata where the solutions will be diverse.
You should add more edge case tests, for lower and upper limits, by example 64 and 65 for a, 399 and 400 for b. A lot of solutions rely on rounding square roots of lower and upper limit, and some straight ways include 64 with 65 as lower limit, or exclude 64 with 64 as lower limit. Testing this cases would invalidate a lot of given solutions.
Upvoted
I enjoyed this kata after figuring out how to improve performance. Thank you so much.
Me too!
Python
Can you add following test?
Many solutions result in
[64]
which is lesser thana
.There appears to be a bug with the solution in one of the random tests (this random incident doesn't always occur; it was during a 2nd test run when it was discovered).
Image link: https://i.imgur.com/abRnHuX.png
The last value,
4000000
is greater than theb
limit.You solved it in javascript. I'll have a look to see what's going on. Thanks a lot for the feedback.
It's fixed. Thanks for your time. Please let me know if everything works ok from your p.o.v.
Yeah, everything looks fine now.
It's awaiting for approval, if you agree and want to approve it, I'll appreciate it.