Last active
October 29, 2021 00:40
-
-
Save moomdate/1cafb3e7bb1618e6426d1b173cee60bf to your computer and use it in GitHub Desktop.
This file contains 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
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