...
Now we need to find a way transforming the input to the flag, ie. 0 for 48..58 and 1 for 65..70. Oh look, a logarithm!
INPUT | ASCII | ASCII-48 | LOG10(ASCII-48) | LOG10((ASCII-48)*0.9+1) | INT(LOG10((ASCII-48)*0.9+1) |
---|---|---|---|---|---|
'0' | 48 | 0 | n/a | 0,00 | 0 |
'1' | 49 | 1 | 0,00 | 0,28 | 0 |
'2' | 50 | 2 | 0,30 | 0,45 | 0 |
'3' | 51 | 3 | 0,48 | 0,57 | 0 |
'4' | 51 | 4 | 0,60 | 0,66 | 0 |
'5' | 52 | 5 | 0,70 | 0,74 | 0 |
'6' | 54 | 6 | 0,78 | 0,81 | 0 |
'7' | 55 | 7 | 0,85 | 0,86 | 0 |
'8' | 56 | 8 | 0,90 | 0,91 | 0 |
'9' | 57 | 9 | 0,95 | 0,96 | 0 |
'A' | 65 | 17 | 1,23 | 1,21 | 1 |
'B' | 66 | 18 | 1,26 | 1,24 | 1 |
'C' | 67 | 19 | 1,28 | 1,26 | 1 |
'D' | 68 | 20 | 1,30 | 1,28 | 1 |
'E' | 69 | 21 | 1,32 | 1,30 | 1 |
'F' | 70 | 22 | 1,34 | 1,32 | 1 |
Let's put it together:
Readable implementation:
...
Just cut'n paste this formula, that's it.
Enjoy,
Aleš
...