Let S be the set of {(1,1),(1,−1),(−1,1)}-lattice path which begin at (1,1), do not use the same vertex twice, and never touch either the x-axis or the y-axis. Determine the largest value of n such that every path in S which ends at (n,n) has length at most 50000.

To solve this problem, we need to find the largest value of n such that every path in the given set S, which starts at (1,1) and ends at (n,n), has a length at most 50000.

Let's first understand what a lattice path is. A lattice path is a path consisting of a series of steps, where each step either moves one unit to the right or one unit upwards. In this problem, we are given a specific set of lattice paths which begin at (1,1), do not repeat any vertex, and do not touch either the x-axis or the y-axis. The set S is defined as {(1,1), (1,-1), (-1,1)}.

To find the length of a lattice path, we need to count the number of steps it takes to reach the endpoint (n,n). Since each step moves either one unit to the right or one unit upwards, the length of a path can be calculated as the sum of the absolute differences between the x-coordinates and y-coordinates of each step.

Let's take an example to understand this concept. Consider the lattice path (or sequence of steps): (1,1) -> (2,1) -> (3,2) -> (4,2) -> (5,3), which starts at (1,1) and ends at (5,3). Here, the length of the path can be calculated as |2-1| + |3-2| + |4-2| + |5-3| = 1 + 1 + 2 + 2 = 6.

Now, to find the largest value of n such that every path in S, which ends at (n,n), has a length at most 50000, we need to iterate over different values of n and check the length of each path. We start with n = 1 and keep incrementing it until we find a value where the length of all paths ending at (n,n) exceeds 50000. The previous value of n will then be the largest value that satisfies the condition.

Here is a Python code snippet that implements this approach:

```python
S = [(1, 1), (1, -1), (-1, 1)]
n = 1
length_limit = 50000

while True:
path_lengths = []
for i in range(1, n + 1):
path_length = sum([abs(x - y) for x, y in zip(range(1, i + 1), range(1, i + 1))])
if path_length > length_limit:
break
path_lengths.append(path_length)

if len(path_lengths) != n:
break

n += 1

largest_n = n - 1
print("Largest value of n:", largest_n)
```

When you run this code, it will print the largest value of n that satisfies the condition of having a length at most 50000 for every path ending at (n,n) in the given set S.