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 listApr 20, 2024 14:19Joad NacerJoad NacerScore: 7,397Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 20, 2024 14:194,883116,060,31753,715,70502,273,280
2Apr 20, 2024 14:224,884117,578,94453,722,04102,273,280
3Apr 20, 2024 14:224,890115,309,09653,794,45302,273,280
4Apr 20, 2024 14:194,892114,902,34953,807,82302,273,280
5Apr 20, 2024 14:194,894112,801,43853,839,05502,273,280
6Apr 20, 2024 14:224,903108,440,36353,937,18102,265,088
7Apr 20, 2024 14:227,376104,043,45279,137,0002,003,0002,289,664
8Apr 20, 2024 14:227,391102,475,72679,297,0002,007,0002,527,232
9Apr 20, 2024 14:227,391104,081,80381,304,00002,523,136
10Apr 20, 2024 14:197,393104,945,47379,312,0002,007,0002,277,376
11Apr 20, 2024 14:197,395110,364,93280,337,0001,004,0002,531,328
12Apr 20, 2024 14:197,396105,223,97081,359,00002,371,584
13Apr 20, 2024 14:227,397111,441,34980,358,0001,004,0002,289,664
14Apr 20, 2024 14:227,400109,373,92979,392,0002,009,0002,269,184
15Apr 20, 2024 14:227,401109,307,84180,409,0001,005,0002,289,664
16Apr 20, 2024 14:197,402106,817,74180,415,0001,005,0002,289,664
17Apr 20, 2024 14:197,406104,210,86979,452,0002,011,0002,289,664
18Apr 20, 2024 14:197,407111,285,55879,489,0001,987,0002,289,664
19Apr 20, 2024 14:227,412103,866,17780,529,0001,006,0002,289,664
20Apr 20, 2024 14:227,413105,423,03180,538,0001,006,0002,273,280
21Apr 20, 2024 14:197,414102,406,19280,546,0001,006,0002,273,280
22Apr 20, 2024 14:227,415112,111,59580,562,0001,007,0002,289,664
23Apr 20, 2024 14:197,418104,829,89680,586,0001,007,0002,269,184
24Apr 20, 2024 14:197,420110,206,52181,625,00002,523,136