15
1
The task is simple: your program reads an integer as an input, and prints whether it is a prime or not. You can print "yes/no", "true/false" or anything what unambiguously identifies the result.
The challenge is, the code has to work with its rows and columns transposed.
To exclude the obvious solution (shortest "simple" solution repeated vertically char-by-char with the use of comments), the metric is a little bit different from the usual code-golf:
Because formatting is very important in this challenge, the code size is measured in the area of the smallest rectangle the code fits in. In other words, whitespace does count, and the lines should be filled to be of equal length (you don't have to actually do it when you post the solution, for simplicity's sake). For example
int main()
{
return 0;
}
would have a size of 4*13 = 52, (and obviously it does not fit either of the two criteria: prime detection and transposable.)
Smallest size wins.
You can use any language, and any library function except if the sole purpose of that function is to find, generate, or detect primes.
Edit:
While the winner would probably be the Golfscript solution, I'll award a 50 point bounty for the best C or C++ solution!
Your rectangle metric fails to discourage the obvious solution -- better would be to take the longest sidelength. Though, this would reduce the GS answer to having score 4. – boothby – 2012-10-09T19:31:55.880
You are right. The next transposed problem should have a different metric and forbid symmetrical solutions. However I think even then there will be someone who circumvents the rules or at least finds a solution the QA was not expecting when composing the rules. – vsz – 2012-10-10T03:09:27.043