Goal: Create the smallest possible code to open a separate window, in which there are 100 circles of random sizes and colors.

Rules: All circles must be visible to the unassisted, naked eye, so in other words more than 2 pixels across, the background must be black, at least 5 different colors must be recognizable, and at all circles must fit within the window.


closed as unclear what you're asking by Rɪᴋᴇʀ, Nathan Merrill, Value Ink, Marv, NinjaBearMonkey May 8 '16 at 1:37

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    \$\begingroup\$ what do you mean by random sizes? what size should the window be? Can they be overlapping? Do the positions have to be random? Does it have to be filled or only have an outline? \$\endgroup\$ – Maltysen May 8 '16 at 0:18
  • 2
    \$\begingroup\$ Bash, 5 bytes. feh f Must be ran in a directory containg a file named 'f' that is an image containing 100 circles of random sizes and colors, and feh must be installed. This is technically not against the rules since their aren't any. \$\endgroup\$ – DJMcMayhem May 8 '16 at 0:23
  • \$\begingroup\$ I like the challange but as it stands, this is way to broad. As @DrGreenEggsandHamDJ said, you should definitely think about some limiting rules. \$\endgroup\$ – Marv May 8 '16 at 1:32

Mathematica 106 bytes

The code is fairly straightforward. A palette is a floating window. The 100 circles are stored in an array. The first ryields coordinates; the second r yields a radius.




Java, 352 Bytes

Yeah, I know, an applet, but still...

import java.applet.*;import java.awt.*;import java.util.*;public class C extends Applet{public void paint(Graphics a){Random b=new Random();int x,y,diameter;setBackground(Color.black);for(int c=1;c<=100;c++){a.setColor(new Color(b.nextInt(0xFFFFFF)));d=b.nextInt(getWidth()/10);x1=b.nextInt(getWidth());y1=b.nextInt(getHeight());a.drawOval(x,y,d,d);}}}

Ungolfed Code:

import java.applet.*;
import java.awt.*;
import java.util.*;

public class C extends Applet {
    public void paint(Graphics a) {

        Random b = new Random();

        int x, y, d;


        for (int c = 1; c <= 100; c++) {
            a.setColor(new Color(b.nextInt(0xFFFFFF)));

            d = b.nextInt(getWidth() / 10);
            x = b.nextInt(getWidth());
            y = b.nextInt(getHeight());

            a.drawOval(x, y, d, d);

  • \$\begingroup\$ @EᴀsᴛᴇʀʟʏIʀᴋ Nope. \$\endgroup\$ – Nic Hartley May 8 '16 at 0:11
  • \$\begingroup\$ Have you tried using Math.random()*getWidth() in place of b.nextInt(getWidth())? It may save you a few bytes (you'd remove the Random b definition too) \$\endgroup\$ – Nic Hartley May 8 '16 at 0:14
  • \$\begingroup\$ how about c<101 rather than c<=100 \$\endgroup\$ – Bald Bantha May 9 '16 at 15:39

Python 2 PIL - 199 bytes

Making some assumptions of the rules based on OP's answer. Not optimally golfed in the sense that the image could be 5 pixels across and the circles could be all the same place with grayscale colors, but goes with the spirit of the rules.

import Image,ImageDraw,random

Not the answer you're looking for? Browse other questions tagged or ask your own question.