Dear algorithm architect,
Directories are sorted already from biggest to smallest:
[
{"SIZE":"23574708","DIR":"/"},
{"SIZE":"6702576","DIR":"/backup"},
{"SIZE":"6583344","DIR":"/usr"},
{"SIZE":"5576524","DIR":"/var"},
{"SIZE":"4885968","DIR":"/var/lib"},
{"SIZE":"4524956","DIR":"/var/lib/docker"},
{"SIZE":"4506592","DIR":"/var/lib/docker/overlay2"},
{"SIZE":"4450984","DIR":"/backup/postgres/2020"},
{"SIZE":"4450984","DIR":"/backup/postgres"},
{"SIZE":"3124856","DIR":"/usr/share"},
{"SIZE":"2933876","DIR":"/backup/postgres/2020/10"},
{"SIZE":"1517108","DIR":"/backup/postgres/2020/11"},
{"SIZE":"1459688","DIR":"/backup/mysql/zabbix"},
{"SIZE":"1459688","DIR":"/backup/mysql"},
{"SIZE":"1269132","DIR":"/usr/lib"},
{"SIZE":"1053312","DIR":"/root"},
{"SIZE":"973236","DIR":"/root/zabbix-source"},
{"SIZE":"887136","DIR":"/backup/mysql/zabbix/raw"},
{"SIZE":"851540","DIR":"/root/zabbix-source/.git"},
{"SIZE":"850992","DIR":"/root/zabbix-source/.git/objects/pack"},
{"SIZE":"850992","DIR":"/root/zabbix-source/.git/objects"},
{"SIZE":"791904","DIR":"/backup/filesystem/2020"},
{"SIZE":"791904","DIR":"/backup/filesystem"},
{"SIZE":"772344","DIR":"/usr/bin"},
{"SIZE":"572552","DIR":"/backup/mysql/zabbix/2020"},
{"SIZE":"534732","DIR":"/backup/filesystem/2020/10"},
{"SIZE":"479956","DIR":"/usr/local"},
{"SIZE":"467752","DIR":"/usr/lib64"},
{"SIZE":"462980","DIR":"/usr/lib/firmware"},
{"SIZE":"436656","DIR":"/var/cache"}
]
The task is to optimize the JSON array by deleting a few lines based on conditions:
1) If there is 2 consequental rows having the same size like:
{"SIZE":"791904","DIR":"/backup/filesystem/2020"},
{"SIZE":"791904","DIR":"/backup/filesystem"},
and second path (/backup/filesystem) is already included in first (/backup/filesystem/2020),
then delete the second row (/backup/filesystem).
Because the first directory shows more precise information.
2) If there is 2 consequntal rows:
{"SIZE":"4524956","DIR":"/var/lib/docker"},
{"SIZE":"4506592","DIR":"/var/lib/docker/overlay2"},
and first path (/var/lib/docker) is already included in next row (/var/lib/docker/overlay2)
and the size difference is less than 20480,
then delete the first row (/var/lib/docker).
Because the second directory shows more precise information.
P.S. I will choose a freelancer after 16h from the time when the project was published.
Please include some keywords coming from the project text so I feel there is a real person behind curtains.
Looking forward to hearing from you,
Aigars