Skip to main content
deleted 4 characters in body
Source Link
Noodle9
  • 20.3k
  • 3
  • 21
  • 46

Python 3, 199 \$\cdots\$ 182 173 bytes

f=lambda s,n=0:s<'.'and f(s[1:],1-n)or len(s)>1and f(s<'2'and s[1:]or(s[0]==s[1]and'-1'or{'ij':'k','jk':'i','ki':'j','ji':'-k','kj':'-i','ik':'-j'}[s[:2]])+s[2:],n)or'-'*n+s

Try it online!

Slightly longer version without direct mappings of \$i\$, \$j\$, and \$k\$ inter-multiplications:

Python 3.8, 176174 bytes

f=lambda s,n=0,o='ijkijki':s<'.'and f(s[1:],1-n)or len(s)>1and f(s<'2'and s[1:]or(s[0]==s[1]and'-1'or((b:=o.find(s[1],(a:=o.find(s[0]))+1))-a-1)*'-'+o[2*b-a])+s[2:],n)or'-'*n+s

Try it online!Try it online!

Python 3, 199 \$\cdots\$ 182 173 bytes

f=lambda s,n=0:s<'.'and f(s[1:],1-n)or len(s)>1and f(s<'2'and s[1:]or(s[0]==s[1]and'-1'or{'ij':'k','jk':'i','ki':'j','ji':'-k','kj':'-i','ik':'-j'}[s[:2]])+s[2:],n)or'-'*n+s

Try it online!

Slightly longer version without direct mappings of \$i\$, \$j\$, and \$k\$ inter-multiplications:

Python 3.8, 176 bytes

f=lambda s,n=0,o='ijkijki':s<'.'and f(s[1:],1-n)or len(s)>1and f(s<'2'and s[1:]or(s[0]==s[1]and'-1'or((b:=o.find(s[1],(a:=o.find(s[0]))+1))-a-1)*'-'+o[2*b-a])+s[2:],n)or'-'*n+s

Try it online!

Python 3, 199 \$\cdots\$ 182 173 bytes

f=lambda s,n=0:s<'.'and f(s[1:],1-n)or len(s)>1and f(s<'2'and s[1:]or(s[0]==s[1]and'-1'or{'ij':'k','jk':'i','ki':'j','ji':'-k','kj':'-i','ik':'-j'}[s[:2]])+s[2:],n)or'-'*n+s

Try it online!

Slightly longer version without direct mappings of \$i\$, \$j\$, and \$k\$ inter-multiplications:

Python 3.8, 174 bytes

f=lambda s,n=0,o='ijkijki':s<'.'and f(s[1:],1-n)or len(s)>1and f(s<'2'and s[1:]or(s[0]==s[1]and'-1'or((b:=o.find(s[1],(a:=o.find(s[0]))))-a-1)*'-'+o[2*b-a])+s[2:],n)or'-'*n+s

Try it online!

added 890 characters in body
Source Link
Noodle9
  • 20.3k
  • 3
  • 21
  • 46

Python 3, 199 \$\cdots\$ 182 173 bytes

f=lambda s,n=0:s<'.'and f(s[1:],1-n)or len(s)>1and f(s<'2'and s[1:]or(s[0]==s[1]and'-1'or{'ij':'k','jk':'i','ki':'j','ji':'-k','kj':'-i','ik':'-j'}[s[:2]])+s[2:],n)or'-'*n+s

Try it online!

Slightly longer version without direct mappings of \$i\$, \$j\$, and \$k\$ inter-multiplications:

Python 3.8, 176 bytes

f=lambda s,n=0,o='ijkijki':s<'.'and f(s[1:],1-n)or len(s)>1and f(s<'2'and s[1:]or(s[0]==s[1]and'-1'or((b:=o.find(s[1],(a:=o.find(s[0]))+1))-a-1)*'-'+o[2*b-a])+s[2:],n)or'-'*n+s

Try it online!

Python 3, 199 \$\cdots\$ 182 173 bytes

f=lambda s,n=0:s<'.'and f(s[1:],1-n)or len(s)>1and f(s<'2'and s[1:]or(s[0]==s[1]and'-1'or{'ij':'k','jk':'i','ki':'j','ji':'-k','kj':'-i','ik':'-j'}[s[:2]])+s[2:],n)or'-'*n+s

Try it online!

Python 3, 199 \$\cdots\$ 182 173 bytes

f=lambda s,n=0:s<'.'and f(s[1:],1-n)or len(s)>1and f(s<'2'and s[1:]or(s[0]==s[1]and'-1'or{'ij':'k','jk':'i','ki':'j','ji':'-k','kj':'-i','ik':'-j'}[s[:2]])+s[2:],n)or'-'*n+s

Try it online!

Slightly longer version without direct mappings of \$i\$, \$j\$, and \$k\$ inter-multiplications:

Python 3.8, 176 bytes

f=lambda s,n=0,o='ijkijki':s<'.'and f(s[1:],1-n)or len(s)>1and f(s<'2'and s[1:]or(s[0]==s[1]and'-1'or((b:=o.find(s[1],(a:=o.find(s[0]))+1))-a-1)*'-'+o[2*b-a])+s[2:],n)or'-'*n+s

Try it online!

deleted 19 characters in body
Source Link
Noodle9
  • 20.3k
  • 3
  • 21
  • 46

Python 3, 199 \$\cdots\$ 182 173 bytes

f=lambda s,n=0:s<'.'and f(s[1:],1-n)or len(s)>1and f(s<'2'and s[1:]or(s[0]==s[1]and'-1'or{'ij':'k','jk':'i','ki':'j','ji':'-k','kj':'-i','ik':'-j'}[s[:2]])+s[2:],n)or'-'*n+s

Try it online!

A bit verbose!

Python 3, 199 \$\cdots\$ 182 173 bytes

f=lambda s,n=0:s<'.'and f(s[1:],1-n)or len(s)>1and f(s<'2'and s[1:]or(s[0]==s[1]and'-1'or{'ij':'k','jk':'i','ki':'j','ji':'-k','kj':'-i','ik':'-j'}[s[:2]])+s[2:],n)or'-'*n+s

Try it online!

A bit verbose!

Python 3, 199 \$\cdots\$ 182 173 bytes

f=lambda s,n=0:s<'.'and f(s[1:],1-n)or len(s)>1and f(s<'2'and s[1:]or(s[0]==s[1]and'-1'or{'ij':'k','jk':'i','ki':'j','ji':'-k','kj':'-i','ik':'-j'}[s[:2]])+s[2:],n)or'-'*n+s

Try it online!

deleted 4 characters in body
Source Link
Noodle9
  • 20.3k
  • 3
  • 21
  • 46
Loading
deleted 4 characters in body
Source Link
Noodle9
  • 20.3k
  • 3
  • 21
  • 46
Loading
deleted 9 characters in body
Source Link
Noodle9
  • 20.3k
  • 3
  • 21
  • 46
Loading
added 6 characters in body
Source Link
Noodle9
  • 20.3k
  • 3
  • 21
  • 46
Loading
added 20 characters in body
Source Link
Noodle9
  • 20.3k
  • 3
  • 21
  • 46
Loading
Source Link
Noodle9
  • 20.3k
  • 3
  • 21
  • 46
Loading