Parse JSON Sergey Svistunov

Compute the total amount of non-canceled external USD transactions from a stream of JSON records as fast as possible.

Input: 1 000 000 JSON records on STDIN, one per line. Each record has the following structure:

{
    "user_id": 0,
    "currency": "USD",
    "transactions": [
        {
            "amount": 0,
            "to_user_id": 0,
            "canceled": false
        }
    ]
}
Field Constraints
user_id Integer, max 10 000
currency One of "GBP", "USD", "RUB", "JPY", "CHF"
transactions Array, max 10 elements
amount Integer, max 1000
canceled Boolean; may be omitted when false

Field order is not guaranteed within any object.

Output: The total amount of all transactions where:

  • record.currency == "USD"
  • transaction.to_user_id != record.user_id (external)
  • transaction.canceled is false or absent
Back to listNov 10, 2021 18:38Sergey StreminSergey StreminScore: 5,715Success
Source Code

Source code access is restricted. Log in to request access.

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 10, 2021 18:395,69593,576,32061,634,0001,010,0002,293,760
2Nov 10, 2021 18:385,69790,533,98561,662,0001,010,0002,363,392
3Nov 10, 2021 18:385,69891,754,51561,667,0001,010,0002,293,760
4Nov 10, 2021 18:395,70987,131,01161,804,000996,0002,359,296
5Nov 10, 2021 18:385,71291,560,99260,842,0001,994,0002,293,760
6Nov 10, 2021 18:395,71289,331,98460,833,0001,994,0002,293,760
7Nov 10, 2021 18:395,71291,175,85061,838,000997,0002,293,760
8Nov 10, 2021 18:395,71391,207,18960,852,0001,995,0002,293,760
9Nov 10, 2021 18:385,71395,141,30460,852,0001,995,0002,293,760
10Nov 10, 2021 18:395,71488,584,14260,861,0001,995,0002,363,392
11Nov 10, 2021 18:395,71493,352,91561,852,000997,0002,293,760
12Nov 10, 2021 18:385,71490,994,20060,858,0001,995,0002,363,392
13Nov 10, 2021 18:395,71587,189,39860,871,0001,995,0002,293,760
14Nov 10, 2021 18:385,71593,362,28361,863,000997,0002,293,760
15Nov 10, 2021 18:385,71587,699,37061,865,000997,0002,293,760
16Nov 10, 2021 18:385,71797,193,14661,894,000998,0002,293,760
17Nov 10, 2021 18:385,72189,684,56460,929,0001,997,0002,355,200
18Nov 10, 2021 18:395,72188,950,54760,934,0001,997,0002,355,200
19Nov 10, 2021 18:385,730130,315,57463,033,46702,191,360
20Nov 10, 2021 18:455,733143,739,61463,063,38002,187,264
21Nov 10, 2021 18:395,735132,238,45463,085,57702,191,360
22Nov 10, 2021 18:395,740135,648,72163,139,26602,191,360
23Nov 10, 2021 18:455,741126,932,64063,155,03102,314,240
24Nov 10, 2021 18:455,746134,460,19363,209,30402,195,456
25Nov 10, 2021 18:385,746134,902,83563,201,36002,191,360
26Nov 10, 2021 18:395,747126,401,37663,214,52202,199,552
27Nov 10, 2021 18:385,755116,713,64663,307,97302,195,456