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 15:54Yuriy LyfenkoYuriy LyfenkoScore: 8,732Success
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 15:548,716118,354,17994,883,000998,0002,334,720
2May 8, 2021 15:548,716125,996,58593,881,0001,997,0002,330,624
3May 8, 2021 15:548,721120,643,76994,930,000999,0002,527,232
4May 8, 2021 15:548,724123,092,62393,970,0001,999,0002,330,624
5May 8, 2021 15:548,724120,063,63392,966,0002,998,0002,334,720
6May 8, 2021 15:548,725121,596,40693,971,0001,999,0002,322,432
7May 8, 2021 15:548,730123,173,02293,029,0003,000,0002,531,328
8May 8, 2021 15:548,731121,521,52794,039,0002,000,0002,531,328
9May 8, 2021 15:548,731121,661,07995,046,0001,000,0002,334,720
10May 8, 2021 15:548,732124,070,15993,056,0003,001,0002,519,040
11May 8, 2021 15:548,733119,141,80294,067,0002,001,0002,330,624
12May 8, 2021 15:548,735123,366,85395,081,0001,000,0002,330,624
13May 8, 2021 15:548,736122,120,12394,099,0002,002,0002,330,624
14May 8, 2021 15:548,742117,523,46293,157,0003,005,0002,527,232
15May 8, 2021 15:548,743118,036,72193,168,0003,005,0002,330,624
16May 8, 2021 15:548,744115,349,48493,178,0003,005,0002,297,856
17May 8, 2021 15:548,744116,508,83793,180,0003,005,0002,523,136
18May 8, 2021 15:548,746117,451,70394,202,0002,004,0002,523,136