MATLAB... and MS-DOS and Bash? 7 bytes
!echo P
Outputs P
. Length verification
First post here.
I thought this was going to be easy with MATLAB, as you can just enter a single digit number and it will return that as-is. Except that MATLAB prints more than just the number back out...
>> 0
ans =
0
Same goes for strings.
>> 'a'
ans =
'a'
Now I might've just waved my hands and said good enough, but where's the fun in that? :)
The only methods I knew of, that can print something to console without the extra ans =
would be to use the fprintf()
or disp()
functions.
12 Bytes.
>> fprintf('T')
T
9 Bytes. Note, Disp(0)
and other single-digit variations will not work due to average length constraint.
>> disp('J')
J
These two are valid submissions, but I kept wondering... Can I do better?
Then I learned I could send commands to the operating system with the Shell Escape Function. i.e. !COMMAND
Except the command is sent to whatever operating system that machine is running on. Since MATLAB is available for both Windows and Unix, whatever command I choose needs to work on both; ensuring that my code runs on all machines.
This more or less locked me to the single command; echo
. (Kinda anti-climactic, really)
A few trials and error with the output character, and I converged to the final answer. 7 Bytes.
>> !echo P
P
I really hope this isn't breaking any rules here...
round(0 / 0)
. It is invalid simply due to divided by zero. So I don't think the empty source code should be allowed. If it must be allowed, by using the definition of division,x / y = z
isy * z = x
, one may argue output any single character should be allowed. \$\endgroup\$