aboutsummaryrefslogtreecommitdiff
path: root/challenge-121/duncan-c-white/README
blob: a67e73b42bd2e5ec632a728718e9bed3f3386f19 (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
43
44
45
46
47
48
49
50
51
Task 1: "Invert Bit

You are given integers 0 <= $m <= 255 and 1 <= $n <= 8.

Write a script to invert $n bit from the end of the binary representation
of $m and print the decimal representation of the new binary number.

Example

  Input: $m = 12, $n = 3
  Output: 8

Binary representation of $m = 00001100
Invert 3rd bit from the end = 00001000
Decimal equivalent of 00001000 = 8

  Input $m = 18, $n = 4
  Output: 26

Binary representation of $m = 00010010
Invert 4th bit from the end = 00011010
Decimal equivalent of 00011010 = 26
"

My notes: trivial again.


Task 2: "Travelling Salesman
Submitted by: Jorg Sommrey

You are given a NxN matrix containing the distances between N cities.

Write a script to find a round trip of minimum length visiting all N
cities exactly once and returning to the start.

Example

Matrix: [0, 5, 2, 7]
        [5, 0, 5, 3]
        [3, 1, 0, 6]
        [4, 5, 4, 0]

Output:
        length = 10
        tour = (0 2 1 3 0)

BONUS 1: For a given number N, create a random NxN distance matrix and find a solution for this matrix.
BONUS 2: Find a solution for a random matrix of size 15x15 or 20x20
"

My notes: gurk!  TSP is hard.  I'm tired and I'm not doing that.