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 11, 2021 14:32Sergey StreminSergey StreminScore: 8,828Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 11, 2021 14:328,788128,100,29565,455,00031,217,0002,281,472
2May 11, 2021 14:328,803122,383,22064,886,00031,944,0002,289,664
3May 11, 2021 14:328,808125,463,40062,929,00033,962,0002,371,584
4May 11, 2021 14:328,811121,945,38167,941,00028,975,0002,379,776
5May 11, 2021 14:328,811125,952,19565,945,00030,974,0002,379,776
6May 11, 2021 14:328,819121,850,87966,004,00031,001,0002,289,664
7May 11, 2021 14:328,821120,171,20266,024,00031,011,0002,289,664
8May 11, 2021 14:328,823118,528,23364,033,00033,017,0002,375,680
9May 11, 2021 14:328,824120,872,78270,050,00027,019,0002,379,776
10May 11, 2021 14:328,828123,395,26067,073,00030,032,0002,289,664
11May 11, 2021 14:328,838124,726,64762,140,00035,079,0002,371,584
12May 11, 2021 14:328,843118,392,91870,200,00027,077,0002,289,664
13May 11, 2021 14:328,861124,664,19665,318,00032,157,0002,375,680
14May 11, 2021 14:328,872123,716,44066,402,00031,188,0002,289,664
15May 11, 2021 14:328,883121,190,77367,490,00030,219,0002,371,584
16May 11, 2021 14:328,895123,593,10465,896,00031,949,0002,289,664
17May 11, 2021 14:328,910132,450,27065,007,00033,004,0002,375,680
18May 11, 2021 14:328,921121,063,15264,086,00034,046,0002,289,664