Beta

Mr. Right & Mr. Wrong #3: How many Mr. Wrong?

Description:

Task

Mr.Right always tell the truth, Mr.Wrong always tell the lies.

Some people are having a conversation, trying to figure out how many in the group are Mr.Wrong. Listen to their conversation and determine how many Mr.Wrong there are.

[[Input]] A string array: conversation

They always talking about ... is Mr.Wrong., ... is Mr. Right, There are ... Mr.Wrong., There are ... Mr.Right.

Please note that everyone has at least one sentence and everyone is either Mr.Right or Mr.Wrong. Also, no one will ever have a paradoxical statement.

[[Output]] The number of Mr.Wrong in the group. If it is impossible to determine, return null.

Examples:

conversation=[
  "Joe:There are 1 Mr.Wrong.",
  "Bob:There are 2 Mr.Wrong.",
  "Tim:There are 3 Mr.Wrong."
]
howManyMrWrong(conversation) should return 2

conversation=[
  "Mario:Luigi is Mr.Wrong.",
  "Luigi:Mario is Mr.Wrong."
]
howManyMrWrong(conversation) should return 1

conversation=[
  "Musk:Zuckerberg is Mr.Right.",
  "Zuckerberg:There are 2 Mr.Wrong.",
  "Musk:Bezos is Mr.Right.",
  "Bezos:There are 1 Mr.Wrong."
]
howManyMrWrong(conversation) should return 3

conversation=[
  "John:Peter is Mr.Right.",
  "Peter:There are 2 Mr.Right",
  "Tom:John is Mr.Wrong."
]
howManyMrWrong(conversation) should return null

Two solutions are possible in the last example: either 1 Mr.Wrong (Tom) or 2 Mr. Wrong (John and Peter). In this case, the result is null.

Random Tests

nn is the number of people.

  • 50 tests with n150n \le 150 with one sentence of type There are ... Mr.Right/Wrong per person

  • 50 tests with n150n \le 150 with one sentence of type ... is Mr.Right/Wrong per person

  • 300 tests with 4n104 \le n \le 10

  • 100 tests with 300n500300 \le n \le 500

Note for Beta:

The Random tests (including test generation) will likely be tweaked quite a lot before they are finished. I also need more good quality fixed tests, so if you run into specific kinds of scenarios in the random tests which aren't covered in the fixed tests, please suggest a fixed test in discourse.

With this in mind, please do not translate the kata until the tests have settled. After that I welcome translations :)

Series

Logic
Performance
Riddles
Set Theory

Stats:

CreatedJan 22, 2025
PublishedJan 29, 2025
Warriors Trained12
Total Skips1
Total Code Submissions180
Total Times Completed3
JavaScript Completions3
Total Stars1
% of votes with a positive feedback rating100% of 2
Total "Very Satisfied" Votes2
Total "Somewhat Satisfied" Votes0
Total "Not Satisfied" Votes0
Total Rank Assessments2
Average Assessed Rank
2 kyu
Highest Assessed Rank
1 kyu
Lowest Assessed Rank
2 kyu
Ad
Contributors
  • Kacarott Avatar
Ad