Skip to content

Instantly share code, notes, and snippets.

@lgueye
Created February 1, 2013 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lgueye/4692040 to your computer and use it in GitHub Desktop.
Save lgueye/4692040 to your computer and use it in GitHub Desktop.
Scalaskel en java
public Map<Integer, List<Map<String, Integer>>> getChange(int id) {
Map<Integer, List<Map<String, Integer>>> collecter = Maps.newHashMap();
for (int foo = 0; foo <= 100; foo++)
for (int bar = 0; bar <= 14; bar++)
for (int qix = 0; qix <= 9; qix++)
for (int baz = 0; baz <= 4; baz++) {
if (foo + bar * 7 + qix * 11 + baz * 21 == id) {
if (collecter.get(id) == null) {
collecter.put(id,
Lists.<Map<String, Integer>>newArrayList());
}
Map<String, Integer> match = new LinkedHashMap<String, Integer>();
if (foo > 0) match.put("foo", foo);
if (bar > 0) match.put("bar", bar);
if (qix > 0) match.put("qix", qix);
if (baz > 0) match.put("baz", baz);
collecter.get(id).add(match);
}
}
return collecter;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment