summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitmodules3
-rw-r--r--ang/exam/2/dokument.md124
-rw-r--r--fiz/naloga/vodnaraketa/.gitignore1
-rw-r--r--fiz/naloga/vodnaraketa/Makefile23
-rw-r--r--fiz/naloga/vodnaraketa/README.txt5
-rw-r--r--fiz/naloga/vodnaraketa/data/index.html19
-rw-r--r--fiz/naloga/vodnaraketa/data/settings.json40
-rw-r--r--fiz/naloga/vodnaraketa/include/README39
-rw-r--r--fiz/naloga/vodnaraketa/lib/README46
-rw-r--r--fiz/naloga/vodnaraketa/platformio.ini25
-rw-r--r--fiz/naloga/vodnaraketa/src/func.c31
-rw-r--r--fiz/naloga/vodnaraketa/src/main.cpp171
-rw-r--r--fiz/naloga/vodnaraketa/test/README11
-rwxr-xr-xinf/rtk/2021-izbirno/1/a.outbin0 -> 20296 bytes
-rw-r--r--inf/rtk/2021-izbirno/1/prog.c62
-rwxr-xr-xinf/rtk/2021-izbirno/2/a.outbin0 -> 20696 bytes
-rw-r--r--inf/rtk/2021-izbirno/2/in.txt2
-rw-r--r--inf/rtk/2021-izbirno/2/prog.c64
-rwxr-xr-xinf/rtk/2021-izbirno/3/a.outbin0 -> 17200 bytes
-rw-r--r--inf/rtk/2021-izbirno/3/in.txt7
-rw-r--r--inf/rtk/2021-izbirno/3/prog.c86
-rw-r--r--inf/rtk/2021-izbirno/p/p.c5
22 files changed, 764 insertions, 0 deletions
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..3cb43a1
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "fiz/naloga/vodnaraketa/esp8266FTPServer"]
+ path = fiz/naloga/vodnaraketa/esp8266FTPServer
+ url = https://github.com/nailbuster/esp8266FTPServer
diff --git a/ang/exam/2/dokument.md b/ang/exam/2/dokument.md
new file mode 100644
index 0000000..5cc0d04
--- /dev/null
+++ b/ang/exam/2/dokument.md
@@ -0,0 +1,124 @@
+## infinitive, gerund
+
+the -ing form is used after prepositions and: detest, dislike, enjoy, hate, like, love, prefer, resent
+
+# words
+
+## megacities
+
+* sustainable infrastructure
+* sprawling, increasing, expanding
+* urban / metropolitan area
+* accomodating
+* enchancing / improving
+* degradation
+* multilingual / diverse
+* density
+* undergo
+* urban sprawl
+* successive waves of immigrants, an excessive influx of immigrants
+* allure
+* emulate / immitate
+* veneer / to develop veneer
+* assorted / diverse cultures
+* racial tensions, prejudices against
+* inadequate infrastructure
+* exclusive / inclusive
+* to be biased
+* alienation = odtujitev
+
+## advertising
+
+* to skew / distort
+* gender discrimination
+* racist connotation
+* perpetrated / perpatuated / stereotyped / portrayed
+* submissive
+* misogynistic
+* misleading
+* implicit
+* catchy jingles
+* subtle
+* blatant
+* ubiquitous
+* watchdog
+* exploit
+* deceptive misleading / false advertisement
+* to endorse a product / to recommend it
+* product endorsement
+* to disclaim / say you have no responsibility
+
+## consumerism
+
+* irresistible bargains
+* an insatiable desire
+* compulsive shopping
+* resist temptation
+* to be tempted into
+* parlance / jargon
+* avalanche
+* parmy / crazy
+* mock-up / replica
+* meandered / wandered
+* critical faculties / ability to judge objectively
+* oasis / refuge
+* blithely / in a carefree manner
+* coughing up / spending
+* banal repetitious and dull
+* proceeds / profits
+* glorified / seeming more important than in reality is
+* gratifying
+
+# phrasal verbs
+
+## take
+
+* to take after = to resemble
+* to take back = apologise
+* to take somebody for = identify wrongly
+* to take in = fully understand
+* to take off = remove / leave the ground / imitating
+* take over = gain control of
+* take to somebody = like immediately
+* take up = start
+* taken aback = strongly surprised
+* taken in = be deceived
+
+## set
+
+* set about = began
+* set aside = save
+* set back = hindered = ovirati
+* set in (weather) = started to continue
+* set off/out = started a journey
+* to set on = to cause to attack
+* set up = started
+
+## stand
+
+* stand by = support
+* stand for = represents
+* stand in = replace temporarily
+* stand out = be noticable
+* stand up = support
+
+## turn
+
+* turn down = refused admittance / refuse an offer
+* turn in = give to the police
+* turn off = switch off
+* turn out = proved to be
+* turn up = appear
+
+
+## wear
+
+* worn away = reduced gradually
+* wear off = stop
+* worn out = exhausted
+
+## work
+
+* work on = what effect it has on
+* work out = find a solution
+* worked up = developed
diff --git a/fiz/naloga/vodnaraketa/.gitignore b/fiz/naloga/vodnaraketa/.gitignore
new file mode 100644
index 0000000..03f4a3c
--- /dev/null
+++ b/fiz/naloga/vodnaraketa/.gitignore
@@ -0,0 +1 @@
+.pio
diff --git a/fiz/naloga/vodnaraketa/Makefile b/fiz/naloga/vodnaraketa/Makefile
new file mode 100644
index 0000000..921476a
--- /dev/null
+++ b/fiz/naloga/vodnaraketa/Makefile
@@ -0,0 +1,23 @@
+default:
+ @echo "*** vodna raketa *** 🚀"
+ @echo "recepti:"
+ @echo " - p: naloži knjižnice"
+ @echo " - c: prevede v strojno kodo"
+ @echo " - u: nalozi na mikrokontroler"
+ @echo " - n: pobriše generirane direktorije in datoteke iz tega direktorija"
+ @echo "imeti morate python3-pip"
+ @echo "to je vse, hvala"
+
+c:
+ pio run
+
+u:
+ pio run --target uploadfs
+ pio run --target upload
+
+p:
+ pip install -U platformio
+ pio run
+
+n:
+ pio run --target clean
diff --git a/fiz/naloga/vodnaraketa/README.txt b/fiz/naloga/vodnaraketa/README.txt
new file mode 100644
index 0000000..1927334
--- /dev/null
+++ b/fiz/naloga/vodnaraketa/README.txt
@@ -0,0 +1,5 @@
+*** vodna raketa *** 🚀
+
+programje za mojo projektno nalogo pri fiziki v drugem letniku
+
+več informacij v predstavitvi sami, ki jo, če je že narejena, najdete v repozitoriju sijanec/sola-gimb-2
diff --git a/fiz/naloga/vodnaraketa/data/index.html b/fiz/naloga/vodnaraketa/data/index.html
new file mode 100644
index 0000000..2e4fd3c
--- /dev/null
+++ b/fiz/naloga/vodnaraketa/data/index.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html lang=sl>
+ <head>
+ <meta charset=UTF-8 />
+ <title>
+ spletni vmesnik vodne rakete
+ </title>
+ <link rel=stylesheet href=//sijanec.eu/assets/css/styles.css />
+ </head>
+ <body>
+ <h1>
+ spletni vmesnik računalnika projetne naloge pri fiziki v drugem letniku
+ </h1>
+ <hr>
+ <p>
+ &copy; Anton Luka Šijanec 2021 - <a href=//git.sijanec.eu/sijanec/sola-gimb-2/src/branch/master/fiz/naloga/vodnaraketa>vodnaraketa</a>
+ </p>
+ </body>
+</html>
diff --git a/fiz/naloga/vodnaraketa/data/settings.json b/fiz/naloga/vodnaraketa/data/settings.json
new file mode 100644
index 0000000..4ef4b59
--- /dev/null
+++ b/fiz/naloga/vodnaraketa/data/settings.json
@@ -0,0 +1,40 @@
+{
+ /* wifi access point configuration */
+ "ap_ssid": "vodnaraketa",
+ "ap_pass": "",
+ "ap_ch": 1,
+ "ap_hidden": 0,
+ "ap_ip": "10.82.66.1",
+ "ap_gw": "10.82.66.1",
+ "ap_nm": "255.255.255.0",
+ "ap_dns1": "",
+ "ap_dns2": "",
+ "ap_host": "vodnaraketa",
+
+ /* wifi station (client) configuration, leave ip settings empty to use DHCP obtained */
+ "sta_ssid": "",
+ "sta_pass": "",
+ "sta_ip": "",
+ "sta_dns": "",
+ "sta_gw": "",
+ "sta_nm": "",
+ "sta_dns1": "",
+ "sta_dns2": "",
+ "sta_host": "vodnaraketa",
+ "sta_static": 0,
+
+ /* pin configuration */
+ "scale_dout": "D6",
+ "scale_sck": "D5",
+
+ /* username and password for FTP and HTTP authentication */
+ "ftp_user": "vodnaraketa",
+ "ftp_pass": "",
+ "http_user": "",
+ "http_pass": "",
+
+ /* general info */
+ "host": "vodnaraketa",
+
+ "json parser": "don't be angry"
+}
diff --git a/fiz/naloga/vodnaraketa/include/README b/fiz/naloga/vodnaraketa/include/README
new file mode 100644
index 0000000..194dcd4
--- /dev/null
+++ b/fiz/naloga/vodnaraketa/include/README
@@ -0,0 +1,39 @@
+
+This directory is intended for project header files.
+
+A header file is a file containing C declarations and macro definitions
+to be shared between several project source files. You request the use of a
+header file in your project source file (C, C++, etc) located in `src` folder
+by including it, with the C preprocessing directive `#include'.
+
+```src/main.c
+
+#include "header.h"
+
+int main (void)
+{
+ ...
+}
+```
+
+Including a header file produces the same results as copying the header file
+into each source file that needs it. Such copying would be time-consuming
+and error-prone. With a header file, the related declarations appear
+in only one place. If they need to be changed, they can be changed in one
+place, and programs that include the header file will automatically use the
+new version when next recompiled. The header file eliminates the labor of
+finding and changing all the copies as well as the risk that a failure to
+find one copy will result in inconsistencies within a program.
+
+In C, the usual convention is to give header files names that end with `.h'.
+It is most portable to use only letters, digits, dashes, and underscores in
+header file names, and at most one dot.
+
+Read more about using header files in official GCC documentation:
+
+* Include Syntax
+* Include Operation
+* Once-Only Headers
+* Computed Includes
+
+https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
diff --git a/fiz/naloga/vodnaraketa/lib/README b/fiz/naloga/vodnaraketa/lib/README
new file mode 100644
index 0000000..6debab1
--- /dev/null
+++ b/fiz/naloga/vodnaraketa/lib/README
@@ -0,0 +1,46 @@
+
+This directory is intended for project specific (private) libraries.
+PlatformIO will compile them to static libraries and link into executable file.
+
+The source code of each library should be placed in a an own separate directory
+("lib/your_library_name/[here are source files]").
+
+For example, see a structure of the following two libraries `Foo` and `Bar`:
+
+|--lib
+| |
+| |--Bar
+| | |--docs
+| | |--examples
+| | |--src
+| | |- Bar.c
+| | |- Bar.h
+| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
+| |
+| |--Foo
+| | |- Foo.c
+| | |- Foo.h
+| |
+| |- README --> THIS FILE
+|
+|- platformio.ini
+|--src
+ |- main.c
+
+and a contents of `src/main.c`:
+```
+#include <Foo.h>
+#include <Bar.h>
+
+int main (void)
+{
+ ...
+}
+
+```
+
+PlatformIO Library Dependency Finder will find automatically dependent
+libraries scanning project source files.
+
+More information about PlatformIO Library Dependency Finder
+- https://docs.platformio.org/page/librarymanager/ldf.html
diff --git a/fiz/naloga/vodnaraketa/platformio.ini b/fiz/naloga/vodnaraketa/platformio.ini
new file mode 100644
index 0000000..5977f35
--- /dev/null
+++ b/fiz/naloga/vodnaraketa/platformio.ini
@@ -0,0 +1,25 @@
+; PlatformIO Project Configuration File
+;
+; Build options: build flags, source filter
+; Upload options: custom upload port, speed and extra flags
+; Library options: dependencies, extra library storages
+; Advanced options: extra scripting
+;
+; Please visit documentation for the other options and examples
+; https://docs.platformio.org/page/projectconf.html
+[env:myboard]
+platform = espressif8266
+board = nodemcuv2
+monitor_speed = 9600
+upload_speed = 921600
+build_flags = -DDEBUG_ESP_CORE -DDEBUG_ESP_WIFI -DDEBUG_ESP_PORT=Serial -DIP_FORWARD=1
+framework = arduino
+board_build.filesystem = littlefs
+board_build.ldscript = eagle.flash.4m2m.ld
+src_filter = -<*> +<main.cpp>
+lib_deps =
+ Time
+ https://github.com/dplasa/FTPClientServer
+ bogde/HX711
+ DNSServer
+ ESP Async WebServer
diff --git a/fiz/naloga/vodnaraketa/src/func.c b/fiz/naloga/vodnaraketa/src/func.c
new file mode 100644
index 0000000..07bfd6e
--- /dev/null
+++ b/fiz/naloga/vodnaraketa/src/func.c
@@ -0,0 +1,31 @@
+const int str2pin_map[] = {
+ D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ A0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+int str2pin(const char * s) {
+ if (s[0] >= '0' && s[0] <= '9')
+ return atoi(s);
+ return str2pin_map[atoi(s+1) + ((s[0]=='A') ? 20 : 0)];
+}
+
+/* reads settings into json object */
+void load_settings () {
+ if (LittleFS.exists("settings.json")) {
+ File s = LittleFS.open("settings.json", "r");
+ if (s)
+ deserializeJson(settings, s);
+ s.close();
+ }
+}
+
+/* stores settings from json object to file */
+void store_settings () {
+ File s = LittleFS.open("settings.json", "w");
+ serializeJson(settings, s);
+ s.close();
+}
+
+void notFound(AsyncWebServerRequest *request) {
+ request->send(404, "text/plain", "404");
+}
diff --git a/fiz/naloga/vodnaraketa/src/main.cpp b/fiz/naloga/vodnaraketa/src/main.cpp
new file mode 100644
index 0000000..91280dd
--- /dev/null
+++ b/fiz/naloga/vodnaraketa/src/main.cpp
@@ -0,0 +1,171 @@
+#define ARDUINOJSON_ENABLE_COMMENTS 1
+#include <stdlib.h>
+#include <Arduino.h>
+#include <ArduinoJson.h>
+#include "LittleFS.h"
+#include <DNSServer.h>
+#include <ESP8266WiFi.h>
+#include <WiFiClient.h>
+#include <TimeLib.h>
+#include <WiFiUdp.h>
+#include <ESP8266httpUpdate.h>
+#include <ESPAsyncWebServer.h>
+#include <HX711.h>
+#include <FTPServer.h>
+
+DynamicJsonDocument settings(2048);
+
+#include <func.c>
+
+FTPServer ftpServer(LittleFS);
+DNSServer dnsServer;
+AsyncWebServer httpServer(80);
+HX711 scale;
+
+time_t measure = 0;
+File measureFile;
+
+void reload (bool w = 0) {
+ /* stop services unless they were never started, indicate this by w in for example setup() */
+ if (!w) {
+ ftpServer.stop();
+ httpServer.reset();
+ dnsServer.stop();
+ }
+
+ /* reload settings */
+ load_settings();
+
+ /* bring up AP networking */
+ IPAddress ap_ip(10, 82, 66, 1);
+ ap_ip.fromString(settings["ap_ip"].as<String>());
+ IPAddress ap_gateway(10, 82, 66, 1);
+ ap_gateway.fromString(settings["ap_gw"].as<String>());
+ IPAddress ap_subnet(255, 255, 255, 0);
+ ap_subnet.fromString(settings["ap_nm"].as<String>());
+ WiFi.mode(WIFI_AP);
+ WiFi.softAPConfig(ap_ip, ap_gateway, ap_subnet);
+ const char * ap_pass = settings["ap_pass"].as<String>().c_str();
+ if (ap_pass && strlen(ap_pass) < 8)
+ ap_pass = NULL;
+ WiFi.softAP(settings["ap_ssid"].as<String>().c_str(), ap_pass, settings["cp_ch"].as<int>(), settings["ap_hidden"].as<int>());
+ Serial.println("WiFi.softAPIP() = " + WiFi.softAPIP().toString());
+
+
+ /* bring up STA networking - if that's desired */
+ const char * sta_ssid = settings["sta_ssid"].as<String>().c_str();
+ if (sta_ssid && strlen(sta_ssid) > 0) {
+ IPAddress sta_ip(10, 69, 69, 82);
+ sta_ip.fromString(settings["sta_ip"].as<String>());
+ IPAddress sta_gw(10, 69, 69, 1);
+ sta_ip.fromString(settings["sta_gw"].as<String>());
+ IPAddress sta_nm(255, 255, 255, 0);
+ sta_ip.fromString(settings["sta_nm"].as<String>());
+ IPAddress sta_dns1(93, 103, 235, 126);
+ sta_dns1.fromString(settings["sta_dns1"].as<String>());
+ IPAddress sta_dns2(193, 2, 1, 66);
+ sta_dns2.fromString(settings["sta_dns2"].as<String>());
+ WiFi.disconnect(true);
+ WiFi.hostname(settings["sta_host"].as<String>());
+ const char * sta_pass = settings["sta_pass"].as<String>().c_str();
+ if (strlen(sta_pass) < 8)
+ sta_pass = NULL;
+ WiFi.begin(sta_ssid, sta_pass);
+ if (settings["sta_static"].as<int>())
+ if (!WiFi.config(sta_ip, sta_gw, sta_nm, sta_dns1, sta_dns2))
+ Serial.println("failed to wifi config");
+ }
+
+ /* start services */
+ dnsServer.start(53, settings["host"], WiFi.softAPIP());
+ ftpServer.begin(settings["ftp_user"], settings["ftp_pass"]);
+ /* web server */
+#define ADD_AUTH(h) if (strlen(settings["http_user"].as<String>().c_str()) || strlen(settings["http_pass"].as<String>().c_str())) h.setAuthentication(settings["http_user"], settings["http_pass"])
+ auto h = httpServer.serveStatic("/", LittleFS, "/")
+ .setDefaultFile("index.html")
+ .setAuthentication(settings["http_user"], settings["http_pass"]);
+ ADD_AUTH(h);
+ h = httpServer.on("/rst", [](AsyncWebServerRequest * r) {
+ r->send(201, "text/plain", "OK");
+ ESP.restart();
+ });
+ ADD_AUTH(h);
+ h = httpServer.on("/rld", [](AsyncWebServerRequest * r) {
+ r->send(201, "text/plain", "OK");
+ reload();
+ });
+ h = httpServer.on("/m", [](AsyncWebServerRequest * r) {
+ if (!r->hasParam("n"))
+ r->send(400, "text/plain", "Manjka parameter n - število sekund meritve");
+ else
+ if (!measure) {
+ measure = time(NULL)+atoi(r->getParam("n")->value().c_str());
+ r->send(201, "text/plain", "OK");
+ } else {
+ r->send(400, "text/plain", "Meritev že poteka!");
+ }
+ });
+ ADD_AUTH(h);
+
+ /* specifični ukazi za meritve: začetek loadcella, kalibracija, tara */
+ scale.begin(str2pin(settings["scale_dout"].as<String>().c_str()), str2pin(settings["scale_sck"].as<String>().c_str()));
+ h = httpServer.on("/c", [](AsyncWebServerRequest * r) {
+ if (!r->hasParam("t")) {
+ r->send(400, "text/plain", "Manjka parameter t - teža na tehtnici");
+ }
+ if (scale.wait_ready_timeout(1000)) {
+ scale.set_scale();
+ scale.tare();
+ scale.set_scale(scale.get_units(10)/atof(r->getParam("t")->value().c_str()));
+ r->send(200, "text/plain", "OK");
+ } else {
+ r->send(500, "text/plain", "Tehtnica ni najdena");
+ }
+ });
+ ADD_AUTH(h);
+ h = httpServer.on("/t", [](AsyncWebServerRequest * r) {
+ if (scale.wait_ready_timeout(1000)) {
+ scale.tare();
+ r->send(400, "text/plain", "OK");
+ } else {
+ r->send(500, "text/plain", "Tehtnica ni najdena.");
+ }
+ });
+ ADD_AUTH(h);
+}
+
+void handleMeasure() {
+ if (measure != 0) {
+ if (measure < time(NULL)) {
+ if (measureFile.isFile()) {
+ char filename[32];
+ snprintf(filename, 32, "meritev%ldl.csv", time(NULL));
+ measureFile = LittleFS.open(filename, "w");
+ scale.power_up();
+ }
+ if (scale.wait_ready_timeout(1000)) {
+ long reading = scale.get_units(10);
+ measureFile.print(millis()+""+"\n");
+ } else {
+ Serial.println("HX711 ni najden.");
+ }
+ } else {
+ measure = 0;
+ measureFile.close();
+ scale.power_down();
+ }
+ }
+}
+
+void setup () {
+ Serial.begin(9600);
+ Serial.println("Živ sem!");
+ LittleFS.begin();
+ reload(1);
+}
+
+void loop () {
+ handleMeasure();
+ ftpServer.handleFTP();
+ dnsServer.processNextRequest();
+}
diff --git a/fiz/naloga/vodnaraketa/test/README b/fiz/naloga/vodnaraketa/test/README
new file mode 100644
index 0000000..b94d089
--- /dev/null
+++ b/fiz/naloga/vodnaraketa/test/README
@@ -0,0 +1,11 @@
+
+This directory is intended for PlatformIO Unit Testing and project tests.
+
+Unit Testing is a software testing method by which individual units of
+source code, sets of one or more MCU program modules together with associated
+control data, usage procedures, and operating procedures, are tested to
+determine whether they are fit for use. Unit testing finds problems early
+in the development cycle.
+
+More information about PlatformIO Unit Testing:
+- https://docs.platformio.org/page/plus/unit-testing.html
diff --git a/inf/rtk/2021-izbirno/1/a.out b/inf/rtk/2021-izbirno/1/a.out
new file mode 100755
index 0000000..354664c
--- /dev/null
+++ b/inf/rtk/2021-izbirno/1/a.out
Binary files differ
diff --git a/inf/rtk/2021-izbirno/1/prog.c b/inf/rtk/2021-izbirno/1/prog.c
new file mode 100644
index 0000000..aa3e62d
--- /dev/null
+++ b/inf/rtk/2021-izbirno/1/prog.c
@@ -0,0 +1,62 @@
+#include <stdio.h>
+#include <stdlib.h>
+int main (int argc, char ** argv) {
+ char * buf = malloc(500);
+ fgets(buf, 500, stdin);
+ char * cp;
+ int n = strtoll(buf, &cp, 10);
+ cp++;
+ int k = strtoll(cp, NULL, 10);
+ int * a = calloc(n+1, sizeof(int));
+ int * t = calloc(n+1, sizeof(int)); /* t[x] = ekipa št <od 1 do k> */
+ realloc(buf, (n+1)*6);
+ fgets(buf, (n+1)*6, stdin);
+ cp = buf;
+ int i = 0; /* i bo število zadnjega in hkrati število vseh, kajti prvi je 1 */
+ do {
+ int ai = strtoll(cp, &cp, 10);
+ if (ai != 0)
+ a[++i] = ai;
+ cp++;
+ } while (cp[-1] != 0 && cp[-1] != '\n' && cp[-1] != '\r');
+ if (i != n)
+ fprintf(stderr, "error %d ni %d\n", n, i);
+ int ze = 0; /* referencaj novo ekipo po (++ze % k)+1 */
+k1:
+ for (int j = 1; j <= n; j++) {
+ if (!t[(i = j)])
+ goto k2;
+ }
+ goto konec;
+k2:
+ /*
+ e = 0;
+ while (!t[zn]) {
+ if (!e++)
+ fprintf(stdout, "%d ", zn);
+ if (t[a[zn]]) { // če je naš a že v ekipi, i damo v to ekipo
+ t[zn] = t[a[zn]];
+ zn++;
+ }
+ t[zn] = (ze % k)+1;
+ zn = a[zn];
+ }
+ ze++;
+ */
+ if (ze)
+ fprintf(stdout, " ");
+ fprintf(stdout, "%d", i);
+ t[i] = ++ze;
+k3:
+ if (t[a[i]])
+ goto k1;
+k4:
+ i = a[i];
+k5:
+ t[i] = ze;
+ goto k3;
+konec:
+ fprintf(stdout, "\n");
+ free(buf);
+ return 0;
+}
diff --git a/inf/rtk/2021-izbirno/2/a.out b/inf/rtk/2021-izbirno/2/a.out
new file mode 100755
index 0000000..d23cc33
--- /dev/null
+++ b/inf/rtk/2021-izbirno/2/a.out
Binary files differ
diff --git a/inf/rtk/2021-izbirno/2/in.txt b/inf/rtk/2021-izbirno/2/in.txt
new file mode 100644
index 0000000..666efb4
--- /dev/null
+++ b/inf/rtk/2021-izbirno/2/in.txt
@@ -0,0 +1,2 @@
+10 1
+6 0 91 14 73 91 67 63 9 69
diff --git a/inf/rtk/2021-izbirno/2/prog.c b/inf/rtk/2021-izbirno/2/prog.c
new file mode 100644
index 0000000..eda85e9
--- /dev/null
+++ b/inf/rtk/2021-izbirno/2/prog.c
@@ -0,0 +1,64 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <limits.h>
+int primerjaj_cela (const void * a, const void * b) {
+ const int * c = (const int *) a;
+ const int * d = (const int *) b;
+ return *d - *c; /* najv proti najm */
+}
+int main (int argc, char ** argv) {
+ char * buf = malloc(500);
+ fgets(buf, 500, stdin);
+ char * cp;
+ int N = strtoll(buf, &cp, 10);
+ cp++;
+ int M = strtoll(cp, NULL, 10);
+ int * x = calloc(N+1, sizeof(int));
+ int * g = malloc((M+1)*sizeof(int));
+ int * gl = malloc((M+1)*sizeof(int));
+ for (int o = 0; o < M; o++)
+ g[o] = INT_MAX;
+ realloc(buf, (N+1)*6*9);
+ fgets(buf, (N+1)*6*9, stdin);
+ cp = buf;
+ int i = 0;
+ int mx = 0;
+ do {
+ int xi = strtoll(cp, &cp, 10);
+ // if (xi != 0)
+ x[++i] = xi;
+ if (xi > mx)
+ mx = xi;
+ cp++;
+ } while (cp[-1] != 0 && cp[-1] != '\n' && cp[-1] != '\r');
+ free(buf);
+ if (N != i) {
+ fprintf(stderr, "error %d ni %d\n", N, i);
+ for (int o = 1; o <= i; o++)
+ fprintf(stderr, " %d\n", x[o]);
+ }
+ fprintf(stderr, "max = %d\n", mx);
+ for (i = 0; i <= mx; i++) {
+ int s = 0;
+ for (int j = 1; j <= N; j++)
+ s += abs(i-x[j]);
+ int mo = 0;
+ int me = 0;
+ for (int o = 0; o < M; o++) {
+ if (g[o] > mo) {
+ mo = g[o];
+ me = o;
+ }
+ }
+ if (mo > s)
+ g[me] = s;
+ }
+ int s = 0;
+ for (int o = 0; o < M; o++) {
+ fprintf(stderr, "GOSTILNA %d ima seštevek %d\n", o, g[o]);
+ s += g[o];
+ }
+ fprintf(stdout, "%d\n", s);
+ return 0;
+}
diff --git a/inf/rtk/2021-izbirno/3/a.out b/inf/rtk/2021-izbirno/3/a.out
new file mode 100755
index 0000000..d7053de
--- /dev/null
+++ b/inf/rtk/2021-izbirno/3/a.out
Binary files differ
diff --git a/inf/rtk/2021-izbirno/3/in.txt b/inf/rtk/2021-izbirno/3/in.txt
new file mode 100644
index 0000000..d8d19ab
--- /dev/null
+++ b/inf/rtk/2021-izbirno/3/in.txt
@@ -0,0 +1,7 @@
+5 4
+1 1 3 3
+5 4 1 2 1
+1 1 8
+2 1 10
+1 1 8
+1 3 0
diff --git a/inf/rtk/2021-izbirno/3/prog.c b/inf/rtk/2021-izbirno/3/prog.c
new file mode 100644
index 0000000..0686c60
--- /dev/null
+++ b/inf/rtk/2021-izbirno/3/prog.c
@@ -0,0 +1,86 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <limits.h>
+int main (int argc, char ** argv) {
+ char * buf = (char *) malloc(500);
+ fgets(buf, 500, stdin);
+ char * cp;
+ int n = strtoll(buf, &cp, 10);
+ cp++;
+ int q = strtoll(cp, NULL, 10);
+ int * r = (int *) calloc(n+1, sizeof(int));
+ int * x = (int *) calloc(n+1, sizeof(int));
+ realloc(buf, (n+1)*6*9);
+ fgets(buf, (n+1)*6*9, stdin);
+ cp = buf;
+ int i = 1; /* začnemo z delavcem 2, ker 1 nima starša */
+ do {
+ int xi = strtoll(cp, &cp, 10);
+ if (xi != 0)
+ r[++i] = xi;
+ cp++;
+ } while (cp[-1] != 0 && cp[-1] != '\n' && cp[-1] != '\r');
+ i = 0; /* začnemo z delavcem 1 */
+ fgets(buf, (n+1)*6*9, stdin);
+ cp = buf;
+ do {
+ int xi = strtoll(cp, &cp, 10);
+ if (xi != 0)
+ x[++i] = xi;
+ cp++;
+ } while (cp[-1] != 0 && cp[-1] != '\n' && cp[-1] != '\r');
+ if (n != i)
+ fprintf(stderr, "error %d ni %d\n", n, i);
+ else
+ fprintf(stderr, "st\n");
+ fgets(buf, 1000, stdin);
+ while (!feof(stdin)) {
+ cp = buf;
+ if (cp[0] == '1') { /* GET */
+ cp += 2;
+ int d = strtol(cp, &cp, 10);
+ cp++;
+ int t = strtol(cp, NULL, 10);
+ int o = INT_MAX;
+ for (int i = 1; i <= n; i++) {
+ int p = i;
+ int y = 0;
+ while (1) {
+ if (p == d) {
+ y++;
+ break;
+ }
+ if (p == 1)
+ break;
+ p = r[p];
+ }
+ if (!y)
+ continue;
+ else
+ fprintf(stderr, "GET V HIER: %d\n", i);
+ if (x[i] > t && x[i] < o) {
+ fprintf(stderr, " x[i] == %d\n", x[i]);
+ o = x[i];
+ }
+ }
+ if (o == INT_MAX)
+ o = -1;
+ fprintf(stdout, "%d\n", o);
+ } else { /* POST */
+ cp += 2;
+ int d = strtol(cp, &cp, 10);
+ cp++;
+ int t = strtol(cp, NULL, 10);
+ x[d] = t;
+ fprintf(stderr, "POST OK: { ");
+ for (int i = 1; i <= n; i++) {
+ fprintf(stderr, "%d:%d, ", i, x[i]);
+ }
+ fprintf(stderr, "}\n");
+ }
+ fgets(buf, 1000, stdin);
+ }
+ free(buf);
+ return 0;
+}
diff --git a/inf/rtk/2021-izbirno/p/p.c b/inf/rtk/2021-izbirno/p/p.c
new file mode 100644
index 0000000..7f02924
--- /dev/null
+++ b/inf/rtk/2021-izbirno/p/p.c
@@ -0,0 +1,5 @@
+#include <stdio.h>
+#include <stdlib.h>
+int main (int argc, char ** argv) {
+ return 0;
+}