Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Shuffled Sequences</title>
- </head>
- <body>
- <div id="output"></div>
- <script>
- let n = 10;
- let counter = 0;
- let output = document.getElementById("output");
- let integers = [];
- for (let i = -n; i <= n; i++) {
- integers.push(i);
- }
- for (let i = 0; i <= 18; i++) {
- integers = integers.concat(integers);
- }
- let L = integers.length;
- function shuffle() {
- let element = integers.splice((counter ** 5) % L, 1)[0];
- integers.push(element);
- }
- function printSequence() {
- shuffle();
- output.innerHTML += integers[L - 1] + " ";
- counter++;
- if (counter > L) {
- counter = 0;
- }
- setTimeout(printSequence, 1);
- }
- printSequence();
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement