Movatterモバイル変換


[0]ホーム

URL:


Sorry, we no longer support your browser
Please upgrade toMicrosoft Edge,Google Chrome, orFirefox. Learn more about ourbrowser support.
Skip to main content

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities includingStack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Loading…
Code Golf

You are notlogged in. Your edit will be placed in a queue until it ispeer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Mandelbrot image in every language

I always used aMandelbrot image as the 'graphical' version of Hello World in any graphical application I got my hands on. Now it's your guys' turn.

  • Language must be capable of graphical output or drawing charts (saving image files disallowed)
  • Render a square image or graph. The size at least 128 and at most 640 across*
  • The fractal coordinates range from approximately -2-2i to 2+2i
  • The pixels outside of the Mandelbrot set should be colored according to the number of iterations before the magnitude exceeds 2 (excluding* black & white)
  • Each iteration count must have a unique color*, and neighboring colors should preferably be easily distinguishable by the eye
  • The other pixels (presumably inside the Mandelbrot set) must be colored either black or white
  • At least 99 iterations
  • ASCII art not allowed

* unless limited by the platform,e.g. graphical calculator

Allowed:
Allowed
Disallowed:
Disallowed
(shrunken images)

Winning conditions:

Shortest version (size in bytes) for each language will get a mention in this post, ordered by size.
No answer will ever be 'accepted' with the button.

Leaderboard:

/* Configuration */var QUESTION_ID = 23423; // Obtain this from the url// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question pagevar ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";var OVERRIDE_USER = 17419; // This should be the user ID of the challenge author./* App */var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;function answersUrl(index) {  return "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;}function commentUrl(index, answers) {  return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;}function getAnswers() {  jQuery.ajax({    url: answersUrl(answer_page++),    method: "get",    dataType: "jsonp",    crossDomain: true,    success: function (data) {      answers.push.apply(answers, data.items);      answers_hash = [];      answer_ids = [];      data.items.forEach(function(a) {        a.comments = [];        var id = +a.share_link.match(/\d+/);        answer_ids.push(id);        answers_hash[id] = a;      });      if (!data.has_more) more_answers = false;      comment_page = 1;      getComments();    }  });}function getComments() {  jQuery.ajax({    url: commentUrl(comment_page++, answer_ids),    method: "get",    dataType: "jsonp",    crossDomain: true,    success: function (data) {      data.items.forEach(function(c) {        if (c.owner.user_id === OVERRIDE_USER)          answers_hash[c.post_id].comments.push(c);      });      if (data.has_more) getComments();      else if (more_answers) getAnswers();      else process();    }  });  }getAnswers();var SCORE_REG = /<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;var OVERRIDE_REG = /^Override\s*header:\s*/i;function getAuthorName(a) {  return a.owner.display_name;}function process() {  var valid = [];    answers.forEach(function(a) {    var body = a.body;    a.comments.forEach(function(c) {      if(OVERRIDE_REG.test(c.body))        body = '<h1>' + c.body.replace(OVERRIDE_REG, '') + '</h1>';    });        var match = body.match(SCORE_REG);    if (match)      valid.push({        user: getAuthorName(a),        size: +match[2],        language: match[1],        link: a.share_link,      });    else console.log(body);  });    valid.sort(function (a, b) {    var aB = a.size,        bB = b.size;    return aB - bB  });  var languages = {};  var place = 1;  var lastSize = null;  var lastPlace = 1;  valid.forEach(function (a) {    if (a.size != lastSize)      lastPlace = place;    lastSize = a.size;    ++place;        var answer = jQuery("#answer-template").html();    answer = answer.replace("{{PLACE}}", lastPlace + ".")                   .replace("{{NAME}}", a.user)                   .replace("{{LANGUAGE}}", a.language)                   .replace("{{SIZE}}", a.size)                   .replace("{{LINK}}", a.link);    answer = jQuery(answer);    jQuery("#answers").append(answer);    var lang = a.language;    lang = jQuery('<a>'+lang+'</a>').text();        languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang, user: a.user, size: a.size, link: a.link};  });  var langs = [];  for (var lang in languages)    if (languages.hasOwnProperty(lang))      langs.push(languages[lang]);  langs.sort(function (a, b) {    if (a.lang_raw.toLowerCase() > b.lang_raw.toLowerCase()) return 1;    if (a.lang_raw.toLowerCase() < b.lang_raw.toLowerCase()) return -1;    return 0;  });  for (var i = 0; i < langs.length; ++i)  {    var language = jQuery("#language-template").html();    var lang = langs[i];    language = language.replace("{{LANGUAGE}}", lang.lang)                       .replace("{{NAME}}", lang.user)                       .replace("{{SIZE}}", lang.size)                       .replace("{{LINK}}", lang.link);    language = jQuery(language);    jQuery("#languages").append(language);  }}
body {  text-align: left !important;  display: block !important;}#answer-list {  padding: 10px;  width: 290px;  float: left;}#language-list {  padding: 10px;  width: 290px;  float: left;}table thead {  font-weight: bold;}table td {  padding: 5px;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Sites/codegolf/all.css?v=ffb5d0584c5f"><div>  <h2>Shortest Solution by Language</h2>  <table>    <thead>      <tr><td>Language</td><td>User</td><td>Score</td></tr>    </thead>    <tbody>    </tbody>  </table></div><div>  <h2>Leaderboard</h2>  <table>    <thead>      <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr>    </thead>    <tbody>    </tbody>  </table></div><table>  <tbody>    <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr>  </tbody></table><table>  <tbody>    <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr>  </tbody></table>

Answer*

More generally…

  • …Please make sure to answer the question and provide sufficient detail.

  • …Avoid asking for help, clarification or responding to other answers (use comments instead).

Draft saved
Draft discarded
Cancel
1
  • \$\begingroup\$No need to plot twice, just go with a more inefficient version. Doesn;t it supportNEXT Y,X?\$\endgroup\$CommentedMar 9, 2014 at 11:59
Add a comment | 
How to Edit
  • Correct minor typos or mistakes
  • Clarify meaning without changing it
  • Add related resources or links
  • Always respect the author’s intent
  • Don’t use edits to reply to the author
How to Format
  • create code fences with backticks ` or tildes ~
    ```
    like so
    ```
  • add language identifier to highlight code
    ```python
    def function(foo):
        print(foo)
    ```
  • put returns between paragraphs
  • for linebreak add 2 spaces at end
  • _italic_ or**bold**
  • indent code by 4 spaces
  • backtick escapes`like _so_`
  • quote by placing > at start of line
  • to make links (use https whenever possible)
    <https://example.com>
    [example](https://example.com)
    <a href="https://example.com">example</a>
  • MathJax equations\$\sin^2 \theta\$

MathJax help »

How to Tag

A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.

  • complete the sentence:my question is about...
  • use tags that describe things or concepts that areessential, not incidental to your question
  • favor usingexisting popular tags
  • read the descriptions that appear below the tag

If your question is primarily about a topic for which you can't find a tag:

popular tags »



[8]ページ先頭

©2009-2025 Movatter.jp