This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |