What do you want to save?
Add Code snippet
New code examples
-
Other 2021-09-21 11:05:02
get flatten array from nested array
// using recursion, .reduce() and .concat() methods // works with arrays of any depth function flatten(arr) { return arr.reduce((acc, cur) => acc.concat(Array.isArray(cur) ? flatten(cur) : cur), []); }; const arr = [[1,2],[3,[4,[5]]]]; const flatte... Add solution -
Python 2021-09-21 03:34:02
expand pandas dataframe into separate rows
def explode(df, lst_cols, fill_value='', preserve_index=False): # make sure `lst_cols` is list-alike if (lst_cols is not None and len(lst_cols) > 0 and not isinstance(lst_cols, (list, tuple, np.ndarray, pd.Series))): lst... Add solution -
Javascript 2021-09-20 18:42:04
javascript sum of all the multiples of 3 or 5 below 1000 running total
(() => { // sum35 :: Int -> Int const sum35 = n => { // The sum of all positive multiples of // 3 or 5 below n. const f = sumMults(n); return f(3) + f(5) - f(15); }; // sumMults ... Add solution -
Javascript 2021-09-18 07:21:02
combination with repetition algorithm js
(() => { 'use strict'; // COMBINATIONS WITH REPETITIONS ------------------------------------------- // combsWithRep :: Int -> [a] -> [[a]] const combsWithRep = (k, xs) => { const comb = (n, ys) => { ... Add solution
Best helpers
+5
+5
+5
+5
+5
+5
+5
+5
+5
+5