Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package luke8;
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.lang.reflect.Array;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.Collections;
- import java.util.HashMap;
- import java.util.Hashtable;
- import java.util.Map.Entry;
- public class Luke8 {
- public static void main(String[] args) throws IOException {
- // FileWriter fw = new FileWriter("o.txt");
- FileReader fr = new FileReader(new File("d.txt"));
- BufferedReader br = new BufferedReader(fr);
- HashMap<String, Integer> ps = new HashMap<String, Integer>();
- String line = null;
- int ladderCount = 0;
- int pC = 0;
- while ((line = br.readLine()) != null) {
- int dice = Integer.parseInt(line);
- pC++;
- if (pC > 1337) {
- pC = 1;
- }
- String pl = pC + " Player " + pC;
- if (!ps.containsKey(pl)) {
- ps.put(pl, dice+1);
- } else {
- ps.put(pl, ps.get(pl) + dice);
- }
- int prev = ps.get(pl) - dice;
- if (ps.get(pl) == 90) {
- System.out.println("P: " + pC + " Dice: " + dice + " Val: "
- + ps.get(pC) + " " + ladderCount + " " + prev);
- // System.out.println(ladderCount);
- }
- switch (ps.get(pl)) {
- case 3:
- prev = ps.get(pl);
- ps.put(pl, 17);
- ladderCount++;
- break;
- case 8:
- prev = ps.get(pl);
- ps.put(pl, 10);
- ladderCount++;
- break;
- case 15:
- prev = ps.get(pl);
- ps.put(pl, 44);
- ladderCount++;
- break;
- case 22:
- prev = ps.get(pl);
- ps.put(pl, 5);
- ladderCount++;
- break;
- case 39:
- prev = ps.get(pl);
- ps.put(pl, 56);
- ladderCount++;
- break;
- case 49:
- prev = ps.get(pl);
- ps.put(pl, 75);
- ladderCount++;
- break;
- case 62:
- prev = ps.get(pl);
- ps.put(pl, 45);
- ladderCount++;
- break;
- case 64:
- prev = ps.get(pl);
- ps.put(pl, 19);
- ladderCount++;
- break;
- case 65:
- prev = ps.get(pl);
- ps.put(pl, 73);
- ladderCount++;
- break;
- case 80:
- prev = ps.get(pl);
- ps.put(pl, 12);
- ladderCount++;
- break;
- case 87:
- prev = ps.get(pl);
- ps.put(pl, 79);
- ladderCount++;
- break;
- default:
- break;
- }
- if (ps.get(pl) > 90) {
- ps.put(pl, ps.get(pl) + prev);
- }
- }
- br.close();
- // fw.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement