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 16:46Yurkov AlekseyYurkov AlekseyScore: 7,499Success
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 16:467,474108,421,59280,206,0002,005,0002,527,232
2May 2, 2021 16:477,474104,284,54581,211,0001,002,0002,277,376
3May 2, 2021 16:487,476109,663,80480,232,0002,005,0002,281,472
4May 2, 2021 16:487,483105,174,20782,309,00002,273,280
5May 2, 2021 16:477,485107,171,80981,327,0001,004,0002,277,376
6May 2, 2021 16:497,486113,719,50380,336,0002,008,0002,277,376
7May 2, 2021 16:497,487103,251,71382,357,00002,277,376
8May 2, 2021 16:477,492102,018,38781,408,0001,005,0002,383,872
9May 2, 2021 16:487,493110,136,56381,420,0001,005,0002,519,040
10May 2, 2021 16:497,494109,674,77181,427,0001,005,0002,277,376
11May 2, 2021 16:467,495106,060,23181,437,0001,005,0002,531,328
12May 2, 2021 16:467,495104,616,33581,440,0001,005,0002,379,776
13May 2, 2021 16:497,495107,119,24681,436,0001,005,0002,531,328
14May 2, 2021 16:487,497104,341,64081,462,0001,005,0002,277,376
15May 2, 2021 16:467,497103,785,11780,454,0002,011,0002,531,328
16May 2, 2021 16:477,498104,764,30381,477,0001,005,0002,277,376
17May 2, 2021 16:487,499103,734,30881,486,0001,006,0002,277,376
18May 2, 2021 16:487,499110,420,68381,487,0001,006,0002,277,376
19May 2, 2021 16:497,499105,523,37781,483,0001,005,0002,277,376
20May 2, 2021 16:477,501114,613,08082,516,00002,269,184
21May 2, 2021 16:497,504103,095,50980,531,0002,013,0002,277,376
22May 2, 2021 16:487,504104,153,50981,535,0001,006,0002,519,040
23May 2, 2021 16:467,505106,304,19082,557,00002,277,376
24May 2, 2021 16:497,506108,660,94181,565,0001,006,0002,265,088
25May 2, 2021 16:477,507109,715,75579,554,0003,021,0002,277,376
26May 2, 2021 16:467,508105,338,61481,579,0001,007,0002,269,184
27May 2, 2021 16:497,510113,198,08681,601,0001,007,0002,277,376
28May 2, 2021 16:497,513115,742,01080,625,0002,015,0002,273,280
29May 2, 2021 16:467,515109,884,69681,662,0001,008,0002,277,376
30May 2, 2021 16:477,517113,124,32181,684,0001,008,0002,277,376
31May 2, 2021 16:487,518108,993,64381,695,0001,008,0002,527,232
32May 2, 2021 16:477,531117,599,00081,848,000998,0002,277,376
33May 2, 2021 16:477,531111,307,84381,845,000998,0002,277,376
34May 2, 2021 16:467,531112,152,70180,848,0001,996,0002,277,376
35May 2, 2021 16:487,533109,435,81581,862,000998,0002,277,376
36May 2, 2021 16:467,533109,215,23880,863,0001,996,0002,523,136