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 05:09Yuriy LyfenkoYuriy LyfenkoScore: 12,095Success
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 05:0912,074155,880,294131,817,000998,0002,392,064
2May 2, 2021 05:0912,075161,672,790132,828,00002,387,968
3May 2, 2021 05:0912,075157,331,842131,824,000998,0002,392,064
4May 2, 2021 05:2712,076157,545,972131,840,000998,0002,510,848
5May 2, 2021 05:2812,076157,141,635130,838,0001,997,0002,383,872
6May 2, 2021 05:2812,081161,037,525130,890,0001,998,0002,396,160
7May 2, 2021 05:2812,083161,626,228130,919,0001,998,0002,260,992
8May 2, 2021 05:0912,088157,273,639129,965,0002,999,0002,260,992
9May 2, 2021 05:2712,090157,151,184131,990,000999,0002,392,064
10May 2, 2021 05:2812,093156,763,952130,028,0003,000,0002,396,160
11May 2, 2021 05:2712,093163,860,109132,019,0001,000,0002,383,872
12May 2, 2021 05:2812,094163,952,290130,038,0003,000,0002,396,160
13May 2, 2021 05:2712,094161,157,483131,029,0002,000,0002,392,064
14May 2, 2021 05:2712,095159,374,019132,042,0001,000,0002,387,968
15May 2, 2021 05:2712,098161,745,253131,073,0002,001,0002,392,064
16May 2, 2021 05:2812,099158,473,967130,084,0003,001,0002,387,968
17May 2, 2021 05:0912,100162,437,863131,097,0002,001,0002,260,992
18May 2, 2021 05:2812,101162,805,497132,113,0001,000,0002,260,992
19May 2, 2021 05:0912,110160,218,528132,214,0001,001,0002,260,992
20May 2, 2021 05:0912,111159,681,636132,215,0001,001,0002,387,968
21May 2, 2021 05:0912,115160,113,182132,264,0001,002,0002,392,064
22May 2, 2021 05:2812,116155,496,725132,278,0001,002,0002,523,136
23May 2, 2021 05:2712,122158,303,787132,338,0001,002,0002,260,992
24May 2, 2021 05:2712,122159,133,175132,338,0001,002,0002,387,968
25May 2, 2021 05:2812,126154,646,449132,380,0001,002,0002,387,968
26May 2, 2021 05:0912,128158,919,703133,406,00002,400,256
27May 2, 2021 05:2713,570173,729,798148,268,0001,001,0002,404,352