Skip to main content
added 298 characters in body
Source Link
l4m2
  • 28.5k
  • 12
  • 14

Given a black-box function f(x) which take a value x and output true for \$p(x)\$, an unknown continious monotone function(not knowing even whether it's increasing), probable; and false otherwise. Output an infinite sequence \$a_n\$ such that \$\lim_{n\rightarrow \infty}p(a_n)=0.5\$. You can assume that the result exists.

Reasonable I/O allowed. Shortest code win.

A possible solution:

for i=1..infty
    S = [i/2] * i*i*2
    for j=0..i*i*2-1
        for k=1..i
            if f(j/i-i)
                S[j]--
    print minPos([t*t for t in S])/i-i

Try It Online!

Given a black-box function f(x) which take a value x and output true for \$p(x)\$, an unknown continious monotone function(not knowing even whether it's increasing), probable; and false otherwise. Output an infinite sequence \$a_n\$ such that \$\lim_{n\rightarrow \infty}p(a_n)=0.5\$. You can assume that the result exists.

Reasonable I/O allowed. Shortest code win.

A possible solution:

for i=1..infty
    S = [i/2] * i*i*2
    for j=0..i*i*2-1
        for k=1..i
            if f(j/i-i)
                S[j]--
    print minPos([t*t for t in S])/i-i

Given a black-box function f(x) which take a value x and output true for \$p(x)\$, an unknown continious monotone function(not knowing even whether it's increasing), probable; and false otherwise. Output an infinite sequence \$a_n\$ such that \$\lim_{n\rightarrow \infty}p(a_n)=0.5\$. You can assume that the result exists.

Reasonable I/O allowed. Shortest code win.

A possible solution:

for i=1..infty
    S = [i/2] * i*i*2
    for j=0..i*i*2-1
        for k=1..i
            if f(j/i-i)
                S[j]--
    print minPos([t*t for t in S])/i-i

Try It Online!

deleted 43 characters in body
Source Link
l4m2
  • 28.5k
  • 12
  • 14

Given a black-box function f(x) which take a value x and output true for \$p(x)\$, an unknown continious monotone function(not knowing even whether it's increasing), probable; and false otherwise. Output an infinite sequence \$a_n\$ such that \$\lim_{n\rightarrow \infty}p(a_n)=0.5\$. You can assume that the result exists and \$\lim_{n\rightarrow \infty}a_n\$ lay in \$(0,1)\$.

Reasonable I/O allowed. Shortest code win.

A possible solution:

for i=1..infty
    S = [i/2] * ii*i*2
    for j=0..ii*i*2-1
        for k=1..i
            if f(j/i-i)
                S[j]--
    print minPos([t*t for t in S])/i-i

Given a black-box function f(x) which take a value x and output true for \$p(x)\$, an unknown continious monotone function(not knowing even whether it's increasing), probable; and false otherwise. Output an infinite sequence \$a_n\$ such that \$\lim_{n\rightarrow \infty}p(a_n)=0.5\$. You can assume that the result exists and \$\lim_{n\rightarrow \infty}a_n\$ lay in \$(0,1)\$.

Reasonable I/O allowed. Shortest code win.

A possible solution:

for i=1..infty
    S = [i/2] * i
    for j=0..i-1
        for k=1..i
            if f(j/i)
                S[j]--
    print minPos([t*t for t in S])/i

Given a black-box function f(x) which take a value x and output true for \$p(x)\$, an unknown continious monotone function(not knowing even whether it's increasing), probable; and false otherwise. Output an infinite sequence \$a_n\$ such that \$\lim_{n\rightarrow \infty}p(a_n)=0.5\$. You can assume that the result exists.

Reasonable I/O allowed. Shortest code win.

A possible solution:

for i=1..infty
    S = [i/2] * i*i*2
    for j=0..i*i*2-1
        for k=1..i
            if f(j/i-i)
                S[j]--
    print minPos([t*t for t in S])/i-i

added 46 characters in body
Source Link
l4m2
  • 28.5k
  • 12
  • 14

Given a black-box function f(x) which take a value x and output true for \$p(x)\$, an unknown continious monotone function(not knowing even whether it's increasing), probable; and false otherwise. Output an infinite sequence \$a_n\$ such that \$\lim_{n\rightarrow \infty}p(a_n)=0.5\$. You can assume that the result exists and \$\lim_{n\rightarrow \infty}a_n\$ lay in \$(0,1)\$.

Reasonable I/O allowed. Shortest code win.

A possible solution:

for i=1..infty
    S = [i/2] * i
    for j=0..i-1
        for k=1..i
            if f(j/i)
                S[j]--
    print minPos([t*t for t in S])/i

Given a black-box function f(x) which take a value x and output true for \$p(x)\$, an unknown continious monotone function(not knowing even whether it's increasing), probable; and false otherwise. Output an infinite sequence \$a_n\$ such that \$\lim_{n\rightarrow \infty}p(a_n)=0.5\$. You can assume that the result exists and \$\lim_{n\rightarrow \infty}a_n\$ lay in \$(0,1)\$.

A possible solution:

for i=1..infty
    S = [i/2] * i
    for j=0..i-1
        for k=1..i
            if f(j/i)
                S[j]--
    print minPos([t*t for t in S])/i

Given a black-box function f(x) which take a value x and output true for \$p(x)\$, an unknown continious monotone function(not knowing even whether it's increasing), probable; and false otherwise. Output an infinite sequence \$a_n\$ such that \$\lim_{n\rightarrow \infty}p(a_n)=0.5\$. You can assume that the result exists and \$\lim_{n\rightarrow \infty}a_n\$ lay in \$(0,1)\$.

Reasonable I/O allowed. Shortest code win.

A possible solution:

for i=1..infty
    S = [i/2] * i
    for j=0..i-1
        for k=1..i
            if f(j/i)
                S[j]--
    print minPos([t*t for t in S])/i

added 2 characters in body
Source Link
l4m2
  • 28.5k
  • 12
  • 14
Loading
added 34 characters in body
Source Link
l4m2
  • 28.5k
  • 12
  • 14
Loading
deleted 8 characters in body
Source Link
l4m2
  • 28.5k
  • 12
  • 14
Loading
added 1 character in body
Source Link
l4m2
  • 28.5k
  • 12
  • 14
Loading
added 216 characters in body
Source Link
l4m2
  • 28.5k
  • 12
  • 14
Loading
added 11 characters in body
Source Link
l4m2
  • 28.5k
  • 12
  • 14
Loading
Source Link
l4m2
  • 28.5k
  • 12
  • 14
Loading