|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Fast Code
Tetris, again. Rules:
1) we remove one square.
For instance, this is a cluster:
but this one isn't:
4) Goto step 2) until there still are some falling squares. 5) Goto step 1) until they are some squares left. Goal: The games starts with the following configuration:
with color convention:
Here is a C-version:
char *Grid[16] = {
"adbdcdbdddcbdbab",
"bccbddbccaadcdaa",
"dabdacdbbdacaccd",
"cdababcacbdcadca",
"baadab????dbaddb", // <- missing
"addbdaadcdaddcba",
"adcacdabcabcaadc",
"acadcbddbbcdcccd",
"bdbaadaaabdcaaba",
"adadbccbdacddcdb",
"dbaaddbcbdbbbcaa",
"dccbdcbaacaaacad",
"cbdacbcadcbdddcc",
"dbaadbacdcaaacab",
"dbcdcdbadbbbdaca",
"dcddccdcccacdcdb"
};
As you've noticed, there's 4 missing squares in the middle, yet-unknown. You program must accept as only argument a string of 4 characters 'a', 'b', 'c' or 'd'. These characters are the 4 ones missing, in order from left to right. They will be randomly chosen later (when ranking the entries). It will be the same for everybody. It will respect the constaint of *NOT* generating any removable cluster once inserted in the initial grid. Given this input, your program must then ouput, on the standard channel (stdout), a sequence of square index to remove, one after the other, with a carriage return ('\n') inbetween. The squares are indexed in increasing order (beginning at 0) starting from the upper-left corner, and heading to the right. The output format must be in hexadecimal, with 2 chars ([0-9A-F] or [0-9a-f]), without any leading '0x' or ending 'h'. Namely, the squares' indexes look like:
+++++++++++++++++++++++++++++++++++++++++++++++++ +00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f+ +10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f+ + ... + +f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff+ +++++++++++++++++++++++++++++++++++++++++++++++++ Each time you give a new index, the corresponding square is removed from the grid and the steps 2), 3), and 4) of game are run until there is no more cluster to remove. The goal is to remove all the grid's squares with as few square removal as possible.
At any time, you can stop the process and print the grid's state.
This will cost you a penalty (see below).
Scoring: As entry, you can supply a dos-box executable, or an ANSI-C source file. This later must compile with 'gcc -o prog prog.c -lm', either with DJGPP or linux' gcc. In case of problem, watcom-C will the tried too, or even MSVC.
- Every byte of executable, or source file, costs 1 point. The program's execution may not exceed 5 minutes in time, on the compo PC. The winning entry will be the one scoring least. Entry's output will be checked using this C-program. Use it! (and warn me if anything seems strange/bugged in this 'check.c' :) /Skal
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[ | | | ]oneliner | fast code | LTP4 information site Archive of the intranet that ran on the LAN of the party. Nothing can be sent from this site. To be removed from this page, contact me. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||