Today's challenge is to write a function that accepts three integer values, calculates the mean, then returns the letter value associated with that...
For further actions, you may consider blocking this person and/or reporting abuse
CSS
This will only work on Safari because, for some forsaken reason, Safari is the only browser that supports min() and max() at the moment. Which is funny considering that normally it is the other way around 🤷♂️
This can be represented as a decision machine with different ranges for different grades. Then the idea would be to have an element to which we pass the three grades as CSS variables (all integers or it will fail), calculate the z-index to set which element should be visible. I would need to double check the logic, I think it's correct. Also, I think the code can be simplified.
Here is the code running. Remember it will only work on Safari:
Too much ternary operators...
You could use something like that:
Not tested but I believe it would work in JavaScript.
I've Started to write a c# answer only to find out I'm going the exact same route as your answer...
Here's mine:
Gist: gist.github.com/kerrishotts/559154...
Nice Js!
Rust:
Python
Clojure (my new adventure):
Elm
Tests
Here's my type-level implementation in haskell:
My first stab at writing something other than "Hello World!" in golang:
This is my quick python solution
APL (I'm using Dyalog APL):
{md←10|m←(+⌿÷⍴)⍵ ⋄ ((1+60 70 80 90 101⍸m)⊃'FDCBA'),' -+'[1+(md≠5)×1+(,5)⍸md]}
If you think that's too short to work - here's the proof:
First, let's define that as a function:
getMark←{md←10|m←(+⌿÷⍴)⍵ ⋄ ((1+60 70 80 90 101⍸m)⊃'FDCBA'),' -+'[1+(md≠5)×1+(,5)⍸md]}
And now you can simply do
getMark 64 55 92
C-
getMark 99 89 93
A-
getMark 33 99 95
C+
And if you still don't believe me, try it here or there! ;-)
(These online solutions use the symbol ≢ instead of ⍴ - they are equivalent in this case, but ≢ renders incorrectly on dev.to. There's also an issue with another APL-Character: ⍸ - if someone from the dev-team would contact me, I'd love to help sorting that out...)
My solution in js
Perl solution, using a regex to extract the last digit (but we need to replace 100 by 99 for it to work).
I wrote this in Python with the assumption that the input of the function will all be integers between 0 and 100.
Scala
Solved Using Purescript inspired from Amin Nairi