Skip to main content
added 23 characters in body
Source Link
emanresu A
  • 44.4k
  • 25
  • 40

Bytewise look-and-say sequence

The look-and-say sequence is a sequence which begins with 1, 11, 21, 1211, 111221, 312211. To get a term of the sequence from the previous, read the previous out literally:

312211 => one three, one one, two twos,two ones => 13112221

So the next term is 13112221.

Given this javascript code (Node.js), which outputs the look-and-say sequence indefinitely (assuming it doesn't crash), delimited by newlines:

function nextTerm(x){
  return x.replace(/(.)\1*/g,z=>z.length+z[0])
}
function printUpTo(x){
  var str = '1';
  for(var i = 0; i < x; i++){
    console.log(str);str = nextTerm(str);
  }
}
printUpTo(Infinity)

It will output a string that begins 1\n11\n21\n1211\n111221 etcetera. Your job is to write a function that takes a number as input and outputs that byte of the output string.

Rules

You may output a different character for newline instead of \n, e.g. # or something.

Scoring

Your program should be able to handle 100 million.

The first answer to handle 1e+18 correctly will receive a 100-rep bounty. This cannot be hard-coded.

Standard loopholes apply.

Test cases:

1 => \n
5 => 2
10 => 1
20 => 3
50 => 3
100 => 1
1000 => 1
100000 => 3
10000000 => 1

This is , so shortest bytes wins.

Bytewise look-and-say sequence

The look-and-say sequence is a sequence which begins with 1, 11, 21, 1211, 111221, 312211. To get a term of the sequence from the previous, read the previous out literally:

312211 => one three, one one, two twos,two ones => 13112221

So the next term is 13112221.

Given this javascript code (Node.js), which outputs the look-and-say sequence indefinitely (assuming it doesn't crash):

function nextTerm(x){
  return x.replace(/(.)\1*/g,z=>z.length+z[0])
}
function printUpTo(x){
  var str = '1';
  for(var i = 0; i < x; i++){
    console.log(str);str = nextTerm(str);
  }
}
printUpTo(Infinity)

It will output a string that begins 1\n11\n21\n1211\n111221 etcetera. Your job is to write a function that takes a number as input and outputs that byte of the output string.

Rules

You may output a different character for newline instead of \n, e.g. # or something.

Scoring

Your program should be able to handle 100 million.

The first answer to handle 1e+18 correctly will receive a 100-rep bounty.

Standard loopholes apply.

Test cases:

1 => \n
5 => 2
10 => 1
20 => 3
50 => 3
100 => 1
1000 => 1
100000 => 3
10000000 => 1

This is , so shortest bytes wins.

Bytewise look-and-say sequence

The look-and-say sequence is a sequence which begins with 1, 11, 21, 1211, 111221, 312211. To get a term of the sequence from the previous, read the previous out literally:

312211 => one three, one one, two twos,two ones => 13112221

So the next term is 13112221.

Given this javascript code (Node.js), which outputs the look-and-say sequence indefinitely, delimited by newlines:

function nextTerm(x){
  return x.replace(/(.)\1*/g,z=>z.length+z[0])
}
function printUpTo(x){
  var str = '1';
  for(var i = 0; i < x; i++){
    console.log(str);str = nextTerm(str);
  }
}
printUpTo(Infinity)

It will output a string that begins 1\n11\n21\n1211\n111221 etcetera. Your job is to write a function that takes a number as input and outputs that byte of the output string.

Rules

You may output a different character for newline instead of \n, e.g. # or something.

Scoring

Your program should be able to handle 100 million.

The first answer to handle 1e+18 correctly will receive a 100-rep bounty. This cannot be hard-coded.

Standard loopholes apply.

Test cases:

1 => \n
5 => 2
10 => 1
20 => 3
50 => 3
100 => 1
1000 => 1
100000 => 3
10000000 => 1

This is , so shortest bytes wins.

added 321 characters in body
Source Link
emanresu A
  • 44.4k
  • 25
  • 40

Bytewise look-and-say sequence

The look-and-say sequence is a sequence which begins with 1, 11, 21, 1211, 111221, 312211. To get a term of the sequence from the previous, read the previous out literally:

312211 => one three, one one, two twos,two ones => 13112221

So the next term is 13112221.

Given this javascript code (Node.js), which outputs the look-and-say sequencelook-and-say sequence indefinitely (assuming it doesn't crash):

function nextTerm(x){
  return x.replace(/(.)\1*/g,z=>z.length+z[0])
}
function printUpTo(x){
  var str = '1';
  for(var i = 0; i < x; i++){
    console.log(str);str = nextTerm(str);
  }
}
printUpTo(Infinity)

It will output a string that begins 1\n11\n21\n1211\n111221 etcetera. Your job is to write a function that takes a number as input and outputs that byte of the output string.

Rules

You may output a different character for newline instead of \n, e.g. # or something.

Scoring

Your program should be able to handle 1000000000100 million.

The first answer to handle 1e+18 correctly will receive a 100-rep bounty.

Standard loopholes apply.

Test cases:

1 => \n
5 => 2
10 => 1
20 => 3
50 => 3
100 => 1
1000 => 1
100000 => 3
10000000 => 1

This is , so shortest bytes wins.

Bytewise look-and-say sequence

Given this javascript code (Node.js), which outputs the look-and-say sequence indefinitely (assuming it doesn't crash):

function nextTerm(x){
  return x.replace(/(.)\1*/g,z=>z.length+z[0])
}
function printUpTo(x){
  var str = '1';
  for(var i = 0; i < x; i++){
    console.log(str);str = nextTerm(str);
  }
}
printUpTo(Infinity)

It will output a string that begins 1\n11\n21\n1211\n111221 etcetera. Your job is to write a function that takes a number as input and outputs that byte of the output string.

Rules

You may output a different character for newline instead of \n, e.g. # or something. Your program should be able to handle 1000000000.

Standard loopholes apply.

Test cases:

1 => \n
5 => 2
10 => 1
20 => 3
50 => 3
100 => 1
1000 => 1
100000 => 3
10000000 => 1

This is , so shortest bytes wins.

Bytewise look-and-say sequence

The look-and-say sequence is a sequence which begins with 1, 11, 21, 1211, 111221, 312211. To get a term of the sequence from the previous, read the previous out literally:

312211 => one three, one one, two twos,two ones => 13112221

So the next term is 13112221.

Given this javascript code (Node.js), which outputs the look-and-say sequence indefinitely (assuming it doesn't crash):

function nextTerm(x){
  return x.replace(/(.)\1*/g,z=>z.length+z[0])
}
function printUpTo(x){
  var str = '1';
  for(var i = 0; i < x; i++){
    console.log(str);str = nextTerm(str);
  }
}
printUpTo(Infinity)

It will output a string that begins 1\n11\n21\n1211\n111221 etcetera. Your job is to write a function that takes a number as input and outputs that byte of the output string.

Rules

You may output a different character for newline instead of \n, e.g. # or something.

Scoring

Your program should be able to handle 100 million.

The first answer to handle 1e+18 correctly will receive a 100-rep bounty.

Standard loopholes apply.

Test cases:

1 => \n
5 => 2
10 => 1
20 => 3
50 => 3
100 => 1
1000 => 1
100000 => 3
10000000 => 1

This is , so shortest bytes wins.

deleted 56 characters in body
Source Link
emanresu A
  • 44.4k
  • 25
  • 40

Bytewise look-and-say sequence

Given this javascript code (Node.js), which outputs the look-and-say sequence indefinitely (assuming it doesn't crash):

function nextTerm(x){
  return x.replace(/(.)\1*/g,z=>z.length+z[0])
}
function printUpTo(x){
  var str = '1';
  for(var i = 0; i < x; i++){
    console.log(str);str = nextTerm(str);
  }
}
printUpTo(Infinity)

It will output a string that begins 1\n11\n21\n1211\n111221 etcetera. Your job is to write a function that takes a number as input and outputs that byte of the output string.

Rules

You may output a different character for newline instead of \n, e.g. # or something. Your program should be able to handle 1,000,000,000 on TIO without crashing1000000000.

Standard loopholes apply.

Test cases:

1 => \n
5 => 2
10 => 1
20 => 3
50 => 3
100 => 1
1000 => 1
100000 => 3
10000000 => 1

This is , so shortest bytes wins.

Bytewise look-and-say sequence

Given this javascript code (Node.js), which outputs the look-and-say sequence indefinitely (assuming it doesn't crash):

function nextTerm(x){
  return x.replace(/(.)\1*/g,z=>z.length+z[0])
}
function printUpTo(x){
  var str = '1';
  for(var i = 0; i < x; i++){
    console.log(str);str = nextTerm(str);
  }
}
printUpTo(Infinity)

It will output a string that begins 1\n11\n21\n1211\n111221 etcetera. Your job is to write a function that takes a number as input and outputs that byte of the output string.

Rules

You may output a different character for newline instead of \n, e.g. # or something. Your program should be able to handle 1,000,000,000 on TIO without crashing.

Standard loopholes apply.

Test cases:

1 => \n
5 => 2
10 => 1
20 => 3
50 => 3
100 => 1
1000 => 1
100000 => 3
10000000 => 1

This is , so shortest bytes wins.

Bytewise look-and-say sequence

Given this javascript code (Node.js), which outputs the look-and-say sequence indefinitely (assuming it doesn't crash):

function nextTerm(x){
  return x.replace(/(.)\1*/g,z=>z.length+z[0])
}
function printUpTo(x){
  var str = '1';
  for(var i = 0; i < x; i++){
    console.log(str);str = nextTerm(str);
  }
}
printUpTo(Infinity)

It will output a string that begins 1\n11\n21\n1211\n111221 etcetera. Your job is to write a function that takes a number as input and outputs that byte of the output string.

Rules

You may output a different character for newline instead of \n, e.g. # or something. Your program should be able to handle 1000000000.

Standard loopholes apply.

Test cases:

1 => \n
5 => 2
10 => 1
20 => 3
50 => 3
100 => 1
1000 => 1
100000 => 3
10000000 => 1

This is , so shortest bytes wins.

added 2 characters in body
Source Link
emanresu A
  • 44.4k
  • 25
  • 40
Loading
Source Link
emanresu A
  • 44.4k
  • 25
  • 40
Loading