String permutation
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 - 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) });
});
Developer | John Urbank |
Username | jurbank |
Uploaded | July 08, 2022 |
Rating | 3.5 |
Size | 2,875 Kb |
Views | 46,552 |
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!
Name | Size |
Time is Money | 4,736 Kb |
Basic motion with JavaScript | 2,202 Kb |
Traveling through Tron - Best viewed in Webkit | 3,195 Kb |
Gutterless Feature Grid | 3,013 Kb |
Logo Slider | 3,508 Kb |
A Pen by John Urbank | 2,984 Kb |
CubeTronic | 3,716 Kb |
Simple jQuery Slider | 2,874 Kb |
Mouse Trailing | 3,268 Kb |
Simple, CSS only, responsive menu | 2,615 Kb |
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!
Name | Username | Size |
SVG Hover Animations | Kjbrum | 10,557 Kb |
Minimelephant | Smashlee | 2,507 Kb |
Ionic Infinite outside ion-content with ion-pane | Felquis | 3,117 Kb |
Parallax with only CSS | Thulioph | 2,297 Kb |
Ipad Mini Showcase | Hornebom | 10,479 Kb |
Adding Items | Valhead | 4,008 Kb |
Hamburger Menu Animation | Salmanraza | 2,580 Kb |
Welcome | Nakome | 6,076 Kb |
Scrolling Horizontal Isotope | Bramus | 2,017 Kb |
SVG Basics | HipsterBrown | 1,852 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!