Načrt napada

Rok za oddajo: sreda, 22. december 2021, 15.12

Disclaimer: Vsaka podobnost z resničnimi osebami, vojskami, podjetji, ministrstvi ali sodišči je večinoma naključna.

Nadaljujemo, kjer smo ostali prejšnjič.

Tokrat ni dodatne naloge.


Tole je ena velika blamaža. V treh točkah.

  1. Gospa Kozjančeva bi strateški plan napada na Marsovce hotela oddati v Excelu. Centralni računalnik za koordinacijo napadov na vesoljce (CRKnaV) seveda ne zna brati Excela. Gospa Kozjančeva je zato kot primer, kaj kani sproducirati, natipkala tole skrpucalo

    4.25, 8.5:   5.0, 5   |   8.125, -7.5    |   3.5, -6.75
    6.0, 1.25:  15.5, 5.5  |  1.5, -1.25 | 2.5, -9.5625  | -3, -3
    8, 1: -2, 5
    

    in v mail napisala, da "so u vsaki vrstici koordinate naše ladje pol pa še marsovskih in tko bom jest delala sploh nej me pa Grabnar iz general štaba neha [cenzurirano], drgač bom pač dala odpovet grem pač rajš delat na kakšno normalno ministrstvo kjer majo excel k to znam".

    Podatki bodo torej v takšni obliki, le številke bodo drugačne. Trenutno so še vojaška skrivnost, ki jo pozna samo gospa Kozjančeva.

  2. Nadalje se je izkazalo, da CRKnaV pričakuje podatke v takšni obliki.

       1:     4.2500     8.5000 ->     5.0000     5.0000
                                       8.1250     8.1250
                                       3.5000     3.5000
       2:     6.0000     1.2500 ->    15.5000     5.5000
                                       1.5000     1.5000
                                       2.5000     2.5000
                                      -3.0000    -3.0000
       3:     8.0000     1.0000 ->    -2.0000     5.0000
    

    Z vsemi decimalkami in presledki in vsem. Kolikor je Kozjančeva šlampasta do enomoglosti, je ta picajzlast do skrajnosti. Vsaka številka ima morebitni -, nato do štiri mesta levo od pike, štiri za piko, vmes presledki, pa dvopičja in puščice, točno tako in nič drugače. Ker je vojska vojska. Čeprav slovenska.

  3. Kot da ta zafrkancija s Kozjančevo in CRKnaV še ne bi bila zadosti, se je zgodilo naslednje. Neko podjetje je začelo izdelovati softver za pretvorbo, potem pa se je konkurenčno podjetje pritožilo na razpis, zadeva je šla do Ustavnega sodišča in le-to je razpis razveljavilo, saj škoda, ki bi nastala zaradi marsovskega napada ni sorazmezna s škodo, ki bi nastala s kršenjem zakonodaje s področja javnih naročil. Vse, kar je ostalo od njihovega dela, je nekaj testov. Znajti se bo potrebno iz njih.


Videti je, da bo potrebno napisati tri funkcije.

  • preberi(ime_datoteke) dobi ime datoteke, kakršne proizvaja Kozjančeva in, kot je sklepati iz testov, vrne slovar, katerega ključi so koordinate naših ladij, pripadajoče vrednosti pa seznami koordinat marsovskih ladij. Ime datoteke je načelno poljubno.

  • vrstica(i, ladja, marsovec) vrne eno vrstico navodil za CRKnaV. Iz testov lahko sklepamo, da i vsebuje zaporedno številko naše ladje ali pa None. Če je i številka, jo izpiše, nato izpiše koordinate naše in koordinate marsovske ladje. Če je i enak None, pa ne izpiše ne številke na koordinat naše ladje, temveč samo koordinato marsovske ladje. Torej: klic vrstica(7, (4.25, 8.50), (5, 12.3)) vrne

       7:     4.2500     8.5000 ->     5.0000    12.3000
    

    klic vrstica(None, (4.25, 8.50), (5, 12.3)) pa bi vrnil

                                       5.0000    12.3000
    

    O tem, kako, točno mora biti oblikovan izpis, bo potrebno sklepati iz testov. Good luck.

  • navodila(razpored, ime_datoteke) dobi slovar v takšni obliki, kot ga vrača prva funkcija in ime datoteke, v katero izpiše navodila, ki se do zadnje pike ujemajo s predvidenim formatom.

Sreča v nesreči: v tej nalogi se se dogaja samo v dveh dimenzijah.

Rok za oddajo

Ker bomo 15.12.21, bo ura oddaje izjemoma do 15.12.


Disclaimer: any similarity with real persons, armies, companies, ministries or courts is mostly coincidental.

This is a continuation of our previous homework.

This time, there is not extra task.


This is all one big embarassement.

  1. See, Mrs. Kozjanc wanted to submit the strategic attack plan in Excel. The Central Computer for Coordination of Slovenian Space Force (CCCSSF) doesn't handle Excel. Therefore she reformatted the document as follows.

    4.25, 8.5:   5.0, 5   |   8.125, -7.5    |   3.5, -6.75
    6.0, 1.25:  15.5, 5.5  |  1.5, -1.25 | 2.5, -9.5625  | -3, -3
    8, 1: -2, 5
    

    Besides, she wrote in a mail that "every line contains the coordinates of our ship followed by coordinates of Martian ships and I'll do it this way so either that Grabnar from the general staff stops [censored] or I'll resign and start working at some other ministry" (for the original, more prophane wording, see the Slovenian original)

    This example describes the form of the data. The actual numbers are top secret known only to Mrs. Kozjanc.

  2. Furthermore, we discovered that CCCSSF expects the data in the following format.

       1:     4.2500     8.5000 ->     5.0000     5.0000
                                       8.1250     8.1250
                                       3.5000     3.5000
       2:     6.0000     1.2500 ->    15.5000     5.5000
                                       1.5000     1.5000
                                       2.5000     2.5000
                                      -3.0000    -3.0000
       3:     8.0000     1.0000 ->    -2.0000     5.0000
    

    With all decimals and spaces and everything. For a contrast from Mrs. Kozjanc's sloppiness, computer is a nazi. Every number possibly has a -, followed by four places (space and digits) before point and four decimals afterwards, and in between all those spaces and arrows. Exactly as prescribed. An army is still an army. Even the Slovenian.

  3. As if those peculiarities of Mrs. Kozjanc and CCCSSF were not sufficient, the following happened. Some company started developing the software to transform between formats, but then a competing company sued about the procedural issues related to selection of army contractors. The case got to the Slovenian Constitutional court, which decided that the damage done by Martian occupation is incomparable to that done by violating the laws regulating the spending of public finances. The contract was annulled. The army kindly asked us to continue the project based on the code already provided by the company. It seems that all the company has actually finished are a few unit tests.


It would seem that we need to provide three functions.

  • preberi(ime_datoteke) gets a name of a file produced by Mrs. Kozjanc and, as we can conclude from the tests, return a dictionary whose keys are coordinates of our ships and values a lists of tuples, representing the coordinates of Martian ships. The name of the file is arbitrary.

  • vrstica(i, ladja, marsovec) returns a single line of instructions for CCCSSF. Tests seem to suggest the the first argument is either a number or None. If it's a number, it's printed out, followed by coordinates of our ship and coordinates of the Martian ship. If i is None, it is not printed, and the coordinates of our ship are ignored as well; only the coordinates of the Martian ship are printed, preceded by the corresponding number of spaces. Therefore, call vrstica(7, (4.25, 8.50), (5, 12.3)) returns

       7:     4.2500     8.5000 ->     5.0000    12.3000
    

    and call vrstica(None, (4.25, 8.50), (5, 12.3)) would return

                                       5.0000    12.3000
    

    The format must be deciphered from the text. Good luck.

  • navodila(razpored, ime_datoteke) gets a dictionary in the form returned by the first function and a name of the file into which is must write the instructions that are exactly, down to the last space, as required by CCCSSF.

Unlike the previous homework, this one fortunately only deals with two dimensions.

Testi

Poberi obe datoteki in ju daj v isti direktorij.