I agree in that async/await is cleaner (IMO) than chaining Promises.
As an aside for the curious, one can await Promise.all for parallel execution and use destructuring to pull return values, assuming you're OK with the inherent fail-fast behavior.
e.g. const [resOne, resTwo] = await Promise.all([ asyncOne(), asyncTwo(), ]);
I agree re: the switch. There was a great S.O. post about this where someone actually took the time to calculate the performance of a forced switch across all browsers and found that it was 6x to 40x slower than the fastest solution (fastest was if-immediate) in all tested environments (pretty much every browser).
That said, my solution was a forced switch much like this one. I just wanted to use a switch statement because I seldom get to use them and was beginning to forget the syntax :-)
Likewise with Python. This wasn't at all an 8 kyu kata. Yes, it's mostly algorithms and critical thinking, but I feel like this level of critical thinking is developed as one becomes more adept at coding (thus, should be a higher difficulty).
As JStegg wrote - f string is available in python >= 3.6. It is new feature (great in my opinion;)). You can choose python version for almost every kata on codewars.
I gotcha; thanks. I didn't realize we could use different versions on here (do we import them or something)? I'm not sure how all that works - I'm still in the initial learning phases, so please excuse the ignorance!
Yeah, but the author should clarify this in the prompt..
I agree in that async/await is cleaner (IMO) than chaining Promises.
As an aside for the curious, one can await Promise.all for parallel execution and use destructuring to pull return values, assuming you're OK with the inherent fail-fast behavior.
e.g.
const [resOne, resTwo] = await Promise.all([ asyncOne(), asyncTwo(), ]);
This comment is hidden because it contains spoiler information about the solution
I had a timeout error with this kind os solution...
click the drop down at the top of the kata and you can select the version
This comment is hidden because it contains spoiler information about the solution
because it's not a list. Look at the documentation of the fonction generating it.
This comment is hidden because it contains spoiler information about the solution
The other great thing about looking at other solutions is seeing cool logic like this when you used parseInt :-)
I agree re: the switch. There was a great S.O. post about this where someone actually took the time to calculate the performance of a forced switch across all browsers and found that it was 6x to 40x slower than the fastest solution (fastest was if-immediate) in all tested environments (pretty much every browser).
That said, my solution was a forced switch much like this one. I just wanted to use a switch statement because I seldom get to use them and was beginning to forget the syntax :-)
It's so fast!!
Likewise with Python. This wasn't at all an 8 kyu kata. Yes, it's mostly algorithms and critical thinking, but I feel like this level of critical thinking is developed as one becomes more adept at coding (thus, should be a higher difficulty).
As JStegg wrote - f string is available in python >= 3.6. It is new feature (great in my opinion;)). You can choose python version for almost every kata on codewars.
I gotcha; thanks. I didn't realize we could use different versions on here (do we import them or something)? I'm not sure how all that works - I'm still in the initial learning phases, so please excuse the ignorance!
You need to use 3.6
Loading more items...