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:02Joad NacerJoad NacerScore: 7,935Success
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:024,837122,346,89053,203,02402,269,184
2Apr 19, 2024 00:024,837122,527,25753,205,10002,265,088
3Apr 19, 2024 00:024,841111,195,28253,252,11602,273,280
4Apr 19, 2024 00:027,923111,595,99085,152,0002,003,0002,523,136
5Apr 19, 2024 00:027,928113,659,03685,202,0002,004,0002,289,664
6Apr 19, 2024 00:027,932110,090,26785,249,0002,005,0002,531,328
7Apr 19, 2024 00:027,935112,290,08885,276,0002,006,0002,273,280
8Apr 19, 2024 00:027,936110,327,79885,292,0002,006,0002,289,664
9Apr 19, 2024 00:027,940114,059,37285,334,0002,007,0002,289,664
10Apr 19, 2024 00:027,955108,933,98087,510,00002,273,280
11Apr 19, 2024 00:027,961109,424,49786,562,0001,006,0002,289,664
12Apr 19, 2024 00:027,962117,909,35586,577,0001,006,0002,289,664