Day 7

Author

Julia Romanowska

Data

List of commands and output from terminal, used to determine the size of files in each directory.

input_file <- here("DATA", "2022", "input_day_07.txt")
scan(
  input_file,
  what = "character",
  sep = "\n",
  nmax = 10
) %>% cat(sep = "\n")
$ cd /
$ ls
dir gqlg
dir hchrwstr
dir lswlpt
189381 mzsnhlf
dir plmdrbn
dir rjwmjd
dir stqq
93174 zfn

I will construct a structure to hold all the information:

  • all the directories will be held in one list,
  • each directory is a list, holding:
    • pointer to the parent directory,
    • pointers to children-directories,
    • list of files

Functions

I will need several small functions:

  • cd / - this is starting from top; this is used only once in the input, so I can ignore this line

  • cd .. - go up in the list-levels

go_up <- function(cur_level){
  cur_level <<- all_dirs[[cur_level$level_up]]
}
  • cd xxx - go down in the list-levels, to the list named xxx
go_down <- function(cur_level, new_level){
  cur_level <<- all_dirs[[new_level]]
}
  • ls - list everything, read all the lines until next one that starts with $ and do one of the following actions:

    • dir xxx - create a list named xxx
create_level <- function(cur_level, new_name){
  # new level needs to contain list of files within this dir., and reference
  #  to the level up
  new_list <- list(
    list(
      files = list(),
      level_up = cur_level$name,
      name = paste0(cur_level$name, "/", new_name),
      children = c()
    )
  )
  names(new_list) <- paste0(cur_level$name, "/", new_name)
  
  # update children
  all_dirs[[cur_level$name]]$children <- c(
    all_dirs[[cur_level$name]]$children, new_name
  )
  # append new list
  all_dirs <<- c(
    all_dirs,
    new_list
  )
}
- `123 xxx` - add element to the 'files' list in the current list, with
`123` as the value (size of the file)
create_element <- function(cur_level, new_el, new_name){
  new_list <- list(as.numeric(new_el))
  names(new_list) <- new_name
  cur_level_name <- cur_level$name
  
  all_dirs[[cur_level_name]]$files <<- c(
    all_dirs[[cur_level_name]]$files, new_list
  )
  # update the pointer
  cur_level <<- all_dirs[[cur_level_name]]
}

Test

I will test it on the example input.

(exmpl_input <- scan(
  here("DATA", "2022", "small_input_day_07.txt"),
  what = "character",
  sep = "\n"
)) %>% cat(sep = "\n")
$ cd /
$ ls
dir a
14848514 b.txt
8504156 c.dat
dir d
$ cd a
$ ls
dir e
29116 f
2557 g
62596 h.lst
$ cd e
$ ls
dir z
584 i
$ cd z
$ ls
$ cd ..
$ cd ..
$ cd ..
$ cd d
$ ls
4060174 j
8033020 d.log
5626152 d.ext
7214296 k
exmpl_input <- exmpl_input[-1]

new_list <- list(
  list(
    files = list(),
    level_up = NULL,
    name = "start",
    children = c()
  )
)
names(new_list) <- "start"
all_dirs <- new_list
cur_level <- all_dirs$start
for(cur_line in exmpl_input){
  cur_line_elements <- str_split(cur_line, pattern = " ") %>% unlist()
  if(cur_line_elements[1] == "$"){
    # check whether it's 'ls' or 'cd'
    if(cur_line_elements[2] == "cd"){
      # go level up or down
      if(cur_line_elements[3] == ".."){
        cat("go up\n")
        go_up(cur_level)
        next
      }
      cat("go down to", paste0(cur_level$name, "/", cur_line_elements[3]), "\n")
      go_down(cur_level, paste0(cur_level$name, "/", cur_line_elements[3]))
      next
    }
    next
  } else {
    if(cur_line_elements[1] == "dir"){
      cat("create level: ", cur_line_elements[2], "\n")
      create_level(cur_level, cur_line_elements[2])
      next
    }
    # this means that it's the size of the file in this directory
    cat("create element: ", cur_line_elements[1:2], "\n")
    create_element(cur_level, cur_line_elements[1], cur_line_elements[2])
  }
}
create level:  a 
create element:  14848514 b.txt 
create element:  8504156 c.dat 
create level:  d 
go down to start/a 
create level:  e 
create element:  29116 f 
create element:  2557 g 
create element:  62596 h.lst 
go down to start/a/e 
create level:  z 
create element:  584 i 
go down to start/a/e/z 
go up
go up
go up
go down to start/d 
create element:  4060174 j 
create element:  8033020 d.log 
create element:  5626152 d.ext 
create element:  7214296 k 

The directory structure looks like this:

str(all_dirs)
List of 5
 $ start      :List of 4
  ..$ files   :List of 2
  .. ..$ b.txt: num 14848514
  .. ..$ c.dat: num 8504156
  ..$ level_up: NULL
  ..$ name    : chr "start"
  ..$ children: chr [1:2] "a" "d"
 $ start/a    :List of 4
  ..$ files   :List of 3
  .. ..$ f    : num 29116
  .. ..$ g    : num 2557
  .. ..$ h.lst: num 62596
  ..$ level_up: chr "start"
  ..$ name    : chr "start/a"
  ..$ children: chr "e"
 $ start/d    :List of 4
  ..$ files   :List of 4
  .. ..$ j    : num 4060174
  .. ..$ d.log: num 8033020
  .. ..$ d.ext: num 5626152
  .. ..$ k    : num 7214296
  ..$ level_up: chr "start"
  ..$ name    : chr "start/d"
  ..$ children: NULL
 $ start/a/e  :List of 4
  ..$ files   :List of 1
  .. ..$ i: num 584
  ..$ level_up: chr "start/a"
  ..$ name    : chr "start/a/e"
  ..$ children: chr "z"
 $ start/a/e/z:List of 4
  ..$ files   : list()
  ..$ level_up: chr "start/a/e"
  ..$ name    : chr "start/a/e/z"
  ..$ children: NULL

And the total size of the elements in each directory:

#' @param cur_dir - path to the directory
get_sum_size_dir <- function(cur_dir){
  cur_sum <- 0
  cur_children <- all_dirs[[cur_dir]]$children
  if(length(cur_children) != 0){
    cur_sum <- map_dbl(
      paste0(cur_dir, "/", cur_children),
      get_sum_size_dir
    ) %>% sum()
  }
  
  cur_files <- all_dirs[[cur_dir]]$files
  if(length(cur_files) != 0){
    cur_sum <- cur_sum + sum(unlist(cur_files))
  }
  return(cur_sum)
}

all_sizes <- map_dbl(all_dirs, function(cur_dir){
  get_sum_size_dir(cur_dir$name)
})
all_sizes
      start     start/a     start/d   start/a/e start/a/e/z 
   48381165       94853    24933642         584           0 

We want to get the directories with size of at most:

max_dir_size <- 100000

So, in the example input, the directories that have size of at most 10^{5} are print(names(all_sizes)[all_sizes < max_dir_size])! 🥳

Real run

(exmpl_input <- scan(
  here("DATA", "2022", "input_day_07.txt"),
  what = "character",
  sep = "\n"
)) %>% head(20) %>% cat(sep = "\n")
$ cd /
$ ls
dir gqlg
dir hchrwstr
dir lswlpt
189381 mzsnhlf
dir plmdrbn
dir rjwmjd
dir stqq
93174 zfn
dir zjhqnlrr
dir zssdlnc
$ cd gqlg
$ ls
187654 cfrdsjf
100589 ntvmgbw
46922 zcmfcjhf.tzw
$ cd ..
$ cd hchrwstr
$ ls
exmpl_input <- exmpl_input[-1]

new_list <- list(
  list(
    files = list(),
    level_up = NULL,
    name = "start",
    children = c()
  )
)
names(new_list) <- "start"
all_dirs <- new_list
cur_level <- all_dirs$start
for(cur_line in exmpl_input){
  cur_line_elements <- str_split(cur_line, pattern = " ") %>% unlist()
  if(cur_line_elements[1] == "$"){
    # check whether it's 'ls' or 'cd'
    if(cur_line_elements[2] == "cd"){
      # go level up or down
      if(cur_line_elements[3] == ".."){
        cat("go up\n")
        go_up(cur_level)
        next
      }
      cat("go down to", paste0(cur_level$name, "/", cur_line_elements[3]), "\n")
      go_down(cur_level, paste0(cur_level$name, "/", cur_line_elements[3]))
      next
    }
    next
  } else {
    if(cur_line_elements[1] == "dir"){
      cat("create level: ", cur_line_elements[2], "\n")
      create_level(cur_level, cur_line_elements[2])
      next
    }
    # this means that it's the size of the file in this directory
    cat("create element: ", cur_line_elements[1:2], "\n")
    create_element(cur_level, cur_line_elements[1], cur_line_elements[2])
  }
}
create level:  gqlg 
create level:  hchrwstr 
create level:  lswlpt 
create element:  189381 mzsnhlf 
create level:  plmdrbn 
create level:  rjwmjd 
create level:  stqq 
create element:  93174 zfn 
create level:  zjhqnlrr 
create level:  zssdlnc 
go down to start/gqlg 
create element:  187654 cfrdsjf 
create element:  100589 ntvmgbw 
create element:  46922 zcmfcjhf.tzw 
go up
go down to start/hchrwstr 
create element:  227766 cljjlcp.pjh 
create element:  102770 rdbrcf.pjl 
create element:  9887 rfnjn.lqn 
create level:  rzsrp 
create level:  shlhgj 
create level:  slwwgc 
go down to start/hchrwstr/rzsrp 
create level:  rzsrp 
go down to start/hchrwstr/rzsrp/rzsrp 
create level:  dvzvmsjz 
create element:  208001 tnflwcsn 
create level:  zfn 
go down to start/hchrwstr/rzsrp/rzsrp/dvzvmsjz 
create element:  149823 hvgbhm.zsc 
go up
go down to start/hchrwstr/rzsrp/rzsrp/zfn 
create element:  292424 gqlg.tzc 
go up
go up
go up
go down to start/hchrwstr/shlhgj 
create element:  61753 fzpzwjdt.jvl 
create element:  195204 jjhc.tzr 
create element:  288094 zcmfcjhf.tzw 
go up
go down to start/hchrwstr/slwwgc 
create element:  118185 jjhc.tzr 
create element:  291916 jwnw.wqv 
create element:  116377 ptlz 
create element:  300849 pzjpw.hwg 
create element:  28679 zfn.grz 
go up
go up
go down to start/lswlpt 
create element:  124160 dbnlt.rqz 
create element:  154412 sfd 
go up
go down to start/plmdrbn 
create level:  fmzjhrq 
create element:  224144 rlc.qns 
create element:  2985 zcmfcjhf.tzw 
go down to start/plmdrbn/fmzjhrq 
create element:  9749 lqj.szc 
create level:  rrjjsvm 
go down to start/plmdrbn/fmzjhrq/rrjjsvm 
create element:  66652 zcmfcjhf.tzw 
go up
go up
go up
go down to start/rjwmjd 
create level:  twcrf 
create element:  125294 zpfws.ctc 
create level:  zwmmrqj 
go down to start/rjwmjd/twcrf 
create element:  229364 tnflwcsn 
create element:  262716 zcmfcjhf.tzw 
go up
go down to start/rjwmjd/zwmmrqj 
create element:  11466 gqlg.ftg 
create element:  220272 lflcgss.jrm 
create element:  79574 tnflwcsn 
go up
go up
go down to start/stqq 
create element:  185160 cwjqldbf.cnm 
create element:  266439 dpg.pwn 
create level:  hpgbcvtb 
create element:  139357 jvps 
create level:  llbthqc 
create element:  250148 mctn.dqw 
create level:  rzsrp 
create element:  22196 tnflwcsn 
create level:  whmdbn 
go down to start/stqq/hpgbcvtb 
create element:  231579 fvjjtd.wdb 
create element:  168118 gjdtscqs 
create element:  113434 ldbqbg 
create level:  mqjfvg 
create element:  182214 nnnr 
create element:  112389 pqqdt.wnn 
go down to start/stqq/hpgbcvtb/mqjfvg 
create element:  170328 gqlg.jjc 
go up
go up
go down to start/stqq/llbthqc 
create element:  25611 bftwd.qrr 
create element:  91550 tnflwcsn 
go up
go down to start/stqq/rzsrp 
create element:  272315 wrsfh.pzd 
create element:  123877 zcmfcjhf.tzw 
go up
go down to start/stqq/whmdbn 
create element:  29628 jjhc.tzr 
create element:  65193 mrhb 
go up
go up
go down to start/zjhqnlrr 
create level:  bzzvj 
create level:  ddzmvh 
create level:  dsjd 
create element:  180806 fqz.dch 
create level:  nnzvl 
create element:  109161 rptmqt 
create element:  6463 rzsrp.sjf 
create element:  111549 rzsrp.wwz 
create element:  241532 zfn 
go down to start/zjhqnlrr/bzzvj 
create element:  278759 gqlg.nsn 
create element:  174223 mvggzqrq 
create element:  156518 tnflwcsn 
create level:  wjtlg 
create level:  zfn 
go down to start/zjhqnlrr/bzzvj/wjtlg 
create element:  52198 fvqbtm.tch 
create element:  44881 tnflwcsn 
go up
go down to start/zjhqnlrr/bzzvj/zfn 
create element:  22926 tnflwcsn 
go up
go up
go down to start/zjhqnlrr/ddzmvh 
create level:  cpvfln 
create element:  180764 gqlg.bjq 
create level:  hgrnmh 
create element:  186254 hgrnmh.tpr 
create level:  hjpgf 
create level:  mghmb 
create level:  pvdwhmcr 
create element:  256578 rzsrp 
create element:  269955 shlhgj 
create element:  172163 vrr.nnm 
go down to start/zjhqnlrr/ddzmvh/cpvfln 
create element:  87025 hgrnmh.lvr 
create element:  187453 rwmq.dph 
create level:  sthhc 
go down to start/zjhqnlrr/ddzmvh/cpvfln/sthhc 
create element:  289580 fdzwmfnf 
create element:  57504 hgrnmh.vqj 
create element:  277639 mzcfchr.mch 
create level:  slsj 
create level:  vsvvprg 
create element:  94836 zqglfrl 
go down to start/zjhqnlrr/ddzmvh/cpvfln/sthhc/slsj 
create element:  178013 hdjgtqt 
go up
go down to start/zjhqnlrr/ddzmvh/cpvfln/sthhc/vsvvprg 
create element:  102783 fvqbtm.tch 
go up
go up
go up
go down to start/zjhqnlrr/ddzmvh/hgrnmh 
create level:  mrnmbbt 
create element:  240216 rzsrp.nfg 
go down to start/zjhqnlrr/ddzmvh/hgrnmh/mrnmbbt 
create element:  245579 gqlg 
go up
go up
go down to start/zjhqnlrr/ddzmvh/hjpgf 
create element:  257544 cjfd.wdq 
create element:  296077 jjhc.tzr 
create element:  195752 zcmfcjhf.tzw 
go up
go down to start/zjhqnlrr/ddzmvh/mghmb 
create level:  bgrcsdc 
create level:  btjq 
create level:  gqlg 
create level:  gtwdqw 
create level:  hgrnmh 
create level:  jts 
create level:  jvp 
create level:  jvrjcv 
create element:  206272 pgf.rgj 
create element:  130746 tnflwcsn 
create element:  256698 zfn.dhl 
go down to start/zjhqnlrr/ddzmvh/mghmb/bgrcsdc 
create element:  235762 lflcgss.jrm 
go up
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq 
create level:  bvrcqb 
create level:  drslln 
create level:  dwzpblb 
create level:  gqlg 
create level:  hgrnmh 
create level:  hvb 
create level:  rqtc 
create level:  vsdz 
create level:  wrnftqh 
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/bvrcqb 
create element:  51508 gjjg.msw 
create level:  gqlg 
create element:  13206 pdwn 
create element:  10427 vbw 
create element:  6909 zfn.ztq 
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/bvrcqb/gqlg 
create element:  20816 cmgcvlh.mzs 
create element:  10358 fvqbtm.tch 
create element:  215142 rzsrp.dns 
create element:  192153 wdjdppzm 
go up
go up
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/drslln 
create element:  258102 tnflwcsn 
go up
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/dwzpblb 
create element:  302466 fvqbtm.tch 
go up
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/gqlg 
create level:  hnr 
create level:  mdzdht 
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/gqlg/hnr 
create level:  fjd 
create element:  159298 fvqbtm.tch 
create element:  46324 gchdll.nrm 
create element:  287907 lflcgss.jrm 
create level:  mqp 
create element:  140272 twdff 
create element:  47399 zfn 
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/gqlg/hnr/fjd 
create element:  227109 fvqbtm.tch 
create element:  223413 wdsfwwwm.rmd 
go up
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/gqlg/hnr/mqp 
create level:  rzsrp 
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/gqlg/hnr/mqp/rzsrp 
create level:  pgwng 
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/gqlg/hnr/mqp/rzsrp/pgwng 
create element:  218271 hgrnmh.gnf 
go up
go up
go up
go up
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/gqlg/mdzdht 
create level:  gqlg 
create level:  tvd 
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/gqlg/mdzdht/gqlg 
create level:  gfjqbdp 
create element:  108335 jjhc.tzr 
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/gqlg/mdzdht/gqlg/gfjqbdp 
create element:  143536 fzvn.jtv 
go up
go up
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/gqlg/mdzdht/tvd 
create element:  238491 wsjmrlqv.bwb 
go up
go up
go up
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/hgrnmh 
create element:  265289 lflcgss.jrm 
create element:  111283 thb 
go up
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/hvb 
create level:  hgrnmh 
create level:  smmwg 
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/hvb/hgrnmh 
create level:  wpvssts 
create element:  84939 zcmfcjhf.tzw 
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/hvb/hgrnmh/wpvssts 
create element:  305634 whcmr 
go up
go up
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/hvb/smmwg 
create element:  36722 cvdbwg.rll 
create element:  16840 nnhbcbwz 
create level:  rzsrp 
create element:  9405 zfn.jzr 
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/hvb/smmwg/rzsrp 
create level:  fzsngr 
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/hvb/smmwg/rzsrp/fzsngr 
create element:  142687 zcmfcjhf.tzw 
go up
go up
go up
go up
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/rqtc 
create level:  pbzhfsg 
create level:  rzsrp 
create level:  shlhgj 
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/rqtc/pbzhfsg 
create element:  41865 hpshz.sdf 
go up
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/rqtc/rzsrp 
create level:  gqlg 
create level:  mbsjjzft 
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/rqtc/rzsrp/gqlg 
create level:  gqlg 
create level:  nvjqp 
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/rqtc/rzsrp/gqlg/gqlg 
create element:  21860 tnflwcsn 
go up
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/rqtc/rzsrp/gqlg/nvjqp 
create level:  gcq 
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/rqtc/rzsrp/gqlg/nvjqp/gcq 
create level:  mslhm 
create level:  rzsrp 
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/rqtc/rzsrp/gqlg/nvjqp/gcq/mslhm 
create element:  41304 rpgvllw.zfj 
go up
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/rqtc/rzsrp/gqlg/nvjqp/gcq/rzsrp 
create element:  290199 ddsnt 
go up
go up
go up
go up
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/rqtc/rzsrp/mbsjjzft 
create element:  47727 ggpmg.pps 
create level:  stgszvmj 
create element:  275954 tnflwcsn 
create element:  248613 vbgnwh.sjz 
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/rqtc/rzsrp/mbsjjzft/stgszvmj 
create level:  dthcrbmr 
create level:  shlhgj 
create element:  206580 zcmfcjhf.tzw 
create level:  zfn 
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/rqtc/rzsrp/mbsjjzft/stgszvmj/dthcrbmr 
create level:  lhp 
create level:  npf 
create level:  qbgrjr 
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/rqtc/rzsrp/mbsjjzft/stgszvmj/dthcrbmr/lhp 
create element:  37925 hgrnmh.lvm 
go up
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/rqtc/rzsrp/mbsjjzft/stgszvmj/dthcrbmr/npf 
create element:  77162 bqvd 
go up
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/rqtc/rzsrp/mbsjjzft/stgszvmj/dthcrbmr/qbgrjr 
create element:  48767 fvqbtm.tch 
go up
go up
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/rqtc/rzsrp/mbsjjzft/stgszvmj/shlhgj 
create level:  wtlngn 
create element:  35422 zfn 
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/rqtc/rzsrp/mbsjjzft/stgszvmj/shlhgj/wtlngn 
create level:  gqlg 
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/rqtc/rzsrp/mbsjjzft/stgszvmj/shlhgj/wtlngn/gqlg 
create element:  64761 fwtqw 
go up
go up
go up
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/rqtc/rzsrp/mbsjjzft/stgszvmj/zfn 
create element:  47247 dmlr.flv 
create element:  259570 htvn.rbz 
create element:  149238 qrdw 
go up
go up
go up
go up
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/rqtc/shlhgj 
create level:  cjmv 
create level:  tns 
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/rqtc/shlhgj/cjmv 
create element:  140919 jjhc.tzr 
go up
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/rqtc/shlhgj/tns 
create element:  248127 fvqbtm.tch 
create element:  216202 pwg 
create level:  qhhtgsvz 
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/rqtc/shlhgj/tns/qhhtgsvz 
create element:  68979 fvqbtm.tch 
go up
go up
go up
go up
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/vsdz 
create element:  224491 hgrnmh 
create level:  jsrqjjtc 
create level:  shlhgj 
create element:  123062 zfn.gss 
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/vsdz/jsrqjjtc 
create element:  245991 phc 
go up
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/vsdz/shlhgj 
create element:  284208 ctwmwlp.lnm 
create element:  11067 vwsrmlf.dvz 
go up
go up
go down to start/zjhqnlrr/ddzmvh/mghmb/btjq/wrnftqh 
create element:  237658 lldrh 
create element:  14804 nszc.wdf 
go up
go up
go down to start/zjhqnlrr/ddzmvh/mghmb/gqlg 
create element:  211474 jjhc.tzr 
go up
go down to start/zjhqnlrr/ddzmvh/mghmb/gtwdqw 
create element:  92613 fvqbtm.tch 
create element:  206813 ppzhmnb.grd 
go up
go down to start/zjhqnlrr/ddzmvh/mghmb/hgrnmh 
create element:  249351 bftm 
go up
go down to start/zjhqnlrr/ddzmvh/mghmb/jts 
create element:  132190 gqlg.vnn 
create element:  208091 ldnq 
create element:  202593 zcmfcjhf.tzw 
go up
go down to start/zjhqnlrr/ddzmvh/mghmb/jvp 
create element:  258220 lflcgss.jrm 
go up
go down to start/zjhqnlrr/ddzmvh/mghmb/jvrjcv 
create element:  20148 dzzlwp.bdj 
create element:  289774 hgrnmh.bvc 
create element:  296981 jwscd.cvj 
create element:  16617 tbnwvcl.tlv 
go up
go up
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr 
create level:  bhmmsbmb 
create level:  bjwbvcq 
create level:  hgrnmh 
create level:  ltvtrtth 
create level:  prtqcb 
create level:  rmn 
create level:  shlhgj 
create level:  tmzcmb 
create level:  vlbqvps 
create level:  wmmfp 
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/bhmmsbmb 
create level:  nccjwf 
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/bhmmsbmb/nccjwf 
create level:  drwhjfjn 
create element:  206638 lflcgss.jrm 
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/bhmmsbmb/nccjwf/drwhjfjn 
create element:  291772 zcmfcjhf.tzw 
go up
go up
go up
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/bjwbvcq 
create level:  zfn 
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/bjwbvcq/zfn 
create element:  303808 wrbldbd 
go up
go up
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/hgrnmh 
create element:  142765 fvqbtm.tch 
create element:  159497 scqf.scf 
create element:  270819 zcmfcjhf.tzw 
go up
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/ltvtrtth 
create level:  fwtwqvn 
create element:  156894 jnmqdq.zgp 
create element:  297860 lflcgss.jrm 
create level:  mcgcc 
create level:  zfn 
create element:  179328 zfn.vnn 
create level:  zzsnz 
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/ltvtrtth/fwtwqvn 
create level:  rqndc 
create level:  rzsrp 
create element:  124999 rzsrp.tvr 
create level:  shlhgj 
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/ltvtrtth/fwtwqvn/rqndc 
create element:  45124 zrcv 
go up
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/ltvtrtth/fwtwqvn/rzsrp 
create element:  74041 rzsrp 
go up
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/ltvtrtth/fwtwqvn/shlhgj 
create element:  117219 qptfpz.cgc 
create element:  281188 shlhgj.bhd 
create element:  121750 sptql 
create element:  173637 vqp.dbs 
go up
go up
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/ltvtrtth/mcgcc 
create element:  18295 gqlg 
create level:  ngvwhnvf 
create element:  177283 rjsrn.rlq 
create element:  54239 rzsrp.tfq 
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/ltvtrtth/mcgcc/ngvwhnvf 
create element:  207616 jjhc.tzr 
go up
go up
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/ltvtrtth/zfn 
create level:  cwzbljh 
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/ltvtrtth/zfn/cwzbljh 
create element:  134952 hmchpgn.nwf 
go up
go up
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/ltvtrtth/zzsnz 
create element:  273014 shlhgj.pls 
go up
go up
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/prtqcb 
create level:  dtr 
create level:  rzsrp 
create element:  199012 tnflwcsn 
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/prtqcb/dtr 
create level:  gqlg 
create level:  grwpbs 
create level:  hgrnmh 
create element:  115701 lflcgss.jrm 
create element:  247838 tnflwcsn 
create element:  268721 zcmfcjhf.tzw 
create element:  15320 zwcd.dqb 
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/prtqcb/dtr/gqlg 
create element:  285009 jjhc.tzr 
create element:  125691 nhnlcjjt.zlj 
create element:  54424 rzsrp.rll 
go up
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/prtqcb/dtr/grwpbs 
create element:  59390 rzsrp.cms 
go up
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/prtqcb/dtr/hgrnmh 
create element:  185747 lvtnqqdh.nzq 
go up
go up
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/prtqcb/rzsrp 
create element:  268631 hvvpfd.smn 
create element:  263890 tcrctpb.pcc 
go up
go up
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/rmn 
create level:  gtnvc 
create element:  205894 hqb.fwh 
create element:  280887 lvvmjb.scj 
create level:  rsnqlfsz 
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/rmn/gtnvc 
create element:  28523 jjhc.tzr 
go up
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/rmn/rsnqlfsz 
create level:  hgrnmh 
create level:  nsfhtthc 
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/rmn/rsnqlfsz/hgrnmh 
create element:  183216 fvqbtm.tch 
go up
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/rmn/rsnqlfsz/nsfhtthc 
create element:  284747 jspmbh.rvh 
go up
go up
go up
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/shlhgj 
create element:  144391 dzf 
create level:  lrths 
create element:  178083 nhlmsd.mnc 
create level:  rwn 
create element:  173833 shlhgj.qss 
create element:  39183 tnflwcsn 
create element:  125029 zfn.hjr 
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/shlhgj/lrths 
create level:  hgrnmh 
create level:  pfc 
create element:  86563 rzsrp.gbc 
create element:  280631 tmhnc.hmc 
create element:  28181 ttsnjc.rhm 
create element:  98060 vdmr.czg 
create level:  vlshvmvj 
create level:  wsn 
create element:  210337 zfn.pqp 
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/shlhgj/lrths/hgrnmh 
create level:  mvrlcvj 
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/shlhgj/lrths/hgrnmh/mvrlcvj 
create element:  121034 vssbr.qjm 
go up
go up
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/shlhgj/lrths/pfc 
create level:  gqlg 
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/shlhgj/lrths/pfc/gqlg 
create element:  305519 hdhn.wds 
go up
go up
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/shlhgj/lrths/vlshvmvj 
create element:  56641 lflcgss.jrm 
create element:  29190 rzsrp.vsh 
create element:  36663 zcmfcjhf.tzw 
go up
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/shlhgj/lrths/wsn 
create element:  137307 gmdfbfjf.crs 
create level:  hgtqj 
create element:  297924 lflcgss.jrm 
create level:  shlhgj 
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/shlhgj/lrths/wsn/hgtqj 
create element:  214202 qnlszftb.bzg 
go up
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/shlhgj/lrths/wsn/shlhgj 
create level:  pmldlbbh 
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/shlhgj/lrths/wsn/shlhgj/pmldlbbh 
create element:  263722 zwfptl.wsh 
go up
go up
go up
go up
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/shlhgj/rwn 
create element:  279589 ttqg.qct 
go up
go up
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/tmzcmb 
create element:  138557 jjhc.tzr 
go up
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/vlbqvps 
create level:  nmfnf 
create element:  123659 rzsrp 
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/vlbqvps/nmfnf 
create level:  jhpnd 
create element:  50537 trzvzvgz.bqp 
create element:  41828 vps 
create element:  195245 wlwt.ftj 
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/vlbqvps/nmfnf/jhpnd 
create element:  257519 shlhgj.fwz 
create element:  32963 wzmbdtz 
go up
go up
go up
go down to start/zjhqnlrr/ddzmvh/pvdwhmcr/wmmfp 
create element:  94749 lflcgss.jrm 
go up
go up
go up
go down to start/zjhqnlrr/dsjd 
create element:  284923 bjvwg.phz 
create level:  bwjp 
create level:  gqlg 
create level:  hgrnmh 
create element:  8771 jjhc.tzr 
create level:  jntt 
create element:  271995 qbtn.vps 
create element:  299501 shlhgj.crl 
create level:  vmph 
create level:  zvg 
go down to start/zjhqnlrr/dsjd/bwjp 
create element:  117739 vtrg 
go up
go down to start/zjhqnlrr/dsjd/gqlg 
create level:  dwhr 
create element:  159876 hgrnmh.jvw 
create level:  rzsrp 
go down to start/zjhqnlrr/dsjd/gqlg/dwhr 
create element:  193289 gqlg 
create element:  171323 lflcgss.jrm 
go up
go down to start/zjhqnlrr/dsjd/gqlg/rzsrp 
create level:  pmsgd 
go down to start/zjhqnlrr/dsjd/gqlg/rzsrp/pmsgd 
create element:  12648 lflcgss.jrm 
create level:  wbppspwq 
go down to start/zjhqnlrr/dsjd/gqlg/rzsrp/pmsgd/wbppspwq 
create element:  38834 tnflwcsn 
go up
go up
go up
go up
go down to start/zjhqnlrr/dsjd/hgrnmh 
create element:  76649 cfdcbvdl.gfs 
create element:  257249 gmmzf 
create element:  83045 lhrtfcz 
go up
go down to start/zjhqnlrr/dsjd/jntt 
create element:  286866 lhqvt.lst 
go up
go down to start/zjhqnlrr/dsjd/vmph 
create level:  fnvpsr 
create level:  gfnvsznj 
create element:  19765 zcmfcjhf.tzw 
create element:  204319 zzsnj.dcp 
go down to start/zjhqnlrr/dsjd/vmph/fnvpsr 
create level:  flz 
create element:  173924 fvqbtm.tch 
create element:  248297 mjrhs.scq 
create level:  rzsrp 
create element:  130580 zfn 
go down to start/zjhqnlrr/dsjd/vmph/fnvpsr/flz 
create element:  106168 brsgg 
go up
go down to start/zjhqnlrr/dsjd/vmph/fnvpsr/rzsrp 
create element:  221882 hgrnmh.nsl 
create level:  smd 
go down to start/zjhqnlrr/dsjd/vmph/fnvpsr/rzsrp/smd 
create level:  drsld 
create element:  131686 fvqbtm.tch 
create level:  gqlg 
create element:  288283 hcw 
go down to start/zjhqnlrr/dsjd/vmph/fnvpsr/rzsrp/smd/drsld 
create element:  85885 zfn.wdf 
go up
go down to start/zjhqnlrr/dsjd/vmph/fnvpsr/rzsrp/smd/gqlg 
create element:  8466 dzjtj.zbc 
go up
go up
go up
go up
go down to start/zjhqnlrr/dsjd/vmph/gfnvsznj 
create level:  fqb 
create element:  265075 gqlg 
create level:  hdhmbtj 
create element:  74385 hpz 
create level:  lzdq 
create level:  rlvqmwv 
create level:  rzsrp 
go down to start/zjhqnlrr/dsjd/vmph/gfnvsznj/fqb 
create element:  55182 ccjgpg 
create element:  245930 ppdgwcm.zfb 
create element:  164364 sgtgqdn.tfp 
go up
go down to start/zjhqnlrr/dsjd/vmph/gfnvsznj/hdhmbtj 
create level:  gqlg 
create element:  68609 jjhc.tzr 
create level:  rzsrp 
create level:  vrmrnt 
create element:  66988 zcmfcjhf.tzw 
go down to start/zjhqnlrr/dsjd/vmph/gfnvsznj/hdhmbtj/gqlg 
create element:  156776 tnflwcsn 
create level:  vdcbg 
go down to start/zjhqnlrr/dsjd/vmph/gfnvsznj/hdhmbtj/gqlg/vdcbg 
create element:  261780 lflcgss.jrm 
go up
go up
go down to start/zjhqnlrr/dsjd/vmph/gfnvsznj/hdhmbtj/rzsrp 
create element:  27818 zfn 
go up
go down to start/zjhqnlrr/dsjd/vmph/gfnvsznj/hdhmbtj/vrmrnt 
create element:  273664 msmzfnj.llc 
create element:  145156 svzmwnrq.chh 
go up
go up
go down to start/zjhqnlrr/dsjd/vmph/gfnvsznj/lzdq 
create element:  214363 fms 
create element:  190021 lfzcgh.dsq 
create element:  21357 qtvvmj.zqw 
go up
go down to start/zjhqnlrr/dsjd/vmph/gfnvsznj/rlvqmwv 
create level:  gqlg 
create element:  198296 gqlg.sdz 
create element:  842 gshcswc.dcb 
create level:  shlhgj 
create element:  199828 snng 
go down to start/zjhqnlrr/dsjd/vmph/gfnvsznj/rlvqmwv/gqlg 
create element:  183087 zfn.nsj 
go up
go down to start/zjhqnlrr/dsjd/vmph/gfnvsznj/rlvqmwv/shlhgj 
create element:  73040 tzgjrqmb 
go up
go up
go down to start/zjhqnlrr/dsjd/vmph/gfnvsznj/rzsrp 
create element:  229576 vtftgng.wfz 
go up
go up
go up
go down to start/zjhqnlrr/dsjd/zvg 
create element:  85701 shlhgj.dvf 
go up
go up
go down to start/zjhqnlrr/nnzvl 
create level:  wwzsf 
go down to start/zjhqnlrr/nnzvl/wwzsf 
create element:  105177 tvbdz 
go up
go up
go up
go down to start/zssdlnc 
create level:  nfgh 
create element:  166004 twdcrh.zld 
create level:  zfn 
go down to start/zssdlnc/nfgh 
create element:  102281 fvqbtm.tch 
go up
go down to start/zssdlnc/zfn 
create level:  fbmww 
create level:  jsst 
create element:  206602 shlhgj.cln 
go down to start/zssdlnc/zfn/fbmww 
create element:  179734 fll 
go up
go down to start/zssdlnc/zfn/jsst 
create level:  flp 
go down to start/zssdlnc/zfn/jsst/flp 
create element:  32274 gctgt.stn 
create element:  67650 ggvj.bwz 
all_sizes <- map_dbl(all_dirs, function(cur_dir){
  get_sum_size_dir(cur_dir$name)
})
all_dirs_less_max_size <- names(all_sizes)[all_sizes < max_dir_size]
all_dirs_less_max_size
 [1] "start/plmdrbn/fmzjhrq"                                                           
 [2] "start/plmdrbn/fmzjhrq/rrjjsvm"                                                   
 [3] "start/stqq/whmdbn"                                                               
 [4] "start/zjhqnlrr/bzzvj/wjtlg"                                                      
 [5] "start/zjhqnlrr/bzzvj/zfn"                                                        
 [6] "start/zjhqnlrr/ddzmvh/mghmb/btjq/rqtc/pbzhfsg"                                   
 [7] "start/zjhqnlrr/ddzmvh/mghmb/btjq/rqtc/rzsrp/gqlg/gqlg"                           
 [8] "start/zjhqnlrr/ddzmvh/mghmb/btjq/rqtc/rzsrp/gqlg/nvjqp/gcq/mslhm"                
 [9] "start/zjhqnlrr/ddzmvh/mghmb/btjq/rqtc/rzsrp/mbsjjzft/stgszvmj/dthcrbmr/lhp"      
[10] "start/zjhqnlrr/ddzmvh/mghmb/btjq/rqtc/rzsrp/mbsjjzft/stgszvmj/dthcrbmr/npf"      
[11] "start/zjhqnlrr/ddzmvh/mghmb/btjq/rqtc/rzsrp/mbsjjzft/stgszvmj/dthcrbmr/qbgrjr"   
[12] "start/zjhqnlrr/ddzmvh/mghmb/btjq/rqtc/rzsrp/mbsjjzft/stgszvmj/shlhgj/wtlngn"     
[13] "start/zjhqnlrr/ddzmvh/mghmb/btjq/rqtc/rzsrp/mbsjjzft/stgszvmj/shlhgj/wtlngn/gqlg"
[14] "start/zjhqnlrr/ddzmvh/mghmb/btjq/rqtc/shlhgj/tns/qhhtgsvz"                       
[15] "start/zjhqnlrr/ddzmvh/pvdwhmcr/wmmfp"                                            
[16] "start/zjhqnlrr/ddzmvh/pvdwhmcr/ltvtrtth/fwtwqvn/rqndc"                           
[17] "start/zjhqnlrr/ddzmvh/pvdwhmcr/ltvtrtth/fwtwqvn/rzsrp"                           
[18] "start/zjhqnlrr/ddzmvh/pvdwhmcr/prtqcb/dtr/grwpbs"                                
[19] "start/zjhqnlrr/ddzmvh/pvdwhmcr/rmn/gtnvc"                                        
[20] "start/zjhqnlrr/dsjd/zvg"                                                         
[21] "start/zjhqnlrr/dsjd/gqlg/rzsrp"                                                  
[22] "start/zjhqnlrr/dsjd/gqlg/rzsrp/pmsgd"                                            
[23] "start/zjhqnlrr/dsjd/gqlg/rzsrp/pmsgd/wbppspwq"                                   
[24] "start/zjhqnlrr/dsjd/vmph/fnvpsr/rzsrp/smd/drsld"                                 
[25] "start/zjhqnlrr/dsjd/vmph/fnvpsr/rzsrp/smd/gqlg"                                  
[26] "start/zjhqnlrr/dsjd/vmph/gfnvsznj/hdhmbtj/rzsrp"                                 
[27] "start/zjhqnlrr/dsjd/vmph/gfnvsznj/rlvqmwv/shlhgj"                                
[28] "start/zssdlnc/zfn/jsst"                                                          
[29] "start/zssdlnc/zfn/jsst/flp"                                                      

In the full input the suz size of the directories that have size of at most 10^{5} is 1.749646^{6}! 🥳