80
6
I came across SVGCaptcha, and immediately knew it was a bad idea.
I would like you to show just how bad an idea this is by extracting the validation code from the SVG images that code produces.
An example image looks like this:
Here is the source of the example image:
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve"
width="200" height="40"
> <rect x="0" y="0" width="200" height="40"
style="stroke: none; fill: none;" >
</rect> <text style="fill: #4d9363;" x="5" y="34" font-size="20" transform="translate(5, 34) rotate(-17) translate(-5, -34)">8</text>
<text style="fill: #be8b33;" x="125" y="29" font-size="21" transform="translate(125, 29) rotate(17) translate(-125, -29)">f</text>
<text style="fill: #d561ff;" x="45" y="35" font-size="20" transform="translate(45, 35) rotate(-2) translate(-45, -35)">4</text>
<text style="fill: #3de754;" x="85" y="31" font-size="21" transform="translate(85, 31) rotate(-9) translate(-85, -31)">8</text>
<text style="fill: #5ed4bf;" x="25" y="33" font-size="22" transform="translate(25, 33) rotate(16) translate(-25, -33)">u</text>
<text style="fill: #894aee;" x="105" y="28" font-size="25" transform="translate(105, 28) rotate(9) translate(-105, -28)">1</text>
<text style="fill: #e4c437;" x="65" y="32" font-size="20" transform="translate(65, 32) rotate(17) translate(-65, -32)">x</text>
</svg>
The input is the SVG image, which is a textual format.
The only real restriction is that your code must produce the values in the correct order.
The input <text>
elements are in random order so you have to pay attention to the x
attribute in the <text>
tag
Score is the number of bytes in the code
Since the code currently does two transforms that cancel each-other out you can ignore them, but if you do take them in consideration, go ahead and take a 30% reduction from your score.
3You haven't actually stated explicitly what the input and output are: I'm presuming the SVG file and the letters contained therein? And it's not clear to me whether answers are required to actually implement the SVG spec or whether they can assume that the SVG is generated by the current version of SVGCaptcha and so the transforms can be ignored. – Peter Taylor – 2015-11-15T22:51:17.123
I suggest limiting the output to STDOUT or function return value, and making it [tag:code-golf] – TheDoctor – 2015-11-15T22:54:02.483
@AlexA. So there can't be a criterion on quality that can't really be quantified? You can't qualify on how funny the code is, or how clear it is? I really want the answers to be so dead simple that people who don't even know a single language could eventually figure it out. – Brad Gilbert b2gills – 2015-11-15T22:55:10.470
@PeterTaylor I totally didn't look to see if the translations actually did anything. I would prefer if it did take them into consideration, but since the code is even dumber than I thought, any answer could ignore them. – Brad Gilbert b2gills – 2015-11-15T22:58:16.980
1No, questions need an objective, quantifiable winning criterion to be on-topic for this site. – Alex A. – 2015-11-15T23:00:10.567
If you want the answers to be "simple", why don't you just make it codegolf so that the shortest possible answer wins? Then we can get this open again. Yes SVGCaptcha is a hilariously dumb idea (I suspect the inventors do in fact know that, though there isn't a trace of irony shown on the linked page.) And it's been good for a laugh, but the purpose of this site is to host challenges, with objective rules. – Level River St – 2015-11-15T23:24:01.847
@steveverrill I really wanted them to be elegant. The shortest code in Perl 5&6 are very often not the simplest for example. (one of the reasons most people think that Perl is hard to read) But in the interest of opening it is now a golfing competition – Brad Gilbert b2gills – 2015-11-15T23:39:22.003
7I'm not sure how relevant [tag:image-processing] is here. – SuperJedi224 – 2015-11-16T00:42:15.150
18This question is now the 4th result when googling 'svgcaptcha' :) – Blue – 2015-11-16T09:33:35.823
It is the 3rd now! – Ioannes – 2015-11-16T12:44:39.270
the google result for svgcaptcha it self and the relevance of this OP to the keyword is the elegant and ironical proof of how bad the idea itself is. ;) – Zaibis – 2015-11-16T17:12:23.373
Can we output it as a list of characters instead of String? I.e.
[8, u, 4, x, 8, 1, f]
instead of8u4x81f
? – Kevin Cruijssen – 2018-01-18T09:30:13.603@KevinCruijssen In some languages there is no difference. So sure why not. – Brad Gilbert b2gills – 2018-01-18T14:52:33.987