Skip to content

Instantly share code, notes, and snippets.

@moomdate
Last active October 29, 2021 00:40
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 moomdate/1cafb3e7bb1618e6426d1b173cee60bf to your computer and use it in GitHub Desktop.
Save moomdate/1cafb3e7bb1618e6426d1b173cee60bf to your computer and use it in GitHub Desktop.
package sha1;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
public class Test2 {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
System.out.print("input:");
String input = reader.readLine();
Map<String, Integer> definitionWorkLevel = new HashMap<String, Integer>() {{
put("Easy", 1);
put("Medium", 2);
put("Hard", 3);
}};
String[] mapped = input
.replaceAll(" ", "")
.replaceAll("“","\"")
.replaceAll("”","\"")
.replaceAll("\\[\\{\"", "")
.replaceAll("\":", ":")
.replaceAll("},\\{\"", "\n")
.replaceAll("}]", "\n")
.split("\n");
int sum = 0;
for (String s : mapped) {
String[] work = s.split(":");
sum = sum + definitionWorkLevel.get(work[0]) * Integer.parseInt(work[1]);
}
System.out.print("จำนวน " + Math.round(sum / 8) + " คน");
}
public static class WorkLevel {
private String level;
private Integer hours;
WorkLevel(String level, Integer hours) {
this.level = level;
this.hours = hours;
}
public String getLevel() {
return this.level;
}
public Integer getHours() {
return this.hours;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment