summaryrefslogtreecommitdiffstats
path: root/šola
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2023-12-17 23:17:03 +0100
committerAnton Luka Šijanec <anton@sijanec.eu>2023-12-17 23:17:03 +0100
commitb0324289066876915efb84a133eca039d8e8c8ee (patch)
tree76b06718de422ed0e5aacbd76c611ee4f82ff526 /šola
parentaoc11 (diff)
downloadr-b0324289066876915efb84a133eca039d8e8c8ee.tar
r-b0324289066876915efb84a133eca039d8e8c8ee.tar.gz
r-b0324289066876915efb84a133eca039d8e8c8ee.tar.bz2
r-b0324289066876915efb84a133eca039d8e8c8ee.tar.lz
r-b0324289066876915efb84a133eca039d8e8c8ee.tar.xz
r-b0324289066876915efb84a133eca039d8e8c8ee.tar.zst
r-b0324289066876915efb84a133eca039d8e8c8ee.zip
Diffstat (limited to 'šola')
-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
7 files changed, 290 insertions, 36 deletions
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))