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 20:14Yuriy LyfenkoYuriy LyfenkoScore: 5,956Success
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 20:145,92093,646,33063,120,0002,003,0002,281,472
2May 2, 2021 20:145,93591,689,96165,281,00002,273,280
3May 2, 2021 20:145,93987,620,12063,315,0002,010,0002,281,472
4May 2, 2021 20:145,94190,023,14464,347,0001,005,0002,281,472
5May 2, 2021 20:145,94694,841,76465,402,00002,269,184
6May 2, 2021 20:145,95087,991,67064,447,0001,006,0002,269,184
7May 2, 2021 20:145,95288,646,86364,468,0001,007,0002,371,584
8May 2, 2021 20:145,95389,738,44364,475,0001,007,0002,269,184
9May 2, 2021 20:145,95487,112,58664,484,0001,007,0002,269,184
10May 2, 2021 20:145,95688,904,31465,517,00002,277,376
11May 2, 2021 20:145,95988,965,62064,536,0001,008,0002,281,472
12May 2, 2021 20:145,95989,986,00363,536,0002,017,0002,281,472
13May 2, 2021 20:145,96296,732,38664,573,0001,008,0002,527,232
14May 2, 2021 20:145,96288,199,55764,578,0001,009,0002,269,184
15May 2, 2021 20:145,96693,516,70764,621,0001,009,0002,281,472
16May 2, 2021 20:145,97391,348,72264,707,000995,0002,273,280
17May 2, 2021 20:145,99388,803,84764,921,000998,0002,269,184
18May 2, 2021 20:145,99390,152,71263,922,0001,997,0002,281,472