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 2, 2021 21:07Yuriy LyfenkoYuriy LyfenkoScore: 5,841Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 2, 2021 21:075,82493,689,15461,059,0003,002,0002,260,992
2May 2, 2021 21:095,82588,637,06263,072,0001,001,0002,387,968
3May 2, 2021 21:095,82690,391,17962,084,0002,002,0002,523,136
4May 2, 2021 21:095,82986,325,60063,121,0001,001,0002,510,848
5May 2, 2021 21:035,83091,885,27463,132,0001,002,0002,523,136
6May 2, 2021 21:095,83189,584,74663,140,0001,002,0002,396,160
7May 2, 2021 21:095,83391,728,42762,157,0002,005,0002,519,040
8May 2, 2021 21:035,83388,410,09361,156,0003,007,0002,523,136
9May 2, 2021 21:035,83391,467,00462,154,0002,004,0002,383,872
10May 2, 2021 21:035,83890,430,48762,211,0002,006,0002,260,992
11May 2, 2021 21:095,84085,528,62663,241,0001,003,0002,383,872
12May 2, 2021 21:035,84186,355,74662,246,0002,007,0002,396,160
13May 2, 2021 21:035,84185,762,26563,247,0001,003,0002,260,992
14May 2, 2021 21:075,84190,672,83562,239,0002,007,0002,392,064
15May 2, 2021 21:075,84189,419,35163,245,0001,003,0002,392,064
16May 2, 2021 21:035,84392,539,94863,266,0001,004,0002,383,872
17May 2, 2021 21:075,84694,162,60963,301,0001,004,0002,265,088
18May 2, 2021 21:075,85087,109,43463,344,0001,005,0002,387,968
19May 2, 2021 21:095,85084,264,57463,342,0001,005,0002,396,160
20May 2, 2021 21:075,85196,449,40464,362,00002,396,160
21May 2, 2021 21:035,85186,432,24663,352,0001,005,0002,506,752
22May 2, 2021 21:035,85286,733,62863,365,0001,005,0002,392,064
23May 2, 2021 21:095,85591,872,15563,396,0001,006,0002,260,992
24May 2, 2021 21:075,85988,029,67863,446,0001,007,0002,392,064
25May 2, 2021 21:075,85986,690,37463,444,0001,007,0002,260,992
26May 2, 2021 21:095,86287,261,41462,467,0002,015,0002,269,184
27May 2, 2021 21:075,86490,925,92263,499,0001,007,0002,387,968