Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

66%
+2 −0
Challenges Can I follow this recipe?

You work in a kitchen which has a peculiar rule. When you mix something into a pot you must always add at least one new ingredient. So you can add pasta, oil, salt then pesto, but not pasta, pesto...

1 answer  ·  posted 9mo ago by WheatWizard‭  ·  last activity 9mo ago by isaacg‭

#1: Initial revision by user avatar WheatWizard‭ · 2024-03-02T17:18:45Z (9 months ago)
Can I follow this recipe?
You work in a kitchen which has a peculiar rule. When you mix something into a pot you must always add at least one new ingredient.

So you can add pasta, oil, salt then pesto, but not pasta, pesto, salt and oil since pesto already contains salt and oil. You only have one pot per dish, so you can't mix ingredients in one pot and then dump that into another.

So we can say that mixing is an associative binary operation \$\otimes\$, which takes the union of two sets of ingredients, but only operates on pairs where the second set contains some element not in the first, so

$$
\{1,2\}\otimes\{6,2\} = \{6,1,2\}
$$

but

$$
\{1,2,3\}\otimes\{1,3\}
$$

is undefined.

Now this rule is annoying because it means you have to be careful about the order you combine things. Sometimes there are even recipes can't be followed because there's no way to mix all the parts without breaking the rule.

A recipe can be followed if there is a way to order the parts so that each part contains an ingredient not found in prior parts.

So if the parts of the recipe are:

$$
\{1,2,3\},\,\{\},\,\{2,6\},\,\{1,2,4\},\,\{3\}
$$

then they can be ordered:

$$
\{\}\otimes\{3\}\otimes\{1,2,3\}\otimes\{2,6\}\otimes\{1,2,4\}
$$

However

$$
\{1,2,3\},\,\{\},\,\{2,4\},\,\{1,2,4\},\,\{3\}
$$

cannot be ordered without breaking the kitchen's rule.

## Task

Take as input sets of positive integers representing parts of a recipe. Output one of two distinct consistent values depending on whether the input represents a possible or impossible recipe.

This is code-golf. The goal is to minimize the size of your source code as measured in bytes.

## Test cases

```
{},{} -> False
{2},{9} -> True
{},{3},{2,6},{1,2,4},{1,2,3} -> True
{1,2,3},{},{2,4},{1,2,4},{3} -> False
```