Skip to main content
added 8 characters in body
Source Link
Sp3000
  • 62.3k
  • 13
  • 117
  • 292

Python 2, 108 89 8787 86 bytes

x=y=0 for m in map(int,raw_input()):x+=m*y and(m-y)%3*3/2;y^=m print"--i"[3-x%4i"[~x%4::2]+`y` 

(Thanks to @grc and @xnor for helping out in chatthe help)

Explanation

Let's split up the coefficient and the base matrix. If we focus on the base matrix only, we get this multiplication table (e.g. 13 is -i2, so we put 2):

 0123 0 0123 1 1032 2 2301 3 3210 

which just happens to be the same thing as doing bitwise xor.

Now let's focus on the coefficients. If we let 0123 denote 1,i,-1,-i respectively, we get:

 0123 0 0000 1 0031 2 0103 3 0310 

For this we first check if either number is 0 by doing m*y, taking care of the left column and top row. Adding in (m-y)%3 then gives:

 0123 0 0000 1 0021 2 0102 3 0210 

which is close, except that we have 2 instead of 3. We account for this by performing *3/2.

For indexing, we notice that if we take the string "--i" and select every second character starting from indices 0123 we get "-i","-","i","".

Python 2, 108 89 87 bytes

x=y=0 for m in map(int,raw_input()):x+=m*y and(m-y)%3*3/2;y^=m print"--i"[3-x%4::2]+`y` 

(Thanks to @grc for helping out in chat)

Explanation

Let's split up the coefficient and the base matrix. If we focus on the base matrix only, we get this multiplication table (e.g. 13 is -i2, so we put 2):

 0123 0 0123 1 1032 2 2301 3 3210 

which just happens to be the same thing as doing bitwise xor.

Now let's focus on the coefficients. If we let 0123 denote 1,i,-1,-i respectively, we get:

 0123 0 0000 1 0031 2 0103 3 0310 

For this we first check if either number is 0 by doing m*y, taking care of the left column and top row. Adding in (m-y)%3 then gives:

 0123 0 0000 1 0021 2 0102 3 0210 

which is close, except that we have 2 instead of 3. We account for this by performing *3/2.

For indexing, we notice that if we take the string "--i" and select every second character starting from indices 0123 we get "-i","-","i","".

Python 2, 108 89 87 86 bytes

x=y=0 for m in map(int,raw_input()):x+=m*y and(m-y)%3*3/2;y^=m print"--i"[~x%4::2]+`y` 

(Thanks to @grc and @xnor for the help)

Explanation

Let's split up the coefficient and the base matrix. If we focus on the base matrix only, we get this multiplication table (e.g. 13 is -i2, so we put 2):

 0123 0 0123 1 1032 2 2301 3 3210 

which just happens to be the same thing as doing bitwise xor.

Now let's focus on the coefficients. If we let 0123 denote 1,i,-1,-i respectively, we get:

 0123 0 0000 1 0031 2 0103 3 0310 

For this we first check if either number is 0 by doing m*y, taking care of the left column and top row. Adding in (m-y)%3 then gives:

 0123 0 0000 1 0021 2 0102 3 0210 

which is close, except that we have 2 instead of 3. We account for this by performing *3/2.

For indexing, we notice that if we take the string "--i" and select every second character starting from indices 0123 we get "-i","-","i","".

added 846 characters in body
Source Link
Sp3000
  • 62.3k
  • 13
  • 117
  • 292

Python 2, 108 89 87 bytes

x=y=0 for m in map(int,raw_input()):x+=m*y and(m-y)%3*3/2;y^=m print"--i"[3-x%4::2]+`y` 

Calculating the base matrix is really nice, but getting the coefficient/output format isn't.

(Thanks to @grc for helping out in chat)

Explanation

Let's split up the coefficient and the base matrix. If we focus on the base matrix only, we get this multiplication table (e.g. 13 is -i2, so we put 2):

 0123 0 0123 1 1032 2 2301 3 3210 

which just happens to be the same thing as doing bitwise xor.

Now let's focus on the coefficients. If we let 0123 denote 1,i,-1,-i respectively, we get:

 0123 0 0000 1 0031 2 0103 3 0310 

For this we first check if either number is 0 by doing m*y, taking care of the left column and top row. Adding in (m-y)%3 then gives:

 0123 0 0000 1 0021 2 0102 3 0210 

which is close, except that we have 2 instead of 3. We account for this by performing *3/2.

For indexing, we notice that if we take the string "--i" and select every second character starting from indices 0123 we get "-i","-","i","".

Python 2, 108 89 87 bytes

x=y=0 for m in map(int,raw_input()):x+=m*y and(m-y)%3*3/2;y^=m print"--i"[3-x%4::2]+`y` 

Calculating the base matrix is really nice, but getting the coefficient/output format isn't.

(Thanks to @grc for helping out in chat)

Python 2, 108 89 87 bytes

x=y=0 for m in map(int,raw_input()):x+=m*y and(m-y)%3*3/2;y^=m print"--i"[3-x%4::2]+`y` 

(Thanks to @grc for helping out in chat)

Explanation

Let's split up the coefficient and the base matrix. If we focus on the base matrix only, we get this multiplication table (e.g. 13 is -i2, so we put 2):

 0123 0 0123 1 1032 2 2301 3 3210 

which just happens to be the same thing as doing bitwise xor.

Now let's focus on the coefficients. If we let 0123 denote 1,i,-1,-i respectively, we get:

 0123 0 0000 1 0031 2 0103 3 0310 

For this we first check if either number is 0 by doing m*y, taking care of the left column and top row. Adding in (m-y)%3 then gives:

 0123 0 0000 1 0021 2 0102 3 0210 

which is close, except that we have 2 instead of 3. We account for this by performing *3/2.

For indexing, we notice that if we take the string "--i" and select every second character starting from indices 0123 we get "-i","-","i","".

deleted 4 characters in body
Source Link
Sp3000
  • 62.3k
  • 13
  • 117
  • 292

Python 2, 108 8989 87 bytes

x=y=0 for m in map(int,raw_input()):x+=m*y and(m-y)%3*3/2;y^=m print"-i"[x%4<2-i"[3-x%4:1+x%2]+`y`:2]+`y` 

Calculating the base matrix is really nice, but getting the coefficient/output format isn't.

(Thanks to @grc for helping out in chat)

Python 2, 108 89 bytes

x=y=0 for m in map(int,raw_input()):x+=m*y and(m-y)%3*3/2;y^=m print"-i"[x%4<2:1+x%2]+`y` 

Calculating the base matrix is really nice, but getting the coefficient/output format isn't.

(Thanks to @grc for helping out in chat)

Python 2, 108 89 87 bytes

x=y=0 for m in map(int,raw_input()):x+=m*y and(m-y)%3*3/2;y^=m print"--i"[3-x%4::2]+`y` 

Calculating the base matrix is really nice, but getting the coefficient/output format isn't.

(Thanks to @grc for helping out in chat)

deleted 4 characters in body
Source Link
Sp3000
  • 62.3k
  • 13
  • 117
  • 292
Loading
deleted 8 characters in body
Source Link
Sp3000
  • 62.3k
  • 13
  • 117
  • 292
Loading
Source Link
Sp3000
  • 62.3k
  • 13
  • 117
  • 292
Loading