Aww, I was just being comical. Obviously you were not intending for your code to be fully correct or even mostly correct in the details beyond using
num_of_realm_counties. That's all I needed to see anyway.
However, if YOU'RE going to come back at my flawless, I assert (is there still room for comedy?), trigger, then... well, I guess then I'll defend it.
You're correct about the first num_of_realm_counties being unnecessary in this case due to targeting 50% as the baseline. It seemed incomplete for edification purposes to leave it out of the logic, though, since it relies on a define and hidden hardcoded conditions to supplement it if so (i.e., ain't true on its own).
Then you had to go besmirch yourself by saying this:
Yes and no.
Yes, in the sense that scoping to the title, which may or may not be held, and then its possibly undefined
holder_scope, and then executing some trigger within that
interesting scope is a lot more efficient than
any_playable_ruler = { <the same or an effectively equal cost inner trigger> }. Like, in the sense that it would run faster if you benchmarked it. Efficiency toward what end, I don't know. Your code fragment did not solve the problem that my code fragment did, nor did it solve the basic problem, so I guess efficiency is subjective.
Once there was a program named Apples and a different program named Bananas. Apples actually didn't accomplish its intended goal and miscalculated most of the time, but its benchmarks were excellent. Bananas, on the other hand, had very poor benchmarks. However, not only did it always calculate the right answer, but it actually answered an entirely different and much more sophisticated question. [ I implemented the "he who is the most powerful within the title and holds the minimum for creation/usurpation" rule that was suggested at one point, as I also mentioned. ]
In the end, the inane competition between the too-fast-to-be-right Apples and the correct-but-too-overloaded-to-compete Bananas led to Apples finally going bananas and Bananas just going nuts:
Obviously, if efficiency were the concern and 4-county was the optimization target (but with the goal of still being valid in the other cases and not hard-coded), the best trigger would have directly checked the direct de jure vassals of FROM twice, nested, to flexibly isolate the case where two different characters that aren't ROOT held counties in the duchy vs. whether only one character held the direct de jure vassal titles not owned by ROOT. That should just barely work for a 6-county case. For an 8-county title, then you'd need to hardcode title references or use
any_playable_ruler again to solve the Bananas question. That is a way more confusing trigger for someone not versed in these dark arts to grok, though.