Skip to main content
replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

This is a solution I modified from my answermy answer for another Hilbert curve question herehere. Any golfing tips are appreciated.

This is a solution I modified from my answer for another Hilbert curve question here. Any golfing tips are appreciated.

This is a solution I modified from my answer for another Hilbert curve question here. Any golfing tips are appreciated.

More golfing
Source Link
Sherlock9
  • 12.4k
  • 1
  • 32
  • 68

Python 3, 327 289 275 271 239 235234 bytes

def h(s): t=[s[0][0]];x=y=g=0;b="A" for j in range(len(bin(len(s)))-3):b=b.translate({65:"-BF+AFA+FB-",66:"+AF-BFB-FA+"}) for c in b:g+=(c<"-")-(c=="-");a=c=="F";x;a=c>"B";x,y=[[x,y],[[x+1-g%4,y],[x,y+g%4-2]][g%2]][a];t+=[s[x][y]]*a return t 

Python 3, 327 289 275 271 239 235 bytes

def h(s): t=[s[0][0]];x=y=g=0;b="A" for j in range(len(bin(len(s)))-3):b=b.translate({65:"-BF+AFA+FB-",66:"+AF-BFB-FA+"}) for c in b:g+=(c<"-")-(c=="-");a=c=="F";x,y=[[x,y],[[x+1-g%4,y],[x,y+g%4-2]][g%2]][a];t+=[s[x][y]]*a return t 

Python 3, 327 289 275 271 239 234 bytes

def h(s): t=[s[0][0]];x=y=g=0;b="A" for j in range(len(bin(len(s)))-3):b=b.translate({65:"-BF+AFA+FB-",66:"+AF-BFB-FA+"}) for c in b:g+=(c<"-")-(c=="-");a=c>"B";x,y=[[x,y],[[x+1-g%4,y],[x,y+g%4-2]][g%2]][a];t+=[s[x][y]]*a return t 
More golfing
Source Link
Sherlock9
  • 12.4k
  • 1
  • 32
  • 68

Python 3, 327 289 275 271 239239 235 bytes

def h(s): t=[s[0][0]];x=y=g=0;b="A" for j in range(len(bin(len(s)))-3):b=b.translate({65:"-BF+AFA+FB-",66:"+AF-BFB-FA+"}) for c in b:g+=(c=="+"c<"-")-(c=="-");a=c=="F";x,y=[[x+1y=[[x,y],[[x+1-g%4,y],[x,y+g%4-2]][g%2]if a else(x,y);t+=[s[x][y]]*a2]][g%2]][a];t+=[s[x][y]]*a return t 

Python 3, 327 289 275 271 239 bytes

def h(s): t=[s[0][0]];x=y=g=0;b="A" for j in range(len(bin(len(s)))-3):b=b.translate({65:"-BF+AFA+FB-",66:"+AF-BFB-FA+"}) for c in b:g+=(c=="+")-(c=="-");a=c=="F";x,y=[[x+1-g%4,y],[x,y+g%4-2]][g%2]if a else(x,y);t+=[s[x][y]]*a return t 

Python 3, 327 289 275 271 239 235 bytes

def h(s): t=[s[0][0]];x=y=g=0;b="A" for j in range(len(bin(len(s)))-3):b=b.translate({65:"-BF+AFA+FB-",66:"+AF-BFB-FA+"}) for c in b:g+=(c<"-")-(c=="-");a=c=="F";x,y=[[x,y],[[x+1-g%4,y],[x,y+g%4-2]][g%2]][a];t+=[s[x][y]]*a return t 
Rollback to Revision 6
Source Link
Sherlock9
  • 12.4k
  • 1
  • 32
  • 68
Loading
More golfing
Source Link
Sherlock9
  • 12.4k
  • 1
  • 32
  • 68
Loading
Editing the explanation
Source Link
Sherlock9
  • 12.4k
  • 1
  • 32
  • 68
Loading
More golfing
Source Link
Sherlock9
  • 12.4k
  • 1
  • 32
  • 68
Loading
More golfing
Source Link
Sherlock9
  • 12.4k
  • 1
  • 32
  • 68
Loading
More golfing
Source Link
Sherlock9
  • 12.4k
  • 1
  • 32
  • 68
Loading
More golfing
Source Link
Sherlock9
  • 12.4k
  • 1
  • 32
  • 68
Loading
Source Link
Sherlock9
  • 12.4k
  • 1
  • 32
  • 68
Loading