我在 public void showPath() {
int[][] sol = new int[m.length][m[0].length];
for (int j = 0; j < sol.length; j++) {
for (int i = 0; i < sol[0].length; i++) {
sol[j][i] = m[j][i];
}
}
if (solveMaze(sol, m.length - 1, 0, exitCords) == false)
System.out.println("Solution doesn't exist");
else {
for (int y = 0; y < sol.length; y++) {
for (int x = 0; x < sol[0].length; x++) {
if (sol[y][x] == exitCords[0] && sol[y][x] == exitCords[1]) {
System.out.print("E ");
} else {
if (sol[y][x] == 1) {
System.out.print(" ");
} else if (sol[y][x] == 3) {
System.out.print("~");
} else {
System.out.print("# ");
}
}
}
System.out.println();
}
}
}
public boolean solveMaze(int[][] sol, int y, int x, int[] exitCords) {
//exitCords[] is a one-dimensional array that holds the x and y coordinate of the exit point on a maze.
if (y == exitCords[1] && x == exitCords[0]) {//Base Case
return true;
}
//North
if (!isWall(x, y - 1) && sol[y - 1][x] != 3) {
sol[y][x] = 3;//3 is assigned to positions you already visited.
y--;
sol[y][x] = 3;
//Implement recursion to call the solveMaze again on this line.
solveMaze(sol, y, x, exitCords);
return true;
}
//South
else if (!isWall(x, y + 1) && sol[y + 1][x] != 3) {
sol[y][x] = 3;
y++;
sol[y][x] = 3;
solveMaze(sol, y, x, exitCords);
return true;
}
//East
else if (!isWall(x + 1, y) && sol[y][x + 1] != 3) {
sol[y][x] = 3;
x++;
sol[y][x] = 3;
solveMaze(sol, y, x, exitCords);
return true;
}
//West
else if (!isWall(x - 1, y) && sol[y][x - 1] != 3) {
sol[y][x] = 3;
x--;
sol[y][x] = 3;
solveMaze(sol, y, x, exitCords);
return true;
}
/*The following line of code are to get out of dead ends and replace every position near a dead end with a wall*/
else if ((isWall(x, y - 1) && isWall(x, y + 1) && isWall(x + 1, y)) || (isWall(x, y - 1) && isWall(x, y + 1) && isWall(x - 1, y))
|| (isWall(x - 1, y) && isWall(x, y + 1) && isWall(x + 1, y)) || (isWall(x - 1, y) && isWall(x, y - 1) && isWall(x + 1, y))) {
if (isWall(x, y - 1) && isWall(x, y + 1) && isWall(x + 1, y)) {
sol[y][x] = 0;
solveMaze(sol, y, x - 1, exitCords);
return true;
}
if (isWall(x, y - 1) && isWall(x, y + 1) && isWall(x - 1, y)) {
sol[y][x] = 0;
solveMaze(sol, y, x + 1, exitCords);
return true;
}
if (isWall(x - 1, y) && isWall(x, y + 1) && isWall(x + 1, y)) {
sol[y][x] = 0;
solveMaze(sol, y - 1, x, exitCords);
return true;
}
if (isWall(x - 1, y) && isWall(x, y - 1) && isWall(x + 1, y)) {
sol[y][x] = 0;
solveMaze(sol, y + 1, x, exitCords);
return true;
}
}
return false;
}
机器中创建了创建的存储库,
UNIX
此外,我还完成了针对个人$sudo git --bare init /var/repos/git/repo00001
执行的以下命令,
UNIX users
我应该在哪个目录下创建$ git config --global user.email "MyfullName@mindtree.com"
$ git config --global user.name "Anand Sadasivam"
,我在签入文件时遇到问题。应该为目录git repsitories
设置权限,用户,组,我将在其下创建git存储库。目前它在root权限下完成。在使用/var/repos/git
UNIX user
独占创建单独的git
或任何特定的步骤或git命令,以便先创建用户
我观察到git init
--bare
在init
下创建了一些基本结构。但当我git repository
时,我的存储库是空的。
由于我使用了git clone
,我可以看到如下创建的文件夹结构,
--bare
以下是我在# ls
HEAD branches config description hooks info objects refs
git bash client side
处为某些文件的初始签入所做的命令, - Windows
Readme.txt
是否出现这种情况,因为安装$ git clone anand@xx.xx.xx.xxx:/var/repos/git/repo00001
Cloning into 'repo00001'...
anand@xx.xx.xx.xxx's password:
warning: You appear to have cloned an empty repository.
<<I had created Readme.txt file under the present directory>>
$ git add Readme.txt
$ git status
On branch master
$ git commit -a
[master (root-commit) 8201309] Initial commit
Committer: Anand Sadasivam <MMyEmpID@mindtree.com>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the
following command and follow the instructions in your editor to edit
your configuration file:
git config --global --edit
After doing this, you may fix the identity used for this commit with:
git commit --amend --reset-author
1 file changed, 1 insertion(+)
create mode 100644 Readme.txt
$ git push origin master
anand@xx.xx.xx.xxx's password:
Counting objects: 3, done.
Writing objects: 100% (3/3), 240 bytes | 120.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
error: remote unpack failed: unable to create temporary object directory
To xx.xx.xx.xxx:/var/repos/git/repo00001
! [remote rejected] master -> master (unpacker error)
error: failed to push some refs to 'anand@xx.xx.xx.xxx:/var/repos/git/repo00001'
$ git show-ref
82013098f6801ea32bb620b612f779c8dade6d83 refs/heads/master
$ git push origin HEAD:master
anand@xx.xx.xx.xxx's password:
Counting objects: 3, done.
Writing objects: 100% (3/3), 240 bytes | 120.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
error: remote unpack failed: unable to create temporary object directory
To xx.xx.xx.xxx:/var/repos/git/repo00001
! [remote rejected] HEAD -> master (unpacker error)
error: failed to push some refs to 'anand@xx.xx.xx.xxx:/var/repos/git/repo00001'
时Windows Settings
被跟踪了。
或git bash/gui client
repository
权限问题或repository creation user
问题
答案 0 :(得分:0)
使用--bare init --shared
选项创建的存储库具有rw
组用户访问权限。
git@xx-xx-xx-xxx~/repos/repo00001$ ls -l
total 32
-rw-rw-r-- 1 git git 23 Apr 20 06:44 HEAD
drwxrwxr-x 2 git git 4096 Apr 20 06:44 branches
-rw-rw-r-- 1 git git 66 Apr 20 06:44 config
-rw-rw-r-- 1 git git 73 Apr 20 06:44 description
drwxrwxr-x 2 git git 4096 Apr 20 06:44 hooks
drwxrwxr-x 2 git git 4096 Apr 20 06:44 info
drwxrwxr-x 62 git git 4096 Apr 25 08:22 objects
drwxrwxr-x 4 git git 4096 Apr 20 06:44 refs
因此,我已将需要使用git存储库的所有用户添加到组git
,因为您可以看到git:git
已创建存储库,而组git
已rwx
对于将要维护修订的大多数文件夹。
我添加了&amp;验证用户是否已添加到群组, - git
anand@capsimt00001:~$ sudo usermod -a -G git anand
anand@capsimt00001:~$ groups
anand geckoo git