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 19, 2024 00:17Joad NacerJoad NacerScore: 7,814Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 19, 2024 00:374,747116,889,11752,218,43802,256,896
2Apr 19, 2024 00:174,752109,495,81152,270,71202,260,992
3Apr 19, 2024 00:174,752112,396,31052,272,88902,265,088
4Apr 19, 2024 00:174,752107,779,33552,268,20002,269,184
5Apr 19, 2024 00:374,754113,399,22752,295,79402,273,280
6Apr 19, 2024 00:374,772117,392,31652,493,27002,256,896
7Apr 19, 2024 00:177,803114,636,91683,839,0001,996,0002,523,136
8Apr 19, 2024 00:177,807110,873,51984,874,000998,0002,523,136
9Apr 19, 2024 00:377,812108,899,91183,934,0001,998,0002,269,184
10Apr 19, 2024 00:177,813113,110,84883,946,0001,998,0002,289,664
11Apr 19, 2024 00:177,814109,795,14383,952,0001,998,0002,289,664
12Apr 19, 2024 00:377,814113,982,16384,953,000999,0002,289,664
13Apr 19, 2024 00:377,814108,842,95583,953,0001,998,0002,519,040
14Apr 19, 2024 00:377,817112,322,01583,993,0001,999,0002,289,664
15Apr 19, 2024 00:377,818107,180,77684,000,0002,000,0002,531,328
16Apr 19, 2024 00:177,820107,665,80684,020,0002,000,0002,273,280
17Apr 19, 2024 00:177,820114,710,75684,016,0002,000,0002,289,664
18Apr 19, 2024 00:377,824109,724,35384,061,0002,001,0002,265,088
19Apr 19, 2024 00:377,828108,846,39485,102,0001,001,0002,392,064
20Apr 19, 2024 00:377,830105,422,75484,123,0002,002,0002,371,584
21Apr 19, 2024 00:177,830111,034,57184,125,0002,002,0002,269,184
22Apr 19, 2024 00:177,830110,322,87585,132,0001,001,0002,277,376
23Apr 19, 2024 00:377,831107,544,28285,145,0001,001,0002,289,664
24Apr 19, 2024 00:177,838109,846,05885,214,0001,002,0002,273,280