📜 ⬆️ ⬇️

JavaOpen and JavaDay in Samara



Recently, two entertaining events took place in Samara: JavaOpen and JavaDay .

The first was a programming tournament with cash prizes. The second is a conference at which tournament winners were announced.

')

The conference


Unfortunately, we managed to attend only the conference. The hall for 150 people was half full, taking into account the fact that the event fell on a working day. The reports were excellent. Especially pleased with the demonstration of Java FX and Java ME Embedded on the Raspberry Pi. And, of course, a robot with Java ME Embedded on board.



Conference materials are available here .

It should be noted that this is the first JavaDay in Samara. On the local TV channel even showed the corresponding plot . That fact is interesting that Microsoft TechDays pass already for a long time, but not so with that scope. Let's hope that IT events of this format will be a regular occurrence. A Java movement will gain momentum.

And finally, the most delicious - the tournament tasks, kindly provided by their creator - Pavel Vasin. The texts of the tasks left unchanged. Below are the answers.

Tournament


The task of the tournament was to identify not just candidates with knowledge of mathematics and skills in sports programming, but people who are closer to production. Therefore, the first task was academic: knowledge of the Java language, knowledge of good and especially bad practices in the industrial implementation of tasks, support, object-oriented programming and class design. The second task - a practical, on the result, time-consuming and without academic. How to do, so well. A hint system was developed for it. Here the task was that people themselves set the task and choose the tools for its solution. At the same time, they correctly estimated and distributed their time; if they could not cope or did not have time, they would take clues.

Exercise 1

Imagine that you perform code review in a very large company that develops software for the needs of the space industry. Requirements for reliability, speed, quality of the developed software are the highest.

Review the code presented on the printout, and in the table, the template of which is attached, indicate all the errors made in the code, inaccuracies, potential problems, etc. The more problems you find, the better. Each problem inherent in the code, the error has a certain "weight" in points. Your task is to score the maximum number of points in this test.

Problem code
01 public class EmployeeList extends LinkedList implements List { 02 //   03 public static final Float _baseHourSalary = new Float("36.60"); 04 public static final Float _high_hour_salary = _maxHourSalary / 4; 05 public static final int _maxHourSalary = _high_hour_salary > 50 ? 110 : 55; 06 public Log log = LogFactory.getLog(); 07 private float[] koefs; 08 09 public EmployeeList() { 10 LoadKoefficients(); 11 } 12 13 @Override 14 public boolean add(Object o) { 15 for (Object obj : this) { 16 if (!(obj instanceof Employee)) continue; 17 if (o.equals(obj)) return false; //  ,     18 if (((Employee)o).getFio() == "  " 19 || ((Employee)o).getFio() == "  ") { 20 //  3244,       21 return false; 22 } 23 } 24 return add(o); 25 } 26 27 public void LoadKoefficients() { 28 float[] arr1 = KoefStorage.getKoefArray("ifns_2003_god"); 29 log.debug("   " + arr1.toString()); 30 float[] arr2 = KoefStorage.getKoefArray("ufns_2003_god"); 31 koefs = new Float[2000]; 32 for (int i = 0; i < arr1.length; i++) koefs[i] = arr1[i]; 33 for (int i = 0; i < arr2.length; i++) koefs[i + arr1.length] = arr2[i]; 34 recalculateKoeffs(); //     35 } 36 37 public void recalculateKoeffs() { 38 for (int i = 0; i < koefs.length; i++) 39 koefs[i] = koefs[i] < 0.88 ? koefs[i] / 4 : koefs[i] / 6; 40 } 41 42 public ArrayList getSalaries(LinkedList<Employee> employee) { 43 ArrayList result = new ArrayList(5); 44 for (int i = 0; i < employee.size(); i++) { 45 Employee e = employee.get(i); 46 if (!this.contains(e)) { 47 //     .      48 return new ArrayList(0); 49 } 50 Employee found = (Employee) this.get(this.indexOf(e)); 51 result.add( 52 found.getFio() == "  " //  53 ? _maxHourSalary : _baseHourSalary); 54 } 55 return result; 56 } 57 58 public LinkedList getSortedView() { 59 DataCollectionsHelper.sortBubble(this, new Comparator() { 60 public int compare(Object o1, Object o2) { 61 if (o1 instanceof Employee && o2 instanceof Employee) { 62 return ((Employee)o1).getTableNumber() - ((Employee)o2).getTableNumber(); 63 } else return -1; 64 } 65 }); 66 return this; 67 } 68 } 



Task 2

In one of the stories of Conan Doyle, the great detective ran into a case that became a real test of his deductive method. The key to the investigation was the solution of a special ciphered language of the “dancing little men” with which the criminals kept their correspondence. In the course of the case, Sherlock Holmes, using his method, was able to calculate how many dancing little men are included in one word, and also identified those who met most often. Solving the meaning of the first word - “How do messages begin? Of course, with greetings, dear Watson! This is elementary! ”- the detective easily calculated all the rest. After that, he was able to participate in their correspondence and expose the gang.

We suggest you to repeat his actions, but with the help of modern technology.

You have:
1) Computer, Java, IDE
2) An uncomplicated encrypted excerpt of an artistic text in Russian
3) The novel "War and Peace" L.N. Tolstoy (if you have a lot of time after decryption, so that you have something to do, you can read a little)
4) A set of 3 tips (â„–1, â„–2, â„–3) that open in turn. Opening each hint reduces the number of points you can get. Only 50 points, opening each hint reduces this amount by 10 points.

Encrypted text
v + l9ooxrl9 3 + afzr2v + l5wxr12fzfb 3n45wa7l9d 5w3p 3e9p5v + 8bv + 5w 3qxm6r2qx3p 3xrn4a | ooos 3n45wa7l9d 5w3p 3xrn4a | ooos 3e9p5v + 8bv + 5w 3qxm6r2qx3p 3xrn4a | ooos 3n45wa7l9d 5w3p 3xrn4a | ooos 3e9p5v + 8bv + 5w 3qxm6r2qx 3fz 3d mlu | 5whc 3fz 3z9xr | c 3e9 3l9fz + ahc 3qhv + e9e9p5v + fhd 35wd fbmlu | 3n4qhxr 3fz5wosa7 3n4v + 125wxr12fzfbv + hc 3fz5wosa | 3n4v + 125wxr12fzfb 3qhxr yfz5we9a | 312 3oo7 | e9a | fbv + 312xre9u | + aose9xroo 312xre9u | + aos yu | e9a | oo 3ooqhu | ooosu | + a 3 | cxr yd 312 3p5xrl9e9oov + l9oofzl9xrn4xr5w –app) 3 + av + 5wu | l9osp5fz + a 3 + av + 5wosfbfzp5xr a | 9 | | | | | | 3 | | | | | | | | q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q o o o o o o o o o 3 z o o o o o o o 3mlp5xr5wd 3l9v + 3p5fzqhxrfbl9xr l 3d 5wfz9 + u | hc 3n4xrooxr + a 3xrl9 3e95wd fhfz5w 312 3p5v + p5xr + angooxr 3 + av + | cv + 8bfzlcfcff4fcfv4p4v + p5xr + angooxr 3 + av + | cv + 8bfzlcff4fdp4v + p5xr + angooxr 3 + av + | 3fbu || cxrngooxr 3 yu | 5wv + 5w3p 3v + 312 3l9v + fbv + 5wu | 3qhu | 12xr5wa79 + fzfz 3m6 + afz | cqhfzqhxr12v + 5w 38bv + 3 | cqhv + l9fz9 + d hc 3l9d 3fz 3z9xr | c 3e9 3l9fz + ahc 3a | 35wd fbmlu | 3qhv + e9e9p5v + fhd 3n4qhxr 3v + l9l9d 3fz cr9v + ooosu | 12l9d hc 3l9xr 3n4qhxr 3v + l9l9d 3fz | cl9v + ooosu | 12l9d 3qhv + e9e3fz | cl9v + ooosu | 12l9d 3qhv + e9e3fz | cl9v + ooosu | 12l9d 3qhv + e9e3fh | 3oov + p5ngooxr 3n4qhxre9ooxrhc 312xrngn4u | qh127 | r23p 3a | 3xr 3l9u | l 3n4xrfboofz 3l9fzfbu || cxr 3l9u | 38bl9v + a73p 3v + 312xrng12ooxrqh7 | r23p 3a | 3e9u | lfbv + e9 3d n4v + 5w 3e9xr 3e9ood 5wv + 3fz 38bv + z97 | 5w3p 3xr 3fbu | + a 3e9xrz9fzqhv + 5we9a | 3qhv + e9e9p5v + 8b7 | 12v + oooshc 3a | 35wd fbmlu | 3qhv + e9e9p5v + fhd 3xr 3e9u | z9u | hc 3a | 3127 | e9xrp5xr | cxr 3qhxre9oov + 3p 3l9u || c5wd n47 | l3p 3xr yu | 12v + a7e9os 3fz8ba | u9l9xr 3fz 3e9xr 312p5d e9xr + a3p 3l9u | 3n4osa73p 3l9v + 3e9p5v + fbp5fz 3l9u | 3r2xrfhd 3p 3l9xr 3p5 3 yv ++ av ++ a 3ooa | l9d e9oshc 3fz 3 yv ++ a7 | 3l9u | 3fz8bz9u || cv + a7oo 3 + au | l9a | hc 3 yv + fhu | 35wa7z9a | oo3p 3p5xr | c yv + 3a | 3e9 3l9fz + afz 3 | cd 5wa | a7hc 3e9u | qhv + c + fz + av + 3fz8b + av + l5wxr12l9v + 3l9u | xr yl9xrp5qhv + ool9xr 3n4qhfz | c5wv + mlv + 5wv + 3 + au | l9a | 3p5 3e9u | z9u | 3p 3fz 38bfzl9v + fz yv + 3a | p5xr125wu | 12l9v + 3ooxrfhu | 3 | cxr12xrqhfz5wv + 3p 3fbooxr 3xrl9v + 312e9u || c yv + 3qhv + yv + 3 + au | l9a | 312fz yu | oooshc 3l9xr 312xroo 3e9 3 + av + qhfzl9xr l 3n4u | ooqhxr12l9xr l 3e95wd fbv + l 38bv + z9v + 12l97 | l 3127 | mlu | 5w 3d 3 + au | l9a | 3p 3xr 3p5xrooxrqhxr + a 3a | 3fz 3r2xrfbd 3qhv + e9e9p5v + 8bv + oooshc 3e95wd fbv + l 312n4xr5wl9u | 3xrz97 | p5l9xr12u | l9l97 | l3p 3l9xr 312e9u | 3fhu | 38bv + z9v + 12l97 | l3p 3fzz9xr 3 + av + qhfzl9v + 3n4u | ooqhxr12l9v + 3z95wv + | cxr yv + qha | 3 + al9u | 3e9xr12u | qhmlu | l9l9xr 3xrz95w7 | e9u | 5wv + 3p 3p5v + p5 35wv + yxrl9oshc 3e95wd fbfz5wxre9os 3m6ooxr 3oov + p5 + w 3n4qhfzmlu | 5w 3a | 3xr yl9v + fh y7 | 3p5 3 + av + qhfzl9u | 3n4u | ooqhxr12l9u | 3p 3v + 3xrl9v + 3ooqhv + r2zj 3ng 3fz 3xrz95w7 | e9u | 5wv + hc 312xroo 3fz 312e9u | hc

Tip # 1
The encrypted text is a small story in Russian. There are no line breaks, only letters of the Russian alphabet (in one register), punctuation marks, spaces. The text is encrypted using the encryption method: when each source symbol replaces with one or a group of characters from a dictionary, the number of symbols in the group is the same for each encoded source symbol. Conan Doyle had such a dictionary men, in our case, the letters of the English alphabet, numbers, spaces, and some special characters.
It would seem that, without knowing the key for which the replacement was carried out, it is impossible to open this cipher ... But the problem is that in modern languages ​​(including Russian) different letters meet with different frequencies, some often, some rarely. Therefore, such ciphers are amenable to so-called. "Frequency analysis." With a sufficiently large amount of text, the frequency will almost unambiguously determine the coded letter. But since we have a small snippet encrypted, then there are some “distortions” in it, and for letters with similar frequencies, there will be uncertainty. Well what can you do? Again I remembered Sherlock - to substitute, try and try to solve some characteristic letter combinations or words, fix some "solved" letters and try again. Each unraveled word will greatly bring you closer to unraveling the entire text. And remember, the more conveniently you make the tool for such an analysis for yourself, the faster you will open the cipher.

Tip number 2
You do not have a table of frequencies of Russian letters? And what do you Tolstoy? Large text will give you a very accurate calculation of the frequency of use of letters in Russian. Just do not forget to pre-process the text and normalize the resulting frequencies.
It will also help a lot if you determine the most frequent symbol in the Russian text - the space and its frequency.
We have agreed that in the cipher table each character of the source text can be encrypted with a group of characters? How to know its size? Here you can advise several ways: to analyze the frequency of occurrence of groups of characters in the encrypted text by a simple search, starting with 1. For the correct amount of frequency will be "special". You can try to find the most frequently-occurring group of characters - it will be a space and it will restrict you to words. Well, by the average word length, finding out the number of letters in a cipher group is easy (thanks again to Tolstoy).

Tip number 3
The encrypted text begins with the words "ANTON MIKHAILOVICH"


Answers

If the tasks could not be solved or there is simply a desire to verify the results, then you can use the answers:
Answer to task 1
Initially, a special table was created to evaluate this task, but then the task changed a little and the table became not entirely relevant. In addition, a number of points depends on the programming style and design in a particular team. Those. share of subjectivity takes place.

In short:
For simple errors, such as looping detection, declaring static variables, comparing strings to ==, endless recursions, etc. 1 point was given.
For hiding errors and performance, like integer division, where there should be a floating division, or not using Arrays.copy was given 2-3 points
For complex time bombs, errors in design class 5 points.

If expanded (the same table):
Error in the codeField of knowledgePoints
Class extends LinkedList already write implements List optionalStyleone
Constants are not named by convention (HIGH_HOUR_SALARY should be something like this)Styleone
Cyclical dependency when declaring a constantSurfaceone
Float type constants are unreasonable, float must beSurfaceone
The constructor new float ("36.60") is terrible.Surfaceone
Calculating _maxHourSalary / 4 will not give the expected result (due to integer division), you must explicitly cast the _maxHourSalary type to floatHidden bug3
The name of the method LoadKoefficients is not by agreement (loadKoefficients must be)Styleone
If we inherit the list, then there should be generics (generics), without them an anachronismStyle2
The constructor uses a public method; this is dangerous in the case of inheritance.Hidden bug3
The LoadKoefficients and recalculateKoeffs methods are meaningless to make public, as they are obviously only needed for the internal logic of the method. Their publication violates encapsulation.OOP3
Judging by the add method, we have an error in the design of the class - this is not a list at all, but a lot (it is checked for re-entry).Class designfive
The class behaves incomprehensibly as when adding NOT EmployeeHidden bug3
Comparing lines for equality (must be equals)Surfaceone
The o.getFio () == check is performed inside the loop (nothing prevents to check the outside)Surfaceone
The practice of such a bug fix 3244 itself is flawed, thus never fixing bugsClass design3
There are many ways to add an item to the list, but only add is redefined. So the logic given in the overdetermined method will not always work, which is even worse than the most erroneous logic.Hidden bug3
Return add (o) causes endless recursion. Must be super.add (o)Surfaceone
"Ifns_2003_god" - must be a constantStyle2
In the debug log, I wanted to transfer the entire array listing, and not an unnecessary pointer. Instead of arr1.toString (), it was necessary to use Arrays.deepToStringLogical error2
Listing the entire array is a long time, it is better to first check whether the debug mode is enabled at allPerformance3
The Float [] array does not give us anything other than permanent boxing / anboxing. Must be float []Surfaceone
Copying arrays needs to be done using Arrays.copyPerformance3
Why an array of precisely 2000 elements? And what if the loaded will be more or less?Logical error2
A bunch of magic numbers in recalculateKoeffsStyle2
The logic in the data processing class is too tightly wired, these parts of logic usually change a lot, so you cannot write classes (logic is wired in recalculateKoeffs, .getFio () ==)Class designfive
What caused the love for LinkedList and inheritance from him? What are the prerequisites for this class? None!Class designfive
What is generally due to inheritance? Here it does not correspond to the class task at all (it was necessary to use composition, and not inheritance)OOPfive
There is no programming to the interface (there are a lot of links to specific implementations of ArrayList, LinkedList, which should have been avoided)OOP2
new ArrayList (5) - and why exactly 5? magic numberStyle2
Passing through the list with a for i = 0 loop and subsequent get is unproductive (especially for LinkedList). Must use for eachPerformance3
Returning an empty ArrayList (0) list, correctly using the EMPTY_LIST constant or the emptyList method in Collections (for a bunch of reasons)Hidden error, Performance3
In general, the logic of returning an empty list if one of the elements of the input list is not found inside is extremely dubious and clumsy.Class design3
Undocumented public methods. How to guess what these methods do?Style2
This getting an item from the list is terrible this.get (this.indexOf (e))Surfaceone
Why sortBubble and not Collections.sort?Surfaceone
An anonymous comparator is created each time a method is called. One could write it in a class field, and even better in a static field.Performance3
If the items being compared are not Employee, then less is given. This is an example of what class behavior is not clear (not to mention the breach of the comparator contract)Logical error3
The difference comparator has a hidden error in it (for too large or small numbers)Hidden bug3
Returning a certain external View to your list by sorting your list is an extremely clumsy class design (not to mention the fact that it breaks encapsulation)Class designfour
TOTAL95


Answer to task 2
ANTON MICHAILOVICH PLUNUN, SAID “EH”, AGAIN SPLOAN, AGAIN SAID “EC”, AGAIN SPLOLL, AGAIN SAID “EC” AND GONE. And GOD IS WITH HIM. I WILL TELL BETTER ABOUT ILYA PAVLOVICH. ILYA PAVLOVICH WAS BORN AT A THOUSAND EIGHT EIGHT EIGHT YEARS IN CONSTANTINOPOL. ANOTHER LITTLE BOY HAS BEEN TRANSFERRED TO ST. PETERSBURG, AND HERE HE HAS FINISHED A GERMAN SCHOOL IN A CHIEF STREET. THEN HE WORKED AT ANY SHOP, THEN DO ANYTHING, AND IN THE BEGINNING OF THE REVOLUTION EMIGRATED OVER THE BORDER. Well, God be with him. I BETTER TELL ANNOUS ABOUT IGNATIVE. BUT ABOUT ANNA IGNITION TO TELL NOT SO JUST. FIRST, I ABOUT HER ALMOST I DON'T KNOW ANYTHING, AND SECOND, I NOW FELL FROM THE CHAIR AND FORGOTTEN TO COULD HAVE COLLECTED TO TELL. I will tell you better about myself. I AM A HIGH-GROWTH, BADLY DOWN, I DRESS UP GRANDLY AND WITH TASTE, DON'T DRINK, I DON'T LIKE THE DOWNLOADS, BUT I DUMMY DAMAGED. AND LADIES DO NOT AVOID ME. EVEN LOVE WHEN I HAM WITH THEM. SERAPHIM IZMAYLOVNA REQUESTS INVITED ME TO ITSELF, AND ZINAIDA YAKOVLEEV ALSO SAID THAT IT IS ALWAYS RADY TO SEE ME. BUT HERE WITH THE MARINE PETROLEVAL CASE FUNNY HAS STILL AT ME WHICH I WANT TO TELL. THE CASE IS FULLY ORDINARY, BUT ALSO FUN, FOR MARINA PETROVNA THANKS TO ME COMPLETELY FALSE, LIKE PALM. IT HAPPENED IT SO: I HAVE COME ONCE TO MARINA PETROVNE, AND IT'S FUCKING! - and baldness. THAT'S ALL.



PS Apparently, if JUG was in Samara, it has not been functioning for a long time. Can anyone suggest this?

Source: https://habr.com/ru/post/184996/


All Articles