For what it's worth: you do not actually need the directory names, except in the sense that you need to distinguish '..' from other directory names.
-- Raul On Thu, Dec 8, 2022 at 11:07 AM 'Michael Day' via Chat <[email protected]> wrote: > > This one was a stinker! > Line spaces as possibly spoilers below!!! > - > - > - > - > - > - > - > - > - > - > - > - > - > - > - > - > - > - > - > - > - > - > - > - > - > - > First mistake was assuming that directory names were unique. NO! > Next mistake - assuming that parent-child pairs were unique. NO! > I ended up with derived directory chained names, such as rt.a, rt.a.e > etc which is far > from elegant but did the trick - and took me hours to get my head around. > > I keep an eye on the Q/K forum. Earlier postings there, but I imagine > they > used K's dictionary facility > . Perhaps boxed/nested arrays are the best approach > in J to representing the directory tree, but I didn't use them. > > I do think it would be better if the day's example included the pitfalls > - yesterday's > example used unique names and parent-child pairs - but probably > deliberate?! > As it was, I had a reasonable, though rather verbose, function which > solved the > example, but whose answer to the day's data was wrong, and stayed > wrong through > various "improvements." > > Mike > > On 08/12/2022 15:05, David Lambert wrote: > > I must misunderstand the instructions since I get same wrong answer in > > every language I try. > > > > Strategy: create a list of rooted path to all files. Make a set of > > the directories-part, producing a unique list of all directories. For > > each of these, add the file sizes for all files with matching leading > > path. Sum the directory totals for those with less than or equal to > > one hundred thousand. This strategy solves the example. > > > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
