commit a5c9a72330bcf1539373afa8c80ddb61f4de79f7
parent dc123f222f9781f36ecb3e87c34938f83559a8fb
Author: mpizzzle <m@michaelpercival.xyz>
Date: Mon, 5 Oct 2020 20:06:43 +0100
temp commit (starting euler 93)
Diffstat:
6 files changed, 23 insertions(+), 53 deletions(-)
diff --git a/Euler.h b/Euler.h
@@ -90,4 +90,5 @@ public:
uint64_t CubeDigitPairs();
int Sudoku();
int AnagramicSquares();
+ int ArithmeticExpressions();
};
diff --git a/Euler_93.cpp b/Euler_93.cpp
@@ -0,0 +1,16 @@
+#include "Euler.h"
+
+int Euler::ArithmeticExpressions() {
+ int a = 1, b = 2, c = 3, d = 4;
+
+ for (a = 1; a < b; ++a) {
+ for (b = a + 1; b < c; ++b) {
+ for (c = b + 1; c < d; ++c) {
+ for (d = c + 1; d < 10; ++d) {
+ std::cout << a << b << c << d << std::endl;
+ }
+ }
+ }
+ }
+ return 0;
+}
diff --git a/Euler_98.cpp b/Euler_98.cpp
@@ -5,7 +5,7 @@
#include <unordered_map>
int anagrams_match(std::vector<std::string>& anagram_pair, std::vector<std::string>& anagram_squares) {
- int solution = 0;
+ int solution = -1;
for (uint64_t i = 0; i < anagram_squares.size(); ++i) {
std::unordered_map<char, char> char_map;
@@ -83,7 +83,7 @@ int Euler::AnagramicSquares() {
file.close();
- for (int i = 0; i < sqrt(1000000000); ++i) {
+ for (int i = 0; i < sqrt(1e9); ++i) {
squares.push_back(std::to_string(i * i));
}
diff --git a/Euler_98.py b/Euler_98.py
@@ -1,48 +0,0 @@
-import sys
-import math
-import re
-from sets import Set
-from datetime import datetime
-
-def find_all_anagrams(words):
- anagram_sets = []
-
- for word in words:
- word_is_anagram = False
- for anagram_set in anagram_sets:
- if sorted(str(word)) == sorted(str(anagram_set[0])):
- anagram_set.append(word)
- word_is_anagram = True
- break
-
- if not word_is_anagram:
- anagram_set = []
- anagram_set.append(word)
- anagram_sets.append(anagram_set)
-
- anagrams = []
-
- for anagram_set in anagram_sets:
- if len(anagram_set) > 1:
- anagrams.append(anagram_set)
-
- return anagrams
-
-def match_anagrams_with_squares(anagram_sets, square_sets):
-
-a = datetime.now()
-
-with open('files/p098_words.txt') as f:
- words = re.split('","',f.read()[1:-1])
-
-squares = []
-
-for i in range(100000):
- if len(str(i**2)) == len(Set([c for c in str(i**2)])):
- squares.append(i**2)
-
-match_anagrams_with_squares(find_all_anagrams(words), find_all_anagrams(squares))
-
-delta = datetime.now() - a
-
-print "total time: " + str(delta.total_seconds())
diff --git a/Makefile b/Makefile
@@ -13,7 +13,7 @@ _OBJ = main.o
Euler_61.o Euler_62.o Euler_63.o Euler_64.o Euler_68.o Euler_69.o Euler_70.o
Euler_71.o Euler_72.o Euler_73.o Euler_74.o Euler_75.o Euler_76.o Euler_77.o Euler_79.o Euler_80.o
Euler_86.o Euler_87.o Euler_90.o
- Euler_94.o Euler_95.o Euler_96.o Euler_98.o Euler_100.o
+ Euler_93.o Euler_94.o Euler_95.o Euler_96.o Euler_98.o Euler_100.o
EulerUtility.o
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
diff --git a/main.cpp b/main.cpp
@@ -91,10 +91,11 @@ int main() {
//std::cout << "problem 86: " << e.CuboidRoute() << std::endl;
//std::cout << "problem 87: " << e.PrimePowerTriples() << std::endl;
//std::cout << "problem 90: " << e.CubeDigitPairs() << std::endl; //in progress
+ std::cout << "problem 93: " << e.ArithmeticExpressions() << std::endl;
//std::cout << "problem 94: " << e.AlmostEquilateralTriangles() << std::endl; //in progress
//std::cout << "problem 95: " << e.AmicableChains() << std::endl;
- //std::cout << "problem 96: " << e.Sudoku() << std::endl; //in progress
- std::cout << "problem 98: " << e.AnagramicSquares() << std::endl; //in progress
+ //std::cout << "problem 96: " << e.Sudoku() << std::endl;
+ //std::cout << "problem 98: " << e.AnagramicSquares() << std::endl;
//std::cout << "problem 100: " << e.ArrangedProbability() << std::endl; //in progress
std::cout << "duration: " << 1000.0 * (std::clock() - start) / CLOCKS_PER_SEC << "ms" << std::endl;