Beta

Reach 1 as Quick as Possible

Description:

Give an algorithm that takes an integer k (k > 0) as parameter, and returns the minimum number of steps needed to convert k to 1. In each step, one can apply one of the operations given below:

• Divide by three. This operation can be applied only if the number is divisible by three.

• Divide by two. This operation can be applied only if the number is divisible by two.

• Subtract one

Code size must be less than 116 characters.

Code must be one line.

TESTS:

  • Easy: 1 to 100
  • Normal: 500 to 2000
  • Hard: 2000 to 10000
  • Insane: 10^6 to 10^7
  • Unhuman: 10^50 to 10^51
Algorithms
Performance
Fundamentals

Similar Kata:

More By Author:

Check out these other kata created by cemsina

Stats:

CreatedAug 24, 2021
PublishedAug 24, 2021
Warriors Trained92
Total Skips1
Total Code Submissions169
Total Times Completed14
Python Completions14
Total Stars4
% of votes with a positive feedback rating67% of 6
Total "Very Satisfied" Votes3
Total "Somewhat Satisfied" Votes2
Total "Not Satisfied" Votes1
Total Rank Assessments4
Average Assessed Rank
5 kyu
Highest Assessed Rank
3 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • cemsina Avatar
Ad