Skip to content

Commit

Permalink
compair hashes and dark theme
Browse files Browse the repository at this point in the history
  • Loading branch information
artemShI0 committed Jan 5, 2025
1 parent 2304b2f commit da6ba74
Show file tree
Hide file tree
Showing 18 changed files with 274,837 additions and 274,866 deletions.
Empty file added code.js
Empty file.
71 changes: 45 additions & 26 deletions create_page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ using namespace std;


const double pi = 3.1415926535;
const long long p = 13;
const long long m = 18014398241046527;
vector<long long> pn(50);


void print(vector<int> v){
Expand All @@ -27,6 +30,24 @@ void mistake(){
throw length_error("carbon forms only 4 bonds");
}

long long mod(long long a, long long b){
if(a >= 0){
return a % b;
}
return b + a % b;
}

long long hash_f(string s){
long long hash = 0;
hash = s[0] - 0;
for(int i = 1; i < s.size(); ++i){
hash = mod((s[i] - 0) * pn[i] + hash, m);
}
return hash;
}




class Atom{
public:
Expand Down Expand Up @@ -66,6 +87,7 @@ class Molecule{
vector<Atom> graph;
vector<int> root;
vector<string> root_AHU;
vector<long long> hash_AHU;
vector<int> sz;
int L = 100;
int x1 = 1000000000, y1 = 1000000000;
Expand Down Expand Up @@ -114,6 +136,9 @@ class Molecule{
root_AHU.push_back(AHU1[root[0]]);
root_AHU.push_back(AHU2[root[1]]);
}
for(int i = 0; i < root_AHU.size(); ++i){
hash_AHU.push_back(hash_f(root_AHU[i]));
}
give_coordinates();
}

Expand Down Expand Up @@ -185,10 +210,10 @@ class Molecule{
if(this->size() != other.size()){
return false;
}
if(this->root_AHU.size() == 1 && other.root_AHU.size() == 1){
return this->root_AHU[0] == other.root_AHU[0];
} else if(this->root_AHU.size() == 2 && other.root_AHU.size() == 2){
return this->root_AHU[0] == other.root_AHU[0] || this->root_AHU[1] == other.root_AHU[1] || this->root_AHU[0] == other.root_AHU[1] || this->root_AHU[1] == other.root_AHU[0];
if(this->hash_AHU.size() == 1 && other.hash_AHU.size() == 1){
return this->hash_AHU[0] == other.hash_AHU[0];
} else if(this->hash_AHU.size() == 2 && other.hash_AHU.size() == 2){
return this->hash_AHU[0] == other.hash_AHU[0] || this->hash_AHU[1] == other.hash_AHU[1] || this->hash_AHU[0] == other.hash_AHU[1] || this->hash_AHU[1] == other.hash_AHU[0];
} else {
return false;
}
Expand Down Expand Up @@ -484,7 +509,7 @@ class Page{
s += to_string(mol[mol[v][i]].x + rx);
s += "\" y2=\"";
s += to_string(mol[mol[v][i]].y + ry);
s += "\" style=\"stroke:rgb(0,0,0); stroke-width:1\" />";
s += "\"/>";
s += '\n';
draw_dfs(mol[v][i], v, mol, rx, ry);
}
Expand All @@ -493,14 +518,10 @@ class Page{

void read_molecules(vector<Molecule>& molecules){ // заполняет файл координатами линий в формате svg
s = "";
s += "<!DOCTYPE html>\n";
s += "<html lang=\"en\">\n";
s += "<head>\n";
s += " <meta charset=\"UTF-8\">\n";
s += " <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n";
s += " <title>Document</title>\n";
s += "</head>\n";
s += "<body>\n";
s += "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><title>Document</title></head>\n";
s += "<style>#line {stroke: #000000;stroke-width: 1;}#back{background-color:#ffffff;}#theme{position:fixed;top:5%;left:90%;height:30px;width:100px;font-size:1em;background-color:#000000;}</style>\n";
s += "<body id=\"back\">\n";
s += " <div id=\"line\">\n";
int rx = 0, ry = 0;
int dy = 0;
s += " <svg height=\"\" width=\"1500\" xmlns=\"http://www.w3.org/2000/svg\">\n";
Expand All @@ -519,9 +540,11 @@ class Page{
y_max = max(y_max, ry + dy);
}
s += " </svg>\n";

s += " </div><button id=\"theme\"></button>\n";
s += "</body>\n";
s += "<script>document.getElementById(\"theme\").onclick = function () {if(window.getComputedStyle(document.getElementById(\"line\"), null).getPropertyValue(\"stroke\") == \"rgb(255, 255, 255)\"){document.getElementById(\"line\").style.stroke = \"#000000\";document.getElementById(\"back\").style.backgroundColor = \"white\";document.getElementById(\"theme\").style.backgroundColor = \"black\";}else{document.getElementById(\"line\").style.stroke = \"#ffffff\";document.getElementById(\"back\").style.backgroundColor = \"black\";document.getElementById(\"theme\").style.backgroundColor = \"white\";}};</script>\n";
s += "</html>\n";
s += '\n';
}
};

Expand Down Expand Up @@ -588,6 +611,13 @@ int main(){
cout << "start time = " << tStart << endl;
int n = 16;


pn[0] = 1;
for(int i = 1; i < pn.size(); ++i){
pn[i] = mod(pn[i - 1] * p, m);
}


Unite_page unite_page(n);
if(true){
string s = ".\\index.html";
Expand Down Expand Up @@ -631,7 +661,7 @@ int main(){
for(int i = 0; i < molecules.size(); ++i){
Page pg;
pg.read_molecules(molecules[i]);
pg.s.insert(202, to_string(pg.y_max));
pg.s.insert(404, to_string(pg.y_max));
pages.push_back(pg);
}

Expand All @@ -649,17 +679,6 @@ int main(){
cout << "molecules.size() = " << molecules.size() << endl;
cout << "pages.size() = " << pages.size() << endl;

// SVG_picture picture;
// picture.read_molecule(molecules[3][0]);
// molecules[3][0].print();
// molecules[3][0].draw();
// ofstream file;
// string name = "demo2";
// string file_name = ".\\" + name + ".svg";
// file.open(file_name.c_str()); // <- here
// file << picture.s;
// file.close();



cout << "end time = " << clock() << endl;
Expand Down
15 changes: 6 additions & 9 deletions pages/C01.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title></head>
<style>#line {stroke: #000000;stroke-width: 1;}#back{background-color:#ffffff;}#theme{position:fixed;top:5%;left:90%;height:30px;width:100px;font-size:1em;background-color:#000000;}</style>
<body id="back">
<div id="line">
<svg height="0" width="1500" xmlns="http://www.w3.org/2000/svg">


</svg>
</div><button id="theme"></button>
</body>
<script>document.getElementById("theme").onclick = function () {if(window.getComputedStyle(document.getElementById("line"), null).getPropertyValue("stroke") == "rgb(255, 255, 255)"){document.getElementById("line").style.stroke = "#000000";document.getElementById("back").style.backgroundColor = "white";document.getElementById("theme").style.backgroundColor = "black";}else{document.getElementById("line").style.stroke = "#ffffff";document.getElementById("back").style.backgroundColor = "black";document.getElementById("theme").style.backgroundColor = "white";}};</script>
</html>

17 changes: 7 additions & 10 deletions pages/C02.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title></head>
<style>#line {stroke: #000000;stroke-width: 1;}#back{background-color:#ffffff;}#theme{position:fixed;top:5%;left:90%;height:30px;width:100px;font-size:1em;background-color:#000000;}</style>
<body id="back">
<div id="line">
<svg height="49" width="1500" xmlns="http://www.w3.org/2000/svg">

<line x1="0" y1="49" x2="85" y2="0" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="0" y1="49" x2="85" y2="0"/>

</svg>
</div><button id="theme"></button>
</body>
<script>document.getElementById("theme").onclick = function () {if(window.getComputedStyle(document.getElementById("line"), null).getPropertyValue("stroke") == "rgb(255, 255, 255)"){document.getElementById("line").style.stroke = "#000000";document.getElementById("back").style.backgroundColor = "white";document.getElementById("theme").style.backgroundColor = "black";}else{document.getElementById("line").style.stroke = "#ffffff";document.getElementById("back").style.backgroundColor = "black";document.getElementById("theme").style.backgroundColor = "white";}};</script>
</html>

19 changes: 8 additions & 11 deletions pages/C03.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title></head>
<style>#line {stroke: #000000;stroke-width: 1;}#back{background-color:#ffffff;}#theme{position:fixed;top:5%;left:90%;height:30px;width:100px;font-size:1em;background-color:#000000;}</style>
<body id="back">
<div id="line">
<svg height="49" width="1500" xmlns="http://www.w3.org/2000/svg">

<line x1="85" y1="0" x2="169" y2="49" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="85" y1="0" x2="0" y2="49" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="85" y1="0" x2="169" y2="49"/>
<line x1="85" y1="0" x2="0" y2="49"/>

</svg>
</div><button id="theme"></button>
</body>
<script>document.getElementById("theme").onclick = function () {if(window.getComputedStyle(document.getElementById("line"), null).getPropertyValue("stroke") == "rgb(255, 255, 255)"){document.getElementById("line").style.stroke = "#000000";document.getElementById("back").style.backgroundColor = "white";document.getElementById("theme").style.backgroundColor = "black";}else{document.getElementById("line").style.stroke = "#ffffff";document.getElementById("back").style.backgroundColor = "black";document.getElementById("theme").style.backgroundColor = "white";}};</script>
</html>

27 changes: 12 additions & 15 deletions pages/C04.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title></head>
<style>#line {stroke: #000000;stroke-width: 1;}#back{background-color:#ffffff;}#theme{position:fixed;top:5%;left:90%;height:30px;width:100px;font-size:1em;background-color:#000000;}</style>
<body id="back">
<div id="line">
<svg height="132" width="1500" xmlns="http://www.w3.org/2000/svg">

<line x1="85" y1="83" x2="169" y2="132" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="85" y1="83" x2="0" y2="132" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="85" y1="83" x2="133" y2="0" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="85" y1="83" x2="169" y2="132"/>
<line x1="85" y1="83" x2="0" y2="132"/>
<line x1="85" y1="83" x2="133" y2="0"/>

<line x1="279" y1="0" x2="363" y2="49" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="363" y1="49" x2="447" y2="1" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="279" y1="0" x2="194" y2="49" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="279" y1="0" x2="363" y2="49"/>
<line x1="363" y1="49" x2="447" y2="1"/>
<line x1="279" y1="0" x2="194" y2="49"/>

</svg>
</div><button id="theme"></button>
</body>
<script>document.getElementById("theme").onclick = function () {if(window.getComputedStyle(document.getElementById("line"), null).getPropertyValue("stroke") == "rgb(255, 255, 255)"){document.getElementById("line").style.stroke = "#000000";document.getElementById("back").style.backgroundColor = "white";document.getElementById("theme").style.backgroundColor = "black";}else{document.getElementById("line").style.stroke = "#ffffff";document.getElementById("back").style.backgroundColor = "black";document.getElementById("theme").style.backgroundColor = "white";}};</script>
</html>

39 changes: 18 additions & 21 deletions pages/C05.html
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title></head>
<style>#line {stroke: #000000;stroke-width: 1;}#back{background-color:#ffffff;}#theme{position:fixed;top:5%;left:90%;height:30px;width:100px;font-size:1em;background-color:#000000;}</style>
<body id="back">
<div id="line">
<svg height="166" width="1500" xmlns="http://www.w3.org/2000/svg">

<line x1="85" y1="83" x2="169" y2="132" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="85" y1="83" x2="0" y2="132" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="85" y1="83" x2="133" y2="0" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="85" y1="83" x2="132" y2="166" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="85" y1="83" x2="169" y2="132"/>
<line x1="85" y1="83" x2="0" y2="132"/>
<line x1="85" y1="83" x2="133" y2="0"/>
<line x1="85" y1="83" x2="132" y2="166"/>

<line x1="279" y1="83" x2="363" y2="132" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="363" y1="132" x2="447" y2="84" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="279" y1="83" x2="194" y2="132" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="279" y1="83" x2="327" y2="0" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="279" y1="83" x2="363" y2="132"/>
<line x1="363" y1="132" x2="447" y2="84"/>
<line x1="279" y1="83" x2="194" y2="132"/>
<line x1="279" y1="83" x2="327" y2="0"/>

<line x1="641" y1="49" x2="725" y2="1" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="725" y1="1" x2="807" y2="49" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="641" y1="49" x2="557" y2="0" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="557" y1="0" x2="472" y2="49" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="641" y1="49" x2="725" y2="1"/>
<line x1="725" y1="1" x2="807" y2="49"/>
<line x1="641" y1="49" x2="557" y2="0"/>
<line x1="557" y1="0" x2="472" y2="49"/>

</svg>
</div><button id="theme"></button>
</body>
<script>document.getElementById("theme").onclick = function () {if(window.getComputedStyle(document.getElementById("line"), null).getPropertyValue("stroke") == "rgb(255, 255, 255)"){document.getElementById("line").style.stroke = "#000000";document.getElementById("back").style.backgroundColor = "white";document.getElementById("theme").style.backgroundColor = "black";}else{document.getElementById("line").style.stroke = "#ffffff";document.getElementById("back").style.backgroundColor = "black";document.getElementById("theme").style.backgroundColor = "white";}};</script>
</html>

65 changes: 31 additions & 34 deletions pages/C06.html
Original file line number Diff line number Diff line change
@@ -1,44 +1,41 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title></head>
<style>#line {stroke: #000000;stroke-width: 1;}#back{background-color:#ffffff;}#theme{position:fixed;top:5%;left:90%;height:30px;width:100px;font-size:1em;background-color:#000000;}</style>
<body id="back">
<div id="line">
<svg height="288" width="1500" xmlns="http://www.w3.org/2000/svg">

<line x1="85" y1="83" x2="169" y2="132" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="169" y1="132" x2="253" y2="84" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="85" y1="83" x2="0" y2="132" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="85" y1="83" x2="133" y2="0" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="85" y1="83" x2="132" y2="165" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="85" y1="83" x2="169" y2="132"/>
<line x1="169" y1="132" x2="253" y2="84"/>
<line x1="85" y1="83" x2="0" y2="132"/>
<line x1="85" y1="83" x2="133" y2="0"/>
<line x1="85" y1="83" x2="132" y2="165"/>

<line x1="363" y1="82" x2="447" y2="131" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="447" y1="131" x2="531" y2="83" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="447" y1="131" x2="494" y2="214" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="363" y1="82" x2="278" y2="131" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="363" y1="82" x2="410" y2="0" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="363" y1="82" x2="447" y2="131"/>
<line x1="447" y1="131" x2="531" y2="83"/>
<line x1="447" y1="131" x2="494" y2="214"/>
<line x1="363" y1="82" x2="278" y2="131"/>
<line x1="363" y1="82" x2="410" y2="0"/>

<line x1="725" y1="49" x2="809" y2="1" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="809" y1="1" x2="891" y2="49" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="725" y1="49" x2="641" y2="0" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="641" y1="0" x2="556" y2="49" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="725" y1="49" x2="772" y2="131" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="725" y1="49" x2="809" y2="1"/>
<line x1="809" y1="1" x2="891" y2="49"/>
<line x1="725" y1="49" x2="641" y2="0"/>
<line x1="641" y1="0" x2="556" y2="49"/>
<line x1="725" y1="49" x2="772" y2="131"/>

<line x1="1001" y1="82" x2="1085" y2="131" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="1085" y1="131" x2="1169" y2="83" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="1169" y1="83" x2="1251" y2="131" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="1001" y1="82" x2="916" y2="131" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="1001" y1="82" x2="1048" y2="0" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="1001" y1="82" x2="1085" y2="131"/>
<line x1="1085" y1="131" x2="1169" y2="83"/>
<line x1="1169" y1="83" x2="1251" y2="131"/>
<line x1="1001" y1="82" x2="916" y2="131"/>
<line x1="1001" y1="82" x2="1048" y2="0"/>

<line x1="169" y1="288" x2="253" y2="240" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="253" y1="240" x2="335" y2="288" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="335" y1="288" x2="417" y2="241" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="169" y1="288" x2="85" y2="239" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="85" y1="239" x2="0" y2="288" style="stroke:rgb(0,0,0); stroke-width:1" />
<line x1="169" y1="288" x2="253" y2="240"/>
<line x1="253" y1="240" x2="335" y2="288"/>
<line x1="335" y1="288" x2="417" y2="241"/>
<line x1="169" y1="288" x2="85" y2="239"/>
<line x1="85" y1="239" x2="0" y2="288"/>

</svg>
</div><button id="theme"></button>
</body>
<script>document.getElementById("theme").onclick = function () {if(window.getComputedStyle(document.getElementById("line"), null).getPropertyValue("stroke") == "rgb(255, 255, 255)"){document.getElementById("line").style.stroke = "#000000";document.getElementById("back").style.backgroundColor = "white";document.getElementById("theme").style.backgroundColor = "black";}else{document.getElementById("line").style.stroke = "#ffffff";document.getElementById("back").style.backgroundColor = "black";document.getElementById("theme").style.backgroundColor = "white";}};</script>
</html>

Loading

0 comments on commit da6ba74

Please sign in to comment.