6 kyu
Triangle of Multiples (Easy One)
300 of 666raulbc777
Loading description...
Mathematics
Data Structures
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.
Fun to practice some code optimization with this kata.
Hello everyone!!! Who knows, tell me what to do, what functions to watch to speed up the code?
i see you've already solved it, but for those who are struggling, there is a purely math way to solve this kata. (Hint: look for patterns in the total_sum)
Thanks! Cool kata
Description should be language-agnostic
Ruby 3.0 should be enabled (Refer this & this for more detail)
Groovy: Random tests expect negative results for some input values:
for some reason the sample test show the same values but say i failed
like:
(1,0,1) should be (1,0,1)
and so on, what should I do?
What language are you using? Seems like you're using python.
I don't use python but that looks like a tuple and you need to return a list.
Don't think it's python; the python solution expects a list.
This was a pretty tricky puzzle. Definitely not an easy one...
Great feeling once you solved it..
Idk if im wrong, but in my machine its working, im using array.flat() but when i try to used it here it show me an error, is it allowed to use array.flat?
That requires a higher Node's version to work: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat#browser_compatibility
oh, got it, thank you
Please review: C++ Translation
Approved +1
Wow!!! Thanks for kata! It made me look for patterns )
Glad you liked it.
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)
Done for Python.
The upper bound should be tested explicitly.
The upper bound in the description is wrong.
This comment has been hidden.
Two goals for a solution: a) correct results b) good performance. As you wrote you didn't achieve both yet. Keep on working. We grow with challenges.
Groovy translation kumited. Please review and approve. Thanks, suic
Haskell : https://www.codewars.com/kumite/5ba6d4e809fd2a545c000082?sel=5ba6d4e809fd2a545c000082
I used a touple, as when I don't, unnamed gets upset.
This comment has been hidden.
I found that one condition (check if superior to 0) was unnecessary. Still too long to process ...
Remember that Brute force algorithms can´t solve all the challenges and as I wrote below, "Try to study a math pattern in the triangle to speed up your code."
Well I didn't though that my solution could be qualified as 'brute force' ... You are telling me that a math pattern will allow me to avoid the double loop ?
Never mind. I didn´t put the name of those algorithms. There is a very important tool for a programmer when integer sequences are involved. www.oeis.org
There are almost always closed form solutions for sums of numbers.
I finally found a solution (one fking year later). Thanks for the oeis.org link it help and I think it will definitely help even more in the future.
could you please tell what pattern, I have to search
The problems here is to avoid loops by finding a formula (or more) that can get the job done quickly. I managed to find a crappy solution but still with one loop (hovewer I saw some solutions with zero loops at all). By typing the inputs of the kata on oeis.org it will return different algorythm with all kind of details. By looking at all this informations and (tinkering a lot) you may find some insight to solves this kata. (Also, leaving the keyborg and using some pencil and paper help me a lot for the tinkering part.)
这个题设计的很巧妙,cool
This comment has been hidden.
A pure brute force algorithm won't be able to pass the tests. Try to study a math pattern in the triangle to speed up your code.
The Ruby tests allow it, I did a really silly solution as I was in such a mood and I was surprised it passed. I even calculated the even and odds individually which makes no sense obviously.
JavaScript version is throwing
ReferenceError
:Maybe you forgot to copy
sum
when you swapped the example and final tests?This comment has been hidden.
Thanks, confirmed :)
This comment has been hidden.
Thanks a lot. OMG!! :)
Solved it, but I have no idea what it is really, I just saw a pattern.
Are you made of numbers?
This comment has been hidden.