- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Program to partitioning into minimum number of Deci- Binary numbers in Python

Suppose we have a number n in string format. We have to find minimum deci-binary numbers are required, so that whose sum is equal to n. A deci-binary number is a decimal number whose digits are either 0 or 1.

So, if the input is like n = "132", then the output will be 3 because 132 is sum of three decibinary number (10 + 11 + 111).

To solve this, we will follow these steps −

- result := 1
- for each i in n, do
- if i is not in {0,1}, then
- result := maximum of result and i

- if i is not in {0,1}, then
- return result

## Example

Let us see the following implementation to get better understanding −

def solve(n): result = 1 for i in n: if i not in {0,1}: result = max(result, int(i)) return result n = "132" print(solve(n))

## Input

132

## Output

3

- Related Questions & Answers
- C++ program to count minimum number of binary digit numbers needed to represent n
- Program to find minimum number of Fibonacci numbers to add up to n in Python?
- Program to count minimum number of operations required to make numbers non coprime in Python?
- Represent a Number as Sum of Minimum Possible Pseudo-Binary Numbers in C++
- Program to find concatenation of consecutive binary numbers in Python
- Java Program to Parse and Format a Number into Binary
- Program to find minimum number of people to teach in Python
- Convert decimal to binary number in Python program
- Program to find minimum number of monotonous string groups in Python
- Python program to convert decimal to binary number
- Python Program for Find minimum sum of factors of number
- Golang Program to find the minimum and maximum number, using binary operations.
- Python program to check if binary representation of two numbers are anagram.
- Program to find minimum number of rocketships needed for rescue in Python
- Program to count number of stepping numbers of n digits in python

Advertisements