Draw lines between every pair of distinct points for n points arranged in a circle, producing something like the below result. Shortest code (in bytes) wins! Your lines don't have to be transparent, but it looks better that way. The output must be a vector graphic, or be an image at least 600 pixels by 600 pixels (either saved to a file or displayed on the screen). To complete the challenge you must draw at least 20.
|
|
||||
|
Mathematica, 13 bytes
Looks like this only fails to give a circular embedding for |
|||||||||||||||||||||
|
MATL,
|
|
|
|||
|
|
|||
|
|
Java,
|
|
|
|||
|
|
@shooqie oops,
Frame x was from another solution that involved a thread. You need the final though as it's an internal class reference to an external variable in the owning class.
– carusocomputing
13 hours ago
|
||
|
|
It works just fine on my machine. BTW I think you can shave off some bytes by moving
int declarations outside the for loops
– shooqie
13 hours ago
|
||
|
|
@shooqie in Java 6 it's saying "Cannot refer to the non-final local variable n in an enclosing scope" at compile time.
– carusocomputing
12 hours ago
|
||
|
|
It worked for me on Java 8, but after you edited your post I'm only getting white screen.
– shooqie
12 hours ago
|
Mathematica, 42 bytesCreates a set of 37 points arranged in a circle, and then draws lines between all possible subsets of two points. Someone posted a shorter answer that takes advantage of CompleteGraph, but I believe this is the shortest one aside from those relying on CompleteGraph.
|
|||||||||
|
Octave,
|
|
|
|||
|
|
HTML + JS (ES6), 34 +
|
Python 2,
|
Perl, 230 bytesIt uses the same formula as most languages that don't have convenient builtin for this challenge (even if I didn't look at them to find it, but that's a fairly easy to find formula). So not very interesting, but there are usually not a lot of Perl answers to this kind of challenges, so I just wanted to propose one.
And you'll need To run it :
It will create a file named You'll need to install
(The And the more readable version (yes, it's fairly readable for a Perl script!) :
|
||||
|
|
PHP,
|
|
|
BBC BASIC, 98 ascii charactersTokenised filesize 86 bytes
Dowload interpreter at http://www.bbcbasic.co.uk/bbcwin/bbcwin.html There's nothing wrong with drawing every line twice, the appearance is identical :-P Ungolfed
Output n=21 This looks much better in the original rendering than in the browser. |
|||||
|
Octave,
|
PICO-8, 131 bytesI wasn't really sure if I'd be breaking any rules, but I did it anyway! Golfed
Ungolfed
PICO-8 is a Lua based fantasy console with a native resolution of 128x128. I made the circle as big as I could... |
|||
|
|
QBIC, 98 bytes
I've converted When run with a command line parameter of 36, it looks like this: |
||||
|
|
GeoGebra, 91 bytes
Each line is separately entered into the input bar. Here is a gif showing the execution: How it works The |
|||
|
|

















nand draw lines fornpoints. – Yodle 13 hours agonwould add much to the challenge as I expect most solutions to work with any number anyway, especially because 37 is odd and hence there are no mirror symmetries. – Laikoni 13 hours agonas input or just pick an arbitrarynover 20? – Easterly Irk 13 hours ago