Generalizing the Print format

Back to General discussions forum

mybismark     2021-01-03 08:06:43

In some languages printing the desired output seems pretty hard. Is there a way to generalize the accaptence of the solution ?

For instance if I type ( 4 5 6 ) ( 4 2 1 ) or (4 5 6)(4 2 1) I am getting an error. However they should be also accapted, since its not much different than the desired solution, (4 5 6) (4 2 1).

Rodion (admin)     2021-01-07 18:14:05
User avatar

Hi there!

While your words about "not much different" are correct in common sense, it is quite not easy to formalize :)

E.g. you may mean "let's ignore optional spaces". But which are "optional"? It won't be good to collapse all spaces, as 8 9 11 and 8 91 1 will become same. Perhaps these are spaces on one of the side of punctuation mark. But then someone other will say "collapse also multiple spaces to single". Perhaps "replace tabs, wide spaces and non-breaking spaces with general spaces".

Then some other person will say "why not allowing commas in this answer, e.g. (4, 5, 6), (4, 2, 1) as may be suitable for MatLab/Octave. And so on, and so on.

While probably I can work on some clever answer checker for every problem, I prefer different approach. In many of the problems answer format is very simple and shouldn't give much trouble. In some problems answer format is "more advanced" but let it be a small challenge for people who solve these problems. Additional challenge is additional chance to learn something!

Particularly you may try to find a way to output this easier in R. Perhaps by using string concatenation and then dumping all the result at once... It is your language of choice anyway so probably it is just that you are to figure this out :)

mybismark     2021-01-08 09:24:35

I see your point..I guess that would reuqire more work indeed. yes I was using R and in R it is difficult for me to print the numbers in that format

Please login and solve 5 problems to be able to post at forum