10
1
Back to basics...
As a teacher at the local primary (grade?) school, you need a way to teach your class their times tables. At your disposal, you have hundred squares and a load of red pens. You need to also be able to show your class the correct answers quickly.
Now, you're clever enough to write a program that can do times tables, but can you draw them on a hundred square?
The challenge
Output a hundred square to stdout or equivalent using ansi-escape codes to shade in numbers which are multiples of the input.
- Output a 10x10 grid containing the numbers 1-100.
- It doesn't matter the alignment of 2 digit numbers in each box as long as it's consistant
- For 1 digit numbers, you may pad to 2 digits and use the same formatting as 2 digit numbers or centered in the middle of the box.
- If the number in the box is a multiple of the input, colour the entire box red.
- This means the whole box, not just the number part
For example, given the input 3
, print the given hundred square
This is code golf so the shortest answer in bytes wins!
2Can we print 01 instead of 1. 02 for 2, etc etc – Keatinge – 2016-06-13T19:20:38.333
1So I can't use
<table>
, for example? – nicael – 2016-06-13T19:22:20.0301Does the colour of the numbers matter? Can it be
white
orgrey
? – Bassdrop Cumberwubwubwub – 2016-06-13T19:23:38.8401@Keatinge I haven't decided yet - I'm veering towards yes @nicael no, it has to be using ansi-escapes or answers wouldn't be on the same playing field, @BassdropCumberwubwubwub you may use different colours but unless you're using
curses
it shouldn't matter - red is short anyway. – Blue – 2016-06-13T19:27:06.510@Keatinge yes you may use padding - but only with zeros and one one digit numbers only – Blue – 2016-06-13T19:29:08.810
ANSI codes aren't supported by windows,,, – TuxCrafting – 2016-06-13T19:30:44.380
@TùxCräftîñg I haven't tried it but https://github.com/adoxa/ansicon - I've got putty on my windows box
– Blue – 2016-06-13T19:39:54.160@muddyfish It don't compile on my machine – TuxCrafting – 2016-06-13T19:47:19.407
@TùxCräftîñg try mobaXterm - I've just tried it and and it works locally with ansi – Blue – 2016-06-13T20:12:02.047
My reference golfed python solution is about 272 bytes - It could easily be beasten though with minimal optimisation – Blue – 2016-06-13T20:14:02.563
@TùxCräftîñg Doesn't mean the question should be closed or is a bad challenge ¯_(ツ)_/¯ – Insane – 2016-06-16T14:20:09.750
@Insane I have never sayed that this is a bad challenge – TuxCrafting – 2016-06-16T14:23:58.050
@TùxCräftîñg I know – Insane – 2016-06-16T14:24:22.160