Jump to content

Solve the no connection puzzle: Difference between revisions

m
→‎JS ES6: ( tidying )
(Added AutoHotkey)
m (→‎JS ES6: ( tidying ))
Line 940:
'use strict';
 
// GENERIC FUNCTIONS ------------------------------------------------------
 
// permutationsabs :: [Num a => a] -> [[a]]
const permutationsabs = xs =>Math.abs;
 
xs.length ? concatMap(x => concatMap(ys => [
// all :: (a -> Bool) -> [a] -> [x].concat(ys)Bool
const all = (f, xs) => ],xs.every(f);
permutations(delete_(x, xs))), xs) : [
[]
];
 
// concatMap :: (a -> [b]) -> [a] -> [b]
Line 980 ⟶ 977:
};
 
// alljustifyRight :: (aInt -> Bool)Char -> [a]Text -> BoolText
const alljustifyRight = (fn, xscFiller, strText) => xs.every(f);
n > strText.length ? (
(cFiller.repeat(n) + strText)
.slice(-n)
) : strText;
 
// abspermutations :: Num a => [a] -> [[a]]
const abspermutations = Math.abs;xs =>
xs.length ? concatMap(x => concatMap(ys => [
[x].concat(ys)
],
permutations(delete_(x, xs))), xs) : [
[]
];
 
// show :: a -> String
const show = x => JSON.stringify(x);
 
// unlines :: [String] -> String
const unlines = xs => xs.join('\n');
 
// until :: (a -> Bool) -> (a -> a) -> a -> a
Line 992 ⟶ 1,005:
return v;
};
 
// unwords :: [String] -> String
const unwords = xs => xs.join(' ');
 
// zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
Line 998 ⟶ 1,014:
return (xs.length <= ny ? xs : xs.slice(0, ny))
.map((x, i) => f(x, ys[i]));
};
 
// justifyRight :: Int -> Char -> Text -> Text
const justifyRight = (n, cFiller, strText) =>
n > strText.length ? (
(cFiller.repeat(n) + strText)
.slice(-n)
) : strText;
 
// CONNECTION PUZZLE ------------------------------------------------------
// show :: a -> String
const show = x => JSON.stringify(x);
 
// unwords :: [String] -> String
const unwords = xs => xs.join(' ');
 
// unlines :: [String] -> String
const unlines = xs => xs.join('\n');
 
 
// CONNECTION PUZZLE
 
// universe :: [[Int]]
Line 1,034:
0
)];
 
// TEST -------------------------------------------------------------------
 
// [Int]
const [a, b, c, d, e, f, g, h] = firstSolution;
 
 
// TEST
return unlines(
zipWith(
9,659

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.