summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xprog/aoc/23/12/1.py53
-rw-r--r--prog/aoc/23/12/correct.txt6
-rw-r--r--prog/aoc/23/12/in.txt6
-rwxr-xr-xprog/aoc/23/13/1.py22
-rw-r--r--prog/skovikanje/skovik/test.html15
m---------prog/ž/QR-Code-generator0
-rw-r--r--skripti/.gitignore2
-rw-r--r--šola/ds1/kolokvij1.lyx179
-rw-r--r--šola/p1/dn/6/Premica.java (renamed from šola/p1/dn/Premica.java)0
-rw-r--r--šola/p1/dn/6/Tocka.java (renamed from šola/p1/dn/Tocka.java)0
-rw-r--r--šola/p1/dn/7/Blok.java33
-rw-r--r--šola/p1/dn/7/Oseba.java17
-rw-r--r--šola/p1/dn/7/Stanovanje.java95
-rwxr-xr-xšola/p1/dn/tj.sh2
14 files changed, 394 insertions, 36 deletions
diff --git a/prog/aoc/23/12/1.py b/prog/aoc/23/12/1.py
new file mode 100755
index 0000000..7e07935
--- /dev/null
+++ b/prog/aoc/23/12/1.py
@@ -0,0 +1,53 @@
+#!/usr/bin/python3
+springs = []
+try:
+ while True:
+ s = input()
+ springs.append((s.split(" ")[0], list(map(int, s.split(" ")[1].split(",")))))
+except EOFError:
+ pass
+def counts(vhod):
+ s = vhod + "$"
+ prev = None
+ r = []
+ run = 0
+ for c in s:
+ if prev == None:
+ prev = c
+ run = 1
+ continue
+ if c == prev:
+ run += 1
+ continue
+ if prev == "#":
+ r.append(run)
+ prev = c
+ run = 1
+ return r
+"""
+for spring in springs:
+ print(counts(spring[0]), spring[1])
+"""
+def possibilities(x):
+ r = 0
+ countq = x[0].count("?")
+ for bits in range(2**countq):
+ copy = x[0]
+ for i in range(countq):
+ if bits & (1 << i):
+ copy = copy.replace("?", ".", 1)
+ else:
+ copy = copy.replace("?", "#", 1)
+ if counts(copy) == x[1]:
+ r += 1
+ return r
+def possibilities_serial(array):
+ s = 0
+ for element in array:
+ s += possibilities(element)
+ return s
+batch_size = 10
+batches = [springs[x:x+batch_size] for x in range(0, len(springs), batch_size)]
+from multiprocessing import Pool
+with Pool(len(batches)) as p:
+ print(sum(p.map(possibilities_serial, batches)))
diff --git a/prog/aoc/23/12/correct.txt b/prog/aoc/23/12/correct.txt
new file mode 100644
index 0000000..e2bdf5e
--- /dev/null
+++ b/prog/aoc/23/12/correct.txt
@@ -0,0 +1,6 @@
+#.#.### 1,1,3
+.#...#....###. 1,1,3
+.#.###.#.###### 1,3,1,6
+####.#...#... 4,1,1
+#....######..#####. 1,6,5
+.###.##....# 3,2,1
diff --git a/prog/aoc/23/12/in.txt b/prog/aoc/23/12/in.txt
new file mode 100644
index 0000000..e925935
--- /dev/null
+++ b/prog/aoc/23/12/in.txt
@@ -0,0 +1,6 @@
+???.### 1,1,3
+.??..??...?##. 1,1,3
+?#?#?#?#?#?#?#? 1,3,1,6
+????.#...#... 4,1,1
+????.######..#####. 1,6,5
+?###???????? 3,2,1
diff --git a/prog/aoc/23/13/1.py b/prog/aoc/23/13/1.py
new file mode 100755
index 0000000..14f231e
--- /dev/null
+++ b/prog/aoc/23/13/1.py
@@ -0,0 +1,22 @@
+#!/usr/bin/python3
+from sys import stdin
+data = stdin.read()[:-1]
+patterns = []
+for datum in data.split("\n\n"):
+ patterns.append(datum.split("\n"))
+def try_gap(pattern, gap):
+ for l in range(gap+1):
+ if pattern[gap-l] != pattern[line+l+1]:
+ return False
+ return True
+def transpose(pattern):
+ r = []
+ for column in range(len(pattern[0])):
+ l = ""
+ for line in range(len(pattern)):
+ l += pattern[line][column]
+ r.append(l)
+ return r
+for pattern in patterns:
+ for line in len(pattern):
+ try_line(line
diff --git a/prog/skovikanje/skovik/test.html b/prog/skovikanje/skovik/test.html
index 67c6136..bf3220a 100644
--- a/prog/skovikanje/skovik/test.html
+++ b/prog/skovikanje/skovik/test.html
@@ -7,6 +7,11 @@
a {
overflow-wrap: break-word;
}
+html {
+ margin: auto;
+ max-width: 60em;
+ text-align: justify;
+}
</style>
<meta name=viewport content='width=device-width, initial-scale=1.0'>
<link rel=alternate type=application/rss+xml title=RSS href=/skovikanje/rss.xml>
@@ -74,6 +79,16 @@ skovik the type of word that drake would use
<img style=max-width:100% src='https://media.tenor.com/KAAhgZ9CTekAAAAd/skeleton-smoking.gif' />
</div>
</div>
+<div class=komentar style='border:1px solid red'>
+<i><a href=# onclick=citiraj('z6nz')><code>z6nz</code></a> <b class=avtor></b> dne <span class=datum>tor 28 nov 2023 12:44:26 CET</span> <a href=//z.4a.si/skovikanje/komentar.php?koga=z6nz target=_blank>uredi</a> <a href=/skovikanje/skovik/test.html>na</a></i>
+<div class=besedilo>
+<img style=max-width:100% src='https://raw.githubusercontent.com/Codelessly/FlutterLoadingGIFs/master/packages/cupertino_activity_indicator_square_small.gif ' />
+<br>
+
+loading demo za un cursed <a class=raw href='https://ass.si'>ass.si</a> link
+
+</div>
+</div>
<div id=odgovor><details open id=odgovordetails><summary>pokaži/skrij</summary><form method=post action='//z.4a.si/skovikanje/komentar.php?na=test&amp;tip=objava&amp;ref=HTTP_REFERER'>
<label for=avtor>
avtor:
diff --git a/prog/ž/QR-Code-generator b/prog/ž/QR-Code-generator
-Subproject 22fac31bdf81da68730c177c0e931c93234d2a3
+Subproject 49a66a2b8bb8f8852fd2e1deb00b8672f576013
diff --git a/skripti/.gitignore b/skripti/.gitignore
new file mode 100644
index 0000000..c73a7f5
--- /dev/null
+++ b/skripti/.gitignore
@@ -0,0 +1,2 @@
+code128
+črtna_koda
diff --git a/šola/ds1/kolokvij1.lyx b/šola/ds1/kolokvij1.lyx
index 01421eb..1df6ebc 100644
--- a/šola/ds1/kolokvij1.lyx
+++ b/šola/ds1/kolokvij1.lyx
@@ -68,7 +68,7 @@ enumitem
\color #008000
\end_index
\leftmargin 1cm
-\topmargin 0cm
+\topmargin 1cm
\rightmargin 1cm
\bottommargin 2cm
\headheight 1cm
@@ -94,33 +94,6 @@ enumitem
\begin_body
-\begin_layout Title
-List s formulami za 1.
- kolokvij Diskretnih struktur 1
-\end_layout
-
-\begin_layout Author
-
-\noun on
-Anton Luka Šijanec
-\end_layout
-
-\begin_layout Date
-\begin_inset ERT
-status open
-
-\begin_layout Plain Layout
-
-
-\backslash
-today
-\end_layout
-
-\end_inset
-
-
-\end_layout
-
\begin_layout Standard
\begin_inset ERT
status open
@@ -353,7 +326,7 @@ Rightarrow C &
\backslash
vDash A
\backslash
-Rightarrow B &&
+Rightarrow C &&
\backslash
text{
\backslash
@@ -538,14 +511,100 @@ Množice
\end_layout
\begin_layout Standard
-\begin_inset Formula $^{\mathcal{C}},\cup\backslash,\cup\oplus$
+\begin_inset Formula $^{\mathcal{C}},\cap\backslash,\cup\oplus$
\end_inset
(left to right)
\end_layout
\begin_layout Standard
-\begin_inset Formula $\mathcal{A}\subseteq\mathcal{B}\Leftrightarrow\mathcal{A}\cup\mathcal{B}=\mathcal{B}\Leftrightarrow\mathcal{A}\cup\mathcal{B}=\mathcal{A}\Leftrightarrow\mathcal{A}\backslash\mathcal{B}=\left\{ \right\} \Leftrightarrow\mathcal{B}^{\mathcal{C}}\subseteq\mathcal{A^{\mathcal{C}}}$
+Distributivnost:
+\begin_inset Formula $\cup\cap$
+\end_inset
+
+,
+\begin_inset Formula $\cap\cup$
+\end_inset
+
+,
+\begin_inset Formula $\left(\mathcal{A}\oplus\mathcal{B}\right)\cap\mathcal{C}=\left(\mathcal{A\cap\mathcal{C}}\right)\oplus\left(\mathcal{B}\cap\mathcal{C}\right)$
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+Asociativnost:
+\begin_inset Formula $\oplus\cup\cap$
+\end_inset
+
+.
+ Distributivnost:
+\begin_inset Formula $\oplus\cup\cap$
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+Absorbcija:
+\begin_inset Formula $\mathcal{A}\cup\left(\mathcal{A}\cap\mathcal{B}\right)=\mathcal{A}=A\cap\left(\mathcal{A}\cup\mathcal{B}\right)$
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset Formula $\mathcal{A}\subseteq\mathcal{B}\Leftrightarrow\mathcal{A}\cup\mathcal{B}=\mathcal{B}\Leftrightarrow\mathcal{A}\cup\mathcal{B}=\mathcal{A}\Leftrightarrow\mathcal{A}\backslash\mathcal{B}=\emptyset\Leftrightarrow\mathcal{B}^{\mathcal{C}}\subseteq\mathcal{A^{\mathcal{C}}}$
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset Formula $\mathcal{A}=\mathcal{B}\Longleftrightarrow\mathcal{A\oplus\mathcal{B}}=\emptyset$
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset Formula $\mathcal{A}=\emptyset\wedge\mathcal{B}=\emptyset\Longleftrightarrow\mathcal{A}\cup\mathcal{B}=\emptyset$
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset Formula $\left(\mathcal{X}\cap\mathcal{P}\right)\cup\left(\mathcal{X^{C}}\cap\mathcal{Q}\right)=\emptyset\Longleftrightarrow\text{\ensuremath{\mathcal{Q\subseteq X}\subseteq\mathcal{P^{C}}}}$
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset Formula $\mathcal{A}\backslash\mathcal{B}\sim\mathcal{A}\cap\mathcal{B}^{C}$
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset Formula $\mathcal{X}\cup\mathcal{X^{C}}=\emptyset$
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset Formula $\mathcal{W}=\mathcal{W}\cap\mathcal{U}=\mathcal{W\cap}\left(\mathcal{X}\cup\mathcal{X^{C}}\right)=\left(\mathcal{W}\cap\mathcal{X}\right)\cup\left(\mathcal{W}\cap\mathcal{X^{C}}\right)$
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset Formula $\mathcal{A}\oplus\mathcal{B}=\left(\mathcal{A}\backslash\mathcal{B}\right)\cup\left(\mathcal{B\backslash\mathcal{A}}\right)$
\end_inset
@@ -557,6 +616,10 @@ Množice
Lastnosti binarnih relacij
\end_layout
+\begin_layout Standard
+
+\end_layout
+
\begin_layout Paragraph
\begin_inset ERT
status open
@@ -1027,7 +1090,7 @@ Faktorska množica:
\end_layout
\begin_layout Standard
-\begin_inset Formula $\vec{\mathcal{B}}\text{ razbitje}A\Longleftrightarrow\bigcup_{i}\mathcal{B}_{i}=A\wedge\forall i\mathcal{B}_{i}\not=\left\{ \right\} \wedge\mathcal{B}_{i}\cap\mathcal{B}_{j}=\left\{ \right\} ,i\not=j$
+\begin_inset Formula $\vec{\mathcal{B}}\text{ razbitje}A\Longleftrightarrow\bigcup_{i}\mathcal{B}_{i}=A\wedge\forall i\mathcal{B}_{i}\not=\emptyset\wedge\mathcal{B}_{i}\cap\mathcal{B}_{j}=\emptyset,i\not=j$
\end_inset
@@ -1109,12 +1172,58 @@ Srečno!
\end_layout
\begin_layout Paragraph
-TODO
+Funkcijska polnost
\end_layout
\begin_layout Standard
-Postovi teoremi za funkcijsko polnost, množice, preglej še zapiske s pisalnega
- stroja.
+\begin_inset Formula $T_{0},$
+\end_inset
+
+
+\begin_inset Formula $T_{1}$
+\end_inset
+
+,
+\begin_inset Formula $S$
+\end_inset
+
+ –
+\begin_inset Formula $f\left(\vec{x}\right)=\neg f\left(\vec{x}\oplus\vec{1}\right)$
+\end_inset
+
+,
+\begin_inset Formula $L$
+\end_inset
+
+,
+\begin_inset Formula $M$
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset Formula $L$
+\end_inset
+
+ –
+\begin_inset Formula $f\left(\vec{x}\right)=\left[\begin{array}{ccc}
+a_{0} & \dots & a_{n}\end{array}\right]^{T}\oplus\wedge\left[\begin{array}{cccc}
+1 & x_{1} & \dots & x_{n}\end{array}\right]$
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset Formula $M$
+\end_inset
+
+ –
+\begin_inset Formula $\forall i,j:\vec{w_{i}}<\vec{w_{j}}\Rightarrow f\left(\vec{w_{i}}\right)\leq f\left(\vec{w_{j}}\right)$
+\end_inset
+
+
\end_layout
\begin_layout Standard
diff --git a/šola/p1/dn/Premica.java b/šola/p1/dn/6/Premica.java
index 2d2ec4e..2d2ec4e 100644
--- a/šola/p1/dn/Premica.java
+++ b/šola/p1/dn/6/Premica.java
diff --git a/šola/p1/dn/Tocka.java b/šola/p1/dn/6/Tocka.java
index 8dce30b..8dce30b 100644
--- a/šola/p1/dn/Tocka.java
+++ b/šola/p1/dn/6/Tocka.java
diff --git a/šola/p1/dn/7/Blok.java b/šola/p1/dn/7/Blok.java
new file mode 100644
index 0000000..2ac1863
--- /dev/null
+++ b/šola/p1/dn/7/Blok.java
@@ -0,0 +1,33 @@
+import java.util.*;
+public class Blok {
+ private Stanovanje stanovanje;
+ public Blok(Stanovanje stanovanje) {
+ this.stanovanje = stanovanje;
+ }
+ public Oseba starosta() {
+ return this.stanovanje.starostaSosescine();
+ }
+ public int[][] razporeditev() {
+ int minx = Integer.MAX_VALUE;
+ int maxx = Integer.MIN_VALUE;
+ int miny = Integer.MAX_VALUE;
+ int maxy = Integer.MIN_VALUE;
+ for (int[] tuple : stanovanje.pozicije()) {
+ if (tuple[1] > maxx)
+ maxx = tuple[1];
+ if (tuple[2] > maxy)
+ maxy = tuple[2];
+ if (tuple[1] < minx)
+ minx = tuple[1];
+ if (tuple[2] < miny)
+ miny = tuple[2];
+ }
+ int[][] r = new int[maxx-minx+1][maxy-miny+1];
+ for (int i = 0; i < r.length; i++)
+ for (int j = 0; j < r[i].length; j++)
+ r[i][j] = -1;
+ for (int[] tuple : stanovanje.pozicije())
+ r[tuple[1]-minx][tuple[2]-miny] = tuple[0]; // TODO think again
+ return r;
+ }
+}
diff --git a/šola/p1/dn/7/Oseba.java b/šola/p1/dn/7/Oseba.java
new file mode 100644
index 0000000..2477ee9
--- /dev/null
+++ b/šola/p1/dn/7/Oseba.java
@@ -0,0 +1,17 @@
+import java.util.*;
+public class Oseba {
+ private String ip;
+ public char spol;
+ public int starost;
+ public Oseba(String ip, char spol, int starost) {
+ this.ip = ip;
+ this.spol = spol;
+ this.starost = starost;
+ }
+ public String toString() {
+ return String.format("%s, %c, %d", this.ip, this.spol, this.starost);
+ }
+ public boolean jeStarejsaOd(Oseba os) {
+ return this.starost > os.starost;
+ }
+}
diff --git a/šola/p1/dn/7/Stanovanje.java b/šola/p1/dn/7/Stanovanje.java
new file mode 100644
index 0000000..30db09f
--- /dev/null
+++ b/šola/p1/dn/7/Stanovanje.java
@@ -0,0 +1,95 @@
+import java.util.*;
+public class Stanovanje {
+ public Oseba[] stanovalci;
+ private Stanovanje[] sosedje = {null, null, null, null};
+ public Stanovanje(Oseba[] stanovalci) {
+ this.stanovalci = stanovalci;
+ }
+ public int steviloStanovalcev() {
+ return this.stanovalci.length;
+ }
+ public int steviloStarejsihOd(Oseba os) {
+ int r = 0;
+ for (int i = 0; i < this.stanovalci.length; i++)
+ if (this.stanovalci[i].jeStarejsaOd(os))
+ r++;
+ return r;
+ }
+ public int[] mz() {
+ int mž[] = {0, 0};
+ for (int i = 0; i < this.stanovalci.length; i++)
+ if (this.stanovalci[i].spol == 'M')
+ mž[0]++;
+ else
+ mž[1]++;
+ return mž;
+ }
+ public Oseba starosta() {
+ Oseba r = null;
+ for (int i = 0; i < this.stanovalci.length; i++)
+ if (r == null || this.stanovalci[i].jeStarejsaOd(r))
+ r = this.stanovalci[i];
+ return r;
+ }
+ public void nastaviSosede(Stanovanje levi, Stanovanje zgornji,
+ Stanovanje desni, Stanovanje spodnji) {
+ this.sosedje[0] = levi;
+ this.sosedje[1] = zgornji;
+ this.sosedje[2] = desni;
+ this.sosedje[3] = spodnji;
+ }
+ public Oseba starostaSosescine() {
+ Oseba r = this.starosta();
+ for (int i = 0; i < this.sosedje.length; i++) {
+ if (this.sosedje[i] == null)
+ continue;
+ if (this.sosedje[i].starosta() == null)
+ continue;
+ if (this.sosedje[i].starosta().jeStarejsaOd(r))
+ r = this.sosedje[i].starosta();
+ }
+ return r;
+ }
+ public Oseba[] sosedjeSosedov() {
+ List<Oseba> r = new ArrayList<Oseba>();
+ for (Stanovanje stanovanje : this.soseščina())
+ r.addAll(Arrays.asList(stanovanje.stanovalci));
+ return r.toArray(new Oseba[0]);
+ }
+ private Set<Stanovanje> soseščina() {
+ return this.soseščina(new HashSet<Stanovanje>());
+ }
+ private Set<Stanovanje> soseščina(Set<Stanovanje> obiskani) {
+ Set<Stanovanje> r = new HashSet<Stanovanje>();
+ if (obiskani.contains(this))
+ return r;
+ r.addAll(Arrays.asList(this.sosedje));
+ r.remove(null);
+ obiskani.add(this);
+ for (int i = 0; i < this.sosedje.length; i++)
+ if (this.sosedje[i] != null)
+ r.addAll(this.sosedje[i].soseščina(obiskani));
+ obiskani.remove(this);
+ return r;
+ }
+ public Set<int[]> pozicije () {
+ return this.pozicije(new HashSet<Stanovanje>(), 0, 0);
+ }
+ private Set<int[]> pozicije (Set<Stanovanje> obiskani, int x, int y) {
+ Set<int[]> r = new HashSet<int[]>();
+ if (obiskani.contains(this))
+ return r;
+ r.add(new int[]{this.stanovalci.length, x, y});
+ obiskani.add(this);
+ if (this.sosedje[0] != null)
+ r.addAll(this.sosedje[0].pozicije(obiskani, x-1, y));
+ if (this.sosedje[1] != null)
+ r.addAll(this.sosedje[1].pozicije(obiskani, x, y+1));
+ if (this.sosedje[2] != null)
+ r.addAll(this.sosedje[2].pozicije(obiskani, x+1, y));
+ if (this.sosedje[3] != null)
+ r.addAll(this.sosedje[3].pozicije(obiskani, x, y-1));
+ obiskani.remove(this);
+ return r;
+ }
+ }
diff --git a/šola/p1/dn/tj.sh b/šola/p1/dn/tj.sh
index dcb1270..908f082 100755
--- a/šola/p1/dn/tj.sh
+++ b/šola/p1/dn/tj.sh
@@ -33,7 +33,7 @@ do
tac $f | tac
echo "IZHOD: Levo je vaš izhod, desno je pravilen izhod:"
head -n-1 <<<$out
- grep 'java$' <<<$f > /dev/null && echo "PRIPOROČILO: Če DN zahteva razrede (kot recimo DN06), morate imeti v trenutnem direktoriju PREVEDENE .class datoteke vaših zahtevanih razredov. Če so v katerem drugem direktoriju, morate nastaviti CLASSPATH."
+ grep 'java$' <<<$f > /dev/null && echo -e "PRIPOROČILO: Če DN zahteva razrede (kot recimo DN06), morate imeti v trenutnem direktoriju PREVEDENE .class datoteke vaših zahtevanih razredov. Če so v katerem drugem direktoriju, morate nastaviti CLASSPATH.\nPoleg tega se lahko zgodi, da v direktoriju s testi obstaja TestSkupno.java (kot recimo DN07), ki ga je potrebno prevesti v z javac."
fi
else
uspelih=$(($uspelih+1))