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 1, 2021 13:58Andrey TsvetkovAndrey TsvetkovScore: 12,075Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 1, 2021 13:5812,012157,323,964105,109,00027,028,0002,314,240
2May 1, 2021 13:5812,015157,372,793100,122,00032,039,0002,318,336
3May 1, 2021 13:5912,045156,840,533100,379,00032,121,0002,392,064
4May 1, 2021 13:5912,050155,081,43998,406,00034,141,0002,334,720
5May 1, 2021 13:5812,051159,214,813105,444,00027,114,0002,318,336
6May 1, 2021 13:5912,053161,983,483106,472,00026,115,0002,334,720
7May 1, 2021 13:5812,072162,583,27199,845,00032,948,0002,334,720
8May 1, 2021 13:5912,074161,236,474104,855,00027,961,0002,334,720
9May 1, 2021 13:5912,074159,384,46696,865,00035,949,0002,334,720
10May 1, 2021 13:5812,075159,852,02395,876,00036,952,0002,334,720
11May 1, 2021 13:5812,091158,769,11197,000,00036,000,0002,318,336
12May 1, 2021 13:5912,101154,159,89597,081,00036,030,0002,334,720
13May 1, 2021 13:5912,102161,346,32099,091,00034,031,0002,334,720
14May 1, 2021 13:5912,106160,077,867105,132,00028,035,0002,322,432
15May 1, 2021 13:5812,126153,871,528103,302,00030,088,0002,334,720
16May 1, 2021 13:5812,165156,220,077106,857,00026,963,0002,334,720
17May 1, 2021 13:5912,202158,564,855103,171,00031,051,0002,334,720
18May 1, 2021 13:5812,731168,651,495108,032,00032,009,0002,314,240