## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
##### Activity
Voile
@Voileexperiments
that's an issue
he shouldn't have put the reference solution in preloaded :trollface:
hobovsky
@hobovsky
okay, let's put this page to the good use. I added random tests, anyone to review? https://www.codewars.com/kumite/544fff1b2433c3f32a000453?sel=5ce7b7f7f6c688000f30e1b6
Java version of "Is prime?"
hobovsky
@hobovsky

O(n) solutions pass the tests in other languages including the original language.

@error256 could you please elaborate on what's the issue here? Do random tests in Java stand out somehow? Because as far as I've checked, the naivestest solution passes java just as other languages(what I think is generally expected for 6 kyu task). Or I get something wrong?

error256
@error256
The most naive is one that checks up to n (by the definition of primes), it certainly doesn't work with MAX = 2_000_000_000.
hobovsky
@hobovsky
okay so check up to sqrt(n) is too optimized, then
but all versions use sqrt(n) as limit (not sure about nasm tho)
hobovsky
@hobovsky
accepted ones, at least. The pending Rust uses n and pending C uses n/2 (sic!)
error256
@error256
There's not much difference between n and n/2. The original version is JS, then Python and Ruby.
hobovsky
@hobovsky
• All of JS, Python, Ruby lack random tests and check just handful of cases. They pass on 2..n
• C#, C++ and Haskell time out on 2...n and pass on 2..sqrt(n) (yeah, you made me even to solve it in Haskell, thank you very much)
Don't get me wrong, I am not fighting about anything, just trying to get to some conclusion :) IMO sqrt(n) and i+=2 are optimizations which do not go out of 6 kyu scope, what you seem to disagree with. So, we fix missing random tests or dumb down other versions?
error256
@error256
First, whenever the input range isn't specified, I assume that any imaginable solution won't time out and won't have overflows in intermediate calculations. Second, I think the original version normally sets the baseline for translations and messed up ranks are a different issue.
When approved translations with different requirements split 50/50 and the kata author is inactive, I don't care which way it's going to be changed, but I don't approve new translation until existing ones are consistent.
hobovsky
@hobovsky

First, whenever the input range isn't specified, I assume that any imaginable solution won't time out

I wonder if my bogosort implementation would pass 8 kyu sorting kata... :)

but I get what you mean
Just don't agree with it in full extent :)
hobovsky
@hobovsky
Okay so I tried to add random tests to this kata: https://www.codewars.com/kata/is-a-number-prime, JS version. If you guys could take a look and check if I did not mess up something (especially whether I did not make it noob-unfriendly, as some people think said ). If you think it;s ok, I will add tests in similar way to Python and Ruby. If not, then tell me.
hobovsky
@hobovsky

Any C-aware person would mind to take a look at this, this and this translations?

Note that I tried only to address the remarks raised in the comments, and not the logic of tests/ref solution/etc. If there's still something to fix, leave a comment.

Diego Mayer
@Chrono79
Is this typescript translation approvable? I've added some conditional comments to the description
Diego Mayer
@Chrono79
Thanks
hobovsky
@hobovsky
there are C and C++ translations to "List Filtering" kata which are based on the same premise of tagged unions. I hesitate between rejecting them of being not applicable to C/C++, and reviewing/updating/accepting them as a lesson in C and "variant" types + rejecting C++ version and turning it into std::variant (is C++17 supported on CW?). waddaya think guys?
error256
@error256
I'm not really sure. I'd more likely reject everything that has to use custom data structures for union types, that is, reject C unconditionally and reject C++ until std::variant. I mean, that's for this kind of kata where it's the main focus, otherwise it would be no more questionable than the need of heterogenuous arrays in the first place. And there's no C++17 on CW :( A lot of katas could really use std::optional and I remember missing something else too...
hobovsky
@hobovsky
rejecting it, then
Voile
@Voileexperiments
we need more guts to actually reject translations
hobovsky
@hobovsky
agreed, I wanted to trash a bunch yesterday but then I was like "but maybe they could be fixed? Maybe they are somehow valuable? Maybe someone will get hurt?|
hobovsky
@hobovsky
rejected it is, then. Damn, I feel like I am putting this list to the really good use! :D
besides, are strings in union even a thing for C++? Isnt it that union can contain only PODs?
error256
@error256
I think non-POD unions were introduced in C++11. There's an example of an int/string union in Stroustrup's book.
hobovsky
@hobovsky
damn, my c++ skills are REALLY rusty :/
Diego Mayer
@Chrono79
Has anyone used chai-spies in a kata? I can't get it to load, even if it says it's available here
hobovsky
@hobovsky
Anyone bothered to take a look into white java translation? https://www.codewars.com/kumite/553d2f4e8c789cf85c000051?sel=5cefeab1c84344002af7887f
Tomasz ZdybaĆ
@tzdybal
Diego Mayer
@Chrono79
Diego Mayer
@Chrono79
Thanks
Diego Mayer
@Chrono79
Hi, can someone check and approve this javascript translation? https://www.codewars.com/kumite/5d1f572c3c70c000219f17e0?sel=5d1f572c3c70c000219f17e0
Diego Mayer
@Chrono79
Thanks
Jonas B. Nielsen
@jonasbn
Can some one point me to a description of how to communicate possible improvements to a kata or does that require that you have sufficient privileges so you can fork?
Blind4Basics
@Blind4Basics
post a "suggestion" in the discourse of the kata
Jonas B. Nielsen
@jonasbn
@Blind4Basics thanks :-)
nomennescio
@nomennescio
Hi, is this the place to ask reviewers to have a look at translations? I'm trying to increase the number of available Forth katas by translating existing ones
hobovsky
@hobovsky
It is a good place indeed, I am just not sure about availability of Forth reviewers
nomennescio
@nomennescio
I see, I also asked in codewars.com room, and apparently people are also looking at translations there too :)
It seems there's a bit more activity over there
error256
@error256
I'm a noob here. Are arrays normally passed as address + size in Forth? What kind of static tests should be preferred? Any subtle things about these approaches?
<{ input-0 dup @ cell under+ foo -> 0 }> => <{ input-0 factored-out foo -> 0 }> - input is defined in a different place, but the output is here; it can probably be stored with the input?..
<{ here 11 , 11 , 11 , 3 foo -> 2 }> -3 cells allot => 11 11 11 3 factored-out-with-brackets - can foo ever have a reason to mess up the dictionary so that -3 cells allot removes something else?
<{ here 11 , 11 , 11 , 3 foo -> 2 }> - looking straightforward, but leaves trash in the dictionary; the arrays are small, so it's not much to worry about; or should it still be avoided?
Any better way?
nomennescio
@nomennescio
Arrays are not a standard language feature. Strings are. Usually you create an array as is most suitable for your problem. Sometimes it can include a length, often you know the length. And for the test framework; it is best to move as much outside the actual test framework, as it will give more helpful reporting on mismatched stack depths. For instance:
: shouldbe { string len -- } <{ string len user-solution -> string len preloaded-solution }> ;
and then call shouldbe with strings
The GForth manual is not that helpful, you're better of reading some better introductory material (see for instance the references in the Forth test framework)
nomennescio
@nomennescio
As for arrays, the following is usually good enough:
create monthdays 31 , 28 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31 ,
monthdays 5 cells + @