Login Register






0xDEAD10CC Programming Challenge #2 filter_list
Author
Message
0xDEAD10CC Programming Challenge #2 #1
Objective: Use only bitwise operations to swap the bits of an integer so that the following digit POSITIONS (marked by each unique color) within the following 32 bit int (in hex format below) are swapped, and assigned back to the original int:

0x123456

1 < - > 5
2 < - > 3
4 < - > 6

Correct Result: 0x532614

Challenge/Bonus: Start off with an integer in hex format with digits 1-6 randomized in terms of position, and swap based on the digit itself, where the position might not always be the same, according to the following map:
Code:
1 < - > 4 2 < - > 6 3 < - > 5

Examples:
1. 0x123456 = 0x465132
2. 0x246135 = 0x612453

In layman's terms, where ever 1 is in the hex format, swap it with 4, swap 2 with where ever 6 is, and 3 with 5.

*Optional: Use all values from 0-F instead of just numeric digits for hex format.

You MUST ONLY use math and bitwise operations to move the digits around. No casting to a string and re-interpreting it after string manipulation or any other cheap tricks...

Reply

RE: 0xDEAD10CC Programming Challenge #2 #2
Lol, there's absolutely no programmers here. I think my boredom on this forum has been painful enough... My activity level here will be in hiatus for a while. Smile

Reply

RE: 0xDEAD10CC Programming Challenge #2 #3
Wrong. Im here.

Working on that shitstorm now.

Reply

RE: 0xDEAD10CC Programming Challenge #2 #4
Just to clarify, in VB at least, there are going to be different results based on whether the input is interpreted as hexadecimal or not.

Code:
Dim x As Integer = 123456 Dim y As Integer = &H123456

Since x != y, should I just use the input like I do in x and just use some simple calculations to switch the numbers, or should I use y? Maybe I'm just confusing myself and you want me to interpret the input and make the output like so:

Code:
Dim input As Integer = Integer.TryParse(inputStream.readLine().Split("x"c)(1)) Dim output As String = String.Format("0x{0}", CStr(switcher(input)))
[Image: CDUAq9d.png]

Reply

RE: 0xDEAD10CC Programming Challenge #2 #5
This shouldn't be as difficult as you guys are making it... Input is hexadecimal, output is hexadecimal. I was using hex notation to show how the numeric value is transformed...

Reply