Skip to content

Instantly share code, notes, and snippets.

@jeromewu
Created March 23, 2021 06:28
Show Gist options
  • Select an option

  • Save jeromewu/7e06f9d689c2084e03ee40398894e0f5 to your computer and use it in GitHub Desktop.

Select an option

Save jeromewu/7e06f9d689c2084e03ee40398894e0f5 to your computer and use it in GitHub Desktop.
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