RNR's blog

By RNR, history, 8 years ago, In English

UVa 11173 — Grey Codes with a one-liner bit manipulation expression for each test case, i.e. find the k-th Gray code.

Solution is k^(k>>1)

Let’s reverse the UVa 11173 problem above. Given a gray code, find its position k using bit manipulation.

Solution: ????

  • Vote: I like it
  • +3
  • Vote: I do not like it

| Write comment?
»
8 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by RNR (previous revision, new revision, compare).

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

This may be helpful.

  • »
    »
    7 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I was searching for one liner when I posted But later found out that it may not be possible