Permanent Programming 2

Put your programming skills to the test in these challenges.

Re: Permanent Programming 2

Post by Xikkub on Fri Feb 27, 2009 12:00 am
([msg=18771]see Re: Permanent Programming 2[/msg])

This was my method and it seems to be the most popular among HTS members.

:arrow: Using the GD Library and PHP, go through every pixel (left to right, then top to down) and check if it's white.
:arrow: If it's white and NOT a space, concatenate it (either going to be a period or a dash) to one index of an array.
:arrow: If it's white and a space, go to the next index in the array.
:arrow: When done storing ascii values (looks like morse code), trim the whitespace.
:arrow: Use a custom function with 36 case statements to convert morse to alphanumeric characters.
:arrow: Concatenate everything and there's the answer.

For users wanting to program in PHP, you must own a web server in order to test out the scripts (unless there is some program that has that functionality). You can host your own local web server by using WAMP for Windows or LAMP for Linux and do your testing on that.

At first I was accidentally using commas and dashes for my morse code, but then I realized that I had to use periods and dashes instead. I was confused because the comma, dash, and period are next to each other in the ascii table, so I was unsure what to use.
Xikkub
New User
New User
 
Posts: 4
Joined: Tue Feb 24, 2009 1:55 am
Blog: View Blog (0)


Re: Permanent Programming 2

Post by lordofthelefthand on Mon Mar 09, 2009 11:55 pm
([msg=19713]see Re: Permanent Programming 2[/msg])

Maven_ wrote:
dnb_den_bert wrote:Is it possible to do this mission in python? <br>If true :p:<br>couldt someone give me a small hint?<br><br>thx


Get PIL (Python image library) and pycurl. Download the image with pycurl and parse it with PIL.

If you have any specific questions you can pm me.


Done with python using:
Code: Select all
import urllib
import cookielib
import urllib2
import Image
User avatar
lordofthelefthand
New User
New User
 
Posts: 16
Joined: Tue Feb 24, 2009 8:28 pm
Blog: View Blog (0)


Re: Permanent Programming 2

Post by zobier on Thu Apr 23, 2009 1:52 am
([msg=22342]see Re: Permanent Programming 2[/msg])

sinelanguage wrote:For those interested, this is quite possible to achieve using Javascript and Canvas' .drawImage and .getImageData methods.

[snip]

I can assure you the pixels are zero indexed, though it was how I was determining the distance between pixels that was giving me the incorrect answer.


I too used JavaScript and canvas and also had the same challenge, sorted now though.
{B:[1,2,3,4,5,6,7,8,9,10,11],R:[1,2,3,4,5,6,7,8,9,10,11,12,13,14],A:[1,2,3,4,5,6],P:[1,2],J:[1,2,3,4,5,6,7],E:[1,2,3,4,5,6,7,8,9,10,11,12,13]}
User avatar
zobier
New User
New User
 
Posts: 30
Joined: Tue Apr 21, 2009 6:46 am
Blog: View Blog (0)


Re: Permanent Programming 2

Post by haha01haha01 on Mon May 18, 2009 12:03 pm
([msg=23875]see Re: Permanent Programming 2[/msg])

I finished it using the .NET image functions, but its not that hard to unpack the zlib block from the PNG and parse the RGB values
There are 11 types of people in the world - those who understand binary, those who don't and those who already heard this joke.
User avatar
haha01haha01
Poster
Poster
 
Posts: 133
Joined: Tue Jan 13, 2009 10:08 am
Location: HackThisSite.org
Blog: View Blog (0)


Re: Permanent Programming 2

Post by JSturgesJr on Tue May 19, 2009 4:47 am
([msg=23917]see Re: Permanent Programming 2[/msg])

Tried to do this one in JAVAScript plus canvas but it threw a security exception cause the image is inaccessible to javascript code, please anyone that has done this in JS, how and did you overcome this?

Writing it down in Java now, almost done, a nice trick I picked up on the way is signing in through the browser and then using the PHPSESSIONID cookie to fool the site into treating my HTTPClient as the browser, never thought of doing that b4, dont think I can think of a reason why I'd want to do it again (except other programming missions on this site).

see yall :mrgreen:
JSturgesJr
New User
New User
 
Posts: 3
Joined: Thu Apr 09, 2009 12:33 pm
Blog: View Blog (0)


Re: Permanent Programming 2

Post by zobier on Wed May 20, 2009 9:58 pm
([msg=24067]see Re: Permanent Programming 2[/msg])

@JSturgesJr

I DLed the image with PHP (re-using the cookie too), then I used the JS + <canvas>.
Could have injected the script into the page instead but the way I did it was easy.
{B:[1,2,3,4,5,6,7,8,9,10,11],R:[1,2,3,4,5,6,7,8,9,10,11,12,13,14],A:[1,2,3,4,5,6],P:[1,2],J:[1,2,3,4,5,6,7],E:[1,2,3,4,5,6,7,8,9,10,11,12,13]}
User avatar
zobier
New User
New User
 
Posts: 30
Joined: Tue Apr 21, 2009 6:46 am
Blog: View Blog (0)


Re: Permanent Programming 2

Post by haha01haha01 on Thu May 21, 2009 11:49 am
([msg=24104]see Re: Permanent Programming 2[/msg])

JSturgesJr wrote:Tried to do this one in JAVAScript plus canvas but it threw a security exception cause the image is inaccessible to javascript code, please anyone that has done this in JS, how and did you overcome this?

Writing it down in Java now, almost done, a nice trick I picked up on the way is signing in through the browser and then using the PHPSESSIONID cookie to fool the site into treating my HTTPClient as the browser, never thought of doing that b4, dont think I can think of a reason why I'd want to do it again (except other programming missions on this site).

see yall :mrgreen:

why would you want to create a script that directly connects to the mission page? its not like mission 11 and 12, you got plenty of time to download the image and run the script here.
There are 11 types of people in the world - those who understand binary, those who don't and those who already heard this joke.
User avatar
haha01haha01
Poster
Poster
 
Posts: 133
Joined: Tue Jan 13, 2009 10:08 am
Location: HackThisSite.org
Blog: View Blog (0)


Re: Permanent Programming 2

Post by Bitbored on Thu Sep 03, 2009 3:41 pm
([msg=29038]see Re: Permanent Programming 2[/msg])

I made a VB.net application that loads in the image after I drop it into a folder on my desktop, reads it out using GetPixel, translates the Morse and tells me the result, it is a simple string with random letters AND numbers, apparently it's wrong, since after I click submit, it sais Sorry: Your answer is wrong...

I guess it isn't a bug in my application, since then it wouldn't create a nice string, but give loads of errors.

Can I post my code here?
Should the letters be Capitals are lower?
How many characters should the code count?
Bitbored
New User
New User
 
Posts: 2
Joined: Thu Sep 03, 2009 3:26 pm
Blog: View Blog (0)


Re: Permanent Programming 2

Post by stephen_will on Sat Dec 26, 2009 7:28 pm
([msg=31990]see Re: Permanent Programming 2[/msg])

Bitbored wrote:I made a VB.net application that loads in the image after I drop it into a folder on my desktop, reads it out using GetPixel, translates the Morse and tells me the result, it is a simple string with random letters AND numbers, apparently it's wrong, since after I click submit, it sais Sorry: Your answer is wrong...

I guess it isn't a bug in my application, since then it wouldn't create a nice string, but give loads of errors.

Can I post my code here?
Should the letters be Capitals are lower?
How many characters should the code count?


Check for off by one errors. For instance, you might start counting from 0 when you need to start from 1 or vice versa.
User avatar
stephen_will
New User
New User
 
Posts: 6
Joined: Mon Dec 21, 2009 5:51 pm
Location: Raleigh NC
Blog: View Blog (0)


Re: Permanent Programming 2

Post by faazshift on Wed Jan 06, 2010 3:05 am
([msg=32910]see Re: Permanent Programming 2[/msg])

Hehe... finally got it! I couldn't find a decent decoder for morse code in python, so I just made my own. That was actually the biggest part. I made it so that it builds the whole tree and walks it to find characters from the given code. I used PIL for analyzing the image (in the gentoo linux portage tree its called 'imaging'), which worked out quite nicely. The one part that stuck me for a while ended up being an off-by-one problem with the first character.
faazshift
Contributor
Contributor
 
Posts: 516
Joined: Wed Jun 03, 2009 3:55 pm
Location: Riverton, Utah
Blog: View Blog (0)


PreviousNext

Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests