Created
March 23, 2021 06:28
-
-
Save jeromewu/7e06f9d689c2084e03ee40398894e0f5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Main { | |
| public static void main(String[] args) { | |
| Set<String> ingredients = new HashSet(); | |
| Set<String> allergens = new HashSet(); | |
| for (int i = 0; i < args.length(); i++) { | |
| String[] cols = args.get(i).split(" (contains "); | |
| String[] ings = cols[0].split(" "); | |
| for (Sring ing : ings) { | |
| ingredients.add(ing); | |
| } | |
| String[] alles = cols[1].substring(0, cols[1].length()-2).split(", "); | |
| for (String alle : alles) { | |
| allergens.add(alle); | |
| } | |
| } | |
| System.out.println(ingredients); | |
| System.out.println(allergens); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment