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
| # first we'll need a set to store results in- that means we won't need to de-dupe | |
| h=set() | |
| total=0; | |
| # obviously i would be less than < 5 digits long, since it's at least n = 2 (number cat number*2) | |
| # and b is less than 7- because with a > 2, that would be 10 digits | |
| for a in range(1,9999): | |
| product = "" | |
| for b in range(1,7): | |
| product += str(a*b) |
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
| #!/usr/local/bin/node | |
| // first, prep prime seive up to 1MM | |
| n=1000000; | |
| myPrimes = new Array(); | |
| for (i=2;i<=n;i++) | |
| { | |
| myPrimes[i]=true; | |
| } |
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
| #!/usr/local/bin/node | |
| function reverse(s){ | |
| return s.split("").reverse().join(""); | |
| } | |
| function ispali(a) | |
| { | |
| a = a.toString(); | |
| for (i=0;i<=a.length-1;i++) |
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
| #!/usr/local/bin/node | |
| // first, prep prime seive up to 1MM | |
| n=1000000; | |
| myPrimes = new Array(); | |
| for (i=2;i<=n;i++) | |
| { | |
| myPrimes[i]=true; | |
| } |
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
| #!/usr/local/bin/node | |
| // these are the values of the factorials of each digit from 0-9- from earlier exercise | |
| factorial = [1,1,2,6,24,120,720,5040,40320,362880] | |
| sum = 0; | |
| // you could use advanced math to figure out the upper bound- i just tried up to 10^7 | |
| for (a=3;a<=100000;a++) |
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
| # first we'll need a set to store results in- that means we won't need to de-dupe | |
| h=set() | |
| total=0; | |
| # now, we'lll make the fractions 10 to 99 in numerator and denominator | |
| for a in range(10,100): | |
| for b in range(10,100): | |
| if (a!=b): | |
| numerator = str(a) | |
| denominator = str(b) |
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
| # first we'll need a set to store results in- that means we won't need to de-dupe | |
| h=set() | |
| total=0; | |
| # now, we'lll make the strings- | |
| # 1 digits x 4 digits will be 4 or 5 digits (9-10 total) and 2 digits x 3 digits will by 4 or 5 digits (9-10 total) so try up to 9999x99 | |
| for a in range(1,9999): | |
| for b in range(1,99): | |
| product = str(a)+"x"+str(b)+"x"+str(a*b) |
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
| #!/usr/local/bin/node | |
| // our basic method here is to start with the largest coin and count down to the smallest | |
| // each time you use up a coin (ie. that loop gets to zero) you're still checking the next | |
| // smallest coin, down to the smallest one. there is probably a way to write this recursively | |
| // instead of copying out the loop 8 times, but i don't know recursive functions yet. | |
| // remove the comments if you want an actual enumeration of each set. | |
| goal = 200; | |
| count = 0; |
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
| #!/usr/local/bin/node | |
| /* the question is a little unclear- b/c a naive reading might assume | |
| you only need to check the five digit numbers, since the example given is 4 digits | |
| this would be a special class of numbers called "narcissistic"- but here we're looking | |
| for a larger case- ANY number of digits that, when ^5 and added, give the number, starting | |
| from two (since the problem says don't count 1). harder is to figure out upper limit. | |
| at first, i just let it run to 1MM, hoping that would be enough. it was. then i read | |
| up and found someone had figured out the exact limit with this logic: | |
| assume each digit is a 9: 9^5~~ 60K-- so every digit we add gives us another 60K or so. |
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
| #!/usr/local/bin/node | |
| // prime sieve from problem 9 (we only need primes through 11, since 11^2=121) | |
| n=100; | |
| myPrimes = new Array(); | |
| for (i=2;i<=n;i++) | |
| { | |
| myPrimes[i]=true; | |
| } | |
| for (i=2;i<=n;i++) |