Skip to main content
added 19 characters in body
Source Link
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372

Octave / Matlab, 74 6764 bytes

Rejection method, 6764 bytes:

u=1;v=1;while hypot(u,v)>1u^2+v^2>1
u=rand;v=rand;end
sprintf('(%f,%f)',u,v)

Direct method, 74 bytes (thanks to Martin Büttner for helping me correct two errors):

t=rand*2*pi;r=1-abs(1-sum(rand(2,1)));sprintf('(%f,%f)',r*cos(t),r*sin(t))

Octave / Matlab, 74 67 bytes

Rejection method, 67 bytes:

u=1;v=1;while hypot(u,v)>1
u=rand;v=rand;end
sprintf('(%f,%f)',u,v)

Direct method, 74 bytes (thanks Martin Büttner for helping me correct errors):

t=rand*2*pi;r=1-abs(1-sum(rand(2,1)));sprintf('(%f,%f)',r*cos(t),r*sin(t))

Octave / Matlab, 74 64 bytes

Rejection method, 64 bytes:

u=1;v=1;while u^2+v^2>1
u=rand;v=rand;end
sprintf('(%f,%f)',u,v)

Direct method, 74 bytes (thanks to Martin Büttner for helping me correct two errors):

t=rand*2*pi;r=1-abs(1-sum(rand(2,1)));sprintf('(%f,%f)',r*cos(t),r*sin(t))
added 19 characters in body
Source Link
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372

Octave / Matlab, 5674 67 bytes

Rejection method, 67 bytes:

t=rand*2*pi;u=rand;sprintfu=1;v=1;while hypot(u,v)>1
u=rand;v=rand;end
sprintf('(%f,%f)',u*cosu,v)

Direct method, 74 bytes (thanks Martin Büttner for helping me correct errors):

t=rand*2*pi;r=1-abs(1-sum(rand(2,1)));sprintf('(%f,%f)',r*cos(t),u*sinr*sin(t))

Octave / Matlab, 56 bytes

t=rand*2*pi;u=rand;sprintf('(%f,%f)',u*cos(t),u*sin(t))

Octave / Matlab, 74 67 bytes

Rejection method, 67 bytes:

u=1;v=1;while hypot(u,v)>1
u=rand;v=rand;end
sprintf('(%f,%f)',u,v)

Direct method, 74 bytes (thanks Martin Büttner for helping me correct errors):

t=rand*2*pi;r=1-abs(1-sum(rand(2,1)));sprintf('(%f,%f)',r*cos(t),r*sin(t))
added 21 characters in body
Source Link
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372

Octave / Matlab, 56 bytes

t=rand*2*pi;sprintft=rand*2*pi;u=rand;sprintf('(%f,%f)',cosu*cos(t),sinu*sin(t))

Octave / Matlab

t=rand*2*pi;sprintf('(%f,%f)',cos(t),sin(t))

Octave / Matlab, 56 bytes

t=rand*2*pi;u=rand;sprintf('(%f,%f)',u*cos(t),u*sin(t))
Source Link
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372
Loading