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 listAug 5, 2022 22:02Eugene ZhydzetskiEugene ZhydzetskiScore: 16,686Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 5, 2022 22:0216,663204,793,172181,295,0002,003,0002,334,720
2Aug 5, 2022 22:0116,664244,562,986183,302,92302,203,648
3Aug 5, 2022 22:0216,668249,600,883183,348,11702,207,744
4Aug 5, 2022 22:0116,668206,840,204183,347,00002,334,720
5Aug 5, 2022 22:0116,671205,730,916182,375,0001,002,0002,531,328
6Aug 5, 2022 22:0116,671209,396,293182,374,0001,002,0002,334,720
7Aug 5, 2022 22:0216,673204,311,614182,401,0001,002,0002,334,720
8Aug 5, 2022 22:0116,674205,643,155181,408,0002,004,0002,363,392
9Aug 5, 2022 22:0116,681204,780,311183,487,00002,334,720
10Aug 5, 2022 22:0216,683244,209,023183,515,95502,211,840
11Aug 5, 2022 22:0116,684209,261,764182,527,0001,002,0002,334,720
12Aug 5, 2022 22:0216,685209,049,989182,534,0001,002,0002,535,424
13Aug 5, 2022 22:0116,686210,303,127183,542,00002,531,328
14Aug 5, 2022 22:0216,688221,461,202182,570,0001,003,0002,334,720
15Aug 5, 2022 22:0116,690257,881,188183,590,91802,207,744
16Aug 5, 2022 22:0116,694208,796,249182,633,0001,003,0002,281,472
17Aug 5, 2022 22:0216,695208,367,854182,641,0001,003,0002,334,720
18Aug 5, 2022 22:0116,697214,628,100180,668,0002,994,0002,334,720
19Aug 5, 2022 22:0216,698213,056,036183,678,00002,334,720
20Aug 5, 2022 22:0116,699248,914,515183,690,75602,207,744
21Aug 5, 2022 22:0216,703251,735,431183,729,67202,199,552
22Aug 5, 2022 22:0216,713211,392,184183,848,00002,281,472
23Aug 5, 2022 22:0216,714213,137,787181,858,0001,998,0002,535,424
24Aug 5, 2022 22:0216,740207,028,116181,141,0003,002,0002,330,624