What is the best way to refactor presentation code out of my domain objects in an ASP.NET MVC solution?
By : Pushpender Sangwan
Date : March 29 2020, 07:55 AM
I wish this helpful for you I like TBD's comment. It's wrong because you are mixing domain concerns with UI concerns. This causes a coupling that you could avoid. As for your suggested solutions, I don't really like any of them.

Finding the shortest or longest solution to a maze
By : Bill Gurling
Date : March 29 2020, 07:55 AM
hop of those help? I agree with @wwii's answer, if you are exploring all the solutions, simply return the length of each successful path and then find the shortest one. This can be achieved with the following changes: changing your solved function to return the path instead of true or false. at each node instead of putting 3 for visited, you can put the minimum length from that node to the solution (or the origin), put 1 for wall and nodes that can't reach the solution. Nodes that can't reach the solution are essentially walls. code :
GOAL = 'G'
WALL = 'W'
EMPTY = 'E'
def solve(grid, x, y):
if grid[x][y] == WALL or grid[x][y].endswith(GOAL):
return grid[x][y]
candidates = []
# explore neighbors clockwise starting by going down
if x < len(grid)1:
candidates.append('d' + solve(grid, x + 1, y))
if y > 0:
candidates.append('l' + solve(grid, x, y  1))
if x > 0:
candidates.append('u' + solve(grid, x  1, y))
if y < len(grid)1:
candidates.append('r' + solve(grid, x, y + 1))
# get rid of none solutions from candidates
candidates = [x for x in candidates if not x.endswith(GOAL)]
if not candidates: # if no solution, it's essentially a wall
grid[x][y] = 'W'
else:
# getting shortest path
grid[x][y] = sorted(candidates, key=lambda x: len(x))[0]
# for longest path use code below instead of above
# grid[x][y] = sorted(candidates, key=lambda x: len(x))[1]
return grid[x][y]

8 puzzle: Solvability and shortest solution
By : hari charan
Date : March 29 2020, 07:55 AM
hope this fix your issue I'll refer only to the solvability issue. Some background in permutations is needed. A permutation is a reordering of an ordered set. For example, 2134 is a reordering of the list 1234, where 1 and 2 swap places. A permutation has a parity property; it refers to the parity of the number of inversions. For example, in the following permutation you can see that exactly 3 inversions exist (23,24,34):

Rearrange a list of points to reach the shortest distance between them
By : Hank M
Date : March 29 2020, 07:55 AM
I hope this helps you . The technical question you're asking is similar to "What is the minimum hamiltonian path of a graph" (your tuples are vertices, and the distance between them are the weight of the edges). This problem can't be solved in polynomial time, so your dataset had better be small. Since your graph is complete (all nodes are connected), the minimum hamiltonian path problem may not completely apply. In any case, the answer below uses brute force. It permutes all possible paths, calculates the distance of each path, and then gets the minimum.

how to rearrange differential equation solution using matlab?
By : Skander Basly
Date : March 29 2020, 07:55 AM
Hope this helps Because your equation has K inside and outside the exponential, you can't get a nice closed form solution, so the best you hope to achieve is a numerical approximation.

