Page 2 of 2

Posted: Sun Jan 29, 2012 2:13 pm
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);

Posted: Wed Mar 07, 2012 2:17 pm
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

Posted: Tue Dec 11, 2012 10:45 am
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'.

Posted: Tue Apr 16, 2013 9:56 pm
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)

Posted: Thu Feb 13, 2014 4:37 pm
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. :]

Posted: Fri Feb 14, 2014 9:45 am
by CodeX
See the bottom of this for automated submitting

Posted: Thu Apr 10, 2014 5:58 pm
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 

Posted: Tue Aug 26, 2014 12:07 pm
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";

Posted: Tue Jul 28, 2015 3:45 am
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:

Posted: Thu Jul 30, 2015 2:47 pm
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 ... :)

Posted: Sat Aug 01, 2015 2:27 pm
by AMindForeverVoyaging
browni3141 wrote:Am I the only one that learned to quickly read and translate the images?
Yes :P

Posted: Mon May 09, 2016 11:44 am
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)))
    }