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:42Sergey StreminSergey StreminScore: 5,737Success
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:435,71587,305,12960,875,0001,995,0002,367,488
2Nov 10, 2021 18:425,71888,755,14360,903,0001,996,0002,367,488
3Nov 10, 2021 18:435,72390,696,21460,959,0001,998,0002,293,760
4Nov 10, 2021 18:425,72792,805,17261,001,0002,000,0002,371,584
5Nov 10, 2021 18:435,72892,001,06162,012,0001,000,0002,293,760
6Nov 10, 2021 18:425,72886,625,75262,012,0001,000,0002,293,760
7Nov 10, 2021 18:435,72890,834,52461,010,0002,000,0002,367,488
8Nov 10, 2021 18:425,73091,938,13861,031,0002,001,0002,359,296
9Nov 10, 2021 18:435,73293,147,74362,048,0001,000,0002,367,488
10Nov 10, 2021 18:425,73388,903,04463,067,00002,293,760
11Nov 10, 2021 18:435,73587,553,14661,084,0002,002,0002,355,200
12Nov 10, 2021 18:435,73688,424,30062,099,0001,001,0002,367,488
13Nov 10, 2021 18:435,73788,954,17061,105,0002,003,0002,293,760
14Nov 10, 2021 18:435,73887,343,02161,110,0002,003,0002,293,760
15Nov 10, 2021 18:425,74291,638,57261,161,0002,005,0002,359,296
16Nov 10, 2021 18:425,74392,034,88661,173,0002,005,0002,293,760
17Nov 10, 2021 18:425,74989,228,17961,232,0002,007,0002,363,392
18Nov 10, 2021 18:425,75691,874,33463,320,00002,469,888
19Nov 10, 2021 18:435,780126,795,72463,584,50302,195,456
20Nov 10, 2021 18:425,789116,947,16963,681,05602,187,264
21Nov 10, 2021 18:435,792134,422,21863,714,34702,195,456
22Nov 10, 2021 18:435,799126,172,08263,794,22802,314,240
23Nov 10, 2021 18:425,809135,218,43663,902,41702,191,360
24Nov 10, 2021 18:425,815133,742,26063,965,26902,187,264