6 kyu

Number of measurements to spot the counterfeit coin

260 of 1,311GiacomoSorbi

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 Trained4080
Total Skips275
Total Code Submissions13051
Total Times Completed1311
JavaScript Completions260
Ruby Completions55
Python Completions706
Crystal Completions8
C Completions116
NASM Completions18
C++ Completions140
C# Completions76
COBOL Completions9
Go Completions30
Rust Completions29
Total Stars85
% of votes with a positive feedback rating88% of 281
Total "Very Satisfied" Votes228
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