Skip to main content
added 6 characters in body
Source Link
Eliseo D'Annunzio
  • 7.6k
  • 1
  • 37
  • 76

JavaScript 127ES6 125 - 10 (30 character lines) - 50 (shifts toward middle) = 6765

I had an epiphany going up the lift to my unit, so I had to get it down before it left my memory...

z=(j=Array(t=29).join`_`)+"."+j;x=(r=Math.random)()*t;for(i=30;i--;)console.log(z.substr(x=(x+=r()<x/t?-1:1)>t?t:x<0?0:x,30)) 

A little variable positional shuffling and a little creativity for calculating the shift probability indicated by x/t... (Thanks Kostronor for pointing it out!) I now gain the -50 bonus for shift to the middle, and I also made the starting position within the full range of the line, which allowed me to shave two bytes!

z=(j=Array(t=29).join("_"))+"."+j;x=(r=Math.random)()*t;for(i=30;i--;)console.log(z.substr(x=(x+=r()<x/t?-1:1)>t?t:x<0?0:x,30))

....5....0....5....0....5....0 <-- Ruler _.____________________________ __.___________________________ ___.__________________________ __.___________________________ ___.__________________________ __.___________________________ _.____________________________ __.___________________________ ___.__________________________ __.___________________________ ___.__________________________ ____._________________________ _____.________________________ ______._______________________ _______.______________________ ________._____________________ _______.______________________ ______._______________________ _______.______________________ ________._____________________ _______.______________________ ________._____________________ _________.____________________ __________.___________________ _________.____________________ __________.___________________ ___________.__________________ ____________._________________ _____________.________________ ______________._______________ 

JavaScript 127 - 10 (30 character lines) - 50 (shifts toward middle) = 67

I had an epiphany going up the lift to my unit, so I had to get it down before it left my memory...

A little variable positional shuffling and a little creativity for calculating the shift probability indicated by x/t... (Thanks Kostronor for pointing it out!) I now gain the -50 bonus for shift to the middle, and I also made the starting position within the full range of the line, which allowed me to shave two bytes!

z=(j=Array(t=29).join("_"))+"."+j;x=(r=Math.random)()*t;for(i=30;i--;)console.log(z.substr(x=(x+=r()<x/t?-1:1)>t?t:x<0?0:x,30))

....5....0....5....0....5....0 <-- Ruler _.____________________________ __.___________________________ ___.__________________________ __.___________________________ ___.__________________________ __.___________________________ _.____________________________ __.___________________________ ___.__________________________ __.___________________________ ___.__________________________ ____._________________________ _____.________________________ ______._______________________ _______.______________________ ________._____________________ _______.______________________ ______._______________________ _______.______________________ ________._____________________ _______.______________________ ________._____________________ _________.____________________ __________.___________________ _________.____________________ __________.___________________ ___________.__________________ ____________._________________ _____________.________________ ______________._______________ 

JavaScript ES6 125 - 10 (30 character lines) - 50 (shifts toward middle) = 65

I had an epiphany going up the lift to my unit, so I had to get it down before it left my memory...

z=(j=Array(t=29).join`_`)+"."+j;x=(r=Math.random)()*t;for(i=30;i--;)console.log(z.substr(x=(x+=r()<x/t?-1:1)>t?t:x<0?0:x,30)) 

A little variable positional shuffling and a little creativity for calculating the shift probability indicated by x/t... (Thanks Kostronor for pointing it out!) I now gain the -50 bonus for shift to the middle, and I also made the starting position within the full range of the line, which allowed me to shave two bytes!

....5....0....5....0....5....0 <-- Ruler _.____________________________ __.___________________________ ___.__________________________ __.___________________________ ___.__________________________ __.___________________________ _.____________________________ __.___________________________ ___.__________________________ __.___________________________ ___.__________________________ ____._________________________ _____.________________________ ______._______________________ _______.______________________ ________._____________________ _______.______________________ ______._______________________ _______.______________________ ________._____________________ _______.______________________ ________._____________________ _________.____________________ __________.___________________ _________.____________________ __________.___________________ ___________.__________________ ____________._________________ _____________.________________ ______________._______________ 
added 455 characters in body
Source Link
Eliseo D'Annunzio
  • 7.6k
  • 1
  • 37
  • 76

JavaScript 129127 - 10 (30 character lines) - 50 (shifts toward middle) = 9967

I had an epiphany going up the lift to my unit, so I had to get it down before it left my memory...

A little variable positional shuffling and a little creativity for calculating the shift probability indicated by r=Math.random;x=15+r()*2;z=x/t... (Thanks Kostronor for pointing it out!) I now gain the -50 bonus for shift to the middle, and I also made the starting position within the full range of the line, which allowed me to shave two bytes!

z=(j=Array(29t=29).join("_"))+"."+j;for"+j;x=(r=Math.random)()*t;for(i=30;i--;)console.log(z.substr(x=(x+=r()<.5<x/t?-1:1)>29>t?29t:x<0?0:x,30))

....5....0....5....0....5....0 <-- Ruler ____________.______________________________________________ ______________.____________________________________________ ________________.__________________________________________ ________________.__________________________________________ __________________.________________________________________ __________________.________________________________________ ________________.__________________________________________ __________________.________________________________________ ____________________.______________________________________ ____________________.______________________________________ ______________________.____________________________________ ______________________.____________________________________ ________________________.__________________________________ __________________________.________________________________ __________________________.________________________________ __________________________.________________________________ __________________________.________________________________ ________________________.__________________________________ __________________________.________________________________ __________________________.________________________________ ________________________.__________________________________ ________________________.__________________________________ ________________________.__________________________________ ________________________.__________________________________ ________________________.__________________________________ ________________________.__________________________________ __________________________.________________________________ ____________________________.______________________________ ____________________________.______________________________ ______________._______________ 

JavaScript 129 - 10 (30 character lines) = 99

r=Math.random;x=15+r()*2;z=(j=Array(29).join("_"))+"."+j;for(i=30;i--;)console.log(z.substr(x=(x+=r()<.5?-1:1)>29?29:x<0?0:x,30))

....5....0....5....0....5....0 <-- Ruler ___________.__________________ ____________._________________ _____________.________________ ______________._______________ _______________.______________ ________________._____________ _______________.______________ ________________._____________ _________________.____________ __________________.___________ ___________________.__________ __________________.___________ ___________________.__________ ____________________._________ ___________________.__________ __________________.___________ ___________________.__________ __________________.___________ ___________________.__________ __________________.___________ _________________.____________ ________________._____________ _______________.______________ ______________._______________ _______________.______________ ______________._______________ _______________.______________ ________________._____________ _______________.______________ ______________._______________ 

JavaScript 127 - 10 (30 character lines) - 50 (shifts toward middle) = 67

I had an epiphany going up the lift to my unit, so I had to get it down before it left my memory...

A little variable positional shuffling and a little creativity for calculating the shift probability indicated by x/t... (Thanks Kostronor for pointing it out!) I now gain the -50 bonus for shift to the middle, and I also made the starting position within the full range of the line, which allowed me to shave two bytes!

z=(j=Array(t=29).join("_"))+"."+j;x=(r=Math.random)()*t;for(i=30;i--;)console.log(z.substr(x=(x+=r()<x/t?-1:1)>t?t:x<0?0:x,30))

....5....0....5....0....5....0 <-- Ruler _.____________________________ __.___________________________ ___.__________________________ __.___________________________ ___.__________________________ __.___________________________ _.____________________________ __.___________________________ ___.__________________________ __.___________________________ ___.__________________________ ____._________________________ _____.________________________ ______._______________________ _______.______________________ ________._____________________ _______.______________________ ______._______________________ _______.______________________ ________._____________________ _______.______________________ ________._____________________ _________.____________________ __________.___________________ _________.____________________ __________.___________________ ___________.__________________ ____________._________________ _____________.________________ ______________._______________ 
deleted 26 characters in body
Source Link
Eliseo D'Annunzio
  • 7.6k
  • 1
  • 37
  • 76

JavaScript 129 - 10 (30 character lines) - 50 (focusing in middle) = 6999

r=Math.random;x=15+r()*2;z=(j=Array(29).join("_"))+"."+j;for(i=30;i--;)console.log(z.substr(x=(x+=r()<.5?-1:1)>29?29:x<0?0:x,30))

....5....0....5....0....5....0 <-- Ruler ___________.__________________ ____________._________________ _____________.________________ ______________._______________ _______________.______________ ________________._____________ _______________.______________ ________________._____________ _________________.____________ __________________.___________ ___________________.__________ __________________.___________ ___________________.__________ ____________________._________ ___________________.__________ __________________.___________ ___________________.__________ __________________.___________ ___________________.__________ __________________.___________ _________________.____________ ________________._____________ _______________.______________ ______________._______________ _______________.______________ ______________._______________ _______________.______________ ________________._____________ _______________.______________ ______________._______________ 

JavaScript 129 - 10 (30 character lines) - 50 (focusing in middle) = 69

r=Math.random;x=15+r()*2;z=(j=Array(29).join("_"))+"."+j;for(i=30;i--;)console.log(z.substr(x=(x+=r()<.5?-1:1)>29?29:x<0?0:x,30))

....5....0....5....0....5....0 <-- Ruler ___________.__________________ ____________._________________ _____________.________________ ______________._______________ _______________.______________ ________________._____________ _______________.______________ ________________._____________ _________________.____________ __________________.___________ ___________________.__________ __________________.___________ ___________________.__________ ____________________._________ ___________________.__________ __________________.___________ ___________________.__________ __________________.___________ ___________________.__________ __________________.___________ _________________.____________ ________________._____________ _______________.______________ ______________._______________ _______________.______________ ______________._______________ _______________.______________ ________________._____________ _______________.______________ ______________._______________ 

JavaScript 129 - 10 (30 character lines) = 99

r=Math.random;x=15+r()*2;z=(j=Array(29).join("_"))+"."+j;for(i=30;i--;)console.log(z.substr(x=(x+=r()<.5?-1:1)>29?29:x<0?0:x,30))

....5....0....5....0....5....0 <-- Ruler ___________.__________________ ____________._________________ _____________.________________ ______________._______________ _______________.______________ ________________._____________ _______________.______________ ________________._____________ _________________.____________ __________________.___________ ___________________.__________ __________________.___________ ___________________.__________ ____________________._________ ___________________.__________ __________________.___________ ___________________.__________ __________________.___________ ___________________.__________ __________________.___________ _________________.____________ ________________._____________ _______________.______________ ______________._______________ _______________.______________ ______________._______________ _______________.______________ ________________._____________ _______________.______________ ______________._______________ 
Source Link
Eliseo D'Annunzio
  • 7.6k
  • 1
  • 37
  • 76
Loading