aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x01-Multiples-of-3-and-5/euler1 (renamed from euler1)bin8608 -> 8608 bytes
-rw-r--r--01-Multiples-of-3-and-5/euler1.c (renamed from euler1.c)0
-rwxr-xr-x02-Even-Fibonacci-numbers/fib (renamed from fib)bin16776 -> 16776 bytes
-rw-r--r--02-Even-Fibonacci-numbers/fib.c (renamed from fib.c)0
-rw-r--r--02-Even-Fibonacci-numbers/fib.py (renamed from fib.py)0
-rwxr-xr-x03-Largest-Prime-Factor/largestprime (renamed from largestprime)bin16648 -> 16648 bytes
-rw-r--r--03-Largest-Prime-Factor/largestprime.c (renamed from largestprime.c)0
-rw-r--r--03-Largest-Prime-Factor/largestprime.py (renamed from largestprime.py)0
-rwxr-xr-x04-Largest-Palindrome-Product/palindrome (renamed from palindrome)bin16824 -> 16824 bytes
-rw-r--r--04-Largest-Palindrome-Product/palindrome.c (renamed from palindrome.c)0
-rw-r--r--04-Largest-Palindrome-Product/palindrome.py (renamed from palindrome.py)0
-rwxr-xr-x05-Smallest-Multiple/smallmult (renamed from smallmult)bin16648 -> 16648 bytes
-rw-r--r--05-Smallest-Multiple/smallmult.c (renamed from smallmult.c)0
-rw-r--r--05-Smallest-Multiple/smallmult.py (renamed from smallmult.py)0
-rw-r--r--06-Sum-Square-Difference/sumsq.py28
-rwxr-xr-x07-10001st-Prime/10001prime (renamed from 10001prime)bin16880 -> 16880 bytes
-rw-r--r--07-10001st-Prime/10001prime.c (renamed from 10001prime.c)0
-rw-r--r--07-10001st-Prime/10001prime.py (renamed from 10001prime.py)0
-rwxr-xr-x08-Largest-Product-In-a-Series/productofdigits (renamed from productofdigits)bin16680 -> 16680 bytes
-rw-r--r--08-Largest-Product-In-a-Series/productofdigits.c (renamed from productofdigits.c)0
-rw-r--r--08-Largest-Product-In-a-Series/productofdigits.py (renamed from productofdigits.py)0
-rw-r--r--09-Special-Pythagorean-Triplet/pyth.py30
-rwxr-xr-x10-Summation-of-Primes/sumofprimes (renamed from sumofprimes)bin16904 -> 16904 bytes
-rw-r--r--10-Summation-of-Primes/sumofprimes.c (renamed from sumofprimes.c)0
-rw-r--r--10-Summation-of-Primes/sumofprimes.py (renamed from sumofprimes.py)0
-rwxr-xr-x11-Largest-Product-In-Grid/prodgrid (renamed from prodgrid)bin10312 -> 10312 bytes
-rw-r--r--11-Largest-Product-In-Grid/prodgrid.c (renamed from prodgrid.c)0
-rwxr-xr-x12-Highly-Divisible-Triangular-Number/bigfactors2 (renamed from bigfactors2)bin16752 -> 16752 bytes
-rw-r--r--12-Highly-Divisible-Triangular-Number/bigfactors2.c (renamed from bigfactors2.c)0
-rw-r--r--12-Highly-Divisible-Triangular-Number/bigfactors2.py (renamed from bigfactors2.py)0
-rwxr-xr-x14-Longest-Collatz-Sequence/collatz (renamed from collatz)bin16696 -> 16696 bytes
-rw-r--r--14-Longest-Collatz-Sequence/collatz.c (renamed from collatz.c)0
-rw-r--r--14-Longest-Collatz-Sequence/collatz.py (renamed from collatz.py)0
-rw-r--r--16-Power-Digit-Sum/sumexp.py (renamed from sumexp.py)0
-rw-r--r--17-Number-Letter-Counts/wordnums.py48
-rw-r--r--README.md19
-rw-r--r--reworking/sumexp.c15
37 files changed, 137 insertions, 3 deletions
diff --git a/euler1 b/01-Multiples-of-3-and-5/euler1
index 585d380..585d380 100755
--- a/euler1
+++ b/01-Multiples-of-3-and-5/euler1
Binary files differ
diff --git a/euler1.c b/01-Multiples-of-3-and-5/euler1.c
index d89956e..d89956e 100644
--- a/euler1.c
+++ b/01-Multiples-of-3-and-5/euler1.c
diff --git a/fib b/02-Even-Fibonacci-numbers/fib
index e9b1b3b..e9b1b3b 100755
--- a/fib
+++ b/02-Even-Fibonacci-numbers/fib
Binary files differ
diff --git a/fib.c b/02-Even-Fibonacci-numbers/fib.c
index 915fccd..915fccd 100644
--- a/fib.c
+++ b/02-Even-Fibonacci-numbers/fib.c
diff --git a/fib.py b/02-Even-Fibonacci-numbers/fib.py
index c2f2691..c2f2691 100644
--- a/fib.py
+++ b/02-Even-Fibonacci-numbers/fib.py
diff --git a/largestprime b/03-Largest-Prime-Factor/largestprime
index c2afe6f..c2afe6f 100755
--- a/largestprime
+++ b/03-Largest-Prime-Factor/largestprime
Binary files differ
diff --git a/largestprime.c b/03-Largest-Prime-Factor/largestprime.c
index bf98414..bf98414 100644
--- a/largestprime.c
+++ b/03-Largest-Prime-Factor/largestprime.c
diff --git a/largestprime.py b/03-Largest-Prime-Factor/largestprime.py
index 387de01..387de01 100644
--- a/largestprime.py
+++ b/03-Largest-Prime-Factor/largestprime.py
diff --git a/palindrome b/04-Largest-Palindrome-Product/palindrome
index f4d607f..f4d607f 100755
--- a/palindrome
+++ b/04-Largest-Palindrome-Product/palindrome
Binary files differ
diff --git a/palindrome.c b/04-Largest-Palindrome-Product/palindrome.c
index aad741a..aad741a 100644
--- a/palindrome.c
+++ b/04-Largest-Palindrome-Product/palindrome.c
diff --git a/palindrome.py b/04-Largest-Palindrome-Product/palindrome.py
index ed2a779..ed2a779 100644
--- a/palindrome.py
+++ b/04-Largest-Palindrome-Product/palindrome.py
diff --git a/smallmult b/05-Smallest-Multiple/smallmult
index 5f4e692..5f4e692 100755
--- a/smallmult
+++ b/05-Smallest-Multiple/smallmult
Binary files differ
diff --git a/smallmult.c b/05-Smallest-Multiple/smallmult.c
index 302f19b..302f19b 100644
--- a/smallmult.c
+++ b/05-Smallest-Multiple/smallmult.c
diff --git a/smallmult.py b/05-Smallest-Multiple/smallmult.py
index a8a6344..a8a6344 100644
--- a/smallmult.py
+++ b/05-Smallest-Multiple/smallmult.py
diff --git a/06-Sum-Square-Difference/sumsq.py b/06-Sum-Square-Difference/sumsq.py
new file mode 100644
index 0000000..fdd43e4
--- /dev/null
+++ b/06-Sum-Square-Difference/sumsq.py
@@ -0,0 +1,28 @@
+# The sum of the squares of the first ten natural numbers is,
+# 12 + 22 + ... + 102 = 385
+# The square of the sum of the first ten natural numbers is,
+# (1 + 2 + ... + 10)2 = 552 = 3025
+# Hence the difference between the sum of the squares
+# of the first ten natural numbers and the square of the sum is
+# Find the difference between the sum of the squares of the first
+# one hundred natural numbers and the square of the sum.
+
+import PIL
+import math
+
+nums = range(1, 11)
+numsq = range(1, 11)
+
+for i in nums:
+ i = i*i
+
+print(nums)
+print(numsq)
+
+sum1 = (sum(nums)**2)
+sum2 = (sum(numsq))
+
+print("The sum squared is: " + str(sum1))
+print("The sum of the squares is: " + str(sum2))
+
+print("The difference is: " + str(abs(sum2-sum1)))
diff --git a/10001prime b/07-10001st-Prime/10001prime
index a9cc351..a9cc351 100755
--- a/10001prime
+++ b/07-10001st-Prime/10001prime
Binary files differ
diff --git a/10001prime.c b/07-10001st-Prime/10001prime.c
index 2ef3bd8..2ef3bd8 100644
--- a/10001prime.c
+++ b/07-10001st-Prime/10001prime.c
diff --git a/10001prime.py b/07-10001st-Prime/10001prime.py
index bc51d49..bc51d49 100644
--- a/10001prime.py
+++ b/07-10001st-Prime/10001prime.py
diff --git a/productofdigits b/08-Largest-Product-In-a-Series/productofdigits
index 9d3f349..9d3f349 100755
--- a/productofdigits
+++ b/08-Largest-Product-In-a-Series/productofdigits
Binary files differ
diff --git a/productofdigits.c b/08-Largest-Product-In-a-Series/productofdigits.c
index 433c433..433c433 100644
--- a/productofdigits.c
+++ b/08-Largest-Product-In-a-Series/productofdigits.c
diff --git a/productofdigits.py b/08-Largest-Product-In-a-Series/productofdigits.py
index 0d1e132..0d1e132 100644
--- a/productofdigits.py
+++ b/08-Largest-Product-In-a-Series/productofdigits.py
diff --git a/09-Special-Pythagorean-Triplet/pyth.py b/09-Special-Pythagorean-Triplet/pyth.py
new file mode 100644
index 0000000..a37f026
--- /dev/null
+++ b/09-Special-Pythagorean-Triplet/pyth.py
@@ -0,0 +1,30 @@
+# A Pythagorean triplet is a set of three natural numbers,
+# a < b < c, for which,
+# a2 + b2 = c2
+# For example, 32 + 42 = 9 + 16 = 25 = 52.
+# There exists exactly one Pythagorean triplet for which a + b + c = 1000.
+# Find the product abc.
+
+import PIL
+import math
+
+
+def isTriple(abc):
+ if len(abc) > 3:
+ return False
+ legs = abc[0]**2 + abc[1]**2
+ hyp = abc[2]**2
+
+ if (hyp == legs):
+ return True
+ else:
+ return False
+
+
+for i in range(1, 1000):
+ for j in range(1, 1000):
+ for k in range(1, 1000):
+ if (i+j+k) == 1000 and isTriple([i, j, k]):
+ print([i, j, k])
+ print(i*j*k)
+ exit()
diff --git a/sumofprimes b/10-Summation-of-Primes/sumofprimes
index a175f6a..a175f6a 100755
--- a/sumofprimes
+++ b/10-Summation-of-Primes/sumofprimes
Binary files differ
diff --git a/sumofprimes.c b/10-Summation-of-Primes/sumofprimes.c
index 90e0bbb..90e0bbb 100644
--- a/sumofprimes.c
+++ b/10-Summation-of-Primes/sumofprimes.c
diff --git a/sumofprimes.py b/10-Summation-of-Primes/sumofprimes.py
index d0db224..d0db224 100644
--- a/sumofprimes.py
+++ b/10-Summation-of-Primes/sumofprimes.py
diff --git a/prodgrid b/11-Largest-Product-In-Grid/prodgrid
index 5054666..5054666 100755
--- a/prodgrid
+++ b/11-Largest-Product-In-Grid/prodgrid
Binary files differ
diff --git a/prodgrid.c b/11-Largest-Product-In-Grid/prodgrid.c
index a4f27c3..a4f27c3 100644
--- a/prodgrid.c
+++ b/11-Largest-Product-In-Grid/prodgrid.c
diff --git a/bigfactors2 b/12-Highly-Divisible-Triangular-Number/bigfactors2
index 3e409b1..3e409b1 100755
--- a/bigfactors2
+++ b/12-Highly-Divisible-Triangular-Number/bigfactors2
Binary files differ
diff --git a/bigfactors2.c b/12-Highly-Divisible-Triangular-Number/bigfactors2.c
index 97ba17d..97ba17d 100644
--- a/bigfactors2.c
+++ b/12-Highly-Divisible-Triangular-Number/bigfactors2.c
diff --git a/bigfactors2.py b/12-Highly-Divisible-Triangular-Number/bigfactors2.py
index 9e51502..9e51502 100644
--- a/bigfactors2.py
+++ b/12-Highly-Divisible-Triangular-Number/bigfactors2.py
diff --git a/collatz b/14-Longest-Collatz-Sequence/collatz
index 37da709..37da709 100755
--- a/collatz
+++ b/14-Longest-Collatz-Sequence/collatz
Binary files differ
diff --git a/collatz.c b/14-Longest-Collatz-Sequence/collatz.c
index ec77af6..ec77af6 100644
--- a/collatz.c
+++ b/14-Longest-Collatz-Sequence/collatz.c
diff --git a/collatz.py b/14-Longest-Collatz-Sequence/collatz.py
index 74d5e1e..74d5e1e 100644
--- a/collatz.py
+++ b/14-Longest-Collatz-Sequence/collatz.py
diff --git a/sumexp.py b/16-Power-Digit-Sum/sumexp.py
index a4d8eaf..a4d8eaf 100644
--- a/sumexp.py
+++ b/16-Power-Digit-Sum/sumexp.py
diff --git a/17-Number-Letter-Counts/wordnums.py b/17-Number-Letter-Counts/wordnums.py
new file mode 100644
index 0000000..34b5705
--- /dev/null
+++ b/17-Number-Letter-Counts/wordnums.py
@@ -0,0 +1,48 @@
+import PIL
+import math
+
+ones = ["", "one", "two", "three", "four",
+ "five", "six", "seven", "eight", "nine"]
+weirdos = ["thirteen", "twelve", "eleven", "ten"]
+tens = ["", "teen", "twenty", "thirty", "forty",
+ "fifty", "sixty", "seventy", "eighty", "ninety"]
+nd = "AND"
+
+#num must be less than 999#
+
+
+def numToWord(num):
+ digits = str(num)
+ if (len(digits) == 1): # one digit
+ return ones[num]
+ if (len(digits) == 2): # two digits
+ if(num < 14): # special case for ten eleven twelve
+ return weirdos[13 - num]
+ if (num == 15):
+ return "fifteen"
+ if (num == 18):
+ return "eighteen"
+ t = digits[0]
+ o = digits[1]
+ if (int(t) == 1):
+ return numToWord(int(o)) + tens[int(t)]
+ else:
+ return tens[int(t)] + numToWord(int(o))
+ #number is three digits#
+ h = digits[0]
+ t = digits[1]
+ o = digits[2]
+ if(num % 100 == 0):
+ return numToWord(int(h)) + "hundred"
+ else:
+ return numToWord(int(h)) + "hundred"+nd+numToWord(int(t+o))
+
+
+n = int(input("Number: "))
+out = ""
+for i in range(1, n):
+ out += numToWord(int(i))
+
+out += "onethousand"
+print(out)
+print(str(len(out)) + " letters")
diff --git a/README.md b/README.md
index 1496221..9e888da 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,20 @@
# Project_Euler_Solutions
Solutions to some problems on https://projecteuler.net/archives
-Apologies that they are unoragnized! I did these back in Summer of 2017 and I need to go back and rename these guys
-Problems are specified in the comments.
+I'm building this repository as I go, mostly as a convenience to myself so I
+can push and pull from work and home.
-There is a mix of C and Python since I was studying both languages at the time
+Solutions are assorted in Python and C. I started with Python since I was more
+familiar with it, but now I'm working to translate everything to C. It really
+forces you to think up more efficient solutions :)
+
+Some python solutions I had to remove since they don't work in Python 3 anymore.
+Most were easy to update, but a few I couldn't figure out.
+
+Improving organization of these day by so apologies if it's not up to snuff!
+
+PLEASE do not use these solutions to cheat through the site! These are only provided
+as resource for you to learn when you get suck, you do not need to copy my solutions.
+Please re-write my solutions in another language. Or if you can't, at least go and
+retype each line, renaming the variables so they make sense to you (I was kind of
+deliberately cryptic).
diff --git a/reworking/sumexp.c b/reworking/sumexp.c
new file mode 100644
index 0000000..8078909
--- /dev/null
+++ b/reworking/sumexp.c
@@ -0,0 +1,15 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <gmp.h>
+
+// Compile Notes: use `gcc <program>.c -lgmp`
+
+mpz_t num;
+
+int main(){
+
+ // From docs, this assigns num the value of (op1*2) ^ op2
+ mpz_mul_2exp(num, )
+ return 0;
+}
+