UPDATE: Announcements for members .
UPDATE 2: Intermediate results and announcements .
Hola Company Announces Programming Contest Again! Winners will receive prizes:
- First place: 3000 USD.
- Second place: 2000 USD.
- Third place: 1000 USD.
- The jury may award at its discretion a special prize of 400 USD.
- If you send someone a link to this contest, putting our address in CC, and this person will take the prize, you will receive half of the prize amount (of course, not to the detriment of the winner’s reward). For one winner, only one person can receive such an award - the one who sent the link first.
Authors of interesting decisions will be invited for interviews.

rules
Competition terms in English are posted
on GitHub . Below is a translation into Russian.
- Submit solutions using this form . No decision is made by email.
- Decisions are made until July 20, 2018 , 23:59:59 UTC.
- Preliminary results will be published on July 27, 2018 , and the final announcement of winners - August 3, 2018 .
- You can send solutions repeatedly, but each participant will only consider the most recent decision sent before the deadline for accepting work.
- For testing, we will use Node.js v10.4.1 (the current version at the time of publication). You can use any language features supported by the interpreter in the standard configuration.
- All solution code should be in a single JS file .
- The solution should be on JS. If you prefer CoffeeScript or similar languages, you need to broadcast the solution to JS before sending it.
- If your JS file is a product of generation, minification and / or compilation from other languages like CoffeeScript, please attach the archive with the sources, and also, preferably, with a description of the approach. The contents of this archive will be published, but we will not test it.
- You can not load any modules , even those that come standard with Node.js.
- One participant can use only one email address to send a solution. Sending a set of solutions that are in "collusion" from different addresses is prohibited; all decisions involved in such a scheme will be disqualified.
- We need to know your full name, but if you want, we will publish a pseudonym instead. We will keep your email address confidential.
- The current and former Hola employees and their closest relatives can take part only out of the competition, without claiming for prizes.
- Ask questions about the problem statement in the comments to this publication or by e-mail .
Trade
Suppose we have a book, two hats and three balls. You and another member must decide how to divide this good between the two of you. For you, the book has a value of $ 4, each ball is $ 2, and hats have no value. For a partner, the same objects may have a different value, but you know that all the objects together are as valuable to him as they are to you - in this case it is $ 10.
You and your partner in turn offer options for the section of items. In turn, one of you can either accept the previous offer (unless it is the very first turn), or make a counter offer. Negotiations are limited to 5 rounds, in total, both participants can put forward up to 10 proposals. If an agreement is reached during this time, then each of you will receive the total value of the items going to him (each in accordance with their own coefficients of value). If an agreement is not reached, that is, the last word in the last round - a counter offer, not an agreement - then no one gets anything. The same happens if one of the partners interrupts the negotiations.
Here is an example of how negotiations can take place:
- You: I want a book and two balls; you get one ball and both hats.
- Partner: I do not agree. I want all the balls and one hat; You will get a book and one hat.
- You: I do not agree. I want a book and one ball; you will get two balls and both hats.
- Partner: I agree.
You did not know this, but for the partner the value of the items was as follows: $ 2 per ball, $ 2 per hat, the book has no value. The agreement brought you $ 6 to you and $ 8 to your partner.
In general, there are two or more object types and a positive integer number of objects of each type. The value of each type of object for each of the partners is a nonnegative integer. The total value of all objects for both partners is the same, although the values of individual objects differ. The section proposal should distribute all objects without partners to the partners; individual objects are not crushed.
Your task is to write a script seeking to make a deal with the highest possible value (for yourself).
Solutions
The solution is a Node.js module without dependencies. The export module must be a class:
module.exports = class {
constructor(me, counts, values, max_rounds, log){
..
}
offer(o){
...
}
}
. :
me
— 0, , 1, .counts
— , . 2 10 .values
— , counts
, .max_rounds
— ( ).log
— , (console.log
).
offer
, .
o
— ,
counts
. , . , ,
o
undefined
.
offer
undefined
, ( ,
o
undefined
). ,
counts
, , . ,
o
,
offer
.
1 . , , , , .
, , .
example.js , . , ; , .
log
.
haggle.js -, .
--help
, . ( ,
npm install
src
.)
, . , , , , , , . . , «» «», , .
: 3 , 6 , $10, 5 . , , .
c3.large (. ) Amazon AWS Ubuntu 14.04 (amd64). .
, ; (
). , , , (
--log
).
, . -: «», .
(3 , 6 , $10, 5 ). 1 , . :
wss://hola.org/challenges/haggling/arena/standard
haggle.js
, - .
--id
: , .
.
. «» ,
.
— . , . - , .
, , -, , UNIX shell:
while true; do node haggle.js --id me@example.com:1234abcd myscript.js wss://hola.org/challenges/haggling/arena/standard; done
. !
, , . , ; , ; CoffeeScript , , . README (-). tar.gz, tar.bz2 zip. , ( JS-, ).
JS- 64 . , , - «» . 64 , , .
, , ,
.
!