This challenge is brought to you by real (and tragic) inspiration. Recently, the number row on my keyboard has been a bit sporadic. The keys
1-9 work sometimes--but other times they have no result. As an avid programmer, this is horrible! (See that exclamation point? That's how you know they're working right now.) Not only do I often need the numbers themselves, but the symbols
!@#$%^&*( are completely ineffective half the time as well! As a C programmer, rather than take time off my busy schedule of doodling around with code to fix my laptop, I've been more interested in working around the problem. Over the course of the past few weeks, slowly, all of the number literals in my code have been replaced with hexadecimal so that I don't have to go hunting around for numbers to copy and paste. However, some numbers aren't easy to type without the keys
1-9. For example, the number
1 cannot be written so simply in hexadecimal, and I've resorted to replacing
1s in my code with
0xF - 0xE. The only keys that are affected are
1-9, so I maintain full use of symbols like
/. However, I cannot use multiplication or parentheses, as
( are often broken. This leads to your challenge.
n to stdin or your language's equivalent. If you wish, the integer may be preceded or followed by a new line or other whitespace character. Alternatively, you may receive input via a command line argument.
Your program should respond to negative input correctly, and be able to handle at least 32-bit signed integers.
Your program should output, in some observable form, the shortest (in non-whitespace characters) possible way to write the number
n as a sum, difference, or division of one or more hexadecimal values. There is more than one way to solve this problem, and there is no requirement that you favor any equal-length output over any other.
The output should be in the form
A % A % A... where
A is a hexadecimal value following
0x containing only digits
A-F a-f, and
% is one of of the symbols
/ describe integer division, not floating-point.
(Note that your output should result in
n when evaluating divisions first, left to right, and then additions and subtractions, left to right, as is convention.)
0xF - 0xE(or
0xd - 0xcor
0xF + 0xF
Scoring and Rules
This is code-golf. Your preliminary score is the number of bytes in your source file.
You may NOT use any of the digits
1-9 in your source.
You MAY use symbols
!@#$%^&*( in your source, but each comes at a penalty of +20 to your score.
Your program may be replaced by a function that takes
n as an argument as long as that function produces some form of human-readable output. Your function's return value does NOT count as output.
Standard loopholes are not allowed.
Lowest score wins! Good luck!
Did I goof something up formatting/questioning/clarity-wise? Let me know! This is my first submission to this site!