-2
Rules/Objectives:
The program must be executed using
./program-name
without shell parameter/arguments.the
program-name
may not contain any of characters in/etc/passwd
, that isacdepstw
You may not open any other file, including own's source code, only
/etc/passwd
that should be read.The program must print the content the
/etc/passwd
file.Total score of the code equal to number of characters in the code added with constant literal declaration point. Each byte of constant declaration literal equal to
+100
to the score, after3
declaration, each byte adds+200
to the score. So the program should not contain too many constant declaration, but you may use predeclared constants (M_PI
for example) or exploit the reflection of the function/variable/class name (function, variable or class names in this case are not considered as constant). Counting example:int x = 12; // counted as 1 byte (12 can fit to 8-bit) x += 345; // counted as 2 bytes (345 can fit to 16-bit) #define Y 'e' // counted as 1 byte ('e') #define X Y // counted as 0 (not considered as constant) string s = "abc"; // counted as 3 bytes ("abc") :foo // counted as 3 bytes (:foo) // ^ EACH characters in atom (Elixir, etc) // or characters in symbol (Ruby, etc) // are counted as 1 byte constant '' // counted as 0 (not considered as constant) [0xAC, 12, 114] // counted as 3 bytes (0xAC, 12, 114)
Clarification:
things that counted as constant literal:
- numbers, each byte, depends on size
- strings/symbols, each character = 1 byte
- chars, one byte
things that not counted as constant literal:
- class declaration
- function declaration
- variable declaration
- operators, brackets
- predefined symbols
- predefined constants
What about languages like Bash, where everything is equivalent to a literal (ex.
echo -n hello
is the same as"echo" "-n" "hello"
)? – Doorknob – 2015-01-27T12:42:19.397echo is function calling so it's not, but
-n
counted as 2 bytes,hello
counted as 5 bytes – Kokizzu – 2015-01-27T12:51:34.703The scoring rules currently just do not make sense. I think I can figure out the grammatical errors, but they require an unsupplied map between the terms you use and the tokens in a program. E.g. if I were following my best guess at the meaning of the rules, I would give your JS answer a much higher score because of all the symbols it contains (e.g. function names used other than in declarations). – Peter Taylor – 2015-01-27T14:43:11.953
I'm confused. We're supposed to print the contents of a specific file without reading any files? – KSFT – 2015-01-27T14:46:50.750
I forgot to add
except /etc/passwd
– Kokizzu – 2015-01-27T15:04:15.020