I'll share a personal anecdote in case it helps. It's not describing an algorithm or code but rather general technique, and it's definitely not a one-off solution. It can help with just about everything.

Many years ago I was doing a lot of training sessions for my clients at work. In order to understand my clients better my coach, a former SV exec, gave me a tip: Study models of personality typology.

So I took up this study and learned about personality differences for many years while doing web work as a solo contractor.

One nice thing is, as you learn this stuff, you can learn to stop telling people they're wrong (in so many words) all the time, and learn to use their own perspectives to help them learn the way they prefer to learn.

Anyway, one day I went out to visit a food products distributor for an interview, to see if I could get a contract to build out their web assets, relieved that I'd be doing some more hands-on tech work for a change. It was a really solid project that would require a lot of effort.

While on site, I was interviewed by the two main stakeholders, family members of the CEO, and immediately identified the relevant personality dynamics.

Some people are waayyyy more "on-type" than others. Everyone is unique and special, but these two had done so much mutual work & mutual combat (so to speak) that their personalities seemed to have retreated to the old, standard psychological lines of defense. In these cases it is pretty easy to see very typical & recognizable relationship patterns or archetypes form.

So from my POV it appeared as if their two personalities were practically cut out of a mold. It was very easy to see what was going on. Like if someone said their computer didn't work, and you realized that they were trying to plug the monitor into the keyboard and the keyboard back into the monitor.

This kind of setup is a huge liability for the individuals involved in a lot of ways--you can end up living a self-sustaining script in which you nearly programatically live out, and defend, a set grouping of general perspectives and decisionmaking styles that are essentially also non-functional as far as the team effort goes. You end up feeling like you need to fight all the time, or subvert others to get your way. Over time it can have really bad consequences for health and relationships.

As I listened to both of them taking turns describing the business & project through their different perspectives, I realized that the two must really hate each other, but they were both trying to be polite. I got the idea that they were looking for a third party so they could displace some of the tension between them and hopefully get this web project done.

Answering their difficult and thoughtful interview questions was easy though, because they were following their personality scripts:

The first interviewer was a highly logical type. Logical people will give you puzzles and usually accompany the puzzle with a narrative...but a lot of times it's 100% OK if you can't solve that stuff. They mostly want to know if you'll look at the puzzle using their preferred approach, or (the only other possibility /s)...if you're an idiot.

Economical people will give you business problems based on doing things the way others in business would do those things. They also usually accompany the description with a suspiciously breezy "just do it, it should be easy" style of language...but a lot of times it's 100% OK if you express that it will be difficult. They mostly want to know if you'll try using their preferred approach, or (the only other possibility /s)...if you're an idiot.

You may see, reading this, how you can absolutely fail at specific interview questions but, due to your style, get the job.

So, this was pretty funny because I found myself trying to develop, on the spot, a way to transcend the two positions:

Subjective, internal, not-invented-here logic to meet a specification on the one hand...

And on the other hand: Objective, external, off-the-shelf toolchain compilation to meet or exceed business metrics.

Speaking to one, I emphasized their main point, and used the other's ideas as candidates for supportive approaches. Speaking to the other, I reiterated what I just said, and emphasized where I knew their fears must be, and discussed how I'd approach the problems I thought they were likely afraid of.

Which, not many people know--but this is a core problem that was expressed by Jungian psychology: How do we transcend any two given opposite approaches or points of view, and develop a solution that integrates both points as best we can? Until we can learn to reliably do so, we'll always have war.

I realized that my job would be much different than what these two expected. It scared me that I'd never get to use my own preferred methods or tools, stuck managing these oscillating perspectives all the time, not just on the project in general but likely on all its details.

I was offered the contract within the day, but I had to turn it down.

If I could go back in time the only thing I'd change is to request a phone interview first. They clearly appreciated my time and thought the approach was on target, but it wasn't my job to fix their personality clashes. That'd be a huge overreach of my boundaries given what I knew and what I was being interviewed to do. In a position like that it's nearly 100% about team fit.

If I could advise other people--you can stop focusing on so many interview questions if you learn about personality differences and team dynamics. Not just so you can better solve others' problems and show them some consideration for their preferred ways of doing things, but so you can start to identify your own team- and project-fit, faster, wasting less of your time sweating the little details.

Anyway, I'm sure there are lots of helpful tips out there, good luck.