I want to write a code that solve this puzzle for me.
The rules:
If you click the green tile it becomes red.
If you click the red tile it becomes gray.
If you click the gray tile it becomes green.
Also, if you click on a tile, it's neighbors vertically and horizontally also changes color, like a cross.
You can click on a tile as many as you like.
For exmaple:
Click to view - If I click on the marked tile...
Click to view - It will look like this
I'm looking for a logic behind it, so far I have no clue. I can code that, it's not what I'm looking for, but the (mathematical?) logic behind the solution. For example, the Rubik's Cube steps to make to have a full ordered cube. I want to make a program that automatically tries to solve this.
Its very simple if you do this with an array,
int[][] box;
if(//if you click box[a][b])
{
change_color(a,b);
change_color(a-1,b);
change_color(a+1,b);
change_color(a,b-1);
change_color(a,b+1);
}
change_color(int x,int y)
{
if(box[x][y]==red)
box[x][y]=grey;
if(box[x][y]==grey)
box[x][y]=green;
if(box[x][y]==green)
box[x][y]=red;
}
Related
I don't know how to properly explain this.
I have a svg element which is a big rectangle. If i scroll down, then click on my element, the click isn't registered where my mouse is, but where my mouse would be if i didn't scroll down.
So, if i scroll down by 100px and click on my rectangle, the click will be registered 100px above where i actually clicked.
It's behaving as if i hadn't scrolled down.
Edit: I'm using event.clientX and event.clientY to get the mouse position.
I'm new to svg and i don't know the right keywords to describe my problem.
I'm using svg.js, though i don't think it's relevant to the problem.
I assume this is a well known thing. Can someone point me in the right direction? What kind of keyword am i looking for here?
The problem seems simple enough, i just need to know what to search for.
Thank you.
The problem was the utilization of (event.clientX, event.clientY) to get the mouse position.
In the presence of a vertical and/or horizontal scroll, using these properties caused a mismatch between where the mouse appeared within the page and the mouse position provided by (event.clientX, event.clientY).
I was using the mousedown event, with the mousemove event to create a selection rectangle, similar to what you can find in video games. When horizontal or vertical scrolling had been applied, my selection rectangle didn't appear where my mouse was.
This was solved by using event.pageX and event.pageY (instead of clientX and clientY).
Thank you to #ccprog for pointing me in the right direction.
This is a new one for me. In Design view I am unable to see the first 150 pixels of the design view window-- including the buttons/options to the left of the AppTheme button. I've tried the Pan and Zoom tool, which seems to do nothing. It shows the full view and blueprint view filling the Pan and Zoom tool interface. Any idea how to fix this:
"Window" -> "Restore Default Layout" worked for me.
I had the same problem.
Just drag the mouse where your projects are to the far left of the screen and slowly move with your mouse over to the right until you will see somewhere in the middle resize pointer- thats your design view border. Click it and move to the right and it should appear!
If you want i can try to make a gif how to do it if the above does not help.
For instance, I have a body with a hollow area which is not visible from the outside. What's a good way to view the whole body, visualizing all of the surfaces, especially when there are voids within the body? Is changing the opacity the only way? I was hoping there would be a wireframe view, but I haven't been able to find a way to toggle one, if it exists.
Also, to change the opacity, I have to turn the body into a component. Is there a way to do this without having to make a permanent modification like that?
Another way I've found is to use Section Analysis to see a cross section, but that's not great for getting a view of everything at once.
At the bottom of the view, there is a toolbar. Click on the monitor icon, then choose Visual Style, Wireframe in the menu:
Wireframe with Hidden Edges should be the most appropriate in your case.
I'm trying to animate a search icon with Snap.svg. You can see that here on my Codepen, the search icon.
I use transform scale to have my icon "bouncing" on each click : loupe.animate({transform: 's1.2s.8'},300,mina.easeout);
The animation runs well except on first click, where it just scales down, then on the second click the effect is ok.
Same behavior with the refresh icon (at the bottom of the Pen), the rotation animation turn in the wrong sense on first click althought I reset transform before animate.
I guess maybe my icons aren't scaled and rotate on good position before first click but I can't find where I could check/set that.
Thank you very much for your help !
Hugo
Use absolute values by using capital letters:
loupe.animate({transform: 'S1.2S.8'},300,mina.easeout);
For the refresh icon, change the rotation from R180 to R-180 and R360 to R0. This seems to work consistently.
clicRefresh = function() {
fleche.stop().animate({transform: 'S.6,.6 R-180 114.75 122.5'}, 400, mina.easeout, function() {
fleche.stop().animate({transform: 'S1,1 R0 114.75 122.5'}, 600, mina.easeout);
});
};
I have a cell (call it A) which is used once in a hierarchically higher cell (call it P). When I place A in P, its borders are rather larger than the actual content of A. When I descend to A and zoom-fit, it is way zoomed out, indicating there is something present way out on the edges.
I may have dragged objects there at one point but currently there is nothing visible. It is driving me crazy in terms of aligning objects, etc.
Is there any way to clean this up or something?
If I recall Cadence used to have a problem with leaving steiners behind when you moved routes. They are not visible but the db treats them as real objects for the bbox calculation. According to Cadence, deleting the objects should not harm anything. Open the layout in edit mode and paste this code into the CIW. This will delete all the steiner objects in your layout. If this was the root cause after saving you should see the bbox return to normal.
cv=geGetEditCellView()
foreach( item cv~>steiners
dbDeleteObject( item )
)
This thread may be considered "dead," but hopefully this helps.
It is possible the layers that are not visible are turned off.
To turn them on, go to the layers pane on the left. (If it is not there you can turn it on by going to Window —> Assistants —> Layers)
You can then click the drop down arrow in the top right corner and click Edit Valid Layers.
Then, click all valid in the Set Valid Layers popup. Click Ok.
Finally, check the Used Layers Only checkbox in the Layers pane. Look for any layers that weren't there before that you don't need.
Usually it happens when you draw the cell in LayoutXL, particularly when you insert pins.
Layer and purpose in these pins are selected separately for some reason, that is why it is easy to enter "impossible" combination.
Nothing happens, then you do it again and continue drawing. But there are several invisible squares that will continuously frustrate your inner perfectionist. You do the following:
Open this cell's layout, switch to Virtuoso window and enter:
lppList=list()
then:
foreach(shape hiGetCurrentWindow()~>cellView~>shapes if( (member(shape~>lpp lppList)==nil) then lppList=cons(shape~>lpp lppList)))
You have created the list with all layers in this layout, you can view it by entering:
lppList
You'll get something like this:
(("NW" "drawing")
("NP" "drawing")
("weird" "guy")
("M1" "pin")
("M3" "pin")
)
If you find a weird guy in this company, just enter the following command:
foreach(shape hiGetCurrentWindow()~>cellView~>shapes if((shape~>lpp == list("weird" "guy")) shape~>lpp = list("prBoundary" "drawing")))
If you see that some squares, labels (or whatever unseen before) appears as prBoundary, just delete it, save, and your layout will be small and shiny again.