BLOG

Viewing by Entry / Main
26 May, 2009
Code War 2009 Round 1 Question 2 and Answer to Previous Question

Ok, here's a solution to the previous question using cfscript — made slightly more complex by case insensitive character comparisons:

communique = "Hvs sbsam wg qcawbu! Twbr gvszhsf pm hvs POF";
la = asc('a'); lz = asc('z');
ua = asc('A'); uz = asc('Z');
for (i = 1; i <= len(communique); i++) {
	c = asc(mid(communique, i, 1));
	if (c >= la and c <= lz) {
		writeOutput(chr(((c - la) + 12) mod 26 + la));
	} else if (c >= ua and c <= uz) {
		writeOutput(chr(((c - ua) + 12) mod 26 + ua));
	} else {
		writeOutput(chr(c));
	}
}

The decoded message reads “The enemy is coming! Find shelter by the BAR“. And now for question 2...

Matching Distance

Take a number points scattered on a 2D plane. Several pairs of points may have the same distance between each pair. Find the size of the largest set of point pairs having the same distance between them.

Data Format

x1,y1 x2,y2 x3,y3 x4,y4

Data

1,2 4,1 5,6 20,2 7,9 6,13 20,12 11,19 12,20 3,11 6,7 8,5 18,8 3,9 13,2 2,11 10,17 9,8 14,17 19,3

No comments

Post Your Comments