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 12, 2024 23:28Joad NacerJoad NacerScore: 7,261Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 12, 2024 23:284,726114,544,21851,982,92202,269,184
2May 12, 2024 23:284,747127,355,84852,221,36002,273,280
3May 12, 2024 23:284,754111,938,01452,299,10202,277,376
4May 12, 2024 23:287,257110,107,15378,829,000997,0002,265,088
5May 12, 2024 23:287,257107,941,07777,834,0001,995,0002,289,664
6May 12, 2024 23:287,258110,709,73477,843,0001,995,0002,289,664
7May 12, 2024 23:287,261102,503,03978,868,000998,0002,269,184
8May 12, 2024 23:287,263103,351,45577,898,0001,997,0002,289,664
9May 12, 2024 23:287,277102,588,29878,046,0002,001,0002,289,664
10May 12, 2024 23:287,284101,176,57578,120,0002,003,0002,367,488
11May 12, 2024 23:287,295102,818,55978,235,0002,006,0002,523,136
12May 12, 2024 23:287,300108,039,00778,288,0002,007,0002,273,280