-1
Given the integers N and M, can you print all numbers from N to M comma-seperated? The hitch is to use one single expression.
The output for N=23 and M=42 should look like this:
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42
I'll start with Ruby:
puts (23..42).to_a.join(', ')
related: http://codegolf.stackexchange.com/questions/8588/return-each-number-from-a-group-of-numbers/
– ardnew – 2013-06-27T20:50:12.157@ardnew The special catch of my task is that the solution has to be achieved using only one expression, which is way harder and probably not possible in every language. I don't consider your link as related. – YMMD – 2013-06-27T21:04:15.387
5@YMMD what do you consider a single expression in golfscript? – John Dvorak – 2013-06-27T21:05:33.773
I thought of a nested expression which still could be a code gold issue, but indeed I get your point. I deleted the
code-golf
-tag. – YMMD – 2013-06-27T21:07:29.4636so now that the code golf tag has been removed, is there even an objective or winning criteria anymore? – ardnew – 2013-06-27T21:16:04.767
1Quite poorly worded task. As you can see the answers, there are too many variations:
n..m
vs23..42
, “,” vs “, ”, quoted vs unquoted output, maybe with or without trailing separator. I know, it is not [tag:code-golf] anymore, but I think the answer still should be somehow comparable. – manatwork – 2013-06-28T07:15:58.4501@manatwork, that's the least of its problems. The biggest problem is that, as Jan pointed out, "expression" is not well defined. – Peter Taylor – 2013-06-28T10:06:29.277
@JanDvorak Single expression in golfscript?
"#{(23..42).to_a.join(', ')}"
;-) – Howard – 2013-06-28T10:56:02.123