10
2
Hexadecimal is a base 16 counting system that goes from 0
to f
. Your job is to make a counter that will display these numbers.
Example:
$ python counter.py
1 2 3 4 5 6 7 8 9 a b c d e f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30
Rules:
- The numbers may be separated by spaces, tabs, or new lines.
- The minimum number you must go to is
30
(48 in decimal).- You may also make the program print numbers forever until it is stopped.
- Letters may be in uppercase or lowercase (
A
ora
). - No built in functions allowed (that directly affect hexadecimal conversions/counting).
- Leading zeros are allowed
- It may start from
1
or0
- Shortest code wins!
@Sp3000 How built in are they? Converting decimal to hex? – phase – 2015-07-12T16:05:54.753
@Sp3000 No built in functions allowed! – phase – 2015-07-12T16:09:57.533
@manatwork uppercase is fine – phase – 2015-07-12T16:10:20.387
4How about general base conversion functions then? – Sp3000 – 2015-07-12T16:11:06.153
1@Sp3000 Sure (ignore this, 15 character limit) – phase – 2015-07-12T16:13:28.400
If the program prints things repeatedly, but breaks at some point beyond
30
, (say, atFF
) is that okay? – BrainSteel – 2015-07-12T16:16:13.897@BrainSteel Yes, as long as it gets to
30
– phase – 2015-07-12T16:16:51.480A couple of questions I'd rather have answered now than later: 1. Can the count start from zero? 2. Are leading zeroes allowed? – Dennis – 2015-07-12T16:46:40.857
@Dennis Yes and yes! – phase – 2015-07-12T16:50:48.843
Is it OK if my solution prints an exta newline between 0F and 10, and 1F and 20, ...? – Lynn – 2015-07-13T16:38:32.697
@Mauris yes . . . – phase – 2015-07-13T17:26:34.217
Cool! What about tab-separated output? – Lynn – 2015-07-13T17:28:34.380
1@Mauris Yes! That sure is going to be interesting... – phase – 2015-07-13T17:29:09.903
Can I use a format string that converts parameters to hex inside a string? It's not a function. – mbomb007 – 2015-07-24T17:02:06.903
@mbomb007 Do you mean Regex? There's Retina for that. – phase – 2015-07-24T22:43:15.520
No, a Python format string containing
%x
. – mbomb007 – 2015-07-25T02:30:51.677So if a language has a built-in that only converts to hex it isn't allowed, but a general one such as
5.base(16)
is allowed? – Brad Gilbert b2gills – 2016-01-15T19:08:21.280@BradGilbertb2gills That isn't allowed either. – phase – 2016-01-17T05:21:21.353
I was looking at the previous comments and it looked like you agreed to general base conversion functions when Sp3000 asked. Also does that include
printf
type functions? – Brad Gilbert b2gills – 2016-01-17T14:55:36.600