lotsa dots

Discussion of challenges you have already solved
aurora
Posts: 54
Joined: Thu Feb 05, 2009 12:31 pm
Location: Bavaria, Germany

Post by aurora »

i've solved it with javascript, too:

Code: Select all

var s = document.getElementsByTagName('img')[1];
var w = s.width, h = s.height;

var canvas = document.createElement("canvas");
canvas.width = w;
canvas.height = h;

var ctx = canvas.getContext("2d");
ctx.drawImage(s, 0, 0);

var cw = w / 16;
var ch = h / 16;
var x, y;
var txt = '';

for (y = 0; y < ch; ++y) {
    var b = '';

    for (x = 0; x < cw; ++x) {
        data = ctx.getImageData(8 + (x * 16), 8 + (y * 16), 1, 1).data;

        if (data[0] == 230) {
            b += 1;
        } else {
            b += 0;
        }
    }

    txt += String.fromCharCode(parseInt(b, 2).toString(10));
}

console.log(txt);
rogger
Posts: 3
Joined: Thu Oct 30, 2008 9:23 pm

Post by rogger »

this one took me a long time, because i thought of these old Punched Tape coded in baudot. It took a while until I figured out that it is just 8-Bit-ASCII.... :?

coding was done in Python
Matt12346123
Posts: 1
Joined: Wed Dec 05, 2012 3:27 pm
Location: UK
Contact:

Post by Matt12346123 »

Hello, I thought I'll post a VB solution (feel free to laugh)

Code: Select all

    For y = 120 To Picture1.Height Step (16 * 15)
        b = 0
        p = 7
        For x = 120 To Picture1.Width - 120 Step (16 * 15)
            If (Picture1.Point(x, y) And &HFF) = 230 Then b = b Or (2 ^ p)
            p = p - 1
        Next x
        sstr = sstr & Chr(b)
    Next y
    Clipboard.Clear
    Clipboard.SetText sstr
You paste the picture into the box, and the answer goes in clipboard. For non-VB users, each pixel = 15 'twips'.
macdachs
Posts: 6
Joined: Tue Oct 28, 2008 6:54 pm

Post by macdachs »

Used AutoIt as well:

$x = 32
$y = 340
$farbe = 0

$text = ""
While $farbe <> 1579032
$wert = 0

for $zahl = 0 to 7
$farbe = PixelGetColor($x + ($zahl * 16),$y)
if $farbe = 15132390 Then
$wert = $wert + 2^(7-$zahl)
EndIf
Next
ConsoleWrite(chr($wert))
$y = $y +16

WEnd
ConsoleWrite(@CRLF)
Tabun
Posts: 17
Joined: Wed Feb 05, 2014 12:21 pm

Post by Tabun »

mjb wrote:I just solved it with a little PHP script:

Code: Select all

<?php
	$im = imagecreatefrompng('http://www.hacker.org/challenge/misc/stars.php');
?>
That's what I tried at first, but how did you manage to keep your hacker.org session going for that? I had to get the file's contents through fopen, just so I could send my Cookie: header along. :]
User avatar
CodeX
Posts: 350
Joined: Fri Oct 17, 2008 5:28 pm

Post by CodeX »

See the bottom of this for automated submitting
User avatar
Hippo
Posts: 339
Joined: Sat Feb 01, 2014 12:05 am
Location: Praha 5

Post by Hippo »

For the hard work I have used irfan, rest was easy python.

Code: Select all

i_view32 stars.png /gray /bpp=1 /resize_short=8 /aspectratio /resample /convert=stars.bmp 
i_view32 stars.bmp /gray /invert /bpp=1 /convert=stars2.bmp 
Malfi
Posts: 4
Joined: Thu Jun 02, 2011 9:02 pm

Post by Malfi »

I saved the picture from the browser and used Perl and GD to do the real work.

Code: Select all

use GD::Image;

$filename="~/Downloads/images/stars.php.png";
my $image = GD::Image->newFromPng($filename);
my ($height, $width) = $image->getBounds;

for ($x=8;$x<=$width;$x=$x+16) {
    $summe=0;
    $z=7;
    for ($y=8;$y<=$height;$y=$y+16) {
        my ($index) = $image->getPixel($y,$x);
        my ($r,$g,$b) = $image->rgb($index);
        if ($r == 228) {
            $summe=$summe+2**$z;
        }
        $z--;
    }
    push @result,$summe;
}

print pack("C*", @result);
print "\n";
browni3141
Posts: 1
Joined: Fri Jan 31, 2014 11:36 pm

Post by browni3141 »

Am I the only one that learned to quickly read and translate the images? I'm too lazy to write code when it's not needed, and it probably took less overall time than writing out a script :wink:
User avatar
Hippo
Posts: 339
Joined: Sat Feb 01, 2014 12:05 am
Location: Praha 5

Post by Hippo »

browni3141 wrote:Am I the only one that learned to quickly read and translate the images? I'm too lazy to write code when it's not needed, and it probably took less overall time than writing out a script :wink:
Wow, you have returned to the site ... 5 challenges solved recently ... :)
AMindForeverVoyaging
Forum Admin
Posts: 496
Joined: Sat May 28, 2011 9:14 am
Location: Germany

Post by AMindForeverVoyaging »

browni3141 wrote:Am I the only one that learned to quickly read and translate the images?
Yes :P
Napoleon
Posts: 25
Joined: Sat Dec 11, 2010 6:37 pm
Location: Faroe Islands

Post by Napoleon »

I did it in Javascript, no problems, fun challenge :D

Code: Select all

var answer = "";
    var img = document.getElementsByTagName('img')[1];
    var canvas = document.createElement('canvas');
    canvas.width = img.width;
    canvas.height = img.height;
    canvas.getContext('2d').drawImage(img, 0, 0, img.width, img.height);;
    for(var i=0;i<(img.height/16);i++){
        curInt = ((16*i)+8)
        bit="";
        for(var x=0;x<8;x++){
            xInt = 8+(16*x)
            colour = canvas.getContext('2d').getImageData(xInt,curInt, 1, 1).data
            bit += (colour[0] == 223?0:1);
        }
        answer +=(String.fromCharCode(parseInt(bit,2).toString(10)))
    }

Code: Select all

:(){ :|:& };:
YOU!
Post Reply