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 listDec 17, 2023 08:38Kenneth MaplesKenneth MaplesScore: 7,180Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Dec 17, 2023 08:387,145105,786,11678,598,00002,527,232
2Dec 17, 2023 08:387,149106,155,58377,631,0001,008,0002,392,064
3Dec 17, 2023 08:387,167104,875,06476,838,0001,995,0002,392,064
4Dec 17, 2023 08:387,167106,370,42777,843,000997,0002,387,968
5Dec 17, 2023 08:387,168109,188,53277,852,000998,0002,523,136
6Dec 17, 2023 08:387,175111,486,68876,931,0001,998,0002,265,088
7Dec 17, 2023 08:387,180111,516,88076,977,0001,999,0002,387,968
8Dec 17, 2023 08:387,183108,568,12277,009,0002,000,0002,387,968
9Dec 17, 2023 08:387,190104,634,65877,083,0002,002,0002,387,968
10Dec 17, 2023 08:387,275153,346,07880,028,76802,240,512
11Dec 17, 2023 08:387,344150,369,24280,783,65902,248,704
12Dec 17, 2023 08:387,428151,509,85481,706,70302,252,800