In MATLAB and Octave, the default output looks like this (I guess this is relevant for other languages as well):
'This is a string'
ans =
This is a string
x = 'This is a string'
x =
This is a string
Using disp
will give:
disp('This is a string')
This is a string
There are, as far as I can tell, (at least) three types of challenges where this is relevant:
- The output should look exactly like this (maybe newlines and trailing spaces are OK)
- This one is bankers:
ans = ...
is not OK
- This one is bankers:
- Remove elements, remove letters, etc. from an input string.
- I believe
ans = ...
should be OK, since the output format is not specified.
- I believe
- "Output:
A is greater than B
if A > B", copy from STDIN to STDOUT- ?
What do we do when the question simply states:
- "Output a string"
- "Print to STDOUT"
This is quite important, since disp('String')
is much longer than just String
. Also, for those cases where ans = ...
is OK, will x = ...
also be OK?
Update:
There are some cases that have come up recently:
The following function returns no arguments, but will write
x = 1 2 3 4 5
in the command window:function f;x=1:5
I'm assuming this is disallowed?
The following is not a function, but also doesn't use
disp
. It results in the integers 1-10 being printed likei = 1
,i = 2
etc. clearing the screen between each new number.for i=1:10,pause(1);clc;i,end
I'm assuming this is disallowed?
p"Hello, World!"
saves three chars overputs"Hello, World!"
but outputs the string with quotes around it (and would also escape any backslashes, quotes, etc. in the string if there were any). \$\endgroup\$Echo
which could be used instead ofPrint
if not for the>>
\$\endgroup\$