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 listMay 2, 2021 19:05Yuriy LyfenkoYuriy LyfenkoScore: 6,093Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 2, 2021 19:055,93687,629,00662,285,0003,013,0002,277,376
2May 2, 2021 19:055,95287,814,81463,454,0002,014,0002,281,472
3May 2, 2021 19:055,95990,725,08164,545,0001,008,0002,281,472
4May 2, 2021 19:055,96193,326,26663,553,0002,017,0002,273,280
5May 2, 2021 19:055,97091,550,98364,658,0001,010,0002,281,472
6May 2, 2021 19:055,97490,513,87364,701,0001,010,0002,269,184
7May 2, 2021 19:055,98796,264,07563,860,0001,995,0002,527,232
8May 2, 2021 19:055,98790,523,50364,858,000997,0002,367,488
9May 2, 2021 19:055,98791,484,16063,865,0001,995,0002,281,472
10May 2, 2021 19:056,09388,272,34765,028,0002,000,0002,269,184
11May 2, 2021 19:056,09592,340,53266,041,0001,000,0002,269,184
12May 2, 2021 19:056,10594,656,71365,153,0002,004,0002,281,472
13May 2, 2021 19:056,10791,551,74165,172,0002,005,0002,273,280
14May 2, 2021 19:056,10792,773,47565,172,0002,005,0002,269,184
15May 2, 2021 19:056,11792,322,87365,280,0002,008,0002,269,184
16May 2, 2021 19:056,11988,908,68065,296,0002,009,0002,273,280
17May 2, 2021 19:056,12090,160,64765,308,0002,009,0002,523,136
18May 2, 2021 19:056,12696,881,69767,383,00002,269,184