6 kyu
Blocks in an Irregular Pyramid
211 of 519Trouv
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.
Finding the mathematically optimal solution isn't easy at all.
Scala translation
python new test framework
Approved
This comment has been hidden.
BigInt is so unnecesarry, especially for this level. And even if you get it right, you'll time out. Not really targeting the right audience here.
We have a good alternative for users like yourself -> kyu 8
Well excuse me sir, your ranking system must be broken, because I am not 8, not 7, but 6 kyu ;)
ok, but come on, this kata is yellow, not white ... we can expect users to feel comfortable around bigint and some kind of optimisation
I'm in a bootcamp right now, I have colleagues which are 5 or even 4 kuy and I'm 99% certain that bigint and optimisation are just as unfamiliar to them as they are to me. I guess it all boils to the teachers' choices.
You solved 38 kata's, of which most are white. It's perfectly fine you assess the rank of any kata, but I wonder how you would assess these rather easy kata's after having solved 1000's of them in all colours of difficulty.
SQL Translation
Approved! BTW, first SQL translation for non-SQL-specific yellow kata O^O
\o/
I'm thinking about doing blues too :)
Sounds doable ~~ but I don't have much time these days to translate katas until next year, so I'll come in once in a while and approve your work XDD 😉
COBOL translation.
approved
This comment has been hidden.
problems like this are good because it introduces users to mathematical optimisation, which comes up later in programming
This comment has been hidden.
This comment has been hidden.
In Python I get the error. 261998765738225392543588155392 should equal 261998765738225395043321056933 So for small numbers is works pretty good. How can I handle bit int in python?
More of a challenge in Mathmatics than Programming.
why use bigint? i'm just know why?
Does C++ has overflow issue?
Yes, see the issue below.
C translation. Please, review and approve.
Why are the arguments
signed
and the resultunsigned
?..The returned values in C++ exceed the
unsigned long
data type.Possible options:
__uint128_t
Clang extension; not standard C++; needs a custom stringifier;modular arithmetic (modulo 2**64); doesn't really change the task; guaranteed for unsigned types by the C++ standard; inconsistent with other translations;no, there's division;@Trouv Any thoughts?
If we don't remove it the 1st option seems like the best assuming codewars allows that. In the meantime I could at least add a comment to the c++ initial code warning that it is currently not working.
I agree with @Unnamed, it'd be too much of a hassle compared to the other languages.
According to kazk the related issues have been fixed already. So it should be a viable option as well.
I think another option is to reduce the size of the arguments (between 1e+5 and 1e+6). Then the returned result will fit into the C++ unsigned-long-int data type. The drawback is that it is possible to pass the random tests with a loop and the difficulty of the kata would be mitigated.
How many test does it take to time out linear solutions? Maybe just increase the number of tests?
8000 tests can be passed in
11+ sec
. Raising their number to 10k-15k should work.I forked my translation with number of tests raised to 10k.
@Trouv, please, approve this fork.
C++ translation kumited.
Man I hope y'all know what you're doing bc I'm just approving these without looking too hard at them lol
Do you not even read the comments under translation? C++ version is basically "broken".
Oops. Is the best way to get rid of it just to hit the X next to the language in the editor?
no avoid that: it may generate bugs with the database.
OK I'm glad I asked. Sorry for the confusion folks
I began working in Python. All tests passed except the final set of "Random" (or "Big" I think) tests (10^9 <= w,l,h < 10^10) Same exact solution was used in Javascript it worked correctly for all tests. Might need to take a look at validity of those tests for Python
or you just need to correct your function, considering it's python, not JS (meaning that all operators aren't doing the same thing).
This comment has been hidden.
read 2 threads below ;p
This comment has been hidden.
Should I remind you that any changes to the "established" content are potentially dangerous to the state of the kata, users' accounts, or CW itself?
(duplicated comment)
I don't see why a change in the name would do anything... x) the info are searched in the DB going through the id of the kata, not its name. So I really don't see why that would cause a problem.
Going that way, ANY change to the test suites would brake everything. So... "Should I remind you..." ?
https://github.com/Codewars/codewars.com/issues/1136
Unrelated.
... XD
.
Why use Python 3.60 can not pass the big case while the similar code in Python 2.7 can pass Only difference between the code is int()
nope, the real difference is that you use
/
and they do not do the same thing in both versions.Can please someone tell me how to manage this big number error? Program is working, I tested it on jsbin. But I'm stuck.. Thx!
What do you mean?
I have this on "Sample Tests:"
TypeError: Cannot mix BigInt and other types, use explicit conversions at numBlocks (test.js:7:19) at Context. (test.js:17:18)
Kind of bad code optimization from my side?
You should use
BigInt
's to handle the huge outputs of the function (withw = 1, l = 1, h = 10**10
the output is37007434159723.01
times greater thanNumber.MAX_SAFE_INTEGER
).OK. Thank you for your support, I'm will work on it :)
Ruby translation. Please, review and approve.
This comment has been hidden.
You won't pass 100 tests with a for loop making billions of iterations each time.
It's kind of the 'point' of this kata. You can do smaller problems iteratively, but you need a more robust and efficient solution for larger numbers. If you ever took integrals in school, think of how this problem would look like if it were written as an integral.
How did people figure out such a big formula? Is this a commonly known formula?
This comment has been hidden.
see upper
JavaScript translation. Please, review and approve.
It'd be great if you added this code at the beginning of the final tests suite:
done!
This comment has been hidden.
This comment has been hidden.
you should change the order of this sentence, so that it matcehs the order of the arguments of your fnctioun:
Done!
What for? You could (and should) run 100 tests with values in low range (e.g.
[1; 10]
), and another 100 tests with values in high range (e.g.[10**9; 10**12]
).This comment has been hidden.
It's up to you how to set up the fixture, but don't throw in thousands of tests for no reason. If you're checking the time complexity, do it reasonably - raise the input size, not the amount of tests.
That's meaningless. There's no progression, and no possible optimizations - the solution is either constant time or linear time, hence the user will either pass everything at once, or fail everything at once, there's no third option.
ok, I implemented what you suggested
This comment has been hidden.
This comment has been hidden.
integer overflow? Holy you are using Python, which naturally supports BigNumber
Right right, I realize this now. I went ahead and changed it to exact sum. Thanks for the help