Comments (3)
function combine(k, arr, prefix=[]) {
if(arr.length > k) {
throw new Error('Not enough elements to combine.');
}
if (k == 0) return [prefix];
return arr.flatMap((v, i) =>
combine(k-1, arr.slice(i+1), [...prefix, v])
);
}
from r2g.
interesting technique
from r2g.
function combine(x: number, list: number[]): number[][] {
if (x === 0) {
return [[]];
} else if (x === 1) {
return list.map(e => [e]);
} else {
const combinations: number[][] = [];
for (let i = 0; i < list.length; i++) {
for (const subcombination of combine(x - 1, list.slice(i + 1))) {
combinations.push([list[i], ...subcombination]);
}
}
return combinations;
}
}
from r2g.
Related Issues (20)
- multi / keep tests should be series not parallel
- need to use --no-optional along with --production HOT 1
- npm install --save-exact
- prevent master/dev from being committed to locally
- throttle dir search with async queue HOT 1
- not breaking new releases HOT 1
- r2g rename node_modules dirs
- Use chroot to prevent dropping below $HOME/.r2g/temp
- Remove .r2g folder after tarballing
- Use --perms flag with rsync
- test alpha/beta/rc packages
- As requested, the "work on windows" ticket... HOT 1
- bash completion location
- "could not read your .r2g/config.js files"
- r2g output should be uniform
- Should check for dirty git status and dirty git index as part of r2g test and r2g publish
- create terminal vid/recording
- new command `r2g compare` HOT 1
- create super optimized tarballs HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from r2g.