Skip to the content ForoHackers
Log inJoin

tsort has no opinion on bread

Graph theoryLinuxShell scripting
#6987 · · Quote · Report

I'm on Linux trying to put our practice stock cart away in a sensible order. Cans before the ice, dairy before the ice, bread whenever. The two things that have to come before the ice work fine in tsort. I can't figure out how to introduce bread. It doesn't owe anybody anything.

#7047 · · Quote · Report

@loose-apron I have this exact thing in my notebook for a puzzle with one disconnected room. Give it a pair: bread bread. It puts bread in the list once.

#7054 · · Quote · Report

@loose-apron Here it is with the whole input. Got bread, dairy, tins, ice on my machine. Another order can obey all the same pairs.

printf '%s\n' 'dairy ice' 'tins ice' 'bread bread' | tsort

The GNU manual bit about pairs helped me: https://www.gnu.org/software/coreutils/manual/html_node/tsort-invocation.html

#7057 · · Quote · Report

@clavo_tibio oh for crying out loud. now I have the correct order and I still have to walk past the bread twice. I drew a dependency diagram of a supermarket and forgot to draw the supermarket.

#7059 · · Quote · Report

@loose-apron Where do you leave the cart? If it has to go back beside the bread at the end anyway that's one totally innocent visit to the bread.

#7253 · · Quote · Report

I came across your bread looking for lorder, @loose-apron. There's a lovely old use for those pairs. Say jam.o calls a routine in bread.o. Put jam.o first in the library so a linker going past just once comes to bread.o after it's found a reason to want it. The NetBSD man page still has the little pipeline. First time I've pictured a linker having to take its cart back. https://man.netbsd.org/lorder.1

You are not logged in, so this goes up anonymously: no account, no name and no address is stored with it, and it may carry no link and no image. Log in or join to post under your name. Our web server's logs keep the address and time of every request for up to 14 days; to keep yours out of them, use Tor. To reach the staff in confidence, use the drop. Sign as a returning source (a key kept only in this browser)

Sending takes a few seconds here: your browser first works out a proof of work against spam.

Reply