5 kyu
Perimeter of squares in a rectangle
1,022 of 43,180g964
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.
Absolute dislike for such a task!!! WRITE IN THE TASK CONDITION ALLOWED RANGE n!!!
I don't know why everyone says this is too easy for a 5kyu challenge. I've completed some 3kyu challenges that were easier than this one💀
The first thing I thought was "Really? This simple?" Then I realized why we were to use BigIntegers. It was a nice way to force me into learning more about kotlin's long variable!
g964 огромное тебе спасибо за это Ката. Просто потрясающая задача и, когда понимаешь суть проблемы, вникаешь в возможные пути решения, то выбираешь оптимальный и ВСЕ, задача решена. Очень познавательная и интересная Ката. Еще раз огроное спасибо, было класно.
This one isn't too hard, but man...I am dumb. Passed the test cases, but just can't figure out the attempted cases.
This comment has been deleted.
Gosh, why so nervous.
ez for 5 k
Expected: equal to 213265164688 Actual: 7106734480 Random_tests
Expected: equal to 5219878179714624 Actual: 15446324800
i pass all tests except these , any help ?
Are you using int for fibonacci numbers and unsigned long long for an answer? Then use only unsigned long long for both.
How would you loop different numbers into the array where you added to find the different lengths? (Fibonacci sequence)
Trying to solve this in C#... Simple brute method worked with sample tests, but timed out on the later test. So i've used the Binet formula which works fine up to n = 10 and fails at n = 100. I've used double to define phi, psi and sqrt(5), and to do phi^n, and apparently that starts to fail in lesser digits on the number. What am I missing here?
JS tests for inputs up to 75. Meanwhile, Haskell is apparently intended to test for inputs up to
120_000
( but always tests for1200
because of a bug ).JS should update to
Node 18.x
, useBigInt
s, and test up to$HUGE
.ETA: Haskell has been fixed.
C fork
Merged.
Random test cases have numbers too large for python (SyntaxError: Exceeds the limit (4300) for integer string conversion: value has 15621 digits - Consider hexadecimal for huge integer literals to avoid decimal conversion limits.) and set_int_max_str_digits is needed and downgrading to 3.8. Maybe it's me doing something wrong, I do not know.
I think something is wrong in your code : 13,882 people passed the Python kata.
the code works just fine in vscode but does not work here, and gives a false error.
Your code is wrong and it fails even the first sample test. Debug it properly before creating a kata issue next time, please.
oops, i read one number in the description wrong, i have dyslexia
I tried to store all fibanachi numbers in a list, but this was ineffective. And the decision was not made and I decided to make two variables where the last two numbers are stored
I really don't see how this is a kata issue; your solution passes, and even if it didn't, it wouldn't be a kata problem.
If you really think this is an issue, please elaborate; however, I'm closing this for now.
This comment has been hidden.
Kata hint != kata suggestion. See https://docs.codewars.com/training/troubleshooting#post-discourse.
Also, this is a 5 kyu kata. Users should know how to efficiently compute fibonacci numbers at this level, and if they don't, they should be able to research how to by themselves.
can someone explain why are we doing it for
n+1
not forn
, am I missing out something ?Because the specs say so. Arguments start at
0
, number of squares starts at1
- there's your+ 1
.The specs could easily have said something different ( and arguably more sensible ), but they don't.
I feel like this is easy for 5 kyu
How did you loop different numbers into the array where you added to find the different lengths?
This comment has been hidden.
Does your solution print anything to console? Do you have any debug logs in your solution? If yes, please see this paragraph.
ah got it, had a "System.out.println" there as a control value
.
Am I wrong or the numbers in the test cases are all wrong??? The first case should be 48 not 80...Can someone help me here???
You are wrong. When you don't know, ask a question maybe, but don't raise an issue. Please note this kata has been solved more than 30k times so it's extremely unlikely you find a bug in the fixed tests.
!!! My apologies! Guess I'm a bit clumsy here! 😓
No problem, but think twice next time you feel like raising an issue.
I am unsure whether this is an issue or a question but for some reason my racket code is not doing the math correctly.
For example, (((1+sqrt(5))/2)^73)/(sqrt(5) equals 806,515,533,049,393 but my code gets the math wrong by one digit. I am so confused because the math is correct and this is the simplest formula I know got fibbonacci numbers. I don't understand why it is getting the math wrong because the formula is not that computationaly intensive.
Btw, this problem is also the same in Dr. Racket on my computer. But it is a language problem for sure because the math I am using is a 100% correct.
C#: method name should be
PascalCase
(Please refer to implementation of backward compatibility here )Most of the solutions fail if n == 0 and n == 1; You should add a test case for it.
got an overflow on ocaml on random tests and cant do anything about that
In the depiciton of the squares the one with the 8 should be on the right not on the left
Its a nice kata first of all, even tho i knew about fibonacci sequence, its a premiere for Java's BigInteger class for me, i am passing the tests but for the last one it takes about 80 seconds for my solution to calculate the number so it times out. Could someone give me some subtle hints to point me in the right direction please? Thanks!
g964 makes the best kata
Thanks!
people like to shit on math kata, but i find math fun so these are my favorite. I find mathematics really useful in programming so being able to learn more math is a plus!
I totally agree with you
Finally an opinion worthy of the gigachad profile picture. Math katas are my favourite too, I love the problem solving they force you to do and the feeling of seeing your algorithm complete the task :)
This comment has been hidden.
Not a kata issue. Before posting issues look at the top of the page: 11,143 people passed the Python version; if there were errors somebody would have seen them before you. Sorry and good luck!
Respectfully, I think it is. If you look closely, my code passed it too if I keep updating the sum in a loop. If, in contrast, I collect all the values in a dictionary and then use Python's sum function on the values from the dictionary, I get a much larger number then the tests assert. So, if the kata is trying to teach large number handling in Python, it is an issue, and hints would be appropriate. If, on the other hand, it is just trying to teach algorithmic thinking, the tests should be changed to values where large number handling does not make a difference. Best, Jovan
You're wrong, your code fails because you're using a global var that keeps its value between tests. Just reorder the sample tests to see it.
You are correct, my apologies! Resolved it is :)
This comment has been hidden.
Using recursive function causes timing out easily, but recursive array doesn't
This comment has been hidden.
This comment has been hidden.
I hate this math katas, because instead of writing code or thinking about logic of the function. You like a true dumbass trying to figure out the description and this Fibonacci archive that is older than my grandma, instead of just a link to Wikipedia. And you can call me dumb all you want, but I think these "math" katas are the worst way to practice programming.
Hey @gleb4dead and welcome to Codewars;
Just to say that if you are new to the site and currently using the "Next Challenge" feature to navigate the site, it will offer you a mix of different katas; however if there are specific kinds of katas you want to practice or avoid (the mathematics ones in this case), you can use the Search page:
https://www.codewars.com/kata/latest/my-languages?beta=false
where you can choose to train on the kind of topics you are interested in.
You can use the Tags menu - here you have the
mathematics
tag which tells you it's mathematics themed - to practicerecursion
oralgorithms
, or whatever topic you want, using the appropriate tag.I wouldn't judge "these math katas" so harshly. I understand you're struggling, but through these struggles you grow. Math katas are fundamentally very important since they teach you one of the most important concepts in programming: analyze your problem thoroughly before trying to solve it.
By the way, if you take a basic Algorithms and Data Structures course, a variation of this kata will probably be one of the first problems you will study.
This comment has been hidden.
Sorry but that's not a kata issue. Figuring that out is part of the task. Also, what's complicated about it? It's almost spelled out in the description.
Don't use recursive, espacially with c++, it seems c++ is discriminated :P
This comment has been hidden.
I can't answer your question with the correct "words" because then it will spoil the kata for other people, so let me try to explain as best as I can:
Without seeing your code, I'm guessing that the way you implemented the
thing_you_mentioned_in_your_question
is using the basic "naive" approach (probably involving recursion?).If you are a beginner, this will be a very valuable teaching/learning experience for you so, all I will tell you (this is a 5 kyu kata so it is supposed to be a bit challenging) is: there are better ways of implementing the
thing_you_mentioned
.In fact studying
thing_you_mentioned
is a classic example used in many programming textbooks, so you should find lots of detailled explanations with some simple internet searching.This comment has been hidden.
Thanks!
This comment has been hidden.
This comment has been hidden.
Idk these "Math" katas are diffrent from other katas because you can have working code but you will not pass it only beacuse it's not fast enough. It's like having a car race you both have cars, you both making the same distance but if your opponent has a ferrari and all you have is opel astra you will still lose even tho you did nothing wrong. It's just annoying.
I don;t think I agree with your analogy, because comparison of a programming task to a car race is IMO not very good. I would have a different one: you hire a contractor to renovate or build you a house. One contractor performed the task and built your house in half a year. Another one finished identical house in 150 years. Would you consider any of them as better?
Using an efficient, potentially math based approach is just a right way to do the job. Looping a bajillion of times might give the same result, but is so far from feasible it's difficult to even consider it correct.
I have to say that you are right. The problem I have with these is that I can have a good idea and solution for first few tests but then it's not fast enough and I can't find a way to make it faster :/ (In this particular case I don't even use a loop)
Try harder. (Or less harder) The solution is easier than it seems.
FWIW I have the complete opposite view; I think it's amazing to realise that mathematicians working hundreds of years ago with pen and paper (or even thousands of years ago using sticks in the sand like Euclid) could come up with "algorithms" that are faster than what a decent brute-force programmer can do with a modern computer -- if that isn't motivation to learn more from the "math" katas, I don't know what is!
Also, nothing wrong with Opel Astras >:(
@VaxiZ: with your reasoning, nothing's wrong with bogosort, which is, to say the least, arguable.
I already admitted to mistake. There is no need to continue this topic.
Enjoyed this kata. Kudos!!
Thanks!
NASM translation.
Approved.
This comment has been hidden.
Very easy kata. I think, it should be 6 kyu.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
OP solved it, closing
This comment has been hidden.
Sorry, timing out is not a kata issue. I am a bit surprised that it works fine on dev c++ or online. I tried your solution and I am only getting that
This comment has been hidden.
Very nice kata. It is great when there is a short, simple solution once you understand the problem.
Thanks!
Use it blocks for output info about each random case instead of printing the stuff in console
Yes, I was already said for this kata or for others. It would be better but I have no time for that.
your random tests are not strong filtering the heavy implementation, e.g. my solution, which passes between 3.2 to 9 sec. Could you up the upper bound to 500000? EDIT: language - python
Nobody's going to change the requirements at this point.
@alexbprofit: I could but I have not enough time to change the tests each time some people ask for a change. The random tests are going up to 100000 which is already a bit ridiculous considering the subject. Furthermore I have to keep some equality with other languages of the kata as well as fairness vis-a-vis of those who have already passed. Sorry! @FArekkusu: Thanks!
"The expression (act) == (expr) is false." I'm getting this error for the final test case ,please help!
It means your code produced the value
act
(actual), and it did not match the expected valueexpr
, because your code is wrong. We do not know why your code is wrong because we can't see your code. Here's some documentation on Troubleshooting-your-solution. If you wish, you may post your code with proper markdown and remember to use a spoiler tag. Then someone may be able to help you.COBOL translation.
This comment has been hidden.
If you time out, you could try another way.
This comment has been hidden.
My solution takes ~1s...
Ah.. right.. my mistake..
If done right, it takes only 2 ms :)
Depends on the language!
Large numbers aren't being handled properly, any help ?
Missing return type in TS
Typescript 3.3 or above should be enabled
I think Blind4Basics has already implemented the translation fixing this issue: https://www.codewars.com/kumite/62c1cfbcf8f15c6b384c33af
This comment has been hidden.
its a bug in your code. your solution returns incorrect results if its invoked more than once.
Not a kata issue.
Scala: sample tests fail with confusing error when user solution throws exception. To fix it, it's enough to apply this little fix:
Full tests seem to be OK, the problem is only with sample tests.
Function "check": place of
val z = perimeter(n)
changed so the issue seems to be resolved.Hi, guys. Could anyone please check the random tests in Scala code? My code passed all fixed tests and all random tests if the input argument < 69k, but it falls when the args more than 69k and there is no stacktrace inside the assertion error. If I break my code and run tests again there are many stacktraces with assertion result, including random tests, but like I said, only if the arg less than ~69k
is your solution recursive? Scala runner is known to crash tests in a terrible way when stack overflow occurs. your symptoms resemble the situation i encountered once in Scala kata when my recursion trashed the stack and tests errored out without any feedback. is it possible in your case?
Nope, the solution doesn't use a recursive approach. Moreover, I run it on my local machine, using Intellij IDEA and a code works good with any numbers in range of 100_000 - 200_000
I think I managed to reproduce your issue with my Scala solution. It still looks to me like some kind of a fatal crash which causes no feedback to be emitted. Is it possible you experience out of meomry error? Do you use a memoization of many potentially large values?
I will try to use sub-linear algorithm without memoization and see if it helps. If it does, the kata probably needs to be fixed because it does not match its 5 kyu rank (I wonder what other language versions expect, but for 2 languages I solved, the linear memoization was fine). It's possible that someone overkilled the problem in Scala.
Another thing is that test suite is build incorrectly and tests crash in a bad way when solution crashes. Calls to reference solution ae misplaced, what results in a very confusing feedback when solution is incorrect or throws an exception.
Okay I managed to pass Scala version and this is what I found out:
Thanks a lot! I've just replaced all numbers memoization process with a particular memoization and tests have passed perfectly. Owe you, man!
Translation from @dolgov_vv 3 years ago. I wrote a post for him to have a look.
For what it's worth, the output of Scala tests affected by
OutOfMemoryError
orStackOverflowError
has been improved for all Scala kata and now the failure is signalled in a clearer way. I also raised a dedicated issue related to setup of sample tests.What is still left to clarify (and eventually fix) is the question of performance requirements and consistency between languages (i.e. should complete memoization work like in C#, or maybe it should fail and some other approach needs to be explored by users).
This issue seems resolved because of the fix and another issue above.
For the
Dart
translation, I think auto-importingdart:math
library is misleading.Isn't it required by BigInt (the returned type) ?
It belongs to
dart:core
(at least since the supported version, which is 2.8.0)Ok :)
import removed from "template "Solution".
I think this is 8 kyu kata cause that is too easy. In Python I solved it in 1 minute...
Your ability to solve it in 1min does not mean others can, that's not the way how kyus were measured and evaluated ~~
And ranks can't be changed once kata is approved
ejini战神 I don't think it's that other people can't solve it that quickly (unless they're not familiar with the fibonacci sequence). I just think a lot of people will look over the square and not see it.
Really, it took me 10 minutes only to realize what does the input m stand for.
This comment has been hidden.
C# Completions: 1413 (so far)
BTW, you shouldn't use doubles, they're not precise enough. Stick to BigIntegers.
.
I hated this program in Java as I felt it overcomplicated the problem forcing the use of BigInteger, but Python was super easy! In hindsight, I felt like this was a great example of how some programming languages have massive benefits in certain situations vs other programming languages. In this case, Java is a headache because of the BigInteger syntax (but BigInteger is necessary for large numbers), but python doesn't need different data types for larger numbers, so in that language there's no need to think too hard about this problem.
I've try to do this kata in java but, it's keep getting over 16000ms, i'm stuck xD
I think this was a good kata because it made me realize how ingrained certain methods to solve a problem are in my mind. Once I tried something simple and different it worked without issues.
This comment has been hidden.
good kata, but i think it's 7 kyu
I made a solution using "divide and conquer" fib algorithm. In my test and in kata tests works fine. But when I try via ATTEMPT, it causes error but does not show any error, except "exit code 132"... Does anyone get ths kind of error (blank error XD)?
Thanks for the hint,good kata
This comment has been hidden.
Your Fibonacci sequence is wrong.
Trying to solve this kata in Shell, I wrote a solution that uses an ancient command-line tool called
dc
, basically a calculator. Then I found out that the Codewars shell environment doesn't have dc loaded :(. Thought I'd post the answer here:dc -e "1sx1sy2sa $1sc lc2-sc [lx ly+ d la+ sa lx sy sx lc 1- d sc _1>Z] sZ lZx la4* p"
You can use bc.
Thanks! I knew about
bc
, but maybe warriors who are browsing don't. It's just, you see... It's so much more fun to post a solution a solution that no one at all can understand.Back to the drawing board, I suppose.
Hmmm, I can't edit the error in my original repy either! (it is tested, I just copied & pasted the wrong part of my terminal history).
I needed to replace
>
with<
. Frustrating.Nice kata// GOOD
Thanks!
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
A. It is quite useful and sensible to know BigInteger. Moreover it is too late to change something when 1306 people passed the C# kata. B. The wording is as simple as possible and understood by 19155 people. Instead of complaining propose yourself a simpler wording. C. Maybe you are smart enough but the hint can be useful for newcomers.
my code works fine with three test case but for 4th test case it was different from my solution i dont know why it showing like that
I pass the three fixed tests (for n = 5, 7, 30) but fail when I try ATTEMPT.
The issue is that my code takes too long (not efficient!). I'm guessing that the issue is the recursion that I use to find the Fibonacci sequence, but the Fib sequence is, by its very nature, recursive.
So, my question is: does the program have to be non-recursive in order to pass all the tests?
same thing happening with me, won't seem to work
try to use 'for' cycle. It works perfectly with Fibonacci and code is very easy to understand
Hi eldesanclemente! I think you can try the "divide and conquer" fib algorithm. The recursive version takes much time for long numbers.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
Take time for your fib with n = 500.
Recursive fib is a bad idea for large numbers
Solid 6kyu. I know this has come up many times before but their ought to be a way to override legacy rankings, especially for kata like this one where there seems to be community consensus.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
I don't understand this kata. what does it mean "squares disposed in the same manner as in the drawing:" when applied to arbitrary numbers of squares? what are the rules for how these are placed, do we need to check that these squares can be arranged in any or some special way as a rectangle?
I mean I now see that maybe its supposed to be a sequence 1,1,2,3,5,8 etc but that's not clearly defined. you could make the same rectangle as shown in the image and swap the 1,1,2,3 with a 1,1,1,4 set of squares. The rectangle image has nothing to do with the specific ordering of those values, that's just one example which could form a 13 x 8 rectangle.
I think the diagram is just confusing, but I guess it must only be me that thinks this since nobody else asked
This comment has been hidden.
When you ask for help post a question, not an issue.
Your code is too slow.
Recursion should be allowed in these katas. Simple memoized example below
The kata doesn't forbid recursion.
Recursion isn't blocked. It's just for n > 25, a recursive fibonacci algorithm becomes quite slow.
Recursion can be fast enough if you cache the results.
Exactly how I tried and it throws 'maximum recursion depth exceeded in comparison'. I thought I impoved it with memoizaition, but nope. Where did I go wrong?
Nice kata!
This comment has been hidden.
Read this
We can't guess what's wrong either without more information, language, your code, etc.
This comment has been hidden.
I don't do Scala, but try returning just 1, there are several more tests, so that Exit code 1 seems like a timeout, what I noticed too, is the testing suite is taking a lot of time to generate the tests (when returning 1).
Thanks for your reply !
Any additional help please?
This comment has been hidden.
This comment has been hidden.
Issue not specified.
This comment has been hidden.
You need a faster algorithm. There are 25 random tests, each with inputs from 40k to 100k. So at one second for just one test, you've already taken up 1/12th the total alotted time, and that isn't taking into account the server overhead or the test solution to make its calculations.
Try to think of a more efficient way to keep track of your numbers if you haven't already.
This comment has been hidden.
Codewars has some stuff before your solution, so the line numbers are inaccurate. Also, not an issue. Please post your code with a spoiler flag so we can help.
This comment has been hidden.
You're probably using a global var, don't do that. If I understood what you said, your code is returning the wrong result right?
I just noticed that this time it is not a function it is a struct. Maybe this is causing the problem. I have a var named sum, that is inside a function and that function is inside a strutc (as designed by the creator). I am returning the sum variable.
My C-fu is not so good, but I would look into that if that's what's happening.
Nvm, I forgot to set the sum var to 0, thus being in structure it always kept the previous value I guess.
uninitialized variables in C can do weird things!
if I comment the first one
is a big clue to thatThis comment has been hidden.
Python by default has a recursion limit of 1,000, meaning a function can't call itself more than 1,000 times.
Check that the your solution is not falling foul of this.
'looks like u solved it'
This comment has been hidden.
Some people downvoted your post. I think it is because these people saw that the Python kata was passed by 3672 people (see the top of the page) so if you fail the tests it is not because of the kata but because of something wrong in your solution. Sorry! Succeeding on your computer is good but you do succeed at CW. I don't think that the difference can be explained by the difference of Python versions.
This kata is really easy for 5kyu
i did this in one line
My python code works for test cases and can do up to perimeter(10000) in about 5 seconds. It's pretty efficient I think, but maybe not good enough? It times out.
Random tests input values go in Python from 40000 to 100000. Try another way.
'looks like u solved it'
Edge case
n=0
is needed in all language versions since some top solutions fail against this case. Andn=0
is a valid input since it represents 1 square.Can you show me a top solution that fails on that trivial case?
At least two:
https://www.codewars.com/kata/reviews/56e1816e1b54fdc8b600003c/groups/588deb6eac6e5744060005ea https://www.codewars.com/kata/reviews/56e1816e1b54fdc8b600003c/groups/590b0da27b3959abc50002b9
n=0
should equal4
but these solutions return8
.As usual, you shouldn't expect me to do your job ;-)
Of course:-) OK, lots of thanks. I have added it in JS. I will try do other translations bit by bit when I have time. Too bad that it has not been seen when in beta and with few translations.
Added in Haskell ( first random test will always be
0
).added in C
Added in Python & Ruby
I was thinking: "or this kata is trivial, or I am stupid to understand the task". I guess the kata has complexity of 7 kyu.
This comment has been hidden.
not an issue. The sample tests are just what they are called for: sample. Meaning your algorithm is to slow too pass the full test suite. You'll have to find something more efficient.
cheers
I didn't say sample test. All test case passed when i attempted.
Time: 10719ms Passed: 6 Failed: 0 Exit Code: 1 SquaresPerimeterSuite Fixed Tests perimeter(5) should return correct answer Fixed Tests perimeter(7) should return correct answer Fixed Tests perimeter(20) should return correct answer Fixed Tests perimeter(30) should return correct answer Fixed Tests perimeter(100) should return correct answer Fixed Tests perimeter(500) should return correct answer
It didn't say algorithm is slow. So issue is not resolved yet.
Oh. My mistake. Apologies for inconvenience.
I don't understand the reason why my code is failing. All test cases have been passed and there is no error related to execution time as well.
Same error
OP solved it, closing
I can't understand. Why perimeter(7) should return 216? Because my code return 324, and i think its correct. Update: Why we have to multiply by 4? And why we calculate one block of one? we need calculte only 1 block of 1 but we calculate 2 blocks of 1?
Looks like you need to actually read the challenge and not just skim it.
This comment has been hidden.
This comment has been hidden.
I think that note doesn't apply anymore, your function
fib
is wrong, try your function with these calls:And next time, use spoiler flag please.
It will be better if the problem statement has a constraint information...
This comment has been hidden.
I solved it in java and the main struggle was to figure out how to work with BigInteger. I made a first draft fully expecting it to fail due to timeout since i thought the numbers tested would be huge but it doesn't seem to be the case. Maybe long or some more standard type would be better suited? Anyway pretty good kata which,if nothing else, thought me about BigInteger! :D
This comment has been hidden.
This comment has been hidden.
assuming it's the same as in java you have to give the perimeter of n+1 squares. As such n==1 and n==2 won't have the same result.Furthermore you should reread the problem as you are also returning the wrong values for these cases...
I think my Internet is 2 weak... i got 'timed out'... However, i tested it for individual examples and... it worked.
This comment has been hidden.
Having the variable n declared as a BigInteger is preventing the program from running in java.
@g964,
import java.math.BigInteger;
should be in the initial solution.Done.
I have problem all 6 tests pass, Max Buffer Size Reached (1.5 MiB Passed: 5 Failed: 0 Exit Code: 137 what is wrong?
Which language??
language Java , I solved the problem by accident, the code printed numbers and that's why the buffor filled up
System.out.print.... numbers filled buffor I //System.out.... and it works
It was perfect exercise to remember info about Fibo rows and their exponential growth too)
What should perimeter(1)return? Should there be 2 squares for perimeter(1)?
Yes, perimeter(1) count 2 squares and will return 8
good kata
This comment has been hidden.
'looks like u solved it'
Obviously... after two years...
This comment has been hidden.
See the image above,
There should be 2 squares in a rectangle when n equals 1.
Oh ! You're right ! I'll update my solution ;) Thank you !!! :)
Some of the solutions proposed works only because perimeter(0) is not tested. Maybe you can add this to the tests ?
Nvm
I am 7kyu and this exercise is 5kyu. Why I cannot see the solutions, then ?
With Scala, is there a way to make this more explicit?:
Test Suite Aborted Exception encountered when invoking run on a nested suite - Unable to load a Suite class that was discovered in the runpath: SquaresPerimeterSuite
I am not the Scala translator of this kata (it is "@dolgov_vv"); I think that comes from the scala junit runner and I am afraid the translator has no action on it. Did you try to print input and output to see what happens and where?
You're right, last input is printed (consequent number) but the associated output isn't. I guess I've been used on other katas to be printed case by case tests, so that I forgot to print things to debug. Thanks.
val z = perimeter(n)
should be inside ofit(...)
; now the exception is processed as if it happened in the tests themselves.Modified. Lots of thanks!
This comment has been hidden.
Summing a Fibonacci sequence is harder than I expected.
The type of
n
is Scala isBigInt
, although it obviously isn't and can't be tested with that big numbers.I am not the Scala translator. OK
n
as BigInt is superfluous but has not prevented you to pass. Is it an issue?I had to use a superfluous narrowing convertion to
Int
. I think incorrect or weird types are issues, especially so when it's a guaranteed class vs most likely a primitive if a compiler is good.Haskell has the same situation. Less than ideal design, though I would not argue in favour of changing it now.
Is it useful to keep this open?
As a novice programmer the use of a BigInteger in Java has completely put me off this Kata. I will finish it at some point but it seems like an unneeded way to complicate the problem, not to mention the confusing manner in which its actually described. As much as I'm sure some people appreciated the "See Fibbonaci sequence" Hint it wouldn't have been needed if it made sense to start with.
Not an issue.
Why multiply by 4?
Because each side is X, and the perimeter of any nxn square is 4X.
It seems to be more simple than it is, I like that the most straightforward solution was not enough for Haskell. :)
Although the intention is clear, I think the drawing is geometrically wrong and should be fixed so the sentence "disposed in the same manner as in the drawing" makes any sense. The big pink square with side length 8 should be on the left of the others to follow the pattern of a geometrical spiral. Otherwise there's no recognisable pattern to understand what "the same manner" is.
I think the kata is clear enough since more than 6000 guys passed the kata. There is no intention to dispose the drawing as a spiral, only to show some fib numbers. Cheers.
Is the amount of people passing a kata a good metric of its clarity? Then what about the more than 25000 that did not pass it?
IMHO not a good percentage for a 5kyu kata which, as others already mentioned, is probably more of a 6kyu one.
Sorry to enter your nonsense "clarity metrics" discussion, I was trying to help in the first place.
bit confusing to wrap my head around but after I got the concept, it was suprisingly easy. anyhow a fun kata to try :D
VERY CONFUSING and little bit contradictory instructions ( parameter value and amount of the amountofsquares)
This is the first kata to actually piss me off.
What is the Test 6 in Java, I passed 6 tests, but it came back 5 passed ,1 error. I dindn't use recursive call but it still timed out. What is the problem, I've been stuck at this for way too much time....
Although I can choose "Go" as a language for this kata, it doesn't really work.
The kata is still there but all panels are empty. I reported the bug at Codewars https://github.com/Codewars/codewars.com/issues/1290
Seems a bit simple for a 5kyu
Yeah, I wish it had asked for a few hundred thousand random ones up to a million instead :)
Objective-C Translation Kumited - please accept :D
'alr approved some time ago'
It was very hard to optimize the solution using the concept of indexed global array.
This comment has been hidden.
Seems to be a question: then post a question not an issue. Issues are for possible errors in the kata tests. I am sure there are no errors in there since as you could have seen at the top of the page 2965 guys passed the kata (832 with Python).
@g964: thank you for the reply and the kata. I am new and novice so there may be an error in my code. Yet, I dont understand why it worked for small numbers but for large ones (e.g n = 100) the difference is so significant. I will try another approach to your kata. It's pretty interesting!
It probably failed due to round-off error.
Hi, The problem is the method. The formule is not exact for big numbers.
I have a problem with time of execute code. Is recursion a bad idea to resolve this kata? My code are working correct with the small numbers.
Yes, recursion is a bad idea because you will need to spend time calculating for values which you already know. Try to "remember" values you have calculated.
This comment has been hidden.
Timing out is not an issue of the kata but it is an issue of your code: too slow.
C# here what is the suggested output type? I tried ulong but this strange error occurs: ✘ Expected: 80 But was: 80
and of course i have overflow on the ultra-big numbers
The returned type is in the function template...
nevermind i figured it out and solved it ...Thanks anyway
Horrible kata
You should add bigger numbers in the tests, at least for python, since the naive approach can pass. Or remove "beware of big numbers" from the description. Also, as stated by others, the description is not consistent about the sum asked for.
Just make things clearer, will be a perfect kata.
This comment has been hidden.
Do you output yourself to the console?
So g964.
** ABOUT JavaScript **
5 other users have told you that the random tests in Javascript are wrong and you dismissed them with "other people have passed the kata". It just happens that I have passed the kata in other languages (Python and Java) and I have cross-checked the results.
To prove you the inconsistency of your random tests, I leave you this screenshot:
http://oi68.tinypic.com/8zjus4.jpg
Do you see what's going on here? test case on the right for 20 (that you wrote) expects correctly 114624, but your random test on the left incorrectly expects 300092.
I believe the only 63 persons who passed this kata, did it when tests were good; 63 persons over 1647 is a bit small for popular Javascript, isn't it?
** ABOUT Java **
IMHO the use of BigInteger object instead of integer primitive type is completely unnecessary for the sake of the kata, let alone using numbers up to 22 digits!
Basically the Java author forced the user to use ugly object operations instead of standard math, therefore a simple:
return res*4
have become an ugly:
return res.multiply(new BigInteger("4"));
if you've completed a kata, you should be able to see the translation kumites at '/translations'.
Excuse me, what do you mean? I did use kumite before, but I don't really know how to use them here. You mean I can fix the tests?
not necessarily fix the tests but you can fork the translation to see the tests. from there, you could potentially fix errors in your fork and get it approved once you've published your version.
click the link in my previous post, the JS translation is at the bottom of that page. adding '/translations' to the end of a kata url will take you to this page for all katas.
** ABOUT JavaScript ** I can't understand how you got
300092
as expected with the random tests. Calling "reference" solution the function "perimeterSol" in the random tests and "initial" solution "my" function "perimeter" - used to give the results in the fixed tests - these "iniial" and "reference" solutions are exactly the same as you could guess. In principle they can't give different results. Moreover my JS solution is not very different of Ruby, Python, etc... ones.I tested lots of time the reference solution with n = 20 and I always get the correct result
114624
.The tests of this kata were never changed. You can't say they were good and now they are bad. They are the same. Moreover if I had changed the tests the solutions which passed the kata would not pass anymore and you would see lots of invalidated solutions but there are none. 63 is not a lot I agree but it is not nothing and only one guy cheated to pass. Furthermore maybe this kata has not the style of Javascripters?
I refer to the guys who passed the kata because, as you could see if you want, the solutions they use are very different but pass the tests. There are memoization, no memoization, many calculate the sum of the fibs, others (I am part of others) don't calculate the sum using a property of the fibonacci sequence. Since you passed the kata you can see the random tests, you could also edit the kata as 10XL said or directly edit it. I will consider your issue if you tell me exactly where the problem is. I am sorry of these problems and I would like to know where they are.
** ABOUT Java ** Until now I thought a kata author is free to use Big Integers if he wants to. I think it is a good experience for every one even if it is not completely necessary. I personally regret that some languages don't have Big Integers. BTW it is not my responsibility if Java has an "ugly" way for Big Integers.
If there is a problem, I hope you will find it (and I will be very happy). Then please tell me. Thanks for reading this long post.
** ABOUT JavaScript **
I am very very sorry but I had a typo in the code of one function in the tests... I fixed that and I hope that now everything will go well for your JS code. Please could you tell me if it works now? Forget what I wrote about JS, I am the culprit, sorry again. I consider the issue as resolved but if it is not post a new issue. Thanks for your help, cheers!
and random tests working now.
Thanks again.
Once again, i believe there is something wrong with the test (at least for JS) Here is the output:
Time: 366ms Passed: 8 Failed: 50 <- ALL Basic tests pass, And ALL random tests fail !? Always! Weird!
Test Results: Basic tests Completed in 10ms Random numbers Log Input n=1 <-- just to make sure i log input. it is something which value is 1, not a string "1". Just to make sure i have a guard to test for int ✘ It should work for random inputs too - Expected: NaN, instead got: 8
How could the result of 1 be NaN. All other random test say exactly the same: Input is a number but expected result is NaN.
What's the deal here. Even if the tests are right and i missing something, i really want to know...
I just tried a few solutions and saw no problems.
This comment has been hidden.
Only a piece of advice: try not to use an array to calculate fib (there are lots of ways without arrays). It's not useful and I am afraid you have an overflow somewhere when you fill it and then sum it. Not enough time to go further, sorry! The tests never return "NaN" so I don't understand how you got "Expected Nan".
Neither do i. Could you try running my code as if it's another of your solutions and see if it passes?
Thank you for your advise to avoind arrays. i will see about that. But since in all tests my function returns the right result and the tests say expected NaN, that can't have anything to do with my code, can it? If my code got overflow it would not return right results time after time...
PS.
I can hardly imagine this line produce an error. this is is basic at it gets.
Here is a screen shot: http://tinypic.com/m/jhc0at/3
I am very very sorry but I had a typo in the code of one function in the tests... I fixed that and your code goes right now! Could you try again and tell me if it is right. Thanks for your help.
It runs now. I am glad my code was good but by now the solution is worth measly 2% instead of original 15% or so...
why that?
Because at the time i wrote the code i was 6th kyu and then 5th kyu katas were worth more to me Now being 4th they are not worth much to me ... i don't really care - happy that i was not crazy or stupid and was missing something trivial
When I want to pass final test I got "This error was caused due to an issue processing the web request, not because of an issue executing your code. Please try again."
sometimes the cloud platform of codewars has some hickups, try backing-up your code and refresh the webpage
Nice Kata. I think there might be inconsitency between the basic tests and the random tests in Javascript. The basic tests expect the solution to be
while the random tests expects the solution to be
for example, the basic test expect ƒ(5) to be 80, while the random test for the same number expects 48.
I don't know where, but you are wrong somewhere:-) Since you passed the kata you can have a look at the tests and you will see that the solution (my solution) is the same as my reference solution of the random tests. Otherwise anyway I would not have been able to validate my translation: when you make a translation the "solution" is always the same as the "reference" solution of the random tests even though they have different names. Moreover 58 guys passed the JS solution amongst 1631 (the tests are the same in all languages). Do you frankly think that if there were such an error nobody would have seen it?
Is there anyway better than memoization for this kata? I kept getting runner.codewars.io Host Error messages(not the time out msg designed to tell you to optimize your code), not sure if it is my code or the server. My RUBY code passed all the basic tests but does not show any result when running all test cases Error msg: This error was caused due to an issue processing the web request, not because of an issue executing your code. Please try again.
It is not an error of the kata but a CW error. Report it as a bug: Forum-> Bugs, if you want.
Have the same issues as others, all my exammple test are fine but all the random ones fail... This is second kata by the same author that produces strange test results
The tests are of the same nature in all languages and 1616 guys passed the kata. It would be more interesting if you gave examples of "strange results".
I got your reply about the other kata and admit my ignorance and acknowledge respect for your skills and creativity :) The problem is that it's hard to correct my incorrect code without knowing the test input.
You could simply print the input. Good luck and thanks for your post.
This comment has been hidden.
This was a pretty easy kata in PHP, and I found the warning about large numbers to be misleading since my code was about 7kyu complexity and refused to fail. Also, it would have helped to explicitly state in the description that n represents a fib sequence (the reference is indirect). Otherwise a satisfying kata.
I've come across an interesting situation where if my code incorporates n + 1 number of squares as described the details, then it passes every basic test but fails every random number test. If I set the number to n instead, it passes every random test but fails every basic test.
This comment has been hidden.
Yes, the description is not consistent. The elements of the sum are defined as the Fibonacci numbers themselves, but the tests require the perimeters.
This comment has been hidden.
It simply announces "random tests". It's a general -though a bit clumsy- formulation...
This comment has been hidden.
Some solutions are quite simple. I believe they would take long time to handle big numbers. What is the biggest number in test cases? Feeling this 5kyu kata is even harder than a 3kyu one, considering big numbers. https://www.codewars.com/kata/the-millionth-fibonacci-kata
This comment has been hidden.
It is not an issue of the kata. The tests are the same in all languages and more than 1000 CW passed them. Maybe a Codewar problem. You could try again or report it as a bug.
Hi everyone! I am trying to solve this Kata in Javascript. I have some issues with the random tests..I can't figure out why I get this erros messages. Does anybody have any ideas? Sadly I am clueless...I logged the input numbers to the screen as well.
Random numbers n= 27 It should work for random inputs too - Expected: NaN, instead got: 3328156 n= 58 It should work for random inputs too - Expected: NaN, instead got: 10018923127840 ....
I have some issue too
JS? I just tried a few solutions and all worked fine. Could you post exactly the ouput of a failing test?
You should add tests for SumFct.perimeter(BigInteger.valueOf(0)) and SumFct.perimeter(BigInteger.valueOf(1)). Not all solutions will pass them.
completely agree with this comment. please add these tests to the kata (or add the restriction for the parameter if that is preferred)
true, the top 2 solutions at the moment would fail
I was able to pass all the basic tests with my code, but keep failing the random number tests. I was reading through the output when I noticed a possible issue:
I can't post the screenshot of the output; however, I received an error stating that it expected 212. This shouldn't be an attainable number with the fibonnaci sequence. 212 / 4 = 53 the closest number in the sequence would be 55.
Is this an error in the test code?
Please which language? You can see that 1117 Codewarriors passed the kata so one can be sure there are no errors in the tests. Moreover please don't post as an issue before knowing that your code is correct. Issues are rather for problems in the kata than for problems in your code. Don't need a screenshot, simply post the failing tests within two series of three backticks. Google "markdown" if you don't know how to do.
Hi g964, thank you for replying. I apologize for flagging as an issue, I'm new to Codewars and wasn't sure how to bring it up. I was doing Javascript, and just thought it was odd that the test output stated 212 as an expected value when that number isn't even possible in the fibonnaci sequence. I managed to solve the kata using a different solution, but I just wanted to point out the expected output of 212 being a possible error (somewhere).
Also, I appreciate the assistance/patience, I'm fairly new to programming so it is nice to have a community as helpful as the one here on Codewars.
Thanks for your kind post! You could have posted - when you are not perfectly sure of your code - as a question. Don't worry, no harm made:-) I am happy you got it!
This comment has been hidden.
Yes the random tests need a function named "fib" and I misspelled it "fibs" it is the same problem as the one you saw below. Look at the random tests. Unfortunately it is too late to re-publish the kata. Didn't you see the note I wrote in the description for Javascript?
Thanks. Yes I did see your note, I just wasn't sure if it was the same issue, since my code did have a fib function (it just wasn't outputting what your random number tests required).
Thanks for your feedback!
Good kata, however, this error is outputing in the Javascript version:
ReferenceError: fib is not defined at perimeters at tests_code at Object.Test.describe
There's not any mention of a 'fib' variable in the description and I've successfully completed the C# version using the exact same variable names and solution logic, so either I'm missing something or there's a potentially big issue which gets in the way of completing the kata.
I mis-spelled a function in the reference solution... my mistake:-( and nobody saw it before! Now that the kata has been passed by more than 500 CW I can't modify the tests anymore. If you want to pass in JS or Coffeescript, take the part of your function that calculate Fibonacci numbers, make this part as an auxiliary outer function that you name
fib
and it should pass. Sorry for the inconvenience! Please could you tell me if you succeed with this modification?Thanks for the reply! Yep, it worked, take a look at my solution.
Good and thanks for your feedback!
For Java version if you are using BigInteger in declaration of the method it'll be better to add corresponding import. Because when you run without adding import you'll receive an error :)
Usually it is something that is written by Codewarriors, isn't it?
well it's the first time that I was forced to modify something else besides the function body. So I'm not sure what the rules are :) Usually I just add a function body and can run the tests.
The rules are very often, but maybe not always, that you had to write all you need:-)
This has been added some time ago
Can someone explain this for me? Say that S(n) is the nth term of the above sum. So S(0) = 1, S(1) = 1, S(2) = 2, ... , S(5) = 8 What does it mean nth term of the above sum, I understand it in a way that S(5) is the sum of perimeters of 5 such rectangles.
S - is the sum of a square's sides, than that sum (S) is multiplied by 4 and as a result you get a perimeter of squares. So S(n) - is a length of nth square side.
And you need to write a function that will calculte 4 * S = 4 * ( S(0) + S(1) + .... + S(n) )
Something is wrong with the description. It says we need to compute S = S(0) + S(1) + ... + S(n), but in fact, it wants S*4.
This comment has been hidden.
A priori I think it is a CW problem. See https://bkaestner.github.io/codewars-rules/#errors.
This is a good kata. I am a bit torn about its kyu especially after seeing some of this Sensei's other 5 kyu katas :) Nevertheless, a good question that could send people off in a bad path ;)
Speaking on the Clojure version of this kata, I'm having problems getting this test to pass for large n. Locally, my tests pass without running out of heap.
I created a test for n=77911, and the test passes no problem locally, but I'm met with a "java.lang.OutOfMemoryError: Java heap space" when running on codewars.
Could this have something to do with how the JVM is configured? If so, do the non-JVM versions of this kata have similar restrictions?
Kind of. There's definitely a limit in Haskell, Python and Javascript, although I'm not certain of the actual numbers.
Maybe you are calculating a bunch of Fibonacci's numbers?
Nah, he's calculating the number of kittens. Seriously, some of your comments are completely off :D. But for those, who're interested, g964 means "Do you memoize the whole Fibonacci tree? That takes too much memory. There's an approach that takes O(log n) operations to get the nth Fibonacci number, which should help you to finish in time."
This comment has been hidden.
Does anyone know why the exact same code that I copy and paste from my Eclipse doesn't give me the right resuts in this browser,
but gives the right results in eclipse? I made sure the class names are all correct, but for some reason test 1 works fine but test 2 and 3 the returns are off. In eclipse my
code works totally fine. Any help appreciated, thanks!
Update: I found out for some reason a variable was getting a value from somewhere... no idea where it comes from as I declared the int with 0 and then strangely it would have a value of 20 before doing a loop... fixed by declaring it to 0 right before the loop
I really found this helpful for trying to figure out more efficient ways to execute the same code. This exercise also made me "think big" when considering algorithms and the amount of data that needs to be processed. Because of this kata I stumbled upon some helpful information about different data structures, which was also helpful. Thanks to the author!
Thanks for your kind feedback!
Agreed. Recursive fibonacci will freeze on n=100. I had to rack my brain to implement different approach which was a great exercise.
Ok, I have written code for this Kata in Python, and have used arrays to compute the Fibonacci numbers. When I use the default test cases, they complete in 21ms.
A coworker of mine has completed this challenge using Haskell, and is using a less efficient way to compute fibonacci, and it takes 2430 ms.
When I submit my code, I get the error "Process was terminated. It took longer than 6000ms to complete." But my coworkers code, even though it takes much longer to run, is accepted.
Look at the post below, you will understand that your code in Python isn't fast enough. You can't compare the time between different languages at Codewars. Maybe Haskell is rather lengthy to begin but when it has begun, it goes faster... Who knows? Another possibility: the Haskell tests are a bit less difficult than the Python tests because Python is usually fast. Anyway it's not a Kata issue, it's an issue of your coding. Better the calculation of your Fibonacci and you'll succeed. PS: I think this kata is not an easy one because of big numbers.
@g964:
You can.
runhaskell Main.hs
and/orghc --make Main.hs && ./Main
will always have a greater overhead thanpython main.py
, since GHC compiles everything and loads its RTS.That's bogus. Given that your hidden tests use
1200 * x
, wherex
is an arbitrary positive integer, it's rather likely that QuickCheck will generate several values that are larger than 83. Also, Python has only 25 random tests, where Haskell has 100.It is easy. Even a O(n) implementation will succeed. However, a O(2^n) implementation is guaranteed to fail.
@TheEndIsNear: Add a test case for 100000 to your own test cases. Check whether your algorithm still completes in 21ms.
I would think generally, Haskell code would run faster than python, due to the fact that it is compiled. Python is not known for being the quickest running language, until you start using things like pypy.
It's not under 21 ms, runs around 800ms currently
hi, am new here. when i press test button it is success and takes 16ms, if i press submit button i get an error because it is taking more then 6000ms. I dont get it :)
This means your code is not optimal enough. When you press "Run tests", you run the simple tests, which are editable. When you press "Submit", you run the validating tests, which you cannot edit and which may be quite heavy. If you get the 6000ms error, your code is just too slow, and you have to refactor it so it manages to run the submission tests within 6 seconds.
https://github.com/Codewars/codewars.com/wiki/Error-messages:-Submission-timed-out#huh-it-says-now-process-took-more-than-6000ms-did-they-change-the-message
I can't say better:-)
By the way, you probably use an exponential algorithm to get your result and therefore have O(2^n) instead of O(n).
lovely Kata!!!
This comment has been hidden.
Lots of thanks for your post.
Ah! Would be good if you had published your guide:-)
Why don't you remove if from this kata as well?
If you mean in
testPerimeter
, then no. At least not at the moment.HUnit
provides some helpers, but that means that you need to use its DSL instead of Hspecs one.See above.
Spec
works fine. Don't useSpecWith (Arg ...)
. After all,hspec
has typeSpec -> IO ()
.What exactly don't you understand? Now, it's not so important since GHC can't handle cyclic dependencies at the moment, but if it's ever able to resolve them, you would be in deep trouble.
You didn't read my comment last week, right (the edit also happened last week)?
I suppressed Control.Applicative (<|>) in this kata. I'll see others when I have time, replaced SpecWith with Spec. I had read your comment of last week but before you edit it with a link to Github. I downloaded your guide and will read it. In printf I keep the "n" for the moment because I don't see the need in testPerimeter to have only (printf "should return the perimeter") printed x times. As for import/export I don't see where I export my "solution", I don't see where I have cyclic dependencies. In the tests I import the module with the solution, nothing more.
Make sure to report issues and remarks on GitHub, not on Codewars. I've mostly deactivated Codewars emails lately, but I still get them from GitHub.
You don't have an explicit export list, therefore you export everything within your module. You don't have cyclic dependencies. I said that if GHC was able to handle cyclic dependencies, the user could import your test module. Given that you follow my naming approach (
Codewars.Kata.xxx.Test
), it would be easy for the user to cheat. But it's rather unlikely that GHC will handle those dependencies.Maybe it would be sufficient that I add to Codewars.Kata.xxx.Test something like a "code" (e.g ab345) that I change for each kata?
Why that hassle? Simply export only
main
, e.g.module Codewars.G964.Kata.Test (main) where ...
. Or don't definesolution
in the global namespace.Note that I consider this basic (heh, like Fibonacci, right?) Haskell knowledge. This isn't discussed in the guide so far.
I hope I'm beginning to understand but, you know, I think I'm only Haskell (and elsewhere...) sub-basic:-) Thanks for your patience!
No offence, but one can see that. That's why I don't provide Java or C# (or even Ruby/Python, depending on the difficulty) variants of my katas and instead wait for translations, they usually have a much higher quality and I can learn from them. Also, I suck at writing C# and Java (don't know the standard library at all, in constrast to other languages). Furthermore, one doesn't get additional honor from additional languages (e.g., see my site events), so I leave that honor to others.
Unable to see "e.g., see my site events". Got
Huh. Either way, the important part is: as far as I know, you don't get additional honor if you post your kata in many languages at once.
You do get additional rank progression in that language though - though the additional honor is something we should fix at some point. Although there is another advantage to having multiple languages on a kata which is that they get up voted faster (larger audience) and kata with lots of languages tend to get approved much faster.
BTW @bkaes you can turn your CW emails into daily digests if that helps at all.
I have fixed the Haskell translation to generate inputs
0 .. 100_000
, instead of1200
a hundred times (perimeter 1200 * x
is(perimeter 1200) * x
, notperimeter (1200 * x)
). Also added explicit import and export lists where applicable, and moved showing inputs to failure messages.ETA: Some solutions have been invalidated because of insufficient performance.
100_000
may be higher than you intended.Should include Algorithms in the tags.
Codewars writes for the Tag "Algorithms":
This kata doesn't need elaborate specifications, Fibonacci is a basic for every programmer hence the tag "Fundamentals" is more than sufficient, isn't it?:-)
That's baseless assumption. I've read many books on programming, and only a very small number of them actually had the Fibonacci function.
Yes it's certainly baseless but if you google Fibonacci you get: About 18,900,000 results... Besides that I don't understand very well the tag "Algorithm" because I think every program includes at least one algorithm.
Oh, every program is a algorithm, since a program is a unambigously defined sequence of operations (or has undefined behaviour). But not every problem is stated as an algorithm. You can say "Create a ABC!" and check fundamentals for ABC students. Or you can give the complete sequence of steps and therefore also tackle those, that don't know what an ABC is.
But my criticism wasn't about the tag, just about the "Fibonacci is basic" ;).
Nice kata
Thanks for the feedback!