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.
Your wish is granted
The std::exchange + ternary made it perfect. Nice work!
It seems this kata actually requires finding those prime factors which is a (very) hard problem in general. I'm not sure whether non-sophisticated approaches will work here (that depends on the size of the input numbers), so I will skip this kata for now.
Great stuff, love it! Contains some nice hidden details such as using
operator<
onstd::pair<>
, C++14 lambda captures with initializer, etc. that make the solution very dense.Greatest drawback, in my opinion, is that it doesn't work for empty lists of intervals where it does invoke UB (because of
intervals[0]
). I fixed that in a fork, and additionally improved readability a bit more by using some other modern C++ features.This kata has been much more fun than I initially thought it would!
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Dope!
This comment is hidden because it contains spoiler information about the solution
Lol
I wouldn't want the (unnecessary) memory consumption of the intermediate
ranges
vector in this solution. Imagine millions of ranges the size of 1 or 2...When the integer list
args
is empty on input, wouldn't you then get an emptyresult
string, callpop_back()
on an empty string thereby triggering Undefined Behaviour?This comment is hidden because it contains spoiler information about the solution
Slow but nice and simple.
Loading more items...