day6
This commit is contained in:
parent
b255ad45ae
commit
5ef53ceb94
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
Jonas
|
||||
Daniel
|
||||
README.md.temp
|
||||
|
10
6/README.md
Normal file
10
6/README.md
Normal file
@ -0,0 +1,10 @@
|
||||
# [Day 6](https://adventofcode.com/2022/day/6)
|
||||
:gift::gift::gift::gift::gift::gift:
|
||||
|
||||
Today's language: **HTML** *(javascript)*
|
||||
|
||||
### [Click here to see the website in try it out for yourself](https://quintern.xyz/advent22/day6.html)
|
||||
|
||||
```shell
|
||||
firefox day6.html
|
||||
```
|
1
6/broken-device.txt
Normal file
1
6/broken-device.txt
Normal file
@ -0,0 +1 @@
|
||||
lrgrvgvttzmtmtgglmgmccpclppvdvtvvllvggvrggbwwlzlmzzbppnvpnvppcjjzhjhthnhjnhhhndhnnnsbnnhzzvhhplplzlrzzgpzpwzpwwsvsjvjfvvphpspwswrswscwscwsscffspsbbjjcjwjrwwtgwwgswswwzbzddqnnpqnpnqppwzwszsnsjjpddhvvcbbhhpzzlpzlzppfpvvmcmvvflfttrltrlldlglbgblltqtffrtrwrzwwzmzwmwwlzzhttwzzwnnmrrcdrdjrjqjvqvvjzzgccrllhmhzzfnfwwtzwzwpwhhdjhhmzzbbvggzdzccbzbbpcpqccjbcbppsttdjdnjnppjjnmmszmzgzddtctvctcvttgtbbzqqggnmmdllvdvmvzzhfffzvfvtfvtvwwcnwnvwwbccggjcjqcqcbcrrppdqppdzpzqppttjhjdjqjppzgzjjpllwrrbttrvvzzbhzzqppndppwqppnrpnnttfwttsrrgprggmtmhmzhzczwzmwzwrwqwrrrdqrrvssnlngnppfqqgbgjjcttbgtbtmtctmcmcmgmsgsffhghqhbbvtbbtltmltlnlpnngcnggbngbnnzgzccgcpgcpcjppnnzjzdjdggzjzljjhnncgcjcscfctcvttvqtqmqjjsqjqpqfqhqmmlvvmppfrfjjngnnfllrlhhppcjcbjcctgcgtcgcvgvffqfcfpcpdpffrbrvbvnnphpqpfqqtnttmtgtlgtgzttnvvpwvwvcwcfwcwmccwlclqlflpflplwpllndlltlqtlqqmqnqmnqnvqvrrtddqndnrdnnpzprrqnnggvqvhvpvptvvvzwzrwwscsqqmcmttbgtgpptzptzzvszvzdvvtsscbbrpptssltssztszttlvlqljlgljlhhwvhwvvqhvqhqrhqqcnqccnbcbppbffzqfqsfspsqsjjrhjjchcmhmnhmmzjmjmfjmmsbsvvgcggtdgghchrrpnnrttnthtdtmmhmdmppmgpgllrwlrwlwvvlmlglppzttsvsbsnbncnjnffddzcddbzzbzgbghhhtltwtggljjggsdswwpmmfhfsfvfrrgmrgrfggvzzbnbttwqqdcdppqcqpcpqpjqpjpbbgjbgjjfwfwpfpgpzgzmzgzdzzpwzwqqjqfqllgrgjjfvvqnvncntngnhgnhgnnzvvbsbmbqmqwmqwwhbwhhsccvhcclncnqccnvnzvvdgvgnvnttmbbhccwgwttlwtwqttqcqmcqcdcmmjpmmjsjhhprrnnqddjwdjjvvhvgvssthhnfhnnntfthhtggthhbrbrjbbjfbjjrgrsrjrqqqfwflfclflnnnnvggfqgqzzbbvttfcfvcvsswvssnzndndvnvqqznnrjnnsmmptmppncpchcctwtbbgbqqjqtqsqfsfvfvnvmvzzpgzppdzdvdqdjdnjnttvvjbbzrzqrqwrqrbqrqsqpspjssnqnpqqnjndjjzmmvbbrqrccrffhwhggbttpnpphwhhmrrndrnddzqzzfbfwbwnwtwjjwjmjsjcjgcjjfcftcffvpvwwbffgzgnnlfffnddtdbdlbbcjbjmmfpfzfbbwbdwwfmfpmmfjfffvzvdvvhrvrcvcscjjpfjjnfnzzrtrpphtppzrppwhhphthltlllttghgwwvlwlflhldlzzmbzzjppnwppvlplqqbtbwwccswccqzzjhjbbhbnhnshnsslmmlqqjfjrjjmvvhpjqhzqffhsdsbwpjvgpvmbfqltrmpnwfcptpfmtjcpbzfldbhcmzchshrlbjgggrfjcqhzqqvbzsczmbgqmzqmltlrtlbnsfvmlhbbcqbbltjpdrpznrglshvgdnqwlhthghvtbffddcjwgdzfswzbppjtdhstcqqmvzmjrvfjbhmrznwqczdjjclnhbmtdvvzwttwnrlfqwpglpcppdwdcvfqpqfnmbvzvmqlmnlgnrsqdjvtsftgnlrtzsrcqhltmhzhpmzqqfqrjwhqfnqdtnshwgfhcpjrlplnqczdlntnhsczrgfhflsfbmftsbptflqbpwblrfnfzvqtpblftmscpzgdhhsbdbjhqclnptwtmhbbfglmvwnbqgvqhmmswwjpfwqjbvznmcpdzcvbzjmfqnwstvvtdnlvnpznnblfqzjjrjgnsbtmmbjzsvmgwddtnzcvhvtdrmjgtcrjzznrssscrzcfbfpgpnpppsqcqpccnbdjnwrbvhrcwgqncjrzbdhzqpfhqbnvbfrzmlfbfvtpggrtdswnvlsvpjsmfchhpbbszbnqqfrmhpqzdjhmhmnnmplbtrpgphvvqdfbcfnrfrbfbtshlmlfltjnbmggqntvhdnlvtcvlhmlrlfzfrqmlwqzrdghvdvtsqvmpdjrjclmlmgjqwzzldnzvfmwmrrnfghsvpcwjdtlnrhpjczwpgfbhpnmcbpthsndfflbjhnlwdbbmlttfqcmswvppslptgzbvfgppvpnhjccrpgrpwtngmmccjghhcwddmnglschnpjwqtrtsvggnpzvsqshfvcnhptphtlmqmpznfzwvbnhwpsfwvpflsdjcjgfzjprbbfzgdbmrjgwrgfdphghrhnpvfncrdzcwtthmqtdwlhjsdthqpzhbjpgggndtrmwvcsqhzrzwbhtqsqthvqncprvnpsrlpvlvcjrcflhbdhrfthlfnqbzbmvlvhmbjnbbjhpjwlfflfhpfwcwnnsljthvzwprqjmgpldlzjnjtjfjrgnrpzpvzfcsrprbjhwnmccwhppjrlnndjdjzqwpcwnvqwgmnwbrjqqvbplvsncnmdfrbhrrhghfllhrghzmlnltgdsqlgbvnlchgcbqlpqptdwmsjpqrprlhqmstzjfnzgbgvlfshwpcrgzcqmmfwvhwlsdvplmdgrtfrjwpfvhnjqdbwsfcqhchstlzfpdljgvcqsfcnqccnpmvsqbmwjtzwhpglhbjwzmvgqwjhvwfhnlbtsgljzmlldcpjwdcfppmnmphdmhpmdqwwtjtrdhlrjlvzgpbcgvwcmtclgpqwhtpbdtdbdscfzbrzmgjlbppcnvphphfnvzdzzlvfsvsgbgqcnlqwmtcrpwzcvnmnvtmcdsstvqpqzdpvtdsbvtwhdvgzqmzvwlspgbwmlnsrqdqnjwrllncflqsrzdqtjqvpnpjlqfwqtlqfqwlltszcwtpmjtldjgvmvptpmzqhwmlvjgnntpvcslmhlhdbjtjjnvsbnzwtdclwbzrvlqzjljtbdjvwgbwcltvnbhfvtgqrbmzbbfvldhmdvfvtlqglnblfmmpjqmzlnfjltsqdrgmlhbhngrrmhnjndggsdcfmtssmmtmzvhzrmwjsqjcvbsgqgtvdmvqlvlrvglrtlshfdmfrmljjggwjbcsztsjmjftcbbjwrmgqvssrvtgzcgthtlgsjspfmdgwptjdrbswqlpfsbtjlnhllmjpbfhgpfcprpdnqqvqdmcbqhbcqtstvnjdzwzwvhhwmcvcfbdwczpwpdhvnstjnbblbprzsccmwrzgfhmrpvzfztvsrtncdhzhptpfqtnqwvqtwdpvcqztgjgrcbdnvqftphtfbtqdhrffdrdmwsbpvhshzvjbvsrljnzddmmfgcnfdssvzdbsfwmfjsdnslbrqsqfwfqbqszjwvgcjbhrfjcnlfhzvhcbbbpmhhvjdtgrqlcchqtvnhlrgtssllvgcdjrlzlzfbrrrvwvvcgfjdlpscsqljmmwmvwnvrgdmgcbvmwmgprbfrbgptlfjbhrmczwrzwbdhdvtgvldnzfgcngdfhbgqsfzlrbwbvdflrrsrcwthjzvgmdtndgtsjtswfbdqvcjtsdvrvqpmmdlghsdbzplgpfnstplpjdvttgzmnhssftqcqjvdvvdrmltbrpsjvqwbljrqrtqldzbwzznsdstvmdzbrvvtgrrphmbrzwnjbmqvfhljcdlbzqtcbjsfqdqcr
|
122
6/day6.css
Normal file
122
6/day6.css
Normal file
@ -0,0 +1,122 @@
|
||||
body {
|
||||
text-align: center;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
color: #ffffff;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
h1, h3, p, pre {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #009900;
|
||||
}
|
||||
.footer {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
background: linear-gradient(to bottom, #880000, #aa0000);
|
||||
}
|
||||
|
||||
pre {
|
||||
background-color: #990000;
|
||||
color: #009900;
|
||||
font-family: monospace;
|
||||
padding: 1em;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
h1, h3 {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.clickable {
|
||||
background-color: #009900;
|
||||
border: none;
|
||||
color: #ffffff;
|
||||
padding: 0.5em 1em;
|
||||
margin: 0.5em;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.snow {
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
pointer-events: none;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.snow__flake {
|
||||
position: absolute;
|
||||
top: -50px;
|
||||
left: -50px;
|
||||
right: -50px;
|
||||
bottom: -50px;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
background: #fff;
|
||||
border-radius: 50%;
|
||||
animation: snowAnimation 3s linear infinite;
|
||||
}
|
||||
|
||||
.snow__flake:nth-child(0) {
|
||||
animation-delay: 0s;
|
||||
}
|
||||
|
||||
.snow__flake:nth-child(1) {
|
||||
animation-delay: 0.2s;
|
||||
}
|
||||
|
||||
.snow__flake:nth-child(2) {
|
||||
animation-delay: 0.4s;
|
||||
}
|
||||
|
||||
.snow__flake:nth-child(3) {
|
||||
animation-delay: 0.6s;
|
||||
}
|
||||
|
||||
.snow__flake:nth-child(4) {
|
||||
animation-delay: 0.8s;
|
||||
}
|
||||
|
||||
.snow__flake:nth-child(5) {
|
||||
animation-delay: 1s;
|
||||
}
|
||||
|
||||
.snow__flake:nth-child(6) {
|
||||
animation-delay: 1.2s;
|
||||
}
|
||||
|
||||
.snow__flake:nth-child(7) {
|
||||
animation-delay: 1.4s;
|
||||
}
|
||||
|
||||
.snow__flake:nth-child(8) {
|
||||
animation-delay: 1.6s;
|
||||
}
|
||||
|
||||
.snow__flake:nth-child(9) {
|
||||
animation-delay: 1.8s;
|
||||
}
|
||||
|
||||
.snow__flake:nth-child(10) {
|
||||
animation-delay: 2s;
|
||||
}
|
||||
|
||||
@keyframes snowAnimation {
|
||||
0% {
|
||||
transform: translateY(0) rotate(0deg);
|
||||
opacity: 1;
|
||||
}
|
||||
100% {
|
||||
transform: translateY(1000px) rotate(360deg);
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
59
6/day6.html
Normal file
59
6/day6.html
Normal file
@ -0,0 +1,59 @@
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="description" content="ElvCom SC-22 Stream Analyzer">
|
||||
<meta name="keywords" content="ElvCom, SC-22, stream, analyzer, packets, messages">
|
||||
<meta name="author" content="Matthias Quintern">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="day6.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>ElvCom SC-22 Stream Analyzer</h1>
|
||||
<p>This tool will help you find packets and messages in streams from your <em>ElvCom SC-22</em>.</p>
|
||||
|
||||
<pre>
|
||||
MMMMMMMMMMMMMNKXWMMMMMMMMMMMMMMMMMMMMMMM
|
||||
MMMMMMMMMMMMNx:lKMMMMMMMMMMMMMMMMMMMMMMM
|
||||
MMMMMMMMMMMMNd;:0MMMMMMMMMMMMMMMMMMMMMMM
|
||||
MMMMMMMMMMMMXd,;OMMMMMMMMMMMMMMMMMMMMMMM
|
||||
MMMMMMMMMMMMXo,;kMMMMMMMMMMMMMMMMMMMMMMM
|
||||
MMMMMMMMMMMMXo,,xWMMMMMMMMMMMMMMMMMMMMMM
|
||||
MMMMMMMMMMMMKl;,lkkkOOOO0XWMMMMMMMMMMMMM
|
||||
MMMMMMMMMMMMOc;lO00000Okl:xNMMMMMMMMMMMM
|
||||
MMMMMMMMMMMWk;;xKkxxxxxOx,cKMMMMMMMMMMMM
|
||||
MMMMMMMMMMMWx;,dkccccc:oo,:0MMMMMMMMMMMM
|
||||
MMMMMMMMMMMWk;'lkxddddddc'cKMMMMMMMMMMMM
|
||||
MMMMMMMMMMMMO:';dxxxkxxd;.lXMMMMMMMMMMMM
|
||||
MMMMMMMMMMMMO;..';,,,;;'..lXMMMMMMMMMMMM
|
||||
MMMMMMMMMMMMk,............cKMMMMMMMMMMMM
|
||||
MMMMMMMMMMMWk,............cKMMMMMMMMMMMM
|
||||
MMMMMMMMMMMWx,...... ....:KMMMMMMMMMMMM
|
||||
MMMMMMMMMMMM0:...........'dWMMMMMMMMMMMM
|
||||
MMMMMMMMMMMMNd,..........:0MMMMMMMMMMMMM
|
||||
MMMMMMMMMMMMMN0dooooooodkKWMMMMMMMMMMMMM
|
||||
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
|
||||
</pre>
|
||||
<div class="snow">
|
||||
<div class="snow__flake">penis</div>
|
||||
<div class="snow__flake"></div>
|
||||
<div class="snow__flake"></div>
|
||||
<div class="snow__flake"></div>
|
||||
<div class="snow__flake"></div>
|
||||
<div class="snow__flake"></div>
|
||||
<div class="snow__flake"></div>
|
||||
<div class="snow__flake"></div>
|
||||
<div class="snow__flake"></div>
|
||||
<div class="snow__flake"></div>
|
||||
</div>
|
||||
<hr>
|
||||
<h3>Select Stream-File: </h3><input class="clickable" onchange='readFile(this)' type='file'>
|
||||
<button class="clickable" id="start">Analize!</button>
|
||||
<hr>
|
||||
<h3>Output:</h3>
|
||||
<p id=output>Load a file and press the button to find the packet and </p>
|
||||
|
||||
<h3 class="footer"><b>YES</b>, parts of this html and javascript is stolen from <a href="https://git.quintern.xyz/TheShinyMelon/AOC_2022/src/branch/master/5">UwU</a></h3>
|
||||
</body>
|
||||
|
||||
<script src='day6.js'></script>
|
60
6/day6.js
Normal file
60
6/day6.js
Normal file
@ -0,0 +1,60 @@
|
||||
let output = document.getElementById("output");
|
||||
let input;
|
||||
let fileContent;
|
||||
|
||||
function readFile(input) {
|
||||
let file = input.files[0];
|
||||
console.log("Reading file", file)
|
||||
let fileReader = new FileReader();
|
||||
fileReader.readAsText(file);
|
||||
fileReader.onload = function() {
|
||||
fileContent = fileReader.result;
|
||||
};
|
||||
fileReader.onerror = function() {
|
||||
alert(fileReader.error);
|
||||
};
|
||||
}
|
||||
|
||||
let start = document.getElementById("start");
|
||||
start.addEventListener("mouseover", () => {
|
||||
start.innerHTML = "JUST DO IT"
|
||||
});
|
||||
start.addEventListener("mouseout", () => {
|
||||
start.innerHTML = "Read File"
|
||||
});
|
||||
start.addEventListener("click", () => {
|
||||
findPosition(fileContent)
|
||||
});
|
||||
|
||||
|
||||
function findPosition(line) {
|
||||
let i = 4;
|
||||
let packetStart = line.substring(0, 4); // should always contain 4 chars
|
||||
let messageStart = line.substring(0, 14); // should always contain 14 chars
|
||||
let packetStartI = 0;
|
||||
while (i < line.length) {
|
||||
console.log(i, "Char", line[i], "chars:", packetStart);
|
||||
// if packetStart not found, look for packet start
|
||||
if (packetStartI == 0) {
|
||||
if (/(.).*\1/.test(packetStart)) { // if unique
|
||||
packetStart = packetStart.substring(1, 4) + line[i];
|
||||
}
|
||||
else {
|
||||
packetStartI = i;
|
||||
messageStart = line.substring(i, i + 14);
|
||||
}
|
||||
}
|
||||
else { // search for message start
|
||||
if (/(.).*\1/.test(messageStart)) { // if unique
|
||||
messageStart = messageStart.substring(1, 14) + line[i];
|
||||
}
|
||||
else {
|
||||
output.innerHTML = "Found the first packet start marker at position <b>" + packetStartI + "</b>, the marker is " + packetStart + "<br>" +
|
||||
"Found the first message start marker at position <b>" + i + "</b>, the marker is " + messageStart + "\n";
|
||||
return;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user