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 19, 2021 19:08Yuriy LyfenkoYuriy LyfenkoScore: 5,618Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 19, 2021 19:085,591874,869,15259,522,0001,984,0002,392,064
2May 19, 2021 19:085,5945,014,289,39160,544,000992,0002,260,992
3May 19, 2021 19:085,602163,520,32360,607,0001,010,0002,527,232
4May 19, 2021 19:085,6032,544,062,08360,643,000994,0002,523,136
5May 19, 2021 19:085,6161,247,811,79159,788,0001,992,0002,269,184
6May 19, 2021 19:085,6174,631,142,42359,799,0001,993,0002,260,992
7May 19, 2021 19:085,618530,877,70159,800,0001,993,0002,400,256
8May 19, 2021 19:085,6235,002,904,38358,857,0002,992,0002,260,992
9May 19, 2021 19:085,6235,043,987,18159,854,0001,995,0002,527,232
10May 19, 2021 19:085,8872,676,364,66264,760,87802,244,608
11May 19, 2021 19:085,8921,120,156,23264,808,39902,248,704
12May 19, 2021 19:085,8983,302,339,44764,873,96602,248,704