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
is the number of people.
50 tests with with one sentence of type
There are ... Mr.Right/Wrong
per person50 tests with with one sentence of type
... is Mr.Right/Wrong
per person300 tests with
100 tests with
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
Similar Kata:
Stats:
Created | Jan 22, 2025 |
Published | Jan 29, 2025 |
Warriors Trained | 12 |
Total Skips | 1 |
Total Code Submissions | 180 |
Total Times Completed | 3 |
JavaScript Completions | 3 |
Total Stars | 1 |
% of votes with a positive feedback rating | 100% of 2 |
Total "Very Satisfied" Votes | 2 |
Total "Somewhat Satisfied" Votes | 0 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 2 |
Average Assessed Rank | 2 kyu |
Highest Assessed Rank | 1 kyu |
Lowest Assessed Rank | 2 kyu |