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 17:47Andrey TsvetkovAndrey TsvetkovScore: 12,225Success
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 17:4712,164161,680,72498,857,00034,949,0002,334,720
2May 2, 2021 17:4212,168165,130,379100,885,00032,962,0002,334,720
3May 2, 2021 17:4712,192161,155,177110,092,00024,020,0002,318,336
4May 2, 2021 17:4712,195156,464,396107,116,00027,029,0002,334,720
5May 2, 2021 17:4212,195156,973,408103,115,00031,034,0002,334,720
6May 2, 2021 17:4212,197155,659,329103,131,00031,039,0002,334,720
7May 2, 2021 17:4212,210156,664,88199,229,00035,081,0002,433,024
8May 2, 2021 17:4212,221159,515,518101,324,00033,105,0002,318,336
9May 2, 2021 17:4212,222155,870,492105,349,00029,096,0002,457,600
10May 2, 2021 17:4712,225155,057,491106,378,00028,099,0002,334,720
11May 2, 2021 17:4212,225159,607,61595,337,00039,138,0002,334,720
12May 2, 2021 17:4712,227157,520,408112,414,00022,081,0002,334,720
13May 2, 2021 17:4712,240161,979,395107,511,00027,128,0002,392,064
14May 2, 2021 17:4712,243162,097,122102,509,00032,159,0002,330,624
15May 2, 2021 17:4712,252164,124,970104,819,00029,948,0002,334,720
16May 2, 2021 17:4212,303159,028,412101,246,00034,082,0002,322,432
17May 2, 2021 17:4712,354171,122,625109,912,00025,979,0002,334,720
18May 2, 2021 17:4212,439167,570,955108,868,00027,966,0002,334,720