2
\$\begingroup\$

In Rocket League, there are controls assigned to quick chat. For PC, they are 1, 2, 3, and 4. To use a quick chat, you must press two controls. For example, the first option would be 1, 1.

You will be simulating the Rocket League client. You will be given a non-empty list composed only of four characters of your choosing. The length of the list will always be even and <= 8. I will be using 1, 2, 3, 4 for the examples. If you modify the input domain, you must specify how your input maps to 1, 2, 3, 4.

The first character in each couplet specifies the section, the second the item in the section. Below are all sections, with their default chat:

1
 1 I got it!
 2 Need boost!
 3 Take the shot!
 4 Defending...

2
 1 Nice shot!
 2 Great pass!
 3 Thanks!
 4 What a save!

3
 1 OMG!
 2 Noooo!
 3 Wow!
 4 Close one!

4
 1 $#@%!
 2 No problem.
 3 Whoops...
 4 Sorry!

The above are case sensitive. So, 1 1 would be I got it!, and 3 3 would be Wow!.

In addition, after three quick chats come through rapidly, the game shots you down. You get a message back: Chat disabled for 2 seconds.. If you continue trying, you get one more chance, and then Chat disabled for 4 seconds.. Our challenge will not deal with time, or any further chats.

However, after three chats (6 input characters), you must output Chat disabled for 2 seconds.. After four chats (8 input characters), you must output Chat disabled for 4 seconds.. Since 8 is the maximum input length, that would be your final output, if they are 8 input characters.

Input

First, chose your four characters, and map them to 1, 2, 3, 4.

Your input will be non-empty, contain an even number of items, and only contain up to eight items.

Output

You will output the matching quick chats in order, plus any chat disabled warnings (in the correct location). Output is case sensitive. It must be delimited - suggested delimiters are \n (pretty delimiter) or ,, and you cannot use any delimiters in any of the possible outputs.

Test Cases

In these, input is in the form of a JSON list and can be 1, 2, 3, 4, and the output delimiter is ,.

[1, 1, 1, 1] => I got it!,I got it!
[2, 4, 4, 4] => What a save!,Sorry!
[3, 3] => Wow!
[1, 4, 2, 3, 4, 1, 4, 4] => Defending...,Thanks!,$#@%!,Chat disabled for 2 seconds.,Sorry!,Chat disabled for 4 seconds.

Invalid (out of scope) inputs:

[] //empty
[1, 3, 1] //odd length
[5, 4] //character out of input domain
[1, 2, 3, 4, 1, 2, 3, 4, 1] //length > 8

To ensure the point is made: you are not taking these in real time, like in the game. You are just receiving a (short) list of numbers.

\$\endgroup\$
9
  • \$\begingroup\$ Possible duplicate, though I am in favor of closing the old one as a duplicate of this. \$\endgroup\$ Commented May 24, 2017 at 1:44
  • \$\begingroup\$ @ConorO'Brien oh, didn't see that. They are kinda different, since mine is multiple inputs. We'll see what the community thinks. Guess I shoulda posted this to Sandbox after all :/ \$\endgroup\$
    – Stephen
    Commented May 24, 2017 at 1:46
  • 1
    \$\begingroup\$ It's fine. I personally like this challenge better (being the writer of the aforementioned challenge). The concept is essentially the same, with the only difference being multiple inputs and the lack of a bonus. The latter, at least, is good. \$\endgroup\$ Commented May 24, 2017 at 1:48
  • \$\begingroup\$ @StephenS opps sorry. Forgot I had insta edit \$\endgroup\$
    – user63187
    Commented May 24, 2017 at 1:52
  • \$\begingroup\$ @Christopher oh right, no problem. I have to get used to that too :) \$\endgroup\$
    – Stephen
    Commented May 24, 2017 at 1:53

2 Answers 2

1
\$\begingroup\$

Jelly, 153 150 bytes

⁶;j@“Kẋ3ŒK!D“¿ṁxṁị»Wḣ
J_2ḤÇ€
s2ḅ4ị“w eɲEƓṫ:⁾ṆƙḅƙḣḊṗṠ,`ė)®=Œf°Ẇŀ#ḍḤḌCṭ8v⁻$ʠṄṾŻYtṫʠßR>ĊḷḊc8Þ@Zq8-@⁻⁺ ḃḊĿ`ÆYƒðḤ|3ƓULẇẇŻịỵ1²ṄE'Cṣ\{ṣ{ḃ⁵ḳpẸz.4<»Ỵ¤µżÇ;/ȦÐfY

Input is a list of integers, where 0, 1, 2, and 3 represent 1, 2, 3, and 4 respectively.
Output is a newline separated print out.

Try it online!

How?

There is a compressed string taking up 105 bytes:

“w eɲEƓṫ:⁾ṆƙḅƙḣḊṗṠ,`ė)®=Œf°Ẇŀ#ḍḤḌCṭ8v⁻$ʠṄṾŻYtṫʠßR>ĊḷḊc8Þ@Zq8-@⁻⁺ ḃḊĿ`ÆYƒðḤ|3ƓULẇẇŻịỵ1²ṄE'Cṣ\{ṣ{ḃ⁵ḳpẸz.4<»
= "Need boost!\nTake the shot!\nDefending...\nNice shot!\nGreat pass!\nThanks!\nWhat a save!\nOMG!\nNoooo!\nWow!\nClose one!\n$#@%!\nNo problem.\nWhoops...\nSorry!\nI got it!"

(Somewhat shockingly 1 byte was saved by including all the ! rather than inserting them via code.)

The program then works as follows

⁶;j@“Kẋ3ŒK!D“¿ṁxṁị»Wḣ - Link 1, get a disabled string: number, seconds
⁶                     - space character
 ;                    - concatenate with seconds (e.g. " 4")
    “Kẋ3ŒK!D“¿ṁxṁị»   - compressed list of strings ["Chat disabled for"," seconds"]
  j@                  - join (swap @arguments)  (e.g. "Chat disabled for 4 seconds"
                   W  - wrap in a list
                    ḣ - head to seconds (for -2 and 0 gives an empty list, for 2 and 4 give the string wrapped in a list)

J_2ḤÇ€ - Link 2, get disabled strings: list of chat strings
J      - range of length (e.g. for 4 chat strings [1,2,3,4])
 _2    - subtract 2      (...[-1,0,1,2])
   Ḥ   - double          (...[-2,0,2,4])
    Ç€ - call last link (1) as a monad for €ach

s2ḅ4ị“...»Ỵ¤µżÇ;/ȦÐfY - Main link: list of characters
s2                    - split into twos
  ḅ4                  - convert from base four (vectorises)
           ¤          - nilad followed by link(s) as a nilad:
     “...»            -   compressed string described in code-block above
          Ỵ           -   split on newlines
    ị                 - index into (use the base four representation to get the chat strings)
            µ         - monadic chain separation (call that x)
              Ç       - call last link (2) as a monad
             ż        - zip
               ;/     - flatten list by one level
                  Ðf  - filter keep if:
                 Ȧ    -   any and all (false for empty results, i.e. the empty results from link 2)
                    Y - join with newlines
                      - implicit print
\$\endgroup\$
1
  • 1
    \$\begingroup\$ List of ints is allowed. \$\endgroup\$
    – Stephen
    Commented May 24, 2017 at 12:35
1
\$\begingroup\$

JavaScript, 264 bytes

f=([x,y,...z],n=.5)=>"I got it!,Need boost!,Take the shot!,Defending...,Nice shot!,Great pass!,Thanks!,What a save!,OMG!,Noooo!,Wow!,Close one!,$#@%!,No problem.,Whoops...,Sorry!".split`,`[x*4+y-5]+(n>1?`,Chat disabled for ${n} seconds.`:'')+(z[0]?','+f(z,n*2):'')
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.