Last active
August 29, 2015 14:05
-
-
Save ellenbrook/31bd0dc21f3296ec979a to your computer and use it in GitHub Desktop.
Thue-Morse Sequence to the 6th order as per the rules located at http://www.reddit.com/r/dailyprogrammer/comments/2cld8m/8042014_challenge_174_easy_thuemorse_sequences/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Document</title> | |
</head> | |
<body> | |
<pre id="printTo"></pre> | |
<script> | |
function Logic(length) | |
{ | |
this.input = [0]; | |
this.length = length; | |
this.printTo = document.getElementById("printTo"); | |
this.count = function count() | |
{ | |
for (var i = 0; i <= this.length; i++) //loop through the input num times | |
{ | |
this.printTo.innerHTML += this.input.join("")+"<br>"; //print to screen for each loop that occurs | |
for (var num in this.input) //cycle through each item and check it's value | |
{ | |
if (this.input[num] == 0) | |
{ | |
this.input.push(1); //append the appropriate value | |
} | |
else | |
{ | |
this.input.push(0); //append the appropriate value | |
} | |
} | |
} | |
} | |
} | |
var deploy = new Logic(6); | |
deploy.count(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If anyone has any advice on how to refactor this it would be much appreciated!