Weirdo Incorporates have a weird way of grading their staffs by the number of days they were present in the office:

  0 -  13 : F
14 - 170 : E
171 - 180 : D
181 - 294 : C
295 - 300 : B
301 - 365 : A

Note: The range is inclusive (i.e. 0-13 means 0 days and 13 days both will evaluate


Objective:

Write a program/function that outputs/returns the grade of an employee for the number of days [within inclusive range of 0-365] attended by the employee.

Rules:

• You may take input as a string or a number but must output as a string/alphabet (You may choose either lower or upper-case.)
• Standard loopholes apply.
• This is , so the shortest program in bytes wins!

Test cases:

12  => F
15  => E
301 => A
181 => C


Scoreboard:

var QUESTION_ID=142243,OVERRIDE_USER=8478;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){var F=function(a){return a.lang.replace(/<\/?a.*?>/g,"").toLowerCase()},el=F(e),sl=F(s);return el>sl?1:el<sl?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>

• sandbox – officialaimm Sep 9 '17 at 13:55
• Closely related – Mr. Xcoder Sep 9 '17 at 14:00
• Closer related – H.PWiz Sep 9 '17 at 14:09
• @Mr.Xcoder I recall that it was discussed in the sandbox that it's not a dupe of that since this doesn't have equal-sized ranges and that having suffixes such as +/-. – Erik the Outgolfer Sep 9 '17 at 14:20
• Can we get a scoreboard? – jrtapsell Sep 9 '17 at 17:55

Jelly,  18 17 15  14 bytes

NịØAx“A©r½ɗÇ‘¤


How?

NịØAx“A©r½ɗÇ‘¤ - Link: number, d
N              - negate d
ØA           -   uppercase alphabet yield = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
“A©r½ɗÇ‘  -   code-page indices = [65,6,114,10,157,14]
x          -   times = 'A'x65+'B'*6+'C'x114+'D'x10+'E'*157+'F'*14
ị             - index into (1-indexed & modular - hence the negation to allow all Fs
to be together at one end)


Javascript (ES6), 51 bytes

n=>"ABCDEF"[(n<14)+(n<171)+(n<181)+(n<295)+(n<301)]


Alternative solutions (longer):

53 52 bytes (-1 byte thanks to @Arnauld)

n=>"FEDCBA"[n>300?5:n>294?4:n>180?3:n>170?2:+(n>13)]


55 53 bytes (-2 bytes thanks to @Neil)

n=>"AFEDCB"[[14,171,181,295,301].findIndex(m=>n<m)+1]


55 bytes

n=>"FEDCBA"[[13,170,180,294,300].filter(m=>n>m).length]


Example code snippet:

f=
n=>"ABCDEF"[(n<14)+(n<171)+(n<181)+(n<295)+(n<301)]
console.log(f(12))
console.log(f(15))
console.log(f(301))
console.log(f(181))

• That summing the conditions thing is great!!! Wish I could upvote once again!!! :D – officialaimm Sep 9 '17 at 15:02
• I can save two bytes on one of your alternative solutions: n=>"AFEDCB"[[14,171,181,295,301].findIndex(m=>n<m)+1] – Neil Sep 9 '17 at 16:20
• -1 byte for your first alternative solution: n=>'FEDCBA'[n>300?5:n>294?4:n>180?3:n>170?2:+(n>13)] – Arnauld Sep 9 '17 at 20:35

TI-Basic, 40 bytes

sub("FEDCBA",sum(Ans≥{0,14,171,181,295,301}),1


J, 31 bytes

'FEDCBA'{~13 170 180 294 300&I.


Try it online!

Explanation

'FEDCBA'{~13 170 180 294 300&I.  Input: n
13 170 180 294 300     Constant array [13, 170, 180, 294, 300]
&I.  Use it with interval index to find which of
the intervals (-∞, 13], (13, 170], (170, 180],
(180, 294], (294, 300], (300, ∞) n can be inserted at
{~                       Index into
'FEDCBA'                         This string and return that char

• First time I've seen dyadic I. in the wild. Neat. – cole Sep 9 '17 at 23:23
• @cole I believe I've used it a couple times in the past in code-golf. – miles Sep 9 '17 at 23:55

Python 3, 50 bytes

Thanks to @jferard for -4 bytes.

lambda n:chr(70-sum(n>ord(x)for x in"\rª´ĦĬ"))


Try it online!

Python 3, 54 bytes

lambda n:chr(70-sum(n>x for x in[13,170,180,294,300]))


Try it online!

Saved 2 bytes thanks to @mathmandan, and indirectly thanks to @JonathanFrech.

Python 2, 56 bytes

lambda n:"ABCDEF"[sum(n<x for x in[14,171,181,295,301])]


Try it online!

• 54 bytes: lambda n:chr(70-sum(n>x for x in[13,170,180,294,300])). (See answer by @Jonathan Frech at codegolf.stackexchange.com/a/142244/36885) – mathmandan Sep 9 '17 at 17:21
• 50 bytes – jferard Sep 11 '17 at 7:56
• ruby port: ->n{(70-"ĬĦ´ª\r".chars.count{|i|n>i.ord}).chr} same size – Asone Tuhid Feb 28 '18 at 23:18

C, 62 61 bytes

Thanks to @Jonathan Frech for saving a byte!

f(n){putchar(70-(n<14?0:n<171?1:n<181?2:n<295?3:n<301?4:5));}


Try it online!

C, 57 bytes

#define f(n)70-(n<14?0:n<171?1:n<181?2:n<295?3:n<301?4:5)


Try it online!

C (gcc), 54 bytes

f(n){n=70-(n<14?0:n<171?1:n<181?2:n<295?3:n<301?4:5);}


Try it online!

C (gcc), 50 bytes

Using @Herman Lauenstein's solution.

f(n){n=65+(n<14)+(n<171)+(n<181)+(n<295)+(n<301);}


Try it online!

• 61 bytes. – Jonathan Frech Sep 9 '17 at 14:22
• Why not submit the shortest version as your main solution? – Shaggy Sep 10 '17 at 3:20
• @Shaggy The ones that require gcc resort to undefined behaviour, so I'd rather keep the well defined ones on the top, and sorting them from oldest to newest and at the same time from longest to shortest seems fine to me. – Steadybox Sep 11 '17 at 15:52

Kotlin, 56 bytes

{v->'F'-listOf(13,170,180,294,300).filter{it<v}.count()}


Try it online!

Beautified

{ v->
// Count the grades passed, then subtract that from F
'F' - listOf(13,170,180,294,300)
.filter { it < v }
.count()
}


Test

var x:(Int)->Char =
{v->'F'-listOf(13,170,180,294,300).filter{it<v}.count()}

fun main(args: Array<String>) {
println(x(12))
println(x(15))
println(x(301))
println(x(181))
}

• +1. I edited your answer to a more formal format, hope you won't mind. – officialaimm Sep 9 '17 at 17:52
• Not at all, I meant to fix my tool to output the right header – jrtapsell Sep 9 '17 at 17:52

Japt, 23 21 bytes

'Gc-[#ªT#´D294L*3]è<U


Try it

Explantion

Implicit input of integer U.

'Gc-


Subtract from the codepoints of the (single character) string G ...

è<U


The count of elements less than U ...

[#ªT#´D294L*3]


In the array of 170 (#ª), 0 (T), 180 (#´), 13 (D), 294 (literal) & 300 (L*3), so formatted and ordered to avoid the use of delimiting commas. 0 could be removed (subtracting from the codepoint of F instead) but then a comma would need to be added or C*F (12*15) used for 180, ultimately saving no bytes.

R, 50 44 bytes

LETTERS[6-sum(scan()>c(13,170,180,294,300))]


Try it online!

same as the javascript answer, but uses R's vectorization and LETTERS builtin to come in a tiny bit shorter.

Thanks to rturnbull for shaving off those last 6 bytes.

• 49 bytes – rturnbull Mar 1 '18 at 20:34
• In fact, 44 bytes by just making it a full program instead of a function. – rturnbull Mar 1 '18 at 20:38
• @rturnbull ah, I was about to say "no you need to wrap that in cat or else use source(program,ec=T) and count ec=T as a flag (as per the meta consensus on R programs), but by another, newer meta consensus we don't count flags any longer, so I that's a perfectly valid solution. – Giuseppe Mar 1 '18 at 20:50

Python 2, 77 bytes

lambda n:chr(70-sorted(_*(n>(0,13,170,180,294,300)[_])for _ in range(6))[-1])


Try it online!

Recursiva, 49 30 bytes

Y(++++<a301<a295<a181<a171<a14


Try it online!

Allow me to answer my own question in my own language. :D

• saved 19 bytes by using technique from @Herman Lauenstein's amazing JS answer

Explanation:

Y(++++<a301<a295<a181<a171<a14
<a301<a295<a181<a171<a14 calculate true/false for all the conditions
++++                         sum up all the conditions to obtain n which can be either 0,1,2,3,4 or 5
(                             yield upper-case Alphabet
Y                              Get n-th element


Perl 5, 47 + 1 (-p) = 48 bytes

$_=((F)x14,(E)x157,(D)x10,(C)x114,(B)x6)[$_]||A


Try it online!

Pyke, 28 bytes

G6<13T17*180T30*294]5FhQ>)s@


Try it here!

Explanation

G6<13T17*180T30*294]5FhQ>)s@ - Full program. T is the constant for 10.

G                            - The lowercase alphabet.
6<                          - With the letters after the index 6 trimmed.
13                        - The literal 13.
T17*                    - The integer 170, composed by 17 * 10, to save whitespace.
180                 - The literal 180.
T30*             - The integer 300, composed by 30 * 10.
294          - The literal 294.
]5        - Create a list of 5 elements.
FhQ>)   - For each element in the list.
h      - Increment.
Q     - The input.
>    - Is smaller ^^ than ^? Yields 1 for truthy and 0 for falsy.
)s  - Close loop and sum.
@ - Get the index in the alphabet substring explained above.


Jelly, 19 bytes

“n-'‘+⁹;“ỌẠÇ‘ð>SịØA


Try it online!

Footer executes all test-cases and formats the output.

Pyth, 30 bytes

@GtlfgTQmCdc"\r ª ´ & , m"d


The site doesn't seem to show the character with code point 1, so you need to insert a character with code point 1 before the &, ,, and m at the end

(Replace all 1s with character with code point 1):

@GtlfgTQmCdc"\r ª ´ 1& 1, 1m"d


Pyth, 25  26  bytes

@<G6sgRQ[13*17T180*30T294


Verify all the test cases.

Explanation

@<G6sgRQ[13*17T180*30T294 - Full program.

G                       - The lowercase alphabet.
< 6                      - With the letters after the index 6 trimmed. We will call "S".
[                 - Initialise a list literal.
13               - The literal 13.
*17T           - The integer 170, composed by 17 * 10, so save whitespace.
180        - The literal 180.
294 - The literal 294.
*30T    - The integer 300, composed by 30 * 10.
gRQ                  - For each element, return 1 if is is ≥ the input. 0 otherwise.
s                     - Sum.
@                         - Get the index into S of ^.
- Output implicitly.


Ly, 74 bytes

n(14)L["F"o;]p(171)L["E"o;]p(181)L["D"o;]p(195)L["C"o;]p(301)L["B"o;]"A"o;


Try it online!

A simple if-chain approach. I doubt it can be made much shorter.

• Are those paranthesis (...) required? P.S. nvm, Apparently they are. – officialaimm Sep 10 '17 at 8:34

Bash, 55 bytes

echo obase=16\;10 $[$1<{14,171,181,295,301}]|tr \  +|bc


Java 8, 55 bytes

n->n<14?'F':n<171?'E':n<181?'D':n<295?'C':n<301?'B':'A'


Try it here.

Alternative 57 bytes:

n->(char)(n<14?70:n<171?69:n<181?68:n<295?67:n<301?66:65)


Try it here.

Alternative 60 bytes:

n->"FEDCBA".charAt(n<14?0:n<171?1:n<181?2:n<295?3:n<301?4:5)


Try it here.

Maybe some kind of formula can be find to get 0-5 in a shorter way than n<14?0:n<171?1:n<181?2:n<295?3:n<301?4:5 using the last approach. Still investigating this.

PowerShell, 59 bytes

(,'F'*14+,'E'*157+,'D'*10+,'C'*114+,'B'*6+,'A'*65)["$args"]  Try it online! Similar-ish to Jonathan Allen's Jelly answer, in that we're constructing an array of all the letters concatenated together, then indexing into that array with the input $args.

Rabbit~, 50 bytes

(Noncompeting, postdates question. I just finished the interpreter(yay) and wanted to try and solve something. This is also my first code golf thing ever)

=>FEDCBA$<({.0-\_-^\-&^?n&&}_}\>\{{\>:.¤})Ð"ỤṅỌrḲA  It basically takes the differences from one grade to the next 14,157,10,114,6,65 (encoded as ỤṅỌrḲA) and subtracts from the input. If a negative number is found it stops progressing along the 'FEDCBA' sequence and outputs the letter. Small explanation of this beautiful piece of syntax Rabbit~ uses a grid based memory with one or several carets you can move around; this solution uses 2. =>FEDCBA$<({.0-\_-^\-&^?n&&}_}\>\{{\>:.¤})Ð"ỤṅỌrḲA - Full program.

FEDCBA                                           - Load bytes into grid
Ð"ỤṅỌrḲA - Load bytes 14,157,10,114,6,65 into second line of data grid
>       <      _ ^   ^     _  >   >               - Move caret (most instructions read from the grid below the active caret)
$- Create a new caret ( ) - Loop {.0 } } {{ } - Conditional statement checking if value at caret == 0 then move active caret to next grade else print and quit - - - - Subtract \ \ \ \ - Cycle active caret & && - Bitwise and to see if number is negative ?n - Get negative sign bit :. - Print value at caret as character ¤ - Terminate program  • Nice. Is there a way to try it online? – officialaimm Sep 15 '17 at 14:05 • Not at the moment ^^ – Adam Sep 15 '17 at 14:14 Excel, 53 bytes Sum of conditions, then returns the required ASCII character: =CHAR((A1<14)+(A1<171)+(A1<181)+(A1<295)+(A1<301)+65)  Alternative solutions: Summing conditions, return string index (63 bytes): =MID("ABCDEF",(A1<14)+(A1<171)+(A1<181)+(A1<295)+(A1<301)+1,1)  K (oK), 30 bytes Solution: "FEDCBA"@0 14 171 181 295 301'  Try it online! Explanation: Index into the correct bucket: "FEDCBA"@0 14 171 181 295 301' / the solution 0 14 171 181 295 301' / bin (') input in a bucket "FEDCBA"@ / index (@) into "FEDCBA"  Jotlin, 48 41 bytes {v->'F'-l(13,170,180,294,300).f{a<v}.l()}  Whole program: var x:(Int)->Char = {v->'F'-l(13,170,180,294,300).f{a<v}.l()} println(x(12)) println(x(15)) println(x(301)) println(x(181))  Ported my previous Kotlin answer here. V, 37 34 bytes aFEDCBA5äh113äh9äh156äh13ähÀ|vyVp  Try it online! Hexdump: 00000000: 3133 4146 1b31 3536 4145 1b39 4144 1b31 13AF.156AE.9AD.1 00000010: 3133 4143 1b35 4142 1b36 3441 411b eec0 13AC.5AB.64AA... 00000020: 7c76 7956 70 |vyVp  Basic idea: • Print FEDCBA, create 5 copies of B, 113 copies of C etc. resulting in the string FFFFFFFFFFFFFEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEDDDDDDDDDCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBBBBBA (There is probably a more efficient way to do this) • Go to nth column (n is the first argument), copy a single character and replace the entire string with it. 05AB1E, 19 bytes •5r¥[‚=€®•3ô›_ASsÏ¤  Try it online! Perl 6, 42 39 bytes {chr(65+[+] "\rª´ĦĬ".ords »>»$_)}


Stax, 18 bytes

5"«µħĭ",+|oH-VA@]


Run and debug online!

Explanation

Bytes counted in CP437.

5"«µħĭ",+|oH-VA@]
5            -        5 minus the result of the following
"«µħĭ"                   [14, 171, 181, 295, 301]
,+                Append input
|oH             Index of last element if the array were to be sorted
VA@]    Letter in the alphabet with the given index


C#, 110 bytes

x=>{if(x<14)return"F";if(x<171)return"E";if(x<181)return"D";if(x<295)return"C";if(x<301)return"B";return"A";};


Try it online

• You can shorten your lambda significantly using the trinary operator ?: as x<14?"F":x<170?"E":x<180?"D":x<294?"C":x<300?"B":"A" – Bradley Uffner Sep 11 '17 at 1:00