Skip to main content
fixed a formula in the comments
Source Link
Arnauld
  • 206.5k
  • 21
  • 189
  • 673

JavaScript (V8), 87 bytes

Prints the results.

n=>{for(t=0,x=w=1e6;x--+w;t*n>15708e8&&print((x*x)**.5/1e4+.49|(t=0)))t+=(w*w-x*x)**.5}

Try it online!

NB: This gives the same results as the OP for all test cases. We may disagree for some other inputs, but I've no way of knowing.

Commented

n => {                // n = input
  for(                // loop:
    t = 0,            //   start with t = 0
    x = w = 1e6;      //   and x = w = 1000000
    x-- + w;          //   stop when x = -w (decrement x afterwards)
    t * n > 15708e8   //   if t * n > round(pi / 2 * w² / 10^8) * 10^8 ...
    &&                //
    print(            //   ... print floor(abs(x) * 100 / w + 0.49)
      (x * x) ** .5   //
      / 1e4 + .49     //
      | (t = 0)       //   and reset t to 0
    )                 //
  )                   //
    t +=              //   at each iteration, add to t:
      (w * w - x * x) //     sqrt(w² - x²)
      ** .5           //
}                     //

JavaScript (V8), 87 bytes

Prints the results.

n=>{for(t=0,x=w=1e6;x--+w;t*n>15708e8&&print((x*x)**.5/1e4+.49|(t=0)))t+=(w*w-x*x)**.5}

Try it online!

NB: This gives the same results as the OP for all test cases. We may disagree for some other inputs, but I've no way of knowing.

Commented

n => {                // n = input
  for(                // loop:
    t = 0,            //   start with t = 0
    x = w = 1e6;      //   and x = w = 1000000
    x-- + w;          //   stop when x = -w (decrement x afterwards)
    t * n > 15708e8   //   if t * n > round(pi * w² / 10^8) * 10^8 ...
    &&                //
    print(            //   ... print floor(abs(x) * 100 / w + 0.49)
      (x * x) ** .5   //
      / 1e4 + .49     //
      | (t = 0)       //   and reset t to 0
    )                 //
  )                   //
    t +=              //   add to t:
      (w * w - x * x) //     sqrt(w² - x²)
      ** .5           //
}                     //

JavaScript (V8), 87 bytes

Prints the results.

n=>{for(t=0,x=w=1e6;x--+w;t*n>15708e8&&print((x*x)**.5/1e4+.49|(t=0)))t+=(w*w-x*x)**.5}

Try it online!

NB: This gives the same results as the OP for all test cases. We may disagree for some other inputs, but I've no way of knowing.

Commented

n => {                // n = input
  for(                // loop:
    t = 0,            //   start with t = 0
    x = w = 1e6;      //   and x = w = 1000000
    x-- + w;          //   stop when x = -w (decrement x afterwards)
    t * n > 15708e8   //   if t * n > round(pi / 2 * w² / 10^8) * 10^8 ...
    &&                //
    print(            //   ... print floor(abs(x) * 100 / w + 0.49)
      (x * x) ** .5   //
      / 1e4 + .49     //
      | (t = 0)       //   and reset t to 0
    )                 //
  )                   //
    t +=              //   at each iteration, add to t:
      (w * w - x * x) //     sqrt(w² - x²)
      ** .5           //
}                     //
saved 12 bytes / fixed for the new test cases
Source Link
Arnauld
  • 206.5k
  • 21
  • 189
  • 673

JavaScript (V8), 9987 bytes

n=>{for(t=0,x=w=1100;x--+w;)for(y=w;yx=w=1e6;x--+w;t*n>3801327&&print+w;t*n>15708e8&&print((x*x)**.5/11+1e4+.5|49|(t=0)))t+=x*x+y*y<w*wt+=(w*w-x*x)**.5}

Try it online!Try it online!

n => {                // n = input
  for(                // outer loop:
    t = 0,            //   start with t = 0
    x = w = 1100;1e6;      //   and x = w = 11001000000
    x-- + w;          //   stop when x = -w (decrement x afterwards)
  )                   //
    for(              //   inner loop:
      y = w;          //     start with y = w
      y-- + w;        //     stop when y = -w (decrement y afterwards)
      t * n > 380132715708e8 //  //   if t * n > round(pi * w² / 10^8) * 10^8 ...
    &&  &&              //
      print(          //  //   ... print floor(abs(x) * 100 / w + 0.549)
        (x * x) ** .5   //
        / 111e4 + .549     //
        | (t = 0)     //  //   and reset t to 0
    )  )               //
  )  )                 //
    t +=              //     at each iteration,add incrementto t if:
      x(w * xw +- yx * y  x) //     the squared Euclidean distance between sqrt(x, y- x²)
      <** w.5 * w         //     and the center of the circle is less than w²
}                     //

JavaScript (V8), 99 bytes

n=>{for(t=0,x=w=1100;x--+w;)for(y=w;y--+w;t*n>3801327&&print((x*x)**.5/11+.5|(t=0)))t+=x*x+y*y<w*w}

Try it online!

n => {                // n = input
  for(                // outer loop:
    t = 0,            //   start with t = 0
    x = w = 1100;     //   and x = w = 1100
    x-- + w;          //   stop when x = -w (decrement x afterwards)
  )                   //
    for(              //   inner loop:
      y = w;          //     start with y = w
      y-- + w;        //     stop when y = -w (decrement y afterwards)
      t * n > 3801327 //     if t * n > round(pi * w²) ...
      &&              //
      print(          //     ... print floor(abs(x) * 100 / w + 0.5)
        (x * x) ** .5 //
        / 11 + .5     //
        | (t = 0)     //     and reset t to 0
      )               //
    )                 //
    t +=              //     at each iteration, increment t if
      x * x + y * y   //     the squared Euclidean distance between (x, y)
      < w * w         //     and the center of the circle is less than w²
}                     //

JavaScript (V8), 87 bytes

n=>{for(t=0,x=w=1e6;x--+w;t*n>15708e8&&print((x*x)**.5/1e4+.49|(t=0)))t+=(w*w-x*x)**.5}

Try it online!

n => {                // n = input
  for(                // loop:
    t = 0,            //   start with t = 0
    x = w = 1e6;      //   and x = w = 1000000
    x-- + w;          //   stop when x = -w (decrement x afterwards)
    t * n > 15708e8   //   if t * n > round(pi * w² / 10^8) * 10^8 ...
    &&                //
    print(            //   ... print floor(abs(x) * 100 / w + 0.49)
      (x * x) ** .5   //
      / 1e4 + .49     //
      | (t = 0)       //   and reset t to 0
    )                 //
  )                   //
    t +=              //   add to t:
      (w * w - x * x) //     sqrt( - x²)
      ** .5           //
}                     //
added a commented version
Source Link
Arnauld
  • 206.5k
  • 21
  • 189
  • 673
n=>{for(t=0,x=k=1100;xx=w=1100;x--+k;+w;)for(y=k;yy=w;y--+k;t*n>3801327&&print+w;t*n>3801327&&print((x*x)**.5/11+.5|(t=0)))t+=x*x+y*y<k*kt+=x*x+y*y<w*w}

Try it online!Try it online!

Commented

n => {                // n = input
  for(                // outer loop:
    t = 0,            //   start with t = 0
    x = w = 1100;     //   and x = w = 1100
    x-- + w;          //   stop when x = -w (decrement x afterwards)
  )                   //
    for(              //   inner loop:
      y = w;          //     start with y = w
      y-- + w;        //     stop when y = -w (decrement y afterwards)
      t * n > 3801327 //     if t * n > round(pi * w²) ...
      &&              //
      print(          //     ... print floor(abs(x) * 100 / w + 0.5)
        (x * x) ** .5 //
        / 11 + .5     //
        | (t = 0)     //     and reset t to 0
      )               //
    )                 //
    t +=              //     at each iteration, increment t if
      x * x + y * y   //     the squared Euclidean distance between (x, y)
      < w * w         //     and the center of the circle is less than w²
}                     //
n=>{for(t=0,x=k=1100;x--+k;)for(y=k;y--+k;t*n>3801327&&print((x*x)**.5/11+.5|(t=0)))t+=x*x+y*y<k*k}

Try it online!

n=>{for(t=0,x=w=1100;x--+w;)for(y=w;y--+w;t*n>3801327&&print((x*x)**.5/11+.5|(t=0)))t+=x*x+y*y<w*w}

Try it online!

Commented

n => {                // n = input
  for(                // outer loop:
    t = 0,            //   start with t = 0
    x = w = 1100;     //   and x = w = 1100
    x-- + w;          //   stop when x = -w (decrement x afterwards)
  )                   //
    for(              //   inner loop:
      y = w;          //     start with y = w
      y-- + w;        //     stop when y = -w (decrement y afterwards)
      t * n > 3801327 //     if t * n > round(pi * w²) ...
      &&              //
      print(          //     ... print floor(abs(x) * 100 / w + 0.5)
        (x * x) ** .5 //
        / 11 + .5     //
        | (t = 0)     //     and reset t to 0
      )               //
    )                 //
    t +=              //     at each iteration, increment t if
      x * x + y * y   //     the squared Euclidean distance between (x, y)
      < w * w         //     and the center of the circle is less than w²
}                     //
saved 1 byte
Source Link
Arnauld
  • 206.5k
  • 21
  • 189
  • 673
Loading
saved 4 bytes
Source Link
Arnauld
  • 206.5k
  • 21
  • 189
  • 673
Loading
saved 3 bytes
Source Link
Arnauld
  • 206.5k
  • 21
  • 189
  • 673
Loading
Source Link
Arnauld
  • 206.5k
  • 21
  • 189
  • 673
Loading