title: How do I return false if a value in an array isn't contained in another array?
body: <p>I have two arrays. One being the input user array and the other being the Array of choices. An example is the user array is BLACK, RED, GREEN and the choices array is BLUE,RED,GREEN. Because BLACK isn't in the choices array it would return false. You could also have RED,RED,RED return True as red is contained in the choices array, it doesn't matter how many times you use the choice.</p>
  
  <p>Here is my current code but isTrue only ever goes up once for some reason and I don't think it accounts for having multiple choices of the same colour. I feel there has to be an easier way to do this?</p>
  
  <pre><code>public Boolean isValidColour(String userInput) {
          ArrayList&lt;String&gt; userPegsArray = new ArrayList&lt;&gt;();
          String[] userPegs = userInput.toUpperCase().split(",");
          int isTrue = 0;
          for (String peg: userPegs) {
              userPegsArray.add(peg);
          }
  
          for (int i = 0; i &lt;Peg.values().length; i++) {
              for (String peg:userPegsArray) {
                  if(peg.equals(Peg.valueOf(i).toString())) {
                      isTrue += 1;
                  }
              }
          }
          if(isTrue == 5) {
              return true;
          }
          return false;
      }
  </code></pre>
  
  <p>Update: Solved, thanks for the help in comments.</p>
  
  <p>SOLUTION</p>
  
  <pre><code>    public Boolean isValidColour(String userInput) {
          ArrayList&lt;String&gt; userPegsArray = new ArrayList&lt;&gt;();
          String[] userPegs = userInput.toUpperCase().split(",");
          for (String peg: userPegs) {
              userPegsArray.add(peg);
          }
  
          Map pegMap = new HashMap&lt;String,Integer&gt;();
          for (int i = 0; i &lt; Peg.values().length; i++) {
              pegMap.put(Peg.valueOf(i).toString(), i);
          }
  
          for (String peg:userPegs) {
              System.out.println("Peg: " + peg + " | pegMap: " + pegMap.toString());
              if (pegMap.containsKey(peg)) {
                  System.out.println("ayyyayay");
                  return true;
              }
          }
          return false;
      }
  </code></pre>