6 kyu

Imaginary Base Conversion

107 of 246feeg1
Description
Loading description...
Mathematics
Algorithms
  • Please sign in or sign up to leave a comment.
  • Cloud Walker Avatar

    Great kata! Very original. Enjoyed solving it. Only 189 completions in 7 years? Come on codewarriors, give it a go. This one deserves more attention.

  • Kacarott Avatar
  • MikChan Avatar

    This comment has been hidden.

  • MikChan Avatar

    Why returning std::vector<int> in C++, if there is a built-in std::complex<int>?

  • MikChan Avatar

    Sample tests and initial solution are broken.

    • Initial solution has using namespace std; in it. That shouldn't be a case.
    • Sample tests rely on using namespace std; being in the solution. That shouldn't be a case either.
  • VOID93 Avatar

    I am pretty new to coding and do not really know what to do with a problem that is basically pure maths like this. What does that last block mean [a, b] = a+b*i? What is my output actually supposed to look like? If I am given a string with some number like 101 (one hundred one) and...is that not ALREADY in base 10 form? I am very confused. Could I have some clarification? Thanks!

    • hobovsky Avatar

      Do you know what are number systems with different bases? Like binary, octal, decimal, hexadecimal?
      Do you know what are imaginary numbers, complex numbers, and imaginary unit i?

      There are two ways to solve this kind of problems:

      • research relevant topics, like the two I mentioned above, or
      • leave the kata for now, and forget it, or come back to it after getting better grasp of maths behind it.
    • VOID93 Avatar

      It was like SUPER late when I attempted the problem and I was not at my best. I know all about base-types and numerical expressions. I was just being stupid. I got some help via discord and ended up getting to a solution that, while clunky, helped to teach me some fundamentals. I put an EXTENSIVE comment suite in the solution that explains my data stream for a sample input. Thanks!

  • Mercy Madmask Avatar

    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

    This should be 1 + i, 1 * i^1 = i not -i

  • Voile Avatar

    Approved

  • JohanWiltink Avatar

    Description, second code block: why are you going on into negative exponents? This would be applicable to some fixed point situation, but not here, is it? It's inconsistent with all other examples and tests.

    Third code block: -1 + 0 + 1 does not equal 2. The example test has this correct though.

  • jungerstein Avatar

    This comment has been hidden.