42
3
Given a non-negative integer input, write a program that converts the number to hexadecimal and returns a truthy value if the hexadecimal form of the number contains only the characters A
through F
and a falsey value otherwise.
Test cases
10
==> True (A in hexadecimal)
100
==> False (64 in hexadecimal)
161
==> False (A1 in hexadecimal)
11259375
==> True (ABCDEF in hexadecimal)
0
==> False (0 in hexadecimal)
Bonus: -40 bytes if your program prints Only letters
for the challenge described above, Only numbers
if the hexadecimal version of the number only contains the digits 0-9
and Mix
if the hexadecimal number contains at least one number and at least one letter.
This is code golf. Standard rules apply. Shortest code in bytes wins. Either functions or full programs are allowed.
2Currently drafting an answer in Golfical. – SuperJedi224 – 2015-12-12T20:42:01.847
My current idea: covert to base 16 string, then See if trying to parse that string as a base 10 number returns
NaN
– Cyoce – 2015-12-12T20:54:36.693@Cyoce That may work, depending on your choice of language – SuperJedi224 – 2015-12-12T20:56:50.843
3Unrealistic bonus (once again): just the string
MixOnlynumbersletters
is 21 chars – edc65 – 2015-12-12T21:51:02.107Never mind,
a1
can't be parsed as base 10 either. – Cyoce – 2015-12-12T22:11:21.6633You say "positive integer input", but 0 is a test case. – xnor – 2015-12-12T22:30:43.700
@edc65 Pyth (and I) say otherwise.
– isaacg – 2015-12-13T08:07:55.963@isaacg Pyth (and you) would have been at ease with the original -25 bonus (which I was referring to)? WIth a score of 18 instead of Adnan's 6 – edc65 – 2015-12-13T11:03:25.127
@edc65 Thanks, I didn't realise the original bonus was lower. – isaacg – 2015-12-13T18:43:29.490
@SuperJedi224 Have you come up with a solution? Or have you already posted it and I missed it? – Arcturus – 2015-12-19T04:23:42.947
@Ampora Sorry about that. I kind of forgot. – SuperJedi224 – 2015-12-19T11:49:14.133