6 kyu

Imaginary Base Conversion

107 of 246feeg1

Description:

You have been tasked with converting a number from base i (sqrt of -1) to base 10.

Recall how bases are defined:

abcdef = a * 10^5 + b * 10^4 + c * 10^3 + d * 10^2 + e * 10^1 + f * 10^0

Base i follows then like this:

... i^4 + i^3 + i^2 + i^1 + i^0

The only numbers in any place will be 1 or 0 Examples: 101 in base i would be:

  1 * i^2 + 0 * i^1 + 1*i^0 = -1 + 0 + 1 = 0
  

10010 in base i would be:

  1*i^4 + 0 * i^3 + 0 * i^2 + 1 * i^1 + 0 * i^0 = 1 + i = 1+i

You must take some number, n, in base i and convert it into a number in base 10, in the format of a 2x1 vector.

[a,b] = a+b*i

The number will always be some combination of 0 and 1

In Python you will be given an integer. In Javascript and C++ you will be given a string

Mathematics
Algorithms

Stats:

CreatedNov 27, 2016
PublishedNov 27, 2016
Warriors Trained800
Total Skips158
Total Code Submissions654
Total Times Completed246
Python Completions107
JavaScript Completions45
C++ Completions109
Factor Completions6
Total Stars15
% of votes with a positive feedback rating90% of 73
Total "Very Satisfied" Votes61
Total "Somewhat Satisfied" Votes10
Total "Not Satisfied" Votes2
Total Rank Assessments13
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • feeg1 Avatar
  • Voile Avatar
  • Kacarott Avatar
Ad