I have a nice picture that I want to hang on my wall. And I want it to hang there in a spectacular way, so I chose to hang it on
n nails where
n is any positive integer.
But I'm also indecisive, so if I change my mind, I don't want a lot of trouble taking the picture down. Therefore, removing any one of the
n nails should make the picture fall down. Did I mention that there is no friction in my house?
Can you help me?
- Your program must read the number
nfrom stdin and print to stdout (or your language's equivalents).
- The output must be the solution according to the output specification without any other trailing or leading characters. However, trailing whitespace and/or newlines is acceptable.
- You must use exactly
- Assuming a friction-less world, your solution must fulfill the following conditions:
- Hanging the picture as described by your solution, the picture must not fall down.
- If any one of the nails is removed, the picture must fall down.
- Standard loopholes apply. In particular, you may not make requests to, e.g., the verification program to brute-force solutions.
Note that 4.2 already implies that all
n nails must be involved.
- All nails are named from left to right with the position they are in, starting at
- There are two fundamental ways to put the string around a nail: clockwise and counter-clockwise. We denote a clockwise step with
>and a counter-clockwise step with
- Everytime the string is put around a nail, it comes out on top of the nails, so skipping nails means the string will go across the top of the intermediate nails.
- Every solution must start on nail
1and end on nail
- The output must consist of a sequence of steps wherein a step is a combination fo the nail's name and the direction in which to put the string around it.
Here is an example output for
1>4<3<2>4>5< # n=5, incorrect solution 1>2<1<2>3<2<1>2>1<3> # n=3, correct solution
And here is a visual representation of the incorrect solution for
n=5 (awsumz gimp skillz)
The correct solution for
n=1 is simply
1<. For multiple nails, there can be different solutions. You must only output one since this is part of your score.
You can verify whether a solution is correct here: www.airblader.de/verify.php.
It uses a GET request, so you can call it directly if you want. For example, if
foo is a file containing a solution on each line, you can use
cat foo | while read line; do echo `wget -qO- "www.airblader.de/verify.php?solution=$line" | grep "Passed" | wc -l`; done
If you believe a solution is correct but the verifier marks it as incorrect, please let me know!
Edit: And if your output is so long that a GET request won't cut it, let me know and I'll make a POST request version. :)
This is code-golf. The score is the number of bytes of your source-code in UTF-8 encoding, e.g., use this tool. However, there is a potential bonus for every submission:
Run your program for all
n in the range
[1..20] and add the length of all outputs up to determine your output score. Subtract your output score from
6291370 to get the number of bonus points that you may deduct from your byte count to get your overall score. There is no penalty if your output score is higher than this number.
The submission with the lowest overall score wins. In the unlikely case of a tie, the tie breakers are in this order: higher bonus points, lower byte count, earlier submission date.
Please post both the individual parts (byte count, bonus points) of the score and the final score, e.g., "
LOLCODE (44 - 5 = 39)".