List of equally distanced numbers in an interval [a,b] that contains both a and b

I’m writing a program that should split a given interval $ [a,b]$ into a list of $ \sqrt{N}$ equidistant numbers:

N = 27; a = -1; b = 1; p = 3; Range[a, b, RealAbs[b - a]/(N^(1/p) - 1)]  {-1, 0, 1} 

The result should be a list that has $ N^\frac{1}{p}$ numbers, and that contains both $ a$ and $ b$ . The program works when $ N=x^p$ , where $ x$ is an integer, but fails to include $ b$ in the list when this condition is not met.

For example, when $ p=2$ and $ N$ is not a perfect square:

Np = 10; a = -1; b = 1; p = 2;  Range[a, b, RealAbs[b - a]/(Np^(1/p) - 1)] // N  {-1., -0.0750494, 0.849901} 

Is there a way to specify that both ends, $ a$ and $ b$ , should be part of the list, and then equally split the interval into a total of $ \sqrt{N}$ equidistant numbers?

Create a list copy having distanced duplicate elements

I have a list containing integers, I would like to create a copy of it such that duplicate elements are at least some distance apart. I am aware that it would be necessary to have "enough" different elements and a sufficiently "long" starting list but I would like to create that copy or return a message that it is not possible.

Here is a python "possible" implementation but sometimes this program creates an infinite loop.

import random  out = [] pbs = [1, 2, 3, 1, 2, 3, 5, 8] l = len(pbs) step = 3  while l > 0:      pb = random.choice(pbs)      if pb in out:         lastindex = out[::-1].index(pb)         if (len(out) - lastindex) < step:             continue     pbs.remove(pb)     out.append(pb)     l += -1  print(out) 

Thank you for your help.