task2.py 609 B

12345678910111213141516171819
  1. def convert_base_2_to_16(number):
  2. """
  3. Given a number represented as base 2, convert it to base 16.
  4. To solve this task properly, you should convert directly from
  5. one base to the other without computing the whole number.
  6. >>> convert_base_2_to_16([0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0])
  7. [3, 0, 0, 14]
  8. >>> convert_base_2_to_16([0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0])
  9. [6, 0, 8, 6]
  10. >>> convert_base_2_to_16([0, 0, 1])
  11. [1]
  12. >>> convert_base_2_to_16([1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1])
  13. [1, 6, 10, 1]
  14. """
  15. # Your code here...