Page 1 of 1 [ 7 posts ] 

ahayes
Veteran
Veteran

User avatar

Joined: 2 Dec 2006
Gender: Male
Posts: 9,506

13 Apr 2007, 3:31 pm

This is the output of f(x) from x=1..100, what is f(x)?

Code:
11,
8,
9,
14,
15,
12,
13,
2,
3,
0,
1,
6,
7,
4,
5,
26,
27,
24,
25,
30,
31,
28,
29,
18,
19,
16,
17,
22,
23,
20,
21,
42,
43,
40,
41,
46,
47,
44,
45,
34,
35,
32,
33,
38,
39,
36,
37,
58,
59,
56,
57,
62,
63,
60,
61,
50,
51,
48,
49,
54,
55,
52,
53,
74,
75,
72,
73,
78,
79,
76,
77,
66,
67,
64,
65,
70,
71,
68,
69,
90,
91,
88,
89,
94,
95,
92,
93,
82,
83,
80,
81,
86,
87,
84,
85,
106,
107,
104,
105,
110,


Here is a picture
Image



nitro2k01
Snowy Owl
Snowy Owl

User avatar

Joined: 5 Feb 2007
Gender: Male
Posts: 173

13 Apr 2007, 5:24 pm

I get a feeling it's got to do with manipulating individual bits in the binary representation of the number. Possibly this is an xor pattern or eveb a function that moves bits in the number.



nitro2k01
Snowy Owl
Snowy Owl

User avatar

Joined: 5 Feb 2007
Gender: Male
Posts: 173

13 Apr 2007, 5:26 pm

f(x)=x XOR 10



ahayes
Veteran
Veteran

User avatar

Joined: 2 Dec 2006
Gender: Male
Posts: 9,506

13 Apr 2007, 5:47 pm

Code:
#include <iostream>
#include <fstream>

using std::cout;
using std::endl;
using std::ofstream;

unsigned int tenXor(unsigned int x)
{
   return (unsigned int)10^x;
}

int main () {
   ofstream ostr("output.csv");
   for(int i = 1; i < 101; i++)
   {
      ostr << tenXor(i) //<< "\t\t" << tenXor(i+10) << "\t\t" << tenXor(i+20) << endl;
      << ", " << endl;
   }
   ostr.close();
}



lau
Veteran
Veteran

User avatar

Joined: 17 Jun 2006
Age: 76
Gender: Male
Posts: 9,795
Location: Somerset UK

13 Apr 2007, 7:49 pm

Unfortunately, I'd cheat on this game. The one you chose here was quite a nice little devious one. If you had gone for a more complex one, I would have looked it up on "The On-Line Encyclopedia of Integer Sequences" (this is one of the pair with my name on it).

That even has things like:
4
3
3
5
4
4
3
5
5
4
3
6
6
8
8
7
7
9
8
8
6
10
10
12
11
11
10
12
12
11
6
10
10
12
11
11
10
12
12
11
etc


_________________
"Striking up conversations with strangers is an autistic person's version of extreme sports." Kamran Nazeer


0_equals_true
Veteran
Veteran

User avatar

Joined: 5 Apr 2007
Age: 42
Gender: Male
Posts: 11,038
Location: London

14 Apr 2007, 5:16 pm

Lau wrote:
Unfortunately, I'd cheat on this game. The one you chose here was quite a nice little devious one. If you had gone for a more complex one, I would have looked it up on "The On-Line Encyclopedia of Integer Sequences" (this is one of the pair with my name on it).

That even has things like:
4
3
3
5
4
4
3
5
5
4
3
6
6
8
8
7
7
9
8
8
6
10
10
12
11
11
10
12
12
11
6
10
10
12
11
11
10
12
12
11
etc


Cool site :)



lau
Veteran
Veteran

User avatar

Joined: 17 Jun 2006
Age: 76
Gender: Male
Posts: 9,795
Location: Somerset UK

14 Apr 2007, 5:27 pm

Oh! I forgot to post my bash one-liner:

Code:
for j in "" 1 2 3;do for k in 0 1 2 3 4 5 6 7 8 9;do echo $(( `number -l $j$k|wc -c` - 1 ));done;done


_________________
"Striking up conversations with strangers is an autistic person's version of extreme sports." Kamran Nazeer