From b0324289066876915efb84a133eca039d8e8c8ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Sun, 17 Dec 2023 23:17:03 +0100 Subject: =?UTF-8?q?=C5=A1ola?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\305\241ola/ds1/kolokvij1.lyx" | 179 +++++++++++++++++++++++++++------- "\305\241ola/p1/dn/6/Premica.java" | 50 ++++++++++ "\305\241ola/p1/dn/6/Tocka.java" | 27 +++++ "\305\241ola/p1/dn/7/Blok.java" | 33 +++++++ "\305\241ola/p1/dn/7/Oseba.java" | 17 ++++ "\305\241ola/p1/dn/7/Stanovanje.java" | 95 ++++++++++++++++++ "\305\241ola/p1/dn/Premica.java" | 50 ---------- "\305\241ola/p1/dn/Tocka.java" | 27 ----- "\305\241ola/p1/dn/tj.sh" | 2 +- 9 files changed, 367 insertions(+), 113 deletions(-) create mode 100644 "\305\241ola/p1/dn/6/Premica.java" create mode 100644 "\305\241ola/p1/dn/6/Tocka.java" create mode 100644 "\305\241ola/p1/dn/7/Blok.java" create mode 100644 "\305\241ola/p1/dn/7/Oseba.java" create mode 100644 "\305\241ola/p1/dn/7/Stanovanje.java" delete mode 100644 "\305\241ola/p1/dn/Premica.java" delete mode 100644 "\305\241ola/p1/dn/Tocka.java" (limited to 'šola') diff --git "a/\305\241ola/ds1/kolokvij1.lyx" "b/\305\241ola/ds1/kolokvij1.lyx" index 01421eb..1df6ebc 100644 --- "a/\305\241ola/ds1/kolokvij1.lyx" +++ "b/\305\241ola/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/\305\241ola/p1/dn/6/Premica.java" "b/\305\241ola/p1/dn/6/Premica.java" new file mode 100644 index 0000000..2d2ec4e --- /dev/null +++ "b/\305\241ola/p1/dn/6/Premica.java" @@ -0,0 +1,50 @@ +import java.util.*; +public class Premica { + private double k; + private double n; + public Premica(double k, double n) { + this.k = k; + this.n = n; + } + public double vrniK() { + return this.k; + } + public double vrniN() { + return this.n; + } + public String toString() { + return String.format(Locale.ROOT, "y = %.2f x + %.2f", this.k, this.n); + } + public Tocka tockaPriX(double x) { + return new Tocka(x, this.k*x+this.n); + } + public static Premica skoziTocko(double k, Tocka t) { + return new Premica(k, t.vrniY()-k*t.vrniX()); + } + + public Premica vzporednica(Tocka t) { + return skoziTocko(this.k, t); + } + + public Premica pravokotnica(Tocka t) { + return skoziTocko(-1/this.k, t); + } + + public Tocka presecisce(Premica p, double epsilon) { + if (Math.abs(this.k - p.vrniK()) < epsilon) + return null; + return tockaPriX((this.n-p.vrniN())/(p.vrniK()-this.k)); + } + public Tocka projekcija(Tocka t) { + return presecisce(pravokotnica(t), 0); + } + public double razdalja(Tocka t) { + return t.razdalja(projekcija(t)); + } + public double razdaljaOdIzhodisca() { + return Tocka.izhodisce().razdalja(projekcija(Tocka.izhodisce())); + } + public double razdalja(double n) { + return new Premica(this.k, n).razdalja(tockaPriX(0)); + } +} diff --git "a/\305\241ola/p1/dn/6/Tocka.java" "b/\305\241ola/p1/dn/6/Tocka.java" new file mode 100644 index 0000000..8dce30b --- /dev/null +++ "b/\305\241ola/p1/dn/6/Tocka.java" @@ -0,0 +1,27 @@ +import java.util.*; +public class Tocka { + private double x; + private double y; + public Tocka(double x, double y) { + this.x = x; + this.y = y; + } + public double vrniX() { + return this.x; + } + public double vrniY() { + return this.y; + } + public String toString() { + return String.format(Locale.ROOT, "(%.2f, %.2f)", this.x, this.y); + } + public static Tocka izhodisce() { + return new Tocka(0, 0); + } + public double razdalja(Tocka t) { + return Math.sqrt(Math.pow(this.x-t.x, 2)+Math.pow(this.y-t.y, 2)); + } + public double razdaljaOdIzhodisca() { + return izhodisce().razdalja(this); + } +} diff --git "a/\305\241ola/p1/dn/7/Blok.java" "b/\305\241ola/p1/dn/7/Blok.java" new file mode 100644 index 0000000..2ac1863 --- /dev/null +++ "b/\305\241ola/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/\305\241ola/p1/dn/7/Oseba.java" "b/\305\241ola/p1/dn/7/Oseba.java" new file mode 100644 index 0000000..2477ee9 --- /dev/null +++ "b/\305\241ola/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/\305\241ola/p1/dn/7/Stanovanje.java" "b/\305\241ola/p1/dn/7/Stanovanje.java" new file mode 100644 index 0000000..30db09f --- /dev/null +++ "b/\305\241ola/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 r = new ArrayList(); + for (Stanovanje stanovanje : this.soseščina()) + r.addAll(Arrays.asList(stanovanje.stanovalci)); + return r.toArray(new Oseba[0]); + } + private Set soseščina() { + return this.soseščina(new HashSet()); + } + private Set soseščina(Set obiskani) { + Set r = new HashSet(); + 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 pozicije () { + return this.pozicije(new HashSet(), 0, 0); + } + private Set pozicije (Set obiskani, int x, int y) { + Set r = new HashSet(); + 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/\305\241ola/p1/dn/Premica.java" "b/\305\241ola/p1/dn/Premica.java" deleted file mode 100644 index 2d2ec4e..0000000 --- "a/\305\241ola/p1/dn/Premica.java" +++ /dev/null @@ -1,50 +0,0 @@ -import java.util.*; -public class Premica { - private double k; - private double n; - public Premica(double k, double n) { - this.k = k; - this.n = n; - } - public double vrniK() { - return this.k; - } - public double vrniN() { - return this.n; - } - public String toString() { - return String.format(Locale.ROOT, "y = %.2f x + %.2f", this.k, this.n); - } - public Tocka tockaPriX(double x) { - return new Tocka(x, this.k*x+this.n); - } - public static Premica skoziTocko(double k, Tocka t) { - return new Premica(k, t.vrniY()-k*t.vrniX()); - } - - public Premica vzporednica(Tocka t) { - return skoziTocko(this.k, t); - } - - public Premica pravokotnica(Tocka t) { - return skoziTocko(-1/this.k, t); - } - - public Tocka presecisce(Premica p, double epsilon) { - if (Math.abs(this.k - p.vrniK()) < epsilon) - return null; - return tockaPriX((this.n-p.vrniN())/(p.vrniK()-this.k)); - } - public Tocka projekcija(Tocka t) { - return presecisce(pravokotnica(t), 0); - } - public double razdalja(Tocka t) { - return t.razdalja(projekcija(t)); - } - public double razdaljaOdIzhodisca() { - return Tocka.izhodisce().razdalja(projekcija(Tocka.izhodisce())); - } - public double razdalja(double n) { - return new Premica(this.k, n).razdalja(tockaPriX(0)); - } -} diff --git "a/\305\241ola/p1/dn/Tocka.java" "b/\305\241ola/p1/dn/Tocka.java" deleted file mode 100644 index 8dce30b..0000000 --- "a/\305\241ola/p1/dn/Tocka.java" +++ /dev/null @@ -1,27 +0,0 @@ -import java.util.*; -public class Tocka { - private double x; - private double y; - public Tocka(double x, double y) { - this.x = x; - this.y = y; - } - public double vrniX() { - return this.x; - } - public double vrniY() { - return this.y; - } - public String toString() { - return String.format(Locale.ROOT, "(%.2f, %.2f)", this.x, this.y); - } - public static Tocka izhodisce() { - return new Tocka(0, 0); - } - public double razdalja(Tocka t) { - return Math.sqrt(Math.pow(this.x-t.x, 2)+Math.pow(this.y-t.y, 2)); - } - public double razdaljaOdIzhodisca() { - return izhodisce().razdalja(this); - } -} diff --git "a/\305\241ola/p1/dn/tj.sh" "b/\305\241ola/p1/dn/tj.sh" index dcb1270..908f082 100755 --- "a/\305\241ola/p1/dn/tj.sh" +++ "b/\305\241ola/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)) -- cgit v1.2.3