Skip to content

Instantly share code, notes, and snippets.

const _ = require('lodash');
const getCombination = arr => i => arr.filter((v,j) => i & Math.pow(2, j));
const solve = (a, b) => {
const unders = a.length > b.length ? b : a;
const ups = a.length > b.length ? a : b;
if (!unders.length || !ups.length) return 0;
const m = Math.pow(2, unders.length);
const n = Math.pow(2, ups.length);
const getUndersCombination = getCombination(unders);
const getUpsCombination = getCombination(ups);
const _ = require('lodash');
const getCombination = arr => i => arr.filter((v,j) => i & Math.pow(2, j));
const solve = (unders, ups) => {
if (!unders.length || !ups.length) return 0;
const m = Math.pow(2, unders.length);
const n = Math.pow(2, ups.length);
const getUndersCombination = getCombination(unders);
const getUpsCombination = getCombination(ups);
const underSumMap = {};
for (var i = 0; i < m; i++) {
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<script src='http://code.famo.us/lib/require.js'></script>
<script type='text/javascript' src='http://code.famo.us/famous/0.2/famous.min.js'></script>
<link rel='stylesheet' type='text/css' href='http://code.famo.us/famous/0.2/famous.css' />
</head>
<body>