Thread: 0xDEADBEEF (who can get to it first)

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    18

    0xDEADBEEF (who can get to it first)

    Hey people, I've a challenge for whoever's up to it...
    Here's the deal:

    using the hex values:

    AAAAAAAA
    CCCCCCCC
    F0F0F0F0
    FF00FF00
    FFFF0000

    and only the bitwise operators:
    ~
    |
    &
    ^

    create an expression that comes out to the well-known
    DEADBEEF

    I thought maybe we could do it like a contest if anyone's up for it...I don't have an answer yet, (I've been on it for a few hours now, think I might be going in circles...) but hopefully I will soon to check up with anyone that decides to join in

    Ok, good luck!

    Oh, yeah, and here's a little refresher on the operators if you need it: http://www.cs.cf.ac.uk/Dave/C/node13.html

  2. #2
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Hmm shouldn't be too hard to figure out a solution, but the solution with the least moves is the key I think.

    Could just set it up in a program and just have it randomly choose one of the values and one of the operators and do it untill it comes out as 0xDEADBEEF. With how fast processors are it shouldn't take too long heh... going to play with it.

  3. #3
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    With a mere 1 post under your belt, and this thread reeking of an inventive new ploy (kudos to that, however, if that is the case) to have someone else do your homework, I will close this.

    Feel free to PM a mod or an admin to reconcile this, and it will most happily be reopened. Perhaps you could also post, in this PM, a proposed solution?

    [edit]
    Quote Originally Posted by nine-hundred
    Hey, there are no admins/mods online, and like I said in the post I'm still working on the solution but I can show you what I have so far (in C code anyways)
    I'll just use these as variable names because it's easier to type:
    x = 0xAAAAAAAA
    y = 0xCCCCCCCC
    z = 0xf0f0f0f0
    s = 0xff00ff00
    t = 0xffff0000

    <<"partial solution" removed at OP's request>>

    now in binary this works out to (unless my calculations are wrong, and considering this was done by hand may be)
    1101 1110 1111 1111 0001 0001 1111 1111
    ^ ^ ^ ^ ^
    which is rather close to DEADBEEF in bin:
    1101 1110 1010 1101 1011 1110 1110 1111

    I'm thinking I need only come up with a mask for the grouped middle ones and I hope I'm almost there....of course I don't want to jump the gun on this one.

    If I get to it before I go to sleep, I'll send the full answer out

    Thanks.
    Good enough for me to give this a second chance.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  4. #4
    Registered User
    Join Date
    Jan 2007
    Posts
    18
    Thanks, sorry about the misunderstanding... for anyone who still wants in, I'm going to be working on it again tonight...didn't get much farther last night than what was posted

  5. #5
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    Perhaps the rules should be laid out a little clearer. I second Wraithan, in that fewer operations should be worth more.

    So you know, this is solvable: I do have a solution (not hard to get once you figure out a few tricks...) that involves:
    27 numbers, 17 ANDs, 9 ORs, 10 inverses, and 0 XORs.
    It's a bit long. =) (Hand crafted, of course.)
    I also wrote a program to try and brute force every combination, and it checked every combo up to 5 operations using &, |, ^, and any number of ~s, and found nothing. At 450MHz, the six group is going to take a while. (I need to find a way to add in %done or saving, or something...)
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  6. #6
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Well if you do it sequentially, then you should just have to save the last number and last sign for each position.

    EDIT: Think I am going to go set it up to brute force on my desktop, 2.8ghz and I am not doing much else with it.

  7. #7
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Quote Originally Posted by Cactus_Hugger
    Perhaps the rules should be laid out a little clearer. I second Wraithan, in that fewer operations should be worth more.

    So you know, this is solvable: I do have a solution (not hard to get once you figure out a few tricks...) that involves:
    27 numbers, 17 ANDs, 9 ORs, 10 inverses, and 0 XORs.
    It's a bit long. =) (Hand crafted, of course.)
    I also wrote a program to try and brute force every combination, and it checked every combo up to 5 operations using &, |, ^, and any number of ~s, and found nothing. At 450MHz, the six group is going to take a while. (I need to find a way to add in %done or saving, or something...)
    Let's see, mine was:
    Code:
    '&' : 16
    '(' : 9
    ')' : 9
    'G' : 5
    'I' : 5
    'O' : 5
    'Q' : 3
    '^' : 5
    'l' : 5
    '|' : 1
    '~' : 12
    So 23 values, 16 ANDs, 12 NOTs, 1 OR, and 5 XORs.

    I just had to find a solution myself, too. But I stopped short of trying to simplifying it.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  8. #8
    Registered User
    Join Date
    Jan 2007
    Posts
    18

    Thumbs up

    Meant to post this sooner but couldn't load the site up for some reason or another...

    I also tried to do it with code randomly inject operators and varaibles, after some frustration, but like you guys I got the the answer by hand first.

    I ended up with a huge expression and after simplification it came down to
    (if I counted right)
    9 |
    10 ~
    13 &
    and somehow no ^...don't know why that was

    using the numbers 26 times

    It could probably be simplified more, but I started going in circles on it and stopped

    I'm all for who can do it in the fewest steps!

    If anyone's curious PM me and I can send my solution, but I don't want to ruin it for anyone still going at it! I'm sure there must be a shorter one, I'm going to continue and see if I can get the algorithm for the program to be more successful

    Happy Hunting

  9. #9
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Quote Originally Posted by nine-hundred
    and somehow no ^...don't know why that was
    Probably just your personal choice. I started with an expression that resulted in EEEEEEEE and used successive XORs to set or clear bits to get
    DEEEEEEE
    DEAEEEEE
    DEADEEEE
    DEADBEEE
    DEADBEEF
    It's been way too long, I couldn't even remember Karnaugh maps or Quine-McCluskey until I started searching. But I don't think they apply(?).
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

Popular pages Recent additions subscribe to a feed