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 22, 2021 16:30Yuriy LyfenkoYuriy LyfenkoScore: 8,183Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 22, 2021 16:308,166156,837,36789,829,67302,301,952
2May 22, 2021 17:058,170156,985,79189,868,97902,191,360
3May 22, 2021 16:308,171118,945,81186,885,0002,996,0002,334,720
4May 22, 2021 17:058,173155,621,55689,904,42502,191,360
5May 22, 2021 16:308,175116,265,16886,923,0002,997,0002,334,720
6May 22, 2021 17:058,175119,538,87287,929,0001,998,0002,334,720
7May 22, 2021 17:058,175123,750,71186,933,0002,997,0002,334,720
8May 22, 2021 17:058,176121,931,18287,936,0001,998,0002,535,424
9May 22, 2021 16:308,177150,708,59689,947,56302,187,264
10May 22, 2021 17:058,178116,526,20286,965,0002,998,0002,531,328
11May 22, 2021 16:308,178112,788,84086,961,0002,998,0002,334,720
12May 22, 2021 17:058,182121,277,52488,000,0002,000,0002,531,328
13May 22, 2021 16:308,183112,380,51987,010,0003,000,0002,531,328
14May 22, 2021 17:058,184116,194,21288,029,0002,000,0002,527,232
15May 22, 2021 16:308,184119,648,96188,025,0002,000,0002,334,720
16May 22, 2021 16:308,184141,240,66790,024,20902,191,360
17May 22, 2021 17:058,185140,586,53490,035,97802,191,360
18May 22, 2021 17:058,191115,067,80987,097,0003,003,0002,531,328
19May 22, 2021 16:308,192115,534,20088,110,0002,002,0002,531,328
20May 22, 2021 16:308,197115,071,06187,166,0003,005,0002,334,720
21May 22, 2021 17:058,198114,869,21688,173,0002,003,0002,531,328
22May 22, 2021 16:308,198116,669,51687,173,0003,005,0002,535,424
23May 22, 2021 17:058,200111,733,73088,196,0002,004,0002,531,328
24May 22, 2021 16:308,201114,256,12588,207,0002,004,0002,334,720