In article <11********************@i42g2000cwa.googlegroups.c om>,
em*****@o2.pl says...
Having this unscrambled could you give a clue, how to make it short? It
won't be used anywhere besides some problem solving contest where
points are granted for the shortest code. The shortest code that does
the same (reads, checks a few conditions and prints the result) is 45
bytes long, this one is 99.
If you don't mind it being written in ugly, non-portable C, it's not
terribly difficult to at least get close to that:
main(c){c=getch()-'/';putch("011264"[c*(c<6)]);}
It takes far most space to list problems with this though. It
uses/depends on:
1) getch/putch (shorter names, but utterly non-portable).
2) implicit return type from main
3) an old-style function header
4) implicit variable declaration
5) ASCII or ASCII-like character set
6) implicit function declarations
7) indexing a string literal
8) math on a boolean value
There may be even more ugliness that doesn't occur to me at the moment.
All in all, code to avoid under any reasonable circumstances!
I can't imagine a 45-byte version could be much better either. In
particular, consider that something like this:
#include <stdio.h>
int main(){int c;scanf("%d",&c");printf("%d",c);}
i.e. just the bare bones of reading and writing a number, with no logic
at all, is already 69 bytes long.
--
Later,
Jerry.
The universe is a figment of its own imagination.