I just tried my first problem on Codewars and realised: This solution feels like cheating
Sometimes Julia feels like cheating
https://www.codewars.com/kata/582aafca2d44a4a4560000e7
https://www.codewars.com/kata/582aafca2d44a4a4560000e7
I just tried my first problem on Codewars and realised: This solution feels like cheating
5 Comments
verstra@programming.dev · 6 pts · 3y
What's the solution in Julia?
floorjam@lemmy.world · 3 pts · 3y
I first did something with
findfirst, which needed some bounds checks. Then I saw another answer and they usedsearchsortedfirstwhich is just it ... Even the documentation reads like the problem descriptionverstra@programming.dev · 1 pts · 3y
Ah so the library is just made for problems like this. Who would have thought :)
MatFi@lemmy.thias.xyz · 2 pts · 3y
Naahh… searchsortedfirst is simply faster than other search algorithms (in this specific case). Extremely useful in many applications.It ist there because Julia cares about efficiency
floorjam@lemmy.world · 1 pts · 3y
This helped me realize how much this aligns with my problems (and I guess the spirit of this test problem). Sometimes you have special knowledge of your data and can use much more efficient functions that are just there in Julia.