function duplicate(arr,n) { return (arr.toString() + ',').repeat(n).split(',').slice(0,-1); }
I’m pretty proud of this answer. It turns array arr into a string, adds a comma to the end (because in JavaScript, turning arrays into strings keeps the commas), uses the string repeat() function n times, converts the resulting string back into an array by splitting it with the commas as delimiters, and then removes the last element (which will be blank because of the trailing comma). I love one-liners!
And here’s this week’s question:
Let’s do a (sort of) inverse kinematics question. Given an int armLength, int pair armOrigin, int jointPosition, and int pair target, return a boolean true if the target is reachable by the arm.
Example:
> reachable(15, [0,0], 5, [10,10]) > true
Bonus points: print the position of the joint when the arm reaches the target!
On Saying “I Love You” Only When You Mean It
67g Zilent Blacks w/ Krytox 106 (feat. DSA Hyperfuse on Canoe)
The Brain by Olson Sundberg Kundig Allen Architects
Sign Painting on Car Windshields
Someone broke into my house last night and stole my limbo trophy. How low can you go?
Alrighty folks, have a great week, be safe, make good choices, and give someone a hug that needs one!
cassidoo