Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Yah...This function will accept (xxx) xxx-xxxx as a valid phone number. Everyone says it's so clever! lol
See
https://junli.netlify.app/en/overlapping-regular-expression-in-python/
For a bit of an explanation as to how the lookahead is working and a link to a relevant Stack Overflow question.
This comment is hidden because it contains spoiler information about the solution
The formula needs () around the 5.14/W term or else the top could be interpreted as (A × 5.14)/(W × r)
Thank you! I have been using the + for a little while now because of you. I enjoy many of your Kata's as well. :)
Good Kata! However, I agree with Stranewayesthere is definitely a bit of an English problem with the instructions. You should definitely change the wording to mention that the length of the numbers to the left and right of the decimal point is what decides the correct function to use.
Good one! Thanks for the fun mate!
Thanks! It is kind of ugly, but I am pretty new to all this and usually at the point where I just want to make a solution that works.
function convertToMixedNumeral(parm){
var a = parm.split('/');
var wNum = (a[0]>0)? Math.floor(a[0]/a[1]):Math.ceil(a[0]/a[1]); ;
var fNum = a[0]%a[1];
var ans = (wNum !==0)?
${wNum} ${fNum}/${a[1]}
:${fNum}/${a[1]}
;var ansNeg =
${wNum} ${-1*fNum}/${a[1]}
if( fNum == 0){
return
${wNum}
;} else if (a[0] < a[1] && a[0] > 0){
return parm;
} else if (wNum < 0){
return ansNeg;
}else return ans;
}
Javascript.
I just don't see how it could work for all but that case, when there doesn't seem to be anything special about the 13/5 case.
My code passes 20 of the tests except for 1 which says
`Expected: 2 3/5, instead got: 13/5'
No idea why it would work for all the other conversions and not that one.
I'm not sure why you think it is incorrect. Maybe it has been updated since your comment but it seemed to function fine for me.
Well my solution wasn't passing the random test case where '0' was expected. So I just tried again, got another random array, and it worked. :\