Am I an engineer?

43

12

Recently, an electrical engineer studying traffic light timings was fined $500 by the state of Oregon for referring to himself as an engineer.

Given a 2 letter string as input, representing a US state, output:

  • I am not an engineer if the state is Oregon (OR)
  • I am an engineer if the state is any other US state
  • What is an engineer? given any other input

Output may not contain any leading whitespace, but may contain as much trailing whitespace as you wish.

You can assume the input will always be 2 uppercase letters.

Here is a list of all 50 US state abbreviations:

AL, AK, AZ, AR, CA, CO, CT, DE, FL, GA, HI, ID, IL, IN, IA, KS, KY, LA, ME,
MD, MA, MI, MN, MS, MO, MT, NE, NV, NH, NJ, NM, NY, NC, ND, OH, OK, OR, PA,
RI, SC, SD, TN, TX, UT, VT, VA, WA, WV, WI, WY

Scoring

This is , so fewest bytes in each language wins!

Skidsdev

Posted 2017-06-02T09:31:00.530

Reputation: 9 656

Can I have a trailing space in the output? – Business Cat – 2017-06-02T13:51:27.407

@BusinessCat yes, will update spec to say that – Skidsdev – 2017-06-02T14:06:47.947

4Side note: If you concatenate the whole string together, you get "...OKORPARISCSDTN..." ;-) – Mateen Ulhaq – 2017-06-04T06:42:44.137

Mats Järlström wouldn't be allowed to present himself as an engineer in Texas, either. – Ben Voigt – 2017-06-05T17:22:52.400

Answers

17

C#, 311 309 240 237 222 195 184 183 bytes

s=>s=="OR"?"I am not an engineer":"MINCALA MSCTNMNVAKY WAZ PAR FL GA NHID COKSD ME MDE MA MTX NE NJ NY ND MOH RIA UT WVT WIL WY".Contains(s)?"I am an engineer":"What is an engineer?";

Try it online!

Saved 2 bytes by adding the space before an to b

-69 (huehue) -72 bytes thanks to TheLethalCoder

-15 bytes thanks to TotallyHuman's genius states string

-38 bytes cos more string compression

Ungolfed:

public static string a(string s)
{
    var b = " an engineer";
    if (s == "OR")
    {
        return "I am not" + b;
    }
    else
    {
        if ("MINCALA MSCTNMNVAKY WAZ PAR FL GA NHID COKSD ME MDE MA MTX NE NJ NY ND MOH RIA UT WVT WIL WY".Contains(s))
        {
            return "I am" + b;
        }
        else
        {
            return $"What is{b}?";
        }
    }
}

Skidsdev

Posted 2017-06-02T09:31:00.530

Reputation: 9 656

Use ..."+b instead of interpolated strings, change if..else if...else to return s=="OR"?....:System.Arr...i.e. use a ternary. Useu.Containsinstead ofArray.Exists. I think if you use spaces instead of commas then.Split()` with no params will work. – TheLethalCoder – 2017-06-02T10:28:08.187

declare b and u in the same line and even though you have to use explicit type string should still save you a byte – LiefdeWen – 2017-06-02T10:31:27.847

@StefanDelport u is an array not string. However, you can save bytes by setting u as a string and using .Contains on it. – TheLethalCoder – 2017-06-02T10:35:39.610

240 bytes: s=>{var b=" an engineer";return s=="OR"?"I am not"+b:"AL AK AZ AR CA CO CT DE FL GA HI ID IL IN IA KS KY LA ME MD MA MI MN MS MO MT NE NV NH NJ NM NY NC ND OH OK PA RI SC SD TN TX UT VT VA WA WV WI WY".Contains(s)?"I am"+b:$"What is{b}?";};. Think I've removed all the relevant whitespace. (Untested) – TheLethalCoder – 2017-06-02T10:38:48.210

237: s=>s=="OR"?"I am not an engineer":"AL AK AZ AR CA CO CT DE FL GA HI ID IL IN IA KS KY LA ME MD MA MI MN MS MO MT NE NV NH NJ NM NY NC ND OH OK PA RI SC SD TN TX UT VT VA WA WV WI WY".Contains(s)?"I am an engineer":"What is an engineer?"; implicit return with all strings fully hardcoded, untested but should work. Mmm probably should have made my own solution... Oh well have this for free :P – TheLethalCoder – 2017-06-02T10:45:41.460

An anonymous user suggested saving a byte by dropping the O from ORIA. – Martin Ender – 2017-06-02T11:59:51.437

PAR and RIA can be joined to save 2 bytes. – user202729 – 2017-06-02T14:20:50.707

The input "" responds "I am an engineer." instead of "What is an engineer?". – Monkah VII – 2017-06-02T18:01:49.217

I think COHINCALAKSCTNVARIAZ MNMOKY WVTX MSDE MIL WID FL GA ME MA NJ NY NH PA WA WY NE MD MT ND UT works an saves 2 bytes. – Marie – 2017-06-02T20:34:41.697

1You can golf this by defining " an engineer" as a separate variable to save some bytes. – OldBunny2800 – 2017-06-02T23:29:29.623

11

JavaScript (ES6), 182 bytes

s=>['I am'+(x=' an engineer'),`What is${x}?`,'I am not'+x][s=='OR'?2:'MNNMLATNAKALARAZCACOCTDEFLGAHIIAIDILINKSKYMAMDMEMIMOMSMTNCNDNENHNJNVNYOHOKPARISCSDTXUTVAVTWAWIWVWY'.search(s)&1]

Demo

let f =

s=>['I am'+(x=' an engineer'),`What is${x}?`,'I am not'+x][s=='OR'?2:'MNNMLATNAKALARAZCACOCTDEFLGAHIIAIDILINKSKYMAMDMEMIMOMSMTNCNDNENHNJNVNYOHOKPARISCSDTXUTVAVTWAWIWVWY'.search(s)&1]

console.log(f("OR"))
console.log(f("NY"))
console.log(f("TX"))
console.log(f("YO"))

Arnauld

Posted 2017-06-02T09:31:00.530

Reputation: 111 334

3Fails for e.g. LA :/ – Christoph – 2017-06-02T13:07:26.047

@Christoph Should be OK now. Thanks for reporting this! – Arnauld – 2017-06-02T13:14:48.927

Thought it was missing OR for moment - silly! – Chas Brown – 2017-06-03T02:33:58.760

Use https://codegolf.stackexchange.com/a/124164/76323 to optimize

– l4m2 – 2018-03-09T06:19:00.027

8

C, 215 208 190 bytes

-7 thanks to Cool Guy

#define z" an engineer"
#define f(s)!strcmp(s,"OR")?"I am not"z:strstr("MINCALA MSCTNMNVAKY WAZ PAR FL GA NHID COKSD ME MDE MA MTX NE NJ NY ND MOH RIA UT WVT WIL WY",s)?"I am"z:"What is"z"?"

Used @totallyhuman's "genus string".

How it works:

  • "string"z automatically concatenates "string" with z (" an engineer"). Yes, C does that.
  • !strcmp(s,"OR") compares the string against "OR".
  • ?"I am not"z returns "I am not an engineer" if true. Otherwise...
  • :strstr(...,s) checks if @totallyhuman's genius string contains the provided string.
  • ?"I am"z returns "I am an engineer" if so, and...
  • :"What is"z"?") returns "What is an engineer?" otherwise.

Try it online!

MD XF

Posted 2017-06-02T09:31:00.530

Reputation: 11 605

1206 bytes: #define z " an engineer" f(char*s){!strcmp(s,"OR")?puts("I am not"z):strstr("MINCALA MSCTNMNVAKY WAZ PAR FL GA NHID COKSD ME MDE MA MTX NE NJ NY ND MOH RIA UT WVT WIL WY",s)?puts("I am"z):puts("What is"z);} – Spikatrix – 2017-06-03T09:31:08.620

@CoolGuy That won't work for "What is an engineer?" But I got it to work in 209 bytes. Thanks! – MD XF – 2017-06-03T16:49:05.933

You can return the string instead of printing it – l4m2 – 2018-03-09T16:03:01.487

@l4m2 Did something similar. – MD XF – 2018-03-11T18:23:12.080

6

Python 2, 228 168 bytes

lambda s:('What is%s?','I am'+' not'*(s=='OR')+'%s')[s in'MINCALA MSCTNMNVAKY WAZ PAR FL GA NHID COKSD ME MDE MA MTX NE NJ NY ND MOH ORIA UT WVT WIL WY']%' an engineer'

Try it online!

Felipe Nardi Batista

Posted 2017-06-02T09:31:00.530

Reputation: 2 345

2The state encoding is hilarious. – Ramon Snir – 2017-06-02T16:50:51.330

5

Python 2, 192 186 182 178 176 bytes

Could probably compress the state string more.

lambda s,e=' an engineer':'I am'+' not'*(s=='OR')+e if s in'MINCALAZ SCT FL GA WIAKSD ME MD MA MNMS MOKY MTNE NVTX NH NJ NY ND COHIDE OR PARIL UT VA WA WV WY'else'What is%s?'%e

Try it online!

totallyhuman

Posted 2017-06-02T09:31:00.530

Reputation: 15 378

2You only use u in if s in u can you note use it directly instead of declaring it? – TheLethalCoder – 2017-06-02T11:20:34.483

@TheLethalCoder Yup, just doing that right now lol. – totallyhuman – 2017-06-02T11:21:34.767

1@totallyhuman that string compression is pretty amazing, nice one! – Skidsdev – 2017-06-02T11:23:25.310

2@totallyhuman VALA WAZ NCA COH CTX SDE FL GA HID WIL MIN IAKSC KY ME MD MA MNMS MOK MTNE NH NJ NY ND PARI UT NVT WV WY is the smallest I can make it – Skidsdev – 2017-06-02T11:27:29.473

2'MINCALA MSCTNMNVAKY WAZ PAR FL GA NHID COKSD ME MDE MA MTX NE NJ NY ND MOH ORIA UT WVT WIL WY' – Felipe Nardi Batista – 2017-06-02T11:29:30.870

The above string is still shorter – Skidsdev – 2017-06-02T11:41:29.963

2Whoops, sorry it took me so long. Seems I have lost as copying that string doesn't make my answer better than the one using it. Please stop upvoting this and upvote the other better answer. – totallyhuman – 2017-06-02T12:49:05.413

1@totallyhuman I'll upvote your comment instead for being a good sport – Skidsdev – 2017-06-02T13:24:38.797

5

Java (JDK 10), 184 bytes

s->s.format(s.equals("OR")?"I am not%s":"MINCALA MSCTNMNVAKY WAZ PAR FL GA NHID COKSD ME MDE MA MTX NE NJ NY ND MOH RIA UT WVT WIL WY".contains(s)?"I am%s":"What is%s?"," an engineer")

Try it online!

I apologize for reusing the compressed string: I couldn't find anything better by myself... :(

Olivier Grégoire

Posted 2017-06-02T09:31:00.530

Reputation: 10 647

4

05AB1E, 104 103 101 bytes

„€À€ˆ„I€Ü‚.•~Zµ∞/'—¶[@øl•Œ2ù.•9₆\|&׃Ω#àöF},cΓ páe;ð²∍₆jÌn#dÅ?DvĆ8A•2ôìuIå©è¹„ORQi'€–}„€¤©É)ðýª'?®_×J

Try it online!

Old 104 byte version in case that is more easily improved.

„€À€ˆ„I€Ü‚.•ÂkXñ…ΓVt€Ïè∍‡Λi„2¶’að=–½6™oÑþÁāõgO·ð~
λ†₃›;â&ÄFv¾‡1~ǝQa«;cS•u2ôIå©è¹„ORQi'€–}„€¤©É)ðýª'?®_×J

Not happy with the compression nor the special case for ?.

Emigna

Posted 2017-06-02T09:31:00.530

Reputation: 50 798

OK what is this? Did you just re-order the states or something? – Erik the Outgolfer – 2017-06-02T12:05:57.260

@EriktheOutgolfer: The 104 byte version is just a compression of the numbers corresponding to the characters positions in the alphabet (A=1,C=3 ...). The 103 byte version does the same for some states and merge some states that end in the same letter that a new state starts with. I'm sure this can still be improved and I'll add a better explanation when I've golfed it more. – Emigna – 2017-06-02T12:12:59.703

1Nice answer! I like the .•~Zµ∞/'—¶[@øl•Œ2ù you've used for some of the states, instead of just compressing all the states and doing the . And nice approach overall. (Glad I saw your answer before attempting something myself, because it definitely wouldn't have been as short..) – Kevin Cruijssen – 2018-09-17T14:35:36.070

4

F#, 222 211 bytes

let f v=let(a,b)=if"OR"=v then("I am not",".")elif"WALAKSCARINMNVTNCTX NHIDE MOHIL COKY MSD PAZ WIA WVA FL GA MA MD ME MI MT NE ND NJ NY UT WY".Contains v then("I am",".")else("What is","?")in a+" an engineer"+b

Try it online!

Expanded:

let f v =
    let (a,b) =
        if "OR" = v then ("I am not",".")
        elif "WALAKSCARINMNVTNCTX NHIDE MOHIL COKY MSD PAZ WIA WVA FL GA MA MD ME MI MT NE ND NJ NY UT WY".Contains v then ("I am",".")
        else ("What is","?")
    a + " an engineer" + b

Given a two-letter state v passed to the function f, build a tuple (a, b) representing the head and tail of the "engineer" sentence.

Feel free to use the "compressed state string" freely; it's one whole byte shorter than the MINCALA one...

Vern DeHaven

Posted 2017-06-02T09:31:00.530

Reputation: 41

4

R, 109 96 bytes

function(x)sub("#"," an engineer",c("I am not#","I am#","What is#?"))[2-x%in%state.abb+!x=="OR"]

Try it online!

13 bytes thanks to J.Doe - through use of regex and indexation.

JayCe

Posted 2017-06-02T09:31:00.530

Reputation: 2 655

197 bytes – J.Doe – 2018-09-17T15:01:12.560

1@J.Doe sub is much better, thank you! – JayCe – 2018-09-17T16:54:31.000

96 bytes – J.Doe – 2018-09-18T13:47:09.183

@J.Doe Of course! – JayCe – 2018-09-18T15:34:58.727

3

Japt, 136 135 131 129 128 bytes

More savings may be available by experimenting with the order of the state abbreviations - I'll come back to that in a while.

`mnnmlãGLÏz¯¬ct¸flgaá[9¨kyµmçpCijmsmtnhnvnyn¬kpÂÉcsdk¡x©vavt°±wvwy`ò øUv)?"I am {¥"OR"?"not ":P}"+` à¨\ `:`Wt   à¨\?

Try it online


Explanation

  • We take a compressed string of the lowercased abbreviations, decompress it, and split it into an array of 2 character strings using the ò method.
  • We then use the ø method to see if the array contains Uv, which is the input string converted to lowercase.
  • If we so, we build our output string, beginning with "I am "
  • Checking if the input string ¥ (is equal to) "OR" allows us to append either "not " or the empty string variable P.
  • And then we decompress and append the compressed string "an engineer".
  • If the input was not found in the array, then we output the decompression of compressed string "What is an engineer?".

Shaggy

Posted 2017-06-02T09:31:00.530

Reputation: 24 623

3

CJam, 143 bytes

"ORIA MINCALA MSCTNMNVAKY WAZ PAR FL GA NHID COKSD ME MDE MA MTX NE NJ NY ND MOH UT WVT WIL WY"q#g"I am not 
I am 
What is?"N/=)" an engineer"\

Try it online! or as a test suite

Explanation

"ORIA...."       e# Push a string in which every state is a substring, but no non-state is
                 e# a substring.
q                e# Read the input.
#                e# Find the index of the input in the string. (-1 if not found)
g                e# Signum of the index: -1 for negative, 0 for 0, 1 for positive.
"I am.... "      e# Push this string. Note the trailing space on the first two lines of it.
N/               e# Split it on newlines.
=                e# Get the string at index given by the signum.
)                e# Pull out the last character.
" an engineer"\  e# Push " an engineer" and bring the other character to the TOS.
                 e# Implicit output.

Since Oregon (OR) is at the start of the string, finding the signum of the index of the input in that will be -1 if not found, 0 if OR, 1 if any other state. Which string to print can be decided by that.

Business Cat

Posted 2017-06-02T09:31:00.530

Reputation: 8 927

3

Python 3, 180 179 178 bytes

def f(s):e=" not"*(s=="OR")+" an engineer";return"I am"+e if s in"PALAKSCAZ CTNMINCOR FL GA MDE ME MND MA MSD MOKY NE NH NJ NY WA OHID UTX MTNVARIA WIL WVT WY"else"What is"+e+"?"

Try it online!

int6h

Posted 2017-06-02T09:31:00.530

Reputation: 131

Yep, it's correct: Try it online!

– int6h – 2018-09-17T15:32:47.110

166 bytes. I'm sure the string can also be tightened up a liitle more by reusing states – Jo King – 2018-09-17T22:53:44.403

Thanks @JoKing. It resembles the Python 2 answer too much at this point IMO :). I've been trying to compress the string, but the shortest I could get was 92 symbols. I've written a short script to do that, but it can only cut it down to 94 characters, and it doesn't compress optimally. I also think that in this particular challenge the magic string itself should not be included in the byte count.

– int6h – 2018-09-18T18:50:42.700

2

Haskell, 220 214 210 209 bytes

s(a:b:c)=[a,b]:s(b:c)
s _=[]
a="I am "
e="an engineer "
i"OR"=a++"not "++e
i x|x`elem`s"MINCALA MSCTNMNVAKY WAZ PAR FL GA NHID COKSD ME MDE MA MTX NE NJ NY ND MOH RIA UT WVT WIL WY"=a++e
i _="What is "++e++"?"

Try it online!

bartavelle

Posted 2017-06-02T09:31:00.530

Reputation: 1 261

otherwise = True, 1<2 is even shorter – BlackCap – 2017-06-02T14:45:26.217

Facepalm, thanks! – bartavelle – 2017-06-02T14:51:53.780

You have included OR in the long string in the second definition of i – BlackCap – 2017-06-02T15:02:13.433

I stole the long string from the other answers. OR isn't part of it though? – bartavelle – 2017-06-02T16:26:40.370

1No, not anymore :) – BlackCap – 2017-06-02T16:28:11.910

2

PHP, 188 Bytes

$e=" an engineer";echo strpos(_TNNMLAALAKAZARCACOCTDEFLGAHIIDILINIAKSKYMEMDMAMIMNMSMOMTNENVNHNJNYNCNDOHOKORPARISCSDTXUTVTVAWAWVWIWY,$argn)&1?"I am".($argn!="OR"?"":" not").$e:"What is$e?";

Try it online!

Jörg Hülsermann

Posted 2017-06-02T09:31:00.530

Reputation: 13 026

in_array(...) to strpos(_AKALARAZCACOCTDEFLGAHIIAIDILINKSKYLAMAMDMEMIMNMOMSMTNCNDNENHNJNMNVNYOHOKPARISCSDTNTXUTVAVTWAWIWVWY,$argn)&1. – Christoph – 2017-06-02T12:54:36.077

@Christoph works not for an Input for example of LA – Jörg Hülsermann – 2017-06-02T13:03:45.837

Hm right :/ maybe we can reorder the string a bit .. I'll try. Also invalidates the js answer btw. – Christoph – 2017-06-02T13:08:53.277

_NMMNINTNRIHIMIWISCNCCTMTUTVTWVNVFLILCAALGAIAMAPAVAWACOLAMOAKARKSMSNHOHOKORAZDEIDKYMEMDNENJNYNDSDTXWY works – Christoph – 2017-06-02T13:24:46.450

@Christoph Or my order work too. – Jörg Hülsermann – 2017-06-02T14:40:39.747

2

C#, 178 bytes

s=>(s=="OR"?"I am notx":"MINCALA MSCTNMNVAKY WAZ PARIA FL GA NHID COKSD ME MDE MA MTX NE NJ NY ND MOH UT WVT WIL WY".Contains(s)?"I amx":"What isx?").Replace("x"," an engineer");

Run in C# Pad

Golf based on Mayube's solution; new here, so I don't have enough rep to comment.

Arthur Rump

Posted 2017-06-02T09:31:00.530

Reputation: 81

Might want to edit in a link in to his solution :) If you click share on his solution, it gives you a link straight to it. – Stephen – 2017-06-02T20:26:08.497

@StephenS Thanks for the tip! – Arthur Rump – 2017-06-02T20:27:46.333

1

Javascript 204

s=>{h=/^(A[LKZR]|C[AOT]|DE|FL|[GPLV]A|[HR]I|I[DLNA]|K[SY]|M[EDAINSOT]|N[EVHJMYCD]|O[HK]|S[CD]|T[NX]|[VU]T|W[AVIY]|(OR))$/.exec(s);return(!h?"What is ":"I am "+(h[2]?"not ":""))+"an engineer"+(!h?'?':'')}

martin

Posted 2017-06-02T09:31:00.530

Reputation: 191

1Pure optimize s=>(!(h=/(A[LKZR]|C[AOT]|DE|FL|[GPLV]A|[HR]I|I[DLNA]|K[SY]|M[EDAINSOT]|N[EVHJMYCD]|O[HKR]|S[CD]|T[NX]|[VU]T|W[AVIY])/.test(s))?"What is":"I am"+(s=='OR'?" not":""))+" an engineer"+['?'[+h]] – l4m2 – 2018-03-09T06:15:34.660

@l4m2 nice, that's got my answer beat. – martin – 2018-03-09T06:27:55.123

1

Java, 173 bytes

s->(!"MINCALARIA MSCTNMNVAKY WAZ PAR FL GA NHID COKSD ME MDE MA MTX NE NJ NY ND MOH UT WVT WIL WY OR".contains(s)?"What is":"I am"+(s.equals("OR")?" not":""))+" an engineer"

JWH

Posted 2017-06-02T09:31:00.530

Reputation: 11

3Welcome to PPCG! All entries must be a full program or a function; I believe you can turn this into a valid lambda expression (and therefore function) by adding s-> to the beginning. – ETHproductions – 2017-06-02T23:01:12.600

1

AWK, 189 bytes

/A[LKZR]|C[AOT]|DE|FL|[GPV]A|HI|I[DLNA]|KS|KY|LA|M[EDAINSOT]|N[EVHJMYCD]|O[HKR]|RI|SC|SD|TN|TX|UT|VT|W[AVIY]/{print"I am "($0~OR?"not ":"")"an engineer";exit}
{print"What is an engineer?"}

If input matches a regex containing all the state abbreviations, print "I am an engineer" with a 'not' inserted in the middle if the state is Oregon, then exit.

If the input does not match the regex, it must not be a US state abbreviation.

Arc676

Posted 2017-06-02T09:31:00.530

Reputation: 301

1

Python 3, 238 bytes

def f(x):s=x in('ALAKAZARCACOCTDEFLGAHIIDILINIAKSKYLAMEMDMAMIMNMSMOMTNENVNHNJNMNYNCNDOHOKORPARISCSDTNTXUTVTVAWAWVWIWY'[i:i+2]for i in range(0,100,2));o=x=='OR';q=(1-o)*(1-s);return q*'What is'+(1-q)*('I am'+o*' not')+' an engineer'+q*'?'

Explanation

No compression techniques used.

def f(x):
    # Check if State
    s = x in ('ALAK...WIWY'[i:i+2]
              for i in range(0, 100, 2))

    # Check if Oregon
    o = x == 'OR'

    # Check if neither Oregon nor State
    q = (1-o) * (1-s)

    # Construct output string
    return q * 'What is' + \
        (1-q) * ('I am' + o * ' not') + \
        ' an engineer' + \
        q * '?'

Mateen Ulhaq

Posted 2017-06-02T09:31:00.530

Reputation: 1 889

It's Oregon, not Ohio. – L3viathan – 2017-06-04T09:24:22.270

1@L3viathan Not sure how I mess that up after seeing Oregon everywhere due to Life is Strange... ¯\(ツ) – Mateen Ulhaq – 2017-06-04T09:43:36.277

1

Stax, 100 bytes

This language postdates the challenge. But the author (me) didn't see it until now.

éë&W≈#W¬π█▐╜╣╟◙√a☻∞ZrπU♫ÿô♠▌⌠Që≡AûpI⌡ÄNA綵↑╝╣òøΩ.¬É]╩Æ↓d∩é¡2ŲeB┼¼▬5∟┤sW♠♂↑q▐WMï╝|Ñ↑╫+3¼↔îûvlLΩ∟┬oë

Run and debug it

recursive

Posted 2017-06-02T09:31:00.530

Reputation: 8 616

1

JavaScript ES6, 175171 Bytes

x=>[`What is${e=" an engineer"}?`,`I am${x=="OR"?" not"+e:e}`][+!!'MINCALA MSCTNMNVAKY WAZ PAR FL GA NHID COKSD ME MDE MA MTX NE NJ NY ND MOH ORIA UT WVT WIL WY'.match(x)]

Joined lots of good

Or 152 bytes on ISO encoding

Generator:

'x=>[`What is${e=" an engineer"}?`,`I am${x=="OR"?" not"+e:e}`][+!!btoa`*`.match(x)]'.replace('*',atob('MINCALA MSCTNMNVAKY WAZ PAR FL GA NHID COKSD ME MDE MA MTX NE NJ NY ND MOH ORIA UT WVT WIL WY '.replace(/ /g,'/')))

l4m2

Posted 2017-06-02T09:31:00.530

Reputation: 5 985

It might be possible to rearrange the string so using btoa to expand – l4m2 – 2018-03-09T15:50:40.280

1

C (gcc), 0+176 bytes

-Dz"=an engineer" -Df(s)*s-79|1[s]-82?strstr("MINCALA=MSCTNMNVAKY WAZ PAR FL GA NHID COKSD ME MDE MA MTX NE NJ NY ND MOH RIA UT WVT WIL WY",s)?"I am"z:"What is"z"?":"I am not"z

Try it online!

pure translate

l4m2

Posted 2017-06-02T09:31:00.530

Reputation: 5 985

1

Powershell, 175 bytes

(('I am'+' not'*!($i='ORIA MINCALA MSCTNMNVAKY WAZ PAR FL GA NHID COKSD ME MDE MA MTX NE NJ NY ND MOH UT WVT WIL WY'.IndexOf($args))+($e=' an engineer')),"What is$e`?")[!++$i]

Test script:

$f = {

$e=' an engineer'
$i='ORIA MINCALA MSCTNMNVAKY WAZ PAR FL GA NHID COKSD ME MDE MA MTX NE NJ NY ND MOH UT WVT WIL WY'.IndexOf($args)
(('I am'+' not'*!$i+$e),"What is$e`?")[!++$i]

# Important! OR is a first state in the modified @totallyhuman's genuis string

}

@(
    ,('OR', 'I am not an engineer')
    ,('AL', 'I am an engineer')
    ,('IL', 'I am an engineer')
    ,('ZZ', 'What is an engineer?')
) | % {
    $s,$e = $_
    $r = &$f $s
    "$($r-eq$e): $r"
}

Output:

True: I am not an engineer
True: I am an engineer
True: I am an engineer
True: What is an engineer?

mazzy

Posted 2017-06-02T09:31:00.530

Reputation: 4 832

0

Python 3, 236 182 181 bytes

lambda s:'I am not'+e if s=='OR'else'I am'+e if s in'MINCALA MSCTNMNVAKY WAZ PAR FL GA NHID COKSD ME MDE MA MTX NE NJ NY ND MOH RIA UT WVT WIL WY'else'What is%s?'%e
e=' an engineer'

Try it online!

TIO contains test cases for all the states.
-54 bytes thanks to the string compression

Notts90 supports Monica

Posted 2017-06-02T09:31:00.530

Reputation: 1 211

You can use the string compression from the other answers to save bytes – TheLethalCoder – 2017-06-02T11:31:47.083

1MINCALA MSCTNMNVAKY WAZ PAR FL GA NHID COKSD ME MDE MA MTX NE NJ NY ND MOH ORIA UT WVT WIL WY is better compression – Skidsdev – 2017-06-02T11:38:11.323

0

q/kdb+, 174 bytes

Solution:

{a:" an engineer?";$[(#:)l:ss["ORIA MINCALA MSCTNMNVAKY WAZ PAR FL GA NHID COKSD ME MDE MA MTX NE NJ NY ND MOH UT WVT WIL WY";x];-1_"I am",$[l~(),0;" not";""],a;"What is",a]}

Explanation:

  {
  // save string into variable a
  a:" an engineer?";
  // try to find the input x in the condensed string, save location in variable l, $ is a if/else
  $[(#:)l:ss["ORIA MINCALA MSCTNMNVAKY WAZ PAR FL GA NHID COKSD ME MDE MA MTX NE NJ NY ND MOH UT WVT WIL WY";x];
  // found a match, check if it was at index 0 ('OR') and inject " not" if so, drop the '?' off the end
  -1_"I am",$[l~(),0;" not";""],a;
  // otherwise return 'What is an engineer?'
  "What is",a]
  }

Notes:

Used the 'compressed' string from other answers, struggling to find a way to bring it into a single line in order to avoid assignment of the a variable (yet still add the ? when input is not a state.

streetster

Posted 2017-06-02T09:31:00.530

Reputation: 3 635

0

Retina, 175 bytes

..
I am $&~MINCALAZ SCT FL GA WIAKSD ME MD MA MNMS MOKY MTNE NVTX NH NJ NY ND COHIDE PARIL UT VA WA WV WY
(..)~.*\1.*
~
OR~.*
not ~
I am ..~.*
What is ~?
~
an engineer

Try it online! Hopefully I've appropriated the best state list. Explanation:

..
I am $&~MINCALAZ SCT FL GA WIAKSD ME MD MA MNMS MOKY MTNE NVTX NH NJ NY ND COHIDE PARIL UT VA WA WV WY

Start building up the result. Also, insert the state list for use by the next stage.

(..)~.*\1.*
~

If it's one of the 49 states, delete the state and list.

OR~.*
not ~

If it's Oregon, replace the state with not, and delete the list.

I am ..~.*
What is ~?

If it's anything else, replace everything with the other output.

~
an engineer

Add these word in last to avoid repetition.

Neil

Posted 2017-06-02T09:31:00.530

Reputation: 95 035

0

Crystal, 232 207 205 Bytes

i="ORALAKAZARCACOCTDEFLGAHIIDILINIAKSKYLAMEMDMAMIMNMSMOMTNENVNHNJNMNYNCNDOHOKPARISCSDTNTXUTVTVAWAWVWIWY".split(/(..)/).index ARGV[0];p (i ?"I am ": "What is ")+(i==1 ?"not ": "")+"an engineer"+(i ?"": "?")

Try it online. (slightly modified due to an issue of ARGV)

Domii

Posted 2017-06-02T09:31:00.530

Reputation: 219

0

Factor, 135 bytes

USE: usa-cities [ " an engineer"swap [ "I am"swap string>state OR = 
[ " not"append ] when ""] [ 2drop "What is" "?"] recover surround ]

More readable, and named:

: engineer? ( state-name -- str ) 
  [ " an engineer" ] dip ! put this below the input on the stack 
  [ 
    [ "I am" ] dip       ! put this below the input too but above the other 
    string>state OR =    ! string>state throws on a non-state name 
    [ " not" append ] when ""  ! otherwise and if it is OR, append this 
  ] 
  [ 2drop "What is" "?" ] recover surround ; ! catch error, surround string

[ x ] dip and x swap are equivalent in stack effect but the first is shorter only when nested: [ [ [ x ] dip ] dip ] dip.

cat

Posted 2017-06-02T09:31:00.530

Reputation: 4 989

0

Python 2, 213 211 194 Bytes

c="uTXnMSCORIDEwVAKYmTNHILfLAZpALmNEmOKSDwINCARmEwAnJnDmAmIAgAwYcTnVToHnYmD"
r=(lambda x:x in c or x[0].lower()+x[1]in c)(i)^1
u="What is "*r+("I am "+"not "*(i=="OR"))*(r^1)+"an engineer"+"?"*r

Try It Online

Stuff i'm working on shortening:

  • (i=="OR")
  • or x[0].lower()+x[1]in c

Update:

  • Saved 2 Bytes by replacing s=not r with s=r^1
  • Separated header and footer of code

Raffi

Posted 2017-06-02T09:31:00.530

Reputation: 137

0

Ruby, 164 bytes

->s{r="What is an engineer?"
j=379
"##(*Q0'7q;N>%*$o(.F%#&'#&#5##%$%+%5%)5r@#P,B353*/%".bytes{|i|s==(j+=i-34).to_s(36).upcase&&r="I am not"[0,i==41?8:4]+r[7,12]}
r}

Uses a run length encoding, therefore magic string is 50 bytes long, one per state. In order to build this, it was first necessary to put the state codes in alphabetical order of state code, rather than state name. Unfortunately 7 bytes are needed to convert the base36 representation of j from a lowercase statecode into an uppercase statecode.

Ungolfed in test program

f=->s{                                                  #s is the input string.
  r="What is an engineer?"                              #Set r to "What is an engineer?"
  j=379                                                 #Set j to one less than 380, which in base36 becomes AK, the first statecode alphabetically
  "##(*Q0'7q;N>%*$o(.F%#&'#&#5##%$%+%5%)5r@#P,B353*/%". #Iterate through the run length encoded string 
  bytes{|i|                                             #(each character represents how far in base 36 each state code is from the previous one)
    s==(j+=i-34).to_s(36).upcase&&                      #take the ascii value of the character and subtract 34 (example #=35-34=1) and add to j. Convert j to base36 to get a state code.
      r="I am not"[0,i==41?8:4]+r[7,12]                 #if the state code matches s, modify r. Take the first 4 characters of "I am not" (first 8 in the case of OR where i==41) 
  }                                                     #and add r[7,12]==" an engineer" (12 characters of the existing value of r, starting at character 7 
r}                                                      #return r

%w{AL AK AZ AR CA CO CT DE FL GA HI ID IL IN IA KS KY LA ME MD MA MI MN MS MO MT NE NV NH NJ NM NY NC ND OH OK OR PA RI SC SD TN TX UT VT VA WA WV WI WY XX}.map{|i|p [i,f[i]]}

Level River St

Posted 2017-06-02T09:31:00.530

Reputation: 22 049

0

/// (Slashes), 2102 bytes

/*/\/-\/\///$/\/,\/\///OR/_not .//AL*AK*AZ*AR*CA*CO*CT*DE*FL*GA*HI*ID*IL*IN*IA*KS*KY*LA*ME*MD*MA*MI*MN*MS*MO*MT*NE*NV*NH*NJ*NM*NY*NC*ND*OH*OK*PA*RI*SC*SD*TN*TX*UT*VT*VA*WA*WV*WI*WY*AA$AB$AC$AD$AE$AF$AG$AH$AI$AJ$AM$AN$AO$AP$AQ$AS$AT$AU$AV$AW$AX$AY$BA$BB$BC$BD$BE$BF$BG$BH$BI$BJ$BK$BL$BM$BN$BO$BP$BQ$BR$BS$BT$BU$BV$BW$BX$BY$BZ$CB$CC$CD$CE$CF$CG$CH$CI$CJ$CK$CL$CM$CN$CP$CQ$CR$CS$CU$CV$CW$CX$CY$CZ$DA$DB$DC$DD$DF$DG$DH$DI$DJ$DK$DL$DM$DN$DO$DP$DQ$DR$DS$DT$DU$DV$DW$DX$DY$DZ$EA$EB$EC$ED$EE$EF$EG$EH$EI$EJ$EK$EL$EM$EN$EO$EP$EQ$ER$ES$ET$EU$EV$EW$EX$EY$EZ$FA$FB$FC$FD$FE$FF$FG$FH$FI$FJ$FK$FM$FN$FO$FP$FQ$FR$FS$FT$FU$FV$FW$FX$FY$FZ$GB$GC$GD$GE$GF$GG$GH$GI$GJ$GK$GL$GM$GN$GO$GP$GQ$GR$GS$GT$GU$GV$GW$GX$GY$GZ$HA$HB$HC$HD$HE$HF$HG$HH$HJ$HK$HL$HM$HN$HO$HP$HQ$HR$HS$HT$HU$HV$HW$HX$HY$HZ$IB$IC$IE$IF$IG$IH$II$IJ$IK$IM$IO$IP$IQ$IR$IS$IT$IU$IV$IW$IX$IY$IZ$JA$JB$JC$JD$JE$JF$JG$JH$JI$JJ$JK$JL$JM$JN$JO$JP$JQ$JR$JS$JT$JU$JV$JW$JX$JY$JZ$KA$KB$KC$KD$KE$KF$KG$KH$KI$KJ$KK$KL$KM$KN$KO$KP$KQ$KR$KT$KU$KV$KW$KX$KZ$LB$LC$LD$LE$LF$LG$LH$LI$LJ$LK$LL$LM$LN$LO$LP$LQ$LR$LS$LT$LU$LV$LW$LX$LY$LZ$MB$MC$MF$MG$MH$MJ$MK$ML$MM$MP$MQ$MR$MU$MV$MW$MX$MY$MZ$NA$NB$NF$NG$NI$NK$NL$NN$NO$NP$NQ$NR$NS$NT$NU$NW$NX$NZ$OA$OB$OC$OD$OE$OF$OG$OI$OJ$OL$OM$ON$OO$OP$OQ$OS$OT$OU$OV$OW$OX$OY$OZ$PB$PC$PD$PE$PF$PG$PH$PI$PJ$PK$PL$PM$PN$PO$PP$PQ$PR$PS$PT$PU$PV$PW$PX$PY$PZ$QA$QB$QC$QD$QE$QF$QG$QH$QI$QJ$QK$QL$QM$QN$QO$QP$QQ$QR$QS$QT$QU$QV$QW$QX$QY$QZ$RA$RB$RC$RD$RE$RF$RG$RH$RJ$RK$RL$RM$RN$RO$RP$RQ$RR$RS$RT$RU$RV$RW$RX$RY$RZ$SA$SB$SE$SF$SG$SH$SI$SJ$SK$SL$SM$SN$SO$SP$SQ$SR$SS$ST$SU$SV$SW$SX$SY$SZ$TA$TB$TC$TD$TE$TF$TG$TH$TI$TJ$TK$TL$TM$TO$TP$TQ$TR$TS$TT$TU$TV$TW$TY$TZ$UA$UB$UC$UD$UE$UF$UG$UH$UI$UJ$UK$UL$UM$UN$UO$UP$UQ$UR$US$UU$UV$UW$UX$UY$UZ$VB$VC$VD$VE$VF$VG$VH$VI$VJ$VK$VL$VM$VN$VO$VP$VQ$VR$VS$VU$VV$VW$VX$VY$VZ$WB$WC$WD$WE$WF$WG$WH$WJ$WK$WL$WM$WN$WO$WP$WQ$WR$WS$WT$WU$WW$WX$WZ$XA$XB$XC$XD$XE$XF$XG$XH$XI$XJ$XK$XL$XM$XN$XO$XP$XQ$XR$XS$XT$XU$XV$XW$XX$XY$XZ$YA$YB$YC$YD$YE$YF$YG$YH$YI$YJ$YK$YL$YM$YN$YO$YP$YQ$YR$YS$YT$YU$YV$YW$YX$YY$YZ$ZA$ZB$ZC$ZD$ZE$ZF$ZG$ZH$ZI$ZJ$ZK$ZL$ZM$ZN$ZO$ZP$ZQ$ZR$ZS$ZT$ZU$ZV$ZW$ZX$ZY$ZZ$-/_.//_/I am //./an engineer//,/What is .?/

Try it online

Somewhat ungolfed

/OR/_not ./

/AL/-//AK/-//AZ/-//AR/-//CA/-//CO/-//CT/-//DE/-//FL/-//GA/-//HI/-//ID/-//IL/-//IN/-//IA/-//KS/-//KY/-//LA/-//ME/-//MD/-//MA/-//MI/-//MN/-//MS/-//MO/-//MT/-//NE/-//NV/-//NH/-//NJ/-//NM/-//NY/-//NC/-//ND/-//OH/-//OK/-//PA/-//RI/-//SC/-//SD/-//TN/-//TX/-//UT/-//VT/-//VA/-//WA/-//WV/-//WI/-//WY/-/

/AA/,//AB/,//AC/,//AD/,//AE/,//AF/,//AG/,//AH/,//AI/,//AJ/,//AM/,//AN/,//AO/,//AP/,//AQ/,//AS/,//AT/,//AU/,//AV/,//AW/,//AX/,//AY/,//BA/,//BB/,//BC/,//BD/,//BE/,//BF/,//BG/,//BH/,//BI/,//BJ/,//BK/,//BL/,//BM/,//BN/,//BO/,//BP/,//BQ/,//BR/,//BS/,//BT/,//BU/,//BV/,//BW/,//BX/,//BY/,//BZ/,//CB/,//CC/,//CD/,//CE/,//CF/,//CG/,//CH/,//CI/,//CJ/,//CK/,//CL/,//CM/,//CN/,//CP/,//CQ/,//CR/,//CS/,//CU/,//CV/,//CW/,//CX/,//CY/,//CZ/,//DA/,//DB/,//DC/,//DD/,//DF/,//DG/,//DH/,//DI/,//DJ/,//DK/,//DL/,//DM/,//DN/,//DO/,//DP/,//DQ/,//DR/,//DS/,//DT/,//DU/,//DV/,//DW/,//DX/,//DY/,//DZ/,//EA/,//EB/,//EC/,//ED/,//EE/,//EF/,//EG/,//EH/,//EI/,//EJ/,//EK/,//EL/,//EM/,//EN/,//EO/,//EP/,//EQ/,//ER/,//ES/,//ET/,//EU/,//EV/,//EW/,//EX/,//EY/,//EZ/,//FA/,//FB/,//FC/,//FD/,//FE/,//FF/,//FG/,//FH/,//FI/,//FJ/,//FK/,//FM/,//FN/,//FO/,//FP/,//FQ/,//FR/,//FS/,//FT/,//FU/,//FV/,//FW/,//FX/,//FY/,//FZ/,//GB/,//GC/,//GD/,//GE/,//GF/,//GG/,//GH/,//GI/,//GJ/,//GK/,//GL/,//GM/,//GN/,//GO/,//GP/,//GQ/,//GR/,//GS/,//GT/,//GU/,//GV/,//GW/,//GX/,//GY/,//GZ/,//HA/,//HB/,//HC/,//HD/,//HE/,//HF/,//HG/,//HH/,//HJ/,//HK/,//HL/,//HM/,//HN/,//HO/,//HP/,//HQ/,//HR/,//HS/,//HT/,//HU/,//HV/,//HW/,//HX/,//HY/,//HZ/,//IB/,//IC/,//IE/,//IF/,//IG/,//IH/,//II/,//IJ/,//IK/,//IM/,//IO/,//IP/,//IQ/,//IR/,//IS/,//IT/,//IU/,//IV/,//IW/,//IX/,//IY/,//IZ/,//JA/,//JB/,//JC/,//JD/,//JE/,//JF/,//JG/,//JH/,//JI/,//JJ/,//JK/,//JL/,//JM/,//JN/,//JO/,//JP/,//JQ/,//JR/,//JS/,//JT/,//JU/,//JV/,//JW/,//JX/,//JY/,//JZ/,//KA/,//KB/,//KC/,//KD/,//KE/,//KF/,//KG/,//KH/,//KI/,//KJ/,//KK/,//KL/,//KM/,//KN/,//KO/,//KP/,//KQ/,//KR/,//KT/,//KU/,//KV/,//KW/,//KX/,//KZ/,//LB/,//LC/,//LD/,//LE/,//LF/,//LG/,//LH/,//LI/,//LJ/,//LK/,//LL/,//LM/,//LN/,//LO/,//LP/,//LQ/,//LR/,//LS/,//LT/,//LU/,//LV/,//LW/,//LX/,//LY/,//LZ/,//MB/,//MC/,//MF/,//MG/,//MH/,//MJ/,//MK/,//ML/,//MM/,//MP/,//MQ/,//MR/,//MU/,//MV/,//MW/,//MX/,//MY/,//MZ/,//NA/,//NB/,//NF/,//NG/,//NI/,//NK/,//NL/,//NN/,//NO/,//NP/,//NQ/,//NR/,//NS/,//NT/,//NU/,//NW/,//NX/,//NZ/,//OA/,//OB/,//OC/,//OD/,//OE/,//OF/,//OG/,//OI/,//OJ/,//OL/,//OM/,//ON/,//OO/,//OP/,//OQ/,//OS/,//OT/,//OU/,//OV/,//OW/,//OX/,//OY/,//OZ/,//PB/,//PC/,//PD/,//PE/,//PF/,//PG/,//PH/,//PI/,//PJ/,//PK/,//PL/,//PM/,//PN/,//PO/,//PP/,//PQ/,//PR/,//PS/,//PT/,//PU/,//PV/,//PW/,//PX/,//PY/,//PZ/,//QA/,//QB/,//QC/,//QD/,//QE/,//QF/,//QG/,//QH/,//QI/,//QJ/,//QK/,//QL/,//QM/,//QN/,//QO/,//QP/,//QQ/,//QR/,//QS/,//QT/,//QU/,//QV/,//QW/,//QX/,//QY/,//QZ/,//RA/,//RB/,//RC/,//RD/,//RE/,//RF/,//RG/,//RH/,//RJ/,//RK/,//RL/,//RM/,//RN/,//RO/,//RP/,//RQ/,//RR/,//RS/,//RT/,//RU/,//RV/,//RW/,//RX/,//RY/,//RZ/,//SA/,//SB/,//SE/,//SF/,//SG/,//SH/,//SI/,//SJ/,//SK/,//SL/,//SM/,//SN/,//SO/,//SP/,//SQ/,//SR/,//SS/,//ST/,//SU/,//SV/,//SW/,//SX/,//SY/,//SZ/,//TA/,//TB/,//TC/,//TD/,//TE/,//TF/,//TG/,//TH/,//TI/,//TJ/,//TK/,//TL/,//TM/,//TO/,//TP/,//TQ/,//TR/,//TS/,//TT/,//TU/,//TV/,//TW/,//TY/,//TZ/,//UA/,//UB/,//UC/,//UD/,//UE/,//UF/,//UG/,//UH/,//UI/,//UJ/,//UK/,//UL/,//UM/,//UN/,//UO/,//UP/,//UQ/,//UR/,//US/,//UU/,//UV/,//UW/,//UX/,//UY/,//UZ/,//VB/,//VC/,//VD/,//VE/,//VF/,//VG/,//VH/,//VI/,//VJ/,//VK/,//VL/,//VM/,//VN/,//VO/,//VP/,//VQ/,//VR/,//VS/,//VU/,//VV/,//VW/,//VX/,//VY/,//VZ/,//WB/,//WC/,//WD/,//WE/,//WF/,//WG/,//WH/,//WJ/,//WK/,//WL/,//WM/,//WN/,//WO/,//WP/,//WQ/,//WR/,//WS/,//WT/,//WU/,//WW/,//WX/,//WZ/,//XA/,//XB/,//XC/,//XD/,//XE/,//XF/,//XG/,//XH/,//XI/,//XJ/,//XK/,//XL/,//XM/,//XN/,//XO/,//XP/,//XQ/,//XR/,//XS/,//XT/,//XU/,//XV/,//XW/,//XX/,//XY/,//XZ/,//YA/,//YB/,//YC/,//YD/,//YE/,//YF/,//YG/,//YH/,//YI/,//YJ/,//YK/,//YL/,//YM/,//YN/,//YO/,//YP/,//YQ/,//YR/,//YS/,//YT/,//YU/,//YV/,//YW/,//YX/,//YY/,//YZ/,//ZA/,//ZB/,//ZC/,//ZD/,//ZE/,//ZF/,//ZG/,//ZH/,//ZI/,//ZJ/,//ZK/,//ZL/,//ZM/,//ZN/,//ZO/,//ZP/,//ZQ/,//ZR/,//ZS/,//ZT/,//ZU/,//ZV/,//ZW/,//ZX/,//ZY/,//ZZ/,/

/-/_./
/_/I am /
/./an engineer/
/,/What is .?/

TIO, with some examples

Cedric Reichenbach

Posted 2017-06-02T09:31:00.530

Reputation: 448

0

Python 2, 277 275 201 bytes

Here's one where I've compressed the list to 70 characters. But the compression is complex enough that my decompression makes the code uncompetitively heavy. Perhaps someone else has a better decompression idea.

[edit:] You could do this in binary compressed data pretty trivially and save another 25% on the list size. You only need 6 bits/char to do upper and lower case letters. And it'd probably be even more wordy to decode.

The list is lowercase first letter, followed by upper case second letters of everything with that first letter. Order doesn't matter; I used one extra lowercase at the end to make the regular expression work this way.

Using the lambda cleverness from above, it's 201 bytes, but is still too fattened by that regex:


lambda s,e=' an engineer':'I am'+' not'*(s=='OR')+e if re.match('.*%s[A-Z]*%s[A-Z]*[a-z]'%(s[0].lower(),s[1]),'aLKZRcAOTdEfLgAhIiDLNAkSYlAmEDAINSOTnEVHJMYCDoHKRpArIsCDtNXuTvTAwAVIYz')else'What is%s?'%e
def m(t):
 p='I am'
 e=' an engineer'
 if t=='OR':print(p+' not'+e);return()
 else:
  w='What is'
  if re.match('.*%s[A-Z]*%s[A-Z]*[a-z]'%(t[0].lower(),t[1]),'aLKZRcAOTdEfLgAhIiDLNAkSYlAmEDAINSOTnEVHJMYCDoHKRpArIsCDtNXuTvTAwAVIYz')==None:print(w+e+'?');return()
  print(p+e)

Try it online!

fyngyrz

Posted 2017-06-02T09:31:00.530

Reputation: 101

1199 bytes. – Jonathan Frech – 2018-09-18T21:43:42.253

nice. One byte at a time, eh?:) – fyngyrz – 2018-09-19T22:11:03.830

$|201 - 199| = 2 \neq 1$. – Jonathan Frech – 2018-09-19T22:37:06.923

Okay, two bytes at a time. It was a sentiment, not a count, but I'll roll with ya here. – fyngyrz – 2018-09-20T14:44:25.173

0

Excel VBA, 261 254 Bytes

an anonymous vbe immediate window function that takes input as expected type Variant\String from cell [A1] and outputs my status as an engineer in the given US state to the VBE immediate window.

Golfed

e=" an engineer":i="I am":?IIf(UBound(Filter(Split("AL AK AZ AR CA CO CT DE FL GA HI ID IL IN IA KS KY LA ME MD MA MI MN MS MO MT NE NV NH NJ NM NY NC ND OH OK PA RI SC SD TN TX UT VT VA WA WV WI WY"),[A1])),IIf([A1]="OR",i+" not"+e,"What is"+e+"?"),i+e)

Ungolfed

Function AmIAnEngineer(ByVal state As String) As String

    Dim i As String, _
        e As String

    Let i = "I am"
    Let e = " an engineer"

    Let AmIAnEngineer = _
        IIf(UBound(Filter( _
                Split("AL AK AZ AR CA CO CT DE FL GA HI ID IL IN IA KS KY LA ME MD MA MI MN MS MO MT NE NV NH NJ NM NY NC ND OH OK PA RI SC SD TN TX UT VT VA WA WV WI WY"), _
                state)), IIf(state = "OR", i & " not" & e, "What is" & e & "?"), i & e)
End Function

''# Usage:
''#
''#     ?AmIAnEngineer("VA")
''#     I am an engineer

Taylor Scott

Posted 2017-06-02T09:31:00.530

Reputation: 6 709

0

Jq 1.5, 186 bytes

if.=="OR"then"I am not X"elif inside("MINCALA MSCTNMNVAKY WAZ PAR FL GA NHID COKSD ME MDE MA MTX NE NJ NY ND MOH RIA UT WVT WIL WY")then"I am X"else"What is X?"end|sub("X";"an engineer")

Expanded

  if   . =="OR"                                then "I am not X"
  elif inside("@totallyhuman's genius string") then "I am X"
  else                                              "What is X?"
  end
| sub("X";"an engineer")

Try it online!

Jq 1.5, 195 bytes

if.=="OR"then"I am not X" elif test("A[LKRZ]|I[ADLN]|M[ADEINOST]|N[CDEHJMVY]|W[AIVY]|[GCLPV]A|[CUV]T|CO|DE|FL|HI|KS|KY|OH|OK|RI|SC|SD|TN|TX")then"I am X"else"What is X?"end|sub("X";"an engineer")

Expanded

  if   . =="OR"          then "I am not X"
  elif test("big regex") then "I am X"
  else                        "What is X?"
  end
| sub("X";"an engineer")

Try it online!

jq170727

Posted 2017-06-02T09:31:00.530

Reputation: 411

0

Python 3, 227 bytes

lambda i:['What is an engineer?','I am '+'not '*(i>'OR')+'an engineer'][i in'AL&AK&AZ&AR&CA&CO&CT&DE&FL&GA&HI&ID&IL&IN&IA&KS&KY&LA&M&MD&MA&MI&MN&MS&MO&MT&NE&NV&NH&NJ&NM&NY&NC&ND&OH&OK&OR&PA&RI&SC&SD&TN&TX&UT&VT&VA&WA&WV&WI&WY']

Try it online!

Dat

Posted 2017-06-02T09:31:00.530

Reputation: 879

0

JavaScript (Node.js), 180 bytes

x=>[`What is${e=" an engineer"}?`,`I am${x=="OR"?" not"+e:e}`][+!!/A[LKZR]|CO|DE|FL|[GPVCL]A|[HR]I|I[DLNA]|K[SY]|M[EDAINSOT]|N[EVHJMYCD]|O[HKR]|S[CD]|T[NX]|[UVC]T|W[AVIY]/.exec(x)]

Try it online!

Somehow the combination of the previous 2 JS answers.

Shieru Asakoto

Posted 2017-06-02T09:31:00.530

Reputation: 4 445

Why use !!reg.exec not reg.test? – l4m2 – 2018-03-09T15:55:21.080

@l4m2 Oh I forgot .test method! That helps! – Shieru Asakoto – 2018-03-10T06:07:32.357

0

Python 3, 161 bytes

o=('What is%s?','I am'+' not'*(i=='OR')+"%s")[i in'MINCALA MSCTNMNVAKY WAZ PAR FL GA NHID COKSD ME MDE MA MTX NE NJ NY ND MOH ORIA UT WVT WIL WY']%' an engineer'

Try it online!

Emil Carr

Posted 2017-06-02T09:31:00.530

Reputation: 21

Yeah uh, from looking at others' answers, mine is pretty much exactly the same as a couple others. Not sure if this counts, but I came to this answer independently. – Emil Carr – 2018-09-18T19:43:55.457

1

Hello and welcome to PPCG. As an answer to your comment, yes -- you can answer duplicate answers -- we try to give the benefit of the doubt that the answer was not simply copied. However, your answer does not comply with our default I/O -- either write a function or print to stdout.

– Jonathan Frech – 2018-09-18T20:12:03.913

0

Pyth, 145 bytes

I wish I could do stack manipulation in Pyth. Overly late to the party...

X_1@c"I am not 
I am 
What is?"b._x"ORIA MINCALA MSCTNMNVAKY WAZ PAR FL GA NHID COKSD ME MDE MA MTX NE NJ NY ND MOH UT WVT WIL WY"Q" an engineer"

Try it online!

Explanation

"ORIA MINCALA MSCTNMNVAKY WAZ PAR FL GA NHID COKSD ME MDE MA MTX NE NJ NY ND MOH UT WVT WIL WY"

The magic string from @BusinessCat's answer

x↑Q

What is the string's index in the above magic string? -1 for nonexistent.

._↑

Find the sign, yielding 1, 0, -1.

c"I am not 
I am 
What is?"b

Split the string into a list of newlines.

@↑ ↑↑

Index the sign into the above splitted list

X_1↑" an engineer"

Insert the string " an engineer" before the last character
```

user85052

Posted 2017-06-02T09:31:00.530

Reputation: