473,796 Members | 2,826 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Now a tricky one ;-)

Consider this 3d vector:

const SIZE = 'some_size';
std::vector<std ::vector<std::v ector<char> > >GRID(SIZE,
std::vector<std ::vector<char> >(SIZE,
std::vector<cha r>(SIZE)));

It can be viewed as coords for SIZE^3 different points in a 3d space:
Now, instead of point consider Cubes.
They each have 6 sides:
front - z+
back - z-
top - y+
bottom - y-
rigth - x+
left - x-
(+/- being direction on the axis)

Each of the 6 sides can be turned on/off so you get like a 3d
labyrinth.

And now for the tricky part:
1.
No point/cube can be completely closed, i.e. the sum of the 6 bit
defining it must be < 6 or if you and the bits the result must be 0,
ect.
allso consider only using 3 bits to define each point/cube in the grid.
2.
There must be away from any given point/cube to another.
To help this the cube is infinite/finite, what i mean is best shown
with an example:

The Grid is the size of 16^3
Sudenly you find your self at point 17,17,17 (x,y,z) how ever it is no
problem bacause the point is allso defined as 1,1,1 (x,y,z)
Now only one question remains...
How to do it the easy way?
Hope to get some mindblowing ideas... ;-)

Feb 2 '06 #1
14 2047
fe**********@ho tmail.com wrote:
Consider this 3d vector:

const SIZE = 'some_size';
std::vector<std ::vector<std::v ector<char> > >GRID(SIZE,
std::vector<std ::vector<char> >(SIZE,
std::vector<cha r>(SIZE)));

It can be viewed as coords for SIZE^3 different points in a 3d space:
Now, instead of point consider Cubes.
They each have 6 sides:
front - z+
back - z-
top - y+
bottom - y-
rigth - x+
left - x-
(+/- being direction on the axis)

Each of the 6 sides can be turned on/off so you get like a 3d
labyrinth.

And now for the tricky part:
1.
No point/cube can be completely closed, i.e. the sum of the 6 bit
defining it must be < 6 or if you and the bits the result must be 0,
ect.
allso consider only using 3 bits to define each point/cube in the grid.
2.
There must be away from any given point/cube to another.
To help this the cube is infinite/finite, what i mean is best shown
with an example:

The Grid is the size of 16^3
Sudenly you find your self at point 17,17,17 (x,y,z) how ever it is no
problem bacause the point is allso defined as 1,1,1 (x,y,z)
Now only one question remains...
How to do it the easy way?
If only that question was well-posed. What is *it*?

Options:

a) define a data structure to model the situation.
b) test whether a given set of data satisfies conditions (1) and (2).
c) write a graphics interface to display the model on screen.
d) write a simulation of mice running through that labyrinth.
e) ...

Please, be more specific.

Hope to get some mindblowing ideas... ;-)


Good luck.
Best

Kai-Uwe Bux
Feb 2 '06 #2
I thought i did enough explaining, its an idea i got some time ago, but
i dont really need help with it atm, just though it would be an
interesting subjet to discuss.
Ill try to explain again.

a) Define a data structure to simulate a 3d labyrinth, rubrikscube
like, i.e. a cube containing cubes.
b) test whether condition 1 and 2 is true, if not solve the problem.
Condition 1.
cube can be completely closed
Condition 2.
There must be away from any given point/cube to another.
To help this the cube is infinite/finite, what i means is best shown
with an example:

The Grid is the size of 16^3
Sudenly you find your self at point 17,17,17 (x,y,z) how ever it is no

problem bacause the point is allso defined as 1,1,1 (x,y,z)

c) A 3d graphics interface to move around in the labyrinth would be
nice, it is however not something i expect from anyone but my self.
(sometime in the future)
d) Come with ideas/oppinions.

I dont thing i can write it any simpler than this, sry ;-)

Feb 2 '06 #3
*************** **
Condition 1.
cube can't be completely closed
*************** **

Feb 2 '06 #4
fe**********@ho tmail.com wrote:
*************** **
Condition 1.
cube can't be completely closed
*************** **

What cube? Please quote.

--
Ian Collins.
Feb 2 '06 #5
ofcourse it can be misinterpeted, sry.
the 'GRID' is made up by 'CUBES' like coordinates in 3 dimensions.

heres a little thing i pu together that might amuse some:

#include <iostream>
#include <vector>

const int SIZE = 256;
std::vector<std ::vector<std::v ector<char> > >GRID(SIZE,
std::vector<std ::vector<char> >(SIZE,
std::vector<cha r>(SIZE)));
std::vector<boo l>B(8);

bool rand_bit() {
return rand() > (RAND_MAX / 2);
}

void write_bits(int x,int y,int z) {
GRID[x][y][z] |= B[0]?1:0;
GRID[x][y][z] |= B[1]?2:0;
GRID[x][y][z] |= B[2]?4:0;
GRID[x][y][z] |= B[3]?8:0;
GRID[x][y][z] |= B[4]?16:0;
GRID[x][y][z] |= B[5]?32:0;
GRID[x][y][z] |= B[6]?64:0;
GRID[x][y][z] |= B[7]?128:0;
}

void read_bits(int x,int y,int z) {
B[0] = GRID[x][y][z]&1;
B[1] = GRID[x][y][z]&2;
B[2] = GRID[x][y][z]&4;
B[3] = GRID[x][y][z]&8;
B[4] = GRID[x][y][z]&16;
B[5] = GRID[x][y][z]&32;
B[6] = GRID[x][y][z]&64;
B[7] = GRID[x][y][z]&128;
}

void new_grid() {
int x;
int y;
int z;
for (z = 0; z < SIZE; z++) {
for (y = 0; y < SIZE; y++) {
for (x = 0; x < SIZE; x++) {
B[0] = rand_bit();
B[1] = rand_bit();
B[2] = rand_bit();
write_bits(x,y, z);
if (x == SIZE - 1) {
GRID[x-(SIZE-1)][y][z] |= B[0]?8:0;
}
else {
GRID[x+1][y][z] |= B[0]?8:0;
}
if (y == SIZE - 1) {
GRID[x][y-(SIZE-1)][z] |= B[1]?16:0;
}
else {
GRID[x][y+1][z] |= B[1]?16:0;
}
if (z == SIZE - 1) {
GRID[x][y][z-(SIZE-1)] |= B[2]?32:0;
}
else {
GRID[x][y][z+1] |= B[2]?32:0;
}
}
}
}
}

void search_illegal( ) {
int x;
int y;
int z;
for (z = 0; z < SIZE; z++) {
for (y = 0; y < SIZE; y++) {
for (x = 0; x < SIZE; x++) {
read_bits(x,y,z );
if (B[0]&B[1]&B[2]&B[3]&B[4]&B[5] == 1) {
std::cout << x << "," << y << "," << z << " IS
ILLEGAL!";
std::cin.get();
}
}
}
}
}

int main() {
std::cout << "Defining new grid...";
new_grid();
std::cout << "done";
std::cin.get();
search_illegal( );
}

This way works except that u get alot of "illegal" cubes that are
closed.
it doesnt look at the "get to one point from another without any
trouble" issue.

Feb 2 '06 #6
by the way, this allso need a non pseudo random bit genarator,
otherwise ull just get the same setup every time you restart the
program...

Feb 2 '06 #7
> by the way, this allso need a non pseudo random bit genarator,
otherwise ull just get the same setup every time you restart the
program...


rand, srand, time
Feb 2 '06 #8
fe**********@ho tmail.com wrote:
I thought i did enough explaining, its an idea i got some time ago, but
i dont really need help with it atm, just though it would be an
interesting subjet to discuss.
Ill try to explain again.

a) Define a data structure to simulate a 3d labyrinth, rubrikscube
like, i.e. a cube containing cubes.
b) test whether condition 1 and 2 is true, if not solve the problem.
You keep talking riddles: solve *which* problem. So far you have not stated
any problem.
Condition 1.
cube can be completely closed
Condition 2.
There must be away from any given point/cube to another.
To help this the cube is infinite/finite, what i means is best shown
with an example:

The Grid is the size of 16^3
Sudenly you find your self at point 17,17,17 (x,y,z) how ever it is no

problem bacause the point is allso defined as 1,1,1 (x,y,z)

c) A 3d graphics interface to move around in the labyrinth would be
nice, it is however not something i expect from anyone but my self.
(sometime in the future)
d) Come with ideas/oppinions.

I dont thing i can write it any simpler than this, sry ;-)


It's not a matter of your description not being simple; it is a matter of
your description being neither precise nor complete. You seem to be
obsessed with the wrap-around feature of your model. I guess, that is
understood by now. What is still missing is what you want to do with this
space.

So there is this building with 16*16*16 rooms, each the shape of a cube.
These room have 6 walls each and some walls have doors. Also this building
has a star trek like transport unit so that when you pass through a door
that would take you outside the building, you are automagically teleported
so that you reenter the building from the opposite side. There are so many
doors that you can get from any room to any other room (possibly using the
teleporting feature). I got that much. Now what?
Best

Kai-Uwe Bux
Feb 2 '06 #9
Now nothing, thats all finish, fin, fini, i just need a way to build
this system and a way to hold the information, i have thought alot
about it and think its a pretty hard task. ofcourse i have other ideas
too, fx. what to use it for, but i dont think thats important right
know, just think about it as a big 3d labyrint.

Feb 2 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2163
by: Lars Plessmann | last post by:
Problem: I try to store data in a objects field and read it out again. Sounds easy, yeah. But its a bit tricky here.... ;-) This is the class Customer.php with some setter and getter functions to store customers data within an object. It works. Furthermore, it includes a synchronize method, which calls the individual setXXX function and takes the data from the $_POST or $_GET var.
0
595
by: dracolytch | last post by:
Good day all, Ok, I have a pretty tricky problem that I need some help with. I pass around search query information a fair amount (specifically WHERE statements). Normally, I just rawurlencode() the buggers, and pass them via the URL. I like having the where clauses in the URL, because then someone can just bookmark the URL, or send it to a friend, and I don't have to worry about a thing. If someone does a search that requires a LIKE...
1
13779
by: JZ | last post by:
Oracle 9iR2 I have a table: SQL> select * from test; A B C ------------------- ---------- ---------- 01/01/2004 10:00:00 1 1 01/01/2004 11:00:00 1 2
4
1913
by: Bung | last post by:
Hi, I have a tricky sql statment I have to write (tricky for me) and I am stuck. I'm having trouble with the following problem. Table1 (Column a, Column b, Column c) Table2 (Column a, Column b, Column c) Table3 (Column a, Column b, Column c) Table1 contains a row of value (1, 2, 3)
4
1478
by: Angel Cat | last post by:
I have 2 tables joined together by the IDs, People and the pets they own PEOPLE ID NAME 1 JohnSMith 2 JaneDoe PETS ID PET
25
3412
by: PyPK | last post by:
What possible tricky areas/questions could be asked in Python based Technical Interviews?
5
1636
by: Danny | last post by:
Hi there I need help with a tricky problem. I have a 2 dimensional array with qualities such as ball size, ball color, ball weight. Now I have to print out all the possible combinations of this. assume I have it stored as such i have two dimensional array ball:
8
1885
by: pras.vaidya | last post by:
Hi , below given question was asked to me during an interview and i figured it out little tricky . It would be a great help if anyone could solve it. Code : - main() { char *s1="abcd",*s2=NULL; /* From here you call a function copy which has return type void .
7
15095
by: NileshKorpe | last post by:
Can you please send me link of some c++ tricky (confusing) questions usually asked in the c++ technical interview. Thank You
1
1506
by: MorrganMail | last post by:
Or at least I find it tricky. :-) Assume we have three tables A, B and C. Table A contains a path and the distance for traveling that path: A (PathId, NodeId, Dist (from previous node)) 1, 1, 0 1, 2, 10 1, 3, 5
0
9673
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9525
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10452
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10221
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6785
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5440
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5569
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.