aboutsummaryrefslogtreecommitdiff
path: root/challenge-114/duncan-c-white/README
blob: de73e12315455abacb3db199dd90999711c8a256 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Task 1: "Next Palindrome Number

You are given a positive integer $N.

Write a script to find out the next Palindrome Number higher than the given integer $N.

Example

  Input: $N = 1234
  Output: 1331

  Input: $N = 999
  Output: 1001
"

My notes: sounds very simple.  Generate and test for palindromic-ness.


Task 2: "Higher Integer Set Bits

You are given a positive integer $N.

Write a script to find the next higher integer having the same number
of 1 bits in binary representation as $N.

Example

Input: $N = 3
Output: 5

Binary representation of 3 is 011. There are two 1 bits. So the next
higher integer is 5 having the same the number of 1 bits i.e. 101.

Input: $N = 12
Output: 17

Binary representation of 12 is 1100. There are two 1 bits. So the next
higher integer is 17 having the same number of 1 bits i.e. 10001.
"

My notes: also sounds pretty simple.  Generate and test for "having B
bits set in the binary representation".