Skip to content

Instantly share code, notes, and snippets.

@amilajack
Created June 4, 2017 19:42
Show Gist options
  • Save amilajack/f223465e860fed32444b279cbe6fe132 to your computer and use it in GitHub Desktop.
Save amilajack/f223465e860fed32444b279cbe6fe132 to your computer and use it in GitHub Desktop.
esnextbin sketch
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>ESNextbin Sketch</title>
<!-- put additional styles and scripts here -->
</head>
<body>
<!-- put markup and other contents here -->
</body>
</html>
function recPerm(chars, string) {
if (chars.length === 0) {
console.log(string)
return
} else {
for (let i = 0; i < chars.length; i++) {
recPerm(
chars.filter(e => e !== chars[i]),
string + chars[i]
)
}
}
}
function soo(string) {
recPerm(Array.from(string), '')
}
soo('amila')
{
"name": "esnextbin-sketch",
"version": "0.0.0",
"dependencies": {
"babel-runtime": "6.23.0"
}
}
'use strict';
var _from = require('babel-runtime/core-js/array/from');
var _from2 = _interopRequireDefault(_from);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function recPerm(chars, string) {
if (chars.length === 0) {
console.log(string);
return;
} else {
var _loop = function _loop(i) {
recPerm(chars.filter(function (e) {
return e !== chars[i];
}), string + chars[i]);
};
for (var i = 0; i < chars.length; i++) {
_loop(i);
}
}
}
function soo(string) {
recPerm((0, _from2.default)(string), '');
}
soo('amila');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment