Number of measurements to spot the counterfeit coin
Description:

I found this interesting interview question just today:
8 coins are given where all the coins have equal weight, except one. The odd one weights less than the others, not being of pure gold. In the worst case, how many iterations are actually needed to find the odd one out on a two plates scale.
I am asking you then to tell me what is the minimum amount of weighings it will take to measure n
coins in every possible occurrence (including worst case scenario, ie: without relying on luck at all).
n
is guaranteed to be a positive integer.
Tip: being able to think recursively might help here :p
Note: albeit this is more clearly a logical than a coding problem, do not underestimate (or under-rank) the kata for requiring not necessarily wizard-class coding skills: a good coder is a master of pattern recognition and subsequent optimization ;)
Similar Kata:
Stats:
Created | Jun 28, 2017 |
Published | Jun 28, 2017 |
Warriors Trained | 4034 |
Total Skips | 275 |
Total Code Submissions | 12963 |
Total Times Completed | 1302 |
JavaScript Completions | 258 |
Ruby Completions | 55 |
Python Completions | 705 |
Crystal Completions | 8 |
C Completions | 116 |
NASM Completions | 17 |
C++ Completions | 140 |
C# Completions | 74 |
COBOL Completions | 9 |
Go Completions | 28 |
Rust Completions | 28 |
Total Stars | 85 |
% of votes with a positive feedback rating | 88% of 279 |
Total "Very Satisfied" Votes | 226 |
Total "Somewhat Satisfied" Votes | 40 |
Total "Not Satisfied" Votes | 13 |
Total Rank Assessments | 5 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |