String permutation

Developer
Size
2,875 Kb
Views
46,552

How do I make an string permutation?

Getting creative with string permutation. What is a string permutation? How do you make a string permutation? This script and codes were developed by John Urbank on 08 July 2022, Friday.

String permutation Previews

String permutation - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>String permutation</title> <script src="http://s.codepen.io/assets/libs/modernizr.js" type="text/javascript"></script> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ html, body, .wrap { height: 100%; margin: 0; padding: 0;
}
body { background: #252525; overflow: hidden; font-family: Helvetica;
}
input { background: #1a1a1a; border: 2px solid #2B2B2B; padding: 2%; color: #ccc; font-size: .9em; position: relative; margin: 4% 0 4% 4%; text-align: center; max-width: 90px; outline: none;
}
.bar { text-align: center; position: relative; top: 1%; float: left; padding-top: 3%; color: rgba(255, 255, 255, 0.4);
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <body> <input type="text" placeholder="enter a string" maxlength="4"> <div class="wrap"></div>
</body> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

String permutation - Script Codes CSS Codes

html, body, .wrap { height: 100%; margin: 0; padding: 0;
}
body { background: #252525; overflow: hidden; font-family: Helvetica;
}
input { background: #1a1a1a; border: 2px solid #2B2B2B; padding: 2%; color: #ccc; font-size: .9em; position: relative; margin: 4% 0 4% 4%; text-align: center; max-width: 90px; outline: none;
}
.bar { text-align: center; position: relative; top: 1%; float: left; padding-top: 3%; color: rgba(255, 255, 255, 0.4);
}

String permutation - Script Codes JS Codes

$(document).ready(function($) { var button = $('button'); $('input[type="text"]').keyup(function() { var input = $('input[type="text"]').val(), bar = $('.bar'); bar.remove(); //string permutation algorythm - credit goes to Skeeto: http://www.reddit.com/user/skeeto function permute(string) { function recur(string, prefix) { if (string.length === 0) { return [prefix]; } else { var out = []; for (var i = 0; i < string.length; i++) { var pre = string.substring(0, i); var post = string.substring(i + 1); out = out.concat(recur(pre + post, string[i] + prefix)); } return out; } } var distinct = {}; recur(string, "").forEach(function(result) { distinct[result] = true; }); //let's get creative var permutedString = Object.keys(distinct), a = permutedString.toString(), b = a.split(","), wrap = $('.wrap'); for(i=0; i<b.length; i++) { wrap.append('<div class="bar">' + b[i] + '</div>'); } var bar = $('.bar'); bar.css({ 'width': (100 / b.length) + '%', 'height': '100%' }) bar.each(function(i){ $(this).css({ 'background': 'rgb(255,' + (i*15) + ', 50)' }) }) if(input === ''){ bar.remove(); } } permute(input) });
});
String permutation - Script Codes
String permutation - Script Codes
Home Page Home
Developer John Urbank
Username jurbank
Uploaded July 08, 2022
Rating 3.5
Size 2,875 Kb
Views 46,552
Do you need developer help for String permutation?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

John Urbank (jurbank) Script Codes
Create amazing Facebook ads with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!