5
2
Given a number and either "+" or "*", return an addition or multiplication table with the dimensions of that number.
Specifications
- The input will be formatted as
dimension, operation
. - The program should not return anything if the operation input is not + or *.
- The program should not return anything if the dimension input is less than 1.
(4,*):
1 2 3 4
2 4 6 8
3 6 9 12
4 8 1216
(4,+):
1234
2456
3567
4678
The spaces between the numbers in the table should be equal to one less than the number of digits in dimension^2
for multiplication, and for addition one less than the number of digits in dimension * 2
.
A couple of quite similar questions. I'm not slamming my dup hammer just yet - I'll see what others have to say.
– Digital Trauma – 2016-12-05T17:22:08.7431If the dimension is 10, how would one display the number 100 when there are only 2 digits in 99? – darrylyeo – 2016-12-05T17:25:35.943
7I suggest you allow a somewhat flexible output format. Having to conform to a very specific format is usually boring – Luis Mendo – 2016-12-05T17:41:34.130
4Also input format checking is generally considered to be a tedious task that doesn't really add anything to a [tag:code-golf] challenge. *The program should not return anything if the operation input is not + or . The program should not return anything if the dimension input is less than 1. – Digital Trauma – 2016-12-05T17:49:08.287
Could you add an example of output for
(4,+)
? – steenbergh – 2016-12-05T18:17:49.383Sorry for the mistakes. Please leave this question alone. – Dave Jones – 2016-12-05T18:22:24.117
Mistakes are natural. The question is just on hold to give time for them to be cleared up, then it can be reopened. I find it useful to post my challenge ideas in the sandbox first to get feedback and spot any mistakes I made. I recommend it for future challenges.
– trichoplax – 2016-12-05T22:37:22.8731Your example addition table is wrong. The top-left entry should be 2, for example. – Greg Martin – 2016-12-06T07:55:43.163
I not see why limitate the number of operators in "•The program should not return anything if the operation input is not + or *." Until they are 2 arg to 1: Where is the problem? – RosLuP – 2018-01-31T12:04:18.837