I have a matrix that represents a grid and would like to find out all possible places an object can move to.
An object can only move horizontally or vertically.
Let's assume that the example below is the grid I'm looking at, which is represented as a 2d matrix. The object is the *, the 0s are empty spaces that an object can move to, and the 1s are walls which the object cannot jump over or go on to.
What is the best way to find all possible movements of this object provided that it can only move horizontally or vertically?
I'd like to print a message saying: "There are 9 places the object can go to." The 9 is for the example below, but I would like it to work for any configuration of the below grid. So all I have to do is give the current coordinates of the * and it will give me the number of possible positions it can move to.
A thing to note is that the *'s original position is not considered in the calculations, which is why for the example below the message would print 9 and not 10.
I have a isaWall method that tells me if the cell is a wall or not. The isaWall method is in a Cell class. Each cell is represented by its coordinates. I looked into using Algorithms like BFS or DFS, but I didn't quite understand how to implement them in this case, as I am not too familiar with the algorithms. I thought of using the Cells as nodes of the graph, but wasn't too sure how to traverse the graph because from the examples I saw online of BFS and DFS, you would usually have a destination node and source node (the source being the position of the *), but I don't really have a destination node in this case. I would really appreciate some help.
I am building chat application and I want a table - chats and another - messages. Chat will have many messages, also id and user_first and user_second. Right now I am doing it with a composite primary key where the composite is user_first and user_second and the id is unique auto-increment:
I have 2 @RequestParam parameters in my Controller. I want to set the Required value of both the parameters based on a Condition. The condition could be like, if one of the parameter is passed, the other has to passed. So set the required of other as true and vice-versa. Otherwise set both false if none of the parameters are passed.
The syntax of using the variable name inside @RequestParam() is wrong, but I wanted to explain what I want.
I currently have a Many to Many relationship between Events and Users. The auto generated table in my DB called event_registrations keeps track of the relationship and which user goes to which event based on their ids.
What I want to do is have a controller method that takes in an Event id together with a list of user IDs so that the given users get removed from the given event.
Here are my model classes:
What I've tried so far in the EventController:
This runs without problems but the the entries still exist in the join table afterwards. When debugging this, the users do get deleted from the Event object but the changes don't get persisted to the database.
1.an AdmisRejet can be linked to a Admis or a PreCandidat.
2.Admis and PreCandidat can have many AdmisRejet.
All was working when I only had Admis and AdmisRejet.
But then I add PreCandidat (the same way as Admis), I get an hibernate error.
Can't find out why...
Model (they all have getters and setters and ids):
Caused by: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on nc.unc.importparcoursup.dao.admisDAO.AdmisRejet.preCandidatRejet references an unknown entity: nc.unc.importparcoursup.dao.pgiCocktailDAO.entity.PreCandidat