44
6
This is a graphical output challenge where the task is to give the shortest code per language.
Task
Your code should plot a single purple pixel (hex value #800080 or rgb(128, 0, 128)), moving clockwise round a circle. It should take exactly 60 seconds to make a full journey round the circle and should continue indefinitely. Nothing else should be shown on the screen or window except for the pixel. The width of the circle should be 0.75 (rounding suitably) the width of the screen or window and the background should be white. To prevent silly solutions, the screen or window should be at least 100 pixels wide.
Your code should be a full program.
Languages and libraries
You can use any language or library you like. However, I would like to be able to test your code if possible so if you can provide clear instructions for how to run it in Ubuntu that would be very much appreciated.
Missing top twenty languages. Help needed.
The following top twenty programming languages are currently missing any solution at all.
C, C++,C#,Python,PHP,Visual Basic .NET, Perl, Delphi/Object Pascal,Assembly,Objective-C, Swift, Pascal,Matlab/Octave, PL/SQL, OpenEdge ABL,R
Catalog
The Stack Snippet at the bottom of this post generates the catalog from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.
To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:
## Language Name, N bytes
where N
is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:
## Ruby, <s>104</s> <s>101</s> 96 bytes
If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:
## Perl, 43 + 2 (-p flag) = 45 bytes
You can also make the language name a link which will then show up in the snippet:
## [><>](http://esolangs.org/wiki/Fish), 121 bytes
<style>body { text-align: left !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; }</style><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="language-list"> <h2>Shortest Solution by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr> </thead> <tbody id="languages"> </tbody> </table> </div> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr> </thead> <tbody id="answers"> </tbody> </table> </div> <table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr> </tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr> </tbody> </table><script>var QUESTION_ID = 62095; var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe"; var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk"; var OVERRIDE_USER = 9206; 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 > b.lang_raw) return 1; if (a.lang_raw < b.lang_raw) 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); } }</script>
1what radius should the circle be? – Timothy Groote – 2015-10-29T14:40:26.337
@TimothyGroote "The width of the circle should be 0.75 (rounding suitably) the width of the screen or window and the background should be white." (Although I'm not sure what window, since the animation should fill the entire screen.) – Martin Ender – 2015-10-29T14:40:55.250
19Why should the pixel be purple? I would assume some languages like TI-Basic don't have color capabilities, which means they can't be used for the challenge for a pretty abitrary reason – Fatalize – 2015-10-29T14:42:05.550
1@Fatalize that doesn't mean you can't golf the color into the program in some clever creative way to save bytes. – Timothy Groote – 2015-10-29T14:43:11.983
3@TimothyGroote TI-BASIC has mainly only one color: black. Everything else is an off pixel. There are C(SE) calculators that have colors, but not everyone has one. – Conor O'Brien – 2015-10-29T14:53:34.193
@CᴏɴᴏʀO'Bʀɪᴇɴ The good news is that BBC BASIC can do color. http://www.bbcbasic.co.uk/bbcwin/manual/bbcwin3.html
– None – 2015-10-29T15:01:37.023@Lembik ....Lucky. Verry lucky – Conor O'Brien – 2015-10-29T15:08:10.467
10I'm sure putting a purple cellofane over your screen does not add to your code size in bytes. i mean it worked vor the vectrex ;) – Timothy Groote – 2015-10-29T15:45:06.317
1No restriction on move granularity? So a pixel jumping each 30 seconds to the diagonally opposite point on the circle would be valid? – manatwork – 2015-10-29T15:56:45.127
@manatwork Good question. No that would be no good. It should be smooth animation. I don't want to define exactly what that means but it should certainly not skip pixels out on purpose. – None – 2015-10-29T16:04:08.630
QBasic also has a limited set of colors. Is
#8B008B
(dark magenta,COLOR 5
) close enough? – DLosc – 2015-10-29T16:14:34.843@DLosc Yes that will be fine. If you could include instructions for how to run qbasic code too that would be great. – None – 2015-10-29T16:16:35.393
Another question. The QBasic screen mode I want to use is 320 wide by 200 tall. The biggest circle that fits on that screen will be slightly less than 0.75 of the width of the screen. Ok to use as long as it's more than 0.75 of the height of the screen? – DLosc – 2015-10-29T16:56:52.777
@DLosc Please go ahead :) – None – 2015-10-29T16:57:32.853
Can the pixel blink as it moves? Also curious whether purple is mandatory, I have an answer using TI-Basic and its monochrome screen. – codebreaker – 2015-10-29T19:56:07.267
@codebreaker I am not sure what you mean by blink. purple is the rule but as there is no winning criterion I would just do your best and see if anyone upvotes you :) – None – 2015-10-29T20:00:39.870
I think you should've chosen black for the background so we could actually see the pixel more easily. – mbomb007 – 2015-10-29T20:03:10.767
@mbomb007 Yes you are right. – None – 2015-10-29T20:08:49.693
Is it at least 0.75x screen width, or exactly? – lirtosiast – 2015-10-29T21:28:27.387
There should be a turtle answer! – RobAu – 2015-10-29T21:36:08.357
What is the minimum update rate? 1 frame per second? – lirtosiast – 2015-10-29T22:13:48.400
@Lembik: Is it OK if the time required for a full circle is 60 seconds on a particular machine, or does the timing have to be machine-independent? – Franz D. – 2015-10-30T10:26:28.273
@FranzD. Ideally it would be machine-independent but I won't be too fussy. – None – 2015-10-30T10:27:14.173
@Lembik, you're a quick one :) – Franz D. – 2015-10-30T10:27:54.540
@ThomasKwa Given that it has to do a full circle in 60 seconds and it has to be smooth, the frame rate should be fast enough to allow that. – None – 2015-10-30T10:28:00.043
@Lembik If you mean by smooth that every pixel on the circle must be displayed, I need to change my answer again, since TI-BASIC doesn't have any means of getting fractional seconds. Is it acceptable for the program to terminate after a couple of years? – lirtosiast – 2015-10-30T10:44:12.640
@ThomasKwa Yes it is! – None – 2015-10-30T10:58:18.170
as there is no winning criterion I would just do your best and see if anyone upvotes you That's not how catalogs work. If your challenge says the pixel must be purple, it must be purple. If you want exempt some languages from this rule, say so in the question. – Dennis – 2015-10-31T17:28:10.397
@Dennis You are right. I just didn't want to be mean. – None – 2015-10-31T19:05:01.990
interesting coincidence, a quora answer about drawing a circle to a CRT on a PDP-8 in 1969 just came up in my digest feed this morning: http://qr.ae/RkWTqm
– zamnuts – 2015-11-02T06:07:49.687@zamnuts A clear case of time travel assisted plagiarism I think! – None – 2015-11-02T09:54:20.203