6 kyu

Number of measurements to spot the counterfeit coin

258 of 1,302GiacomoSorbi

Description:

coins balance scale problem

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 ;)

Logic
Fundamentals

Stats:

CreatedJun 28, 2017
PublishedJun 28, 2017
Warriors Trained4034
Total Skips275
Total Code Submissions12963
Total Times Completed1302
JavaScript Completions258
Ruby Completions55
Python Completions705
Crystal Completions8
C Completions116
NASM Completions17
C++ Completions140
C# Completions74
COBOL Completions9
Go Completions28
Rust Completions28
Total Stars85
% of votes with a positive feedback rating88% of 279
Total "Very Satisfied" Votes226
Total "Somewhat Satisfied" Votes40
Total "Not Satisfied" Votes13
Total Rank Assessments5
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • GiacomoSorbi Avatar
  • SandQueen Avatar
  • Voile Avatar
  • KataSideKick Avatar
  • FArekkusu Avatar
  • monadius Avatar
  • hobovsky Avatar
  • akar-0 Avatar
  • Just4FunCoder Avatar
  • saudiGuy Avatar
Ad