Skip to main content
added 313 characters in body
Source Link
resueman
  • 442
  • 2
  • 7

Clojure 63

(fn[v](let[l(apply min v)](map #(/(- % l)(-(apply max v)l))v))) 

Doesn't quite follow the rules, since it returns fractions instead of doubles. If that's not acceptable, add 7 bytes

Ungolfed:

(fn [values]
    (let [low (apply min values)]
         (map #(/ (- % low)
                  (- (apply max values) low))
              values)))

Callable like this:

((fn[v](let[l(apply min v)](map #(/(- % l)(-(apply max v)l))v))) [5 -20 30])

Output: (1/2 0 1)

Clojure 63

(fn[v](let[l(apply min v)](map #(/(- % l)(-(apply max v)l))v))) 

Doesn't quite follow the rules, since it returns fractions instead of doubles. If that's not acceptable, add 7 bytes

Clojure 63

(fn[v](let[l(apply min v)](map #(/(- % l)(-(apply max v)l))v))) 

Doesn't quite follow the rules, since it returns fractions instead of doubles. If that's not acceptable, add 7 bytes

Ungolfed:

(fn [values]
    (let [low (apply min values)]
         (map #(/ (- % low)
                  (- (apply max values) low))
              values)))

Callable like this:

((fn[v](let[l(apply min v)](map #(/(- % l)(-(apply max v)l))v))) [5 -20 30])

Output: (1/2 0 1)

Source Link
resueman
  • 442
  • 2
  • 7

Clojure 63

(fn[v](let[l(apply min v)](map #(/(- % l)(-(apply max v)l))v))) 

Doesn't quite follow the rules, since it returns fractions instead of doubles. If that's not acceptable, add 7 bytes