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 8, 2021 20:12Yuriy LyfenkoYuriy LyfenkoScore: 5,573Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 8, 2021 20:145,55784,763,63959,123,0002,004,0002,396,160
2May 8, 2021 20:125,55987,252,51060,152,0001,002,0002,387,968
3May 8, 2021 20:145,56387,116,26059,182,0002,006,0002,400,256
4May 8, 2021 20:145,56685,947,38860,222,0001,003,0002,392,064
5May 8, 2021 20:145,56786,870,88459,233,0002,007,0002,392,064
6May 8, 2021 20:145,57089,857,90960,266,0001,004,0002,392,064
7May 8, 2021 20:125,57188,938,30160,275,0001,004,0002,387,968
8May 8, 2021 20:125,57284,737,02660,292,0001,004,0002,392,064
9May 8, 2021 20:145,57386,605,35461,304,00002,396,160
10May 8, 2021 20:125,57384,314,48360,296,0001,004,0002,527,232
11May 8, 2021 20:145,57585,840,06860,318,0001,005,0002,265,088
12May 8, 2021 20:125,57584,924,28060,325,0001,005,0002,387,968
13May 8, 2021 20:125,57686,069,72661,338,00002,392,064
14May 8, 2021 20:145,58194,271,84461,393,00002,523,136
15May 8, 2021 20:125,58189,028,15861,393,00002,260,992
16May 8, 2021 20:125,58286,162,93161,403,00002,387,968
17May 8, 2021 20:125,58482,355,59158,399,0003,020,0002,387,968
18May 8, 2021 20:145,58784,677,08360,448,0001,007,0002,392,064