Given a sorted list of unique positive floats (none of which are integers) such as:

[0.1, 0.2, 1.4, 2.3, 2.4, 2.5, 3.2]


Evenly spread out the values that fall between two consecutive integers. So in this case you would get:

[0.333, 0.666, 1.5, 2.25, 2.5, 2.75, 3.5]


(I have truncated the values 1/3 and 2/3 for ease of presentation.)

• Can the input have repeats?
– xnor
Aug 9, 2023 at 6:35
• @xnor No, I edited the question
– Simd
Aug 9, 2023 at 6:36
• I think there should be more than one test case.
– Lynn
Aug 10, 2023 at 16:54

# Nekomata, 8 bytes

kŢᵉR→/+j


Attempt This Online!

Input and output are both in fractions, because Nekomata doesn't have floating point numbers.

kŢᵉR→/+j
k           Floor
e.g. [1/10,2/10,14/10,23/10,24/10,25/10,32/10] -> [0,0,1,2,2,2,3]
Ţ          Tally; returns a list of unique elements and a list of their counts
e.g. [0,0,1,2,2,2,3] -> [0,1,2,3], [2,1,3,1]
ᵉR        Range each count, and push the original list
e.g. [2,1,3,1] -> [[1,2],[1],[1,2,3],[1]], [2,1,3,1]
→       Increment
e.g. [2,1,3,1] -> [3,2,4,2]
/      Divide
e.g. [[1,2],[1],[1,2,3],[1]], [3,2,4,2] -> [[1/3,2/3],[1/2],[1/4,1/2,3/4],[1/2]]
e.g. [0,1,2,3], [[1/3,2/3],[1/2],[1/4,1/2,3/4],[1/2]] -> [[1/3,2/3],[3/2],[9/4,5/2,11/4],[7/2]]
j    Join
e.g. [[1/3,2/3],[3/2],[9/4,5/2,11/4],[7/2]] -> [1/3,2/3,3/2,9/4,5/2,11/4,7/2]


# R, 46 45 bytes

Edit: -1 byte thanks to pajonk

\(x)sequence(y<-rle(t<-x%/%1)$l)/rep(y+1,y)+t  Attempt This Online! A rare use for R's obscure sequence function: "For each element of x the sequence 1...x is created. These are concatenated and the result returned." The documentation also notes: "sequence mainly exists in reverence to the very early history of R." • -1 byte Aug 10, 2023 at 6:22 # APL (Dyalog Unicode), 18 16 bytes ∊⌊(⊂⊣+⍋⍤⊢÷≢⍤,)⌸⊢  Try it online! (Using Extended because TIO is out of date) ⌊()⌸⊢ on each unique floor (⌊) and its corresponding argument elements (⊢): ⊂ enclose the ⊣ left argument, i.e. the floor in question + added to ⍋⍤⊢ the grade (⍋ sorting permutation: 1…length) of (⍤) the right argument (⊢ the elements) ÷ divided by ≢⍤, the count (≢) of (⍤) the concatenation (,) of the floor and the elements ∊enlist (flatten) # 05AB1E, 10 bytes ïγεā¤>/+}˜  Explanation: ï # Floor all values in the (implicit) input-list γ # Group it into adjacent equal values ε # Map over each group: ā # Push a list in the range [1,length] (without popping the list) ¤ # Push its last item - the length (without popping the list) > # Increase this length by 1 / # Divide all values in the [1,length]-ranged list by this (length+1) + # Add it to each floored value of the current group }˜ # After the map: flatten the list of lists # (after which the result is output implicitly)  # Octave, 45 bytes @(x)(t=fix(x))+sum(triu(u=t==t'))./(sum(u)+1)  Try it online! ### Explanation @(x)(t=fix(x))+sum(triu(u=t==t'))./(sum(u)+1) @(x) % Anonymuous function (t=fix(x)) % t: round down x, element-wise u=t==t' % u: matrix of pairwise comparisons of t triu( ) % Upper triangular part of u sum( ) % Sum of each column of that sum(u)+1 % Sum of each column of u, plus 1 ./( ) % Divide, elemment-wise + % Add, element-wise  # Jelly, 11 bytes ḞJ÷L‘$+ƲƙF


Try it online!

# Python, 95 bytes

lambda x:[k+~j/~len(i)for k,[*i]in groupby(x,int)for j in range(len(i))]
from itertools import*


Attempt This Online!

• 97 Aug 9, 2023 at 6:52
• What would a non groupby solution look like?
– Simd
Aug 9, 2023 at 21:24

# JavaScript (Node.js), 61 bytes

x=>x.map(k=v=>(k[v|=0]=~-k[v])/~x.filter(t=>~~t==v).length+v)


Try it online!

# JavaScript (Node.js), 65 bytes

x=>x.map(k=v=>(k[v|=0]=-~k[v],v)).map(m=v=>v+(m[v]=~-m[v])/~k[v])


Try it online!

# Thunno 2S, 9 bytes

Nġıżnl⁺/+


Try it online!

Port of Kevin Cruijssen's 05AB1E answer.

#### Explanation

Nġıżnl⁺/+  # Implicit input
N          # Floor each value
ġ         # Group consecutive
ı        # Map over this list:
ż       #  Without popping, push [1..length]
nl     #  Length of the current group
⁺    #  Incremented
/   #  Divide the range by this
+  #  Add to the group
# Implicit output, flattened


# Vyxal, 64 bitsv2, 8 bytes

⌊øĖ₌ɾ›/+f


Try it Online!

-2 thanks to emanresu

## Explained

⌊Ġ:@₌ɾ›/+f­⁡​‎‎⁪⁡⁪⁠⁪⁡⁪‏⁠‎⁪⁡⁪⁠⁪⁢⁪‏‏​⁡⁠⁡‌⁢​‎‎⁪⁡⁪⁠⁪⁣⁪‏⁠‎⁪⁡⁪⁠⁪⁤⁪‏‏​⁡⁠⁡‌⁣​‎‎⁪⁡⁪⁠⁪⁢⁡⁪‏⁠‎⁪⁡⁪⁠⁪⁢⁢⁪‏⁠‎⁪⁡⁪⁠⁪⁢⁣⁪‏‏​⁡⁠⁡‌⁤​‎‎⁪⁡⁪⁠⁪⁢⁤⁪‏‏​⁡⁠⁡‌⁢⁡​‎‎⁪⁡⁪⁠⁪⁣⁡⁪‏‏​⁡⁠⁡‌⁢⁢​‎‎⁪⁡⁪⁠⁪⁣⁢⁪‏‏​⁡⁠⁡‌­
⌊Ġ          # ‎⁡Group the floored values by consecutive items.
:@        # ‎⁢Push a copy of that where each item is the corresponding length.
₌ɾ›     # ‎⁣Push a list [range 1..n for n in top], [n+1 for n in top]
/    # ‎⁤And divide those lists.
+   # ‎⁢⁡Add that to the original grouped values
f  # ‎⁢⁢Then flatten
💎


Created with the help of Luminespire.

• 9 Aug 9, 2023 at 10:58

# JavaScript (ES6), 63 bytes

a=>a.map(p=v=>a.map(V=>v^V||n++,n=1,p!=(p=~~v)?q=1:q++)&&p+q/n)


Try it online!

### Commented

a =>                 // a[] = input array
a.map(p =            // initialize p to a NaN'ish value
v =>               // for each value v in a[]:
a.map(V =>         //   for each value V in a[]:
v ^ V || n++,    //     increment n if floor(v) = floor(V)
n = 1,           //     starting with n = 1
p != (p = ~~v) ? //     if p is not equal to floor(v)
//     (update p to floor(v) afterwards):
q = 1          //       start a new group with q = 1
:                //     else:
q++            //       increment q
) &&               //   end of inner map()
p + q / n          //   the final value is p + q / n
)                    // end of outer map()


# R, 47 bytes

\(x)ave(x,y<-x%/%1,FUN=\(z)seq(z)/sum(1,z^0))+y


Attempt This Online!

Not as short as the answer using sequence, but ave is pretty neat, too.

# Charcoal, 19 bytes

≦⌊θＩＥθ⁺ι∕⊕№…θκι⊕№θι


Try it online! Link is to verbose version of code. Explanation:

  θ                 Input array
≦                   Apply to all elements
⌊                  Floor
θ              Floored array
Ｅ               Map over floored elements
ι            Current floored element
⁺             Plus
θ       Floored array
…        Truncated to length
κ      Current index
№         Count of
ι     Current floored element
⊕          Incremented
∕           Divided by
θ  Floored array
№   Count of
ι Current floored element
⊕    Incremented
Ｉ                Cast to string
Implicitly print


# Perl 5, 61 bytes

sub{map{//;map{$'+$_/($c+1)}1..($c=grep$'==int,@_)}0..$_[-1]}


Try it online!

sub {
map {                #loop ints in $_ from 0 to highest input number as int //; #copies current$_ to $'$c=grep$'==int,@_; #$c = count of current int in $_ in input array @_ map { #loop 1 to current count in$c
$' +$_ / ($c+1) #return current outer int + inner int / count+1 } 1..$c              #inner loop, no loop and no return if count is 0
}
0..\$_[-1]            #outer loop
}


# Pyth, 16 bytes

=sMQm+c@XdH1d/+Q


Try it online!

### Explanation

=sMQm+c@XdH1d/+QdddQ    # implicitly add Q
# implicitly assign Q=eval(input()), H=dict()
=  Q                    # assign Q to
sMQ                    # floor() mapped over Q
m              Q    # map lambda d over Q
XdH1            #   H[d]+=1 (or H[d]=1 if d not in H)
@    d           #   H[d]
c                 #   divided by
/   d      #   the count of how many times d appears in
+Qd       #   Q with d appended
+            d     #   plus d


# J, 21 bytes

<.+&;<.<@(#\%1+#)/.<.


Try it online!

Repetition of floor <. 3 times was surprisingly shorter than alternatives that DRY it out.

• <..../.<. For each group of the floor...
• <@(#\%1+#) Divide 1...g by (1 + g), where g is the group size. Box it <@ because we have to box heterogeneous lists.
• <.+&;` Add the floor elementwise to that unboxed result.