Search in sources :

Example 6 with Counter

use of com.automatak.dnp3.Counter in project AlgorithmsSolutions by Allenskoo856.

the class Flips method main.

public static void main(String[] args) {
    int T = Integer.parseInt(args[0]);
    Counter heads = new Counter("heads");
    Counter tails = new Counter("tails");
    for (int t = 0; t < T; t++) {
        if (StdRandom.bernoulli(0.5)) {
            heads.increment();
        } else {
            tails.increment();
        }
    }
    StdOut.println(heads);
    StdOut.println(tails);
    int d = heads.tally() - tails.tally();
    StdOut.println("delta: " + Math.abs(d));
}
Also used : Counter(edu.princeton.cs.algs4.Counter)

Example 7 with Counter

use of com.automatak.dnp3.Counter in project AlgorithmsSolutions by Allenskoo856.

the class FlipsMax method main.

public static void main(String[] args) {
    int T = Integer.parseInt(args[0]);
    Counter heads = new Counter("heads");
    Counter tails = new Counter("tails");
    for (int t = 0; t < T; t++) {
        if (StdRandom.bernoulli(0.5)) {
            heads.increment();
        } else {
            tails.increment();
        }
    }
    if (heads.tally() == tails.tally()) {
        StdOut.println("Tie");
    } else {
        StdOut.println(max(heads, tails) + " wins");
    }
}
Also used : Counter(edu.princeton.cs.algs4.Counter)

Example 8 with Counter

use of com.automatak.dnp3.Counter in project AlgorithmsSolutions by Allenskoo856.

the class Ex09 method main.

public static void main(String[] args) {
    System.out.print("N: ");
    int N = StdIn.readInt();
    int[] a = new int[N];
    System.out.print("list: ");
    for (int i = 0; i < N; i++) {
        a[i] = StdIn.readInt();
    }
    Arrays.sort(a);
    System.out.print("key: ");
    int key = StdIn.readInt();
    Counter counter = new Counter("keys");
    System.out.println(rank(key, a, counter));
    System.out.println(counter);
}
Also used : Counter(edu.princeton.cs.algs4.Counter)

Example 9 with Counter

use of com.automatak.dnp3.Counter in project AlgorithmsSolutions by Allenskoo856.

the class Rolls method main.

public static void main(String[] args) {
    int T = Integer.parseInt(args[0]);
    int SIDES = 6;
    Counter[] rolls = new Counter[SIDES + 1];
    for (int i = 1; i <= SIDES; i++) {
        rolls[i] = new Counter(i + "'s");
    }
    for (int t = 0; t < T; t++) {
        int result = StdRandom.uniform(1, SIDES + 1);
        rolls[result].increment();
    }
    for (int i = 1; i <= SIDES; i++) {
        StdOut.println(rolls[i]);
    }
}
Also used : Counter(edu.princeton.cs.algs4.Counter)

Example 10 with Counter

use of com.automatak.dnp3.Counter in project algorithms-sedgewick-wayne by reneargento.

the class Exercise9 method main.

public static void main(String[] args) {
    int[] whitelist = { 2, 10, 3, 6, 5, 4, 7, 1, 9, 8 };
    int[] keys = { 10, 12, 5 };
    Counter counter = new Counter("Operations");
    Arrays.sort(whitelist);
    for (int i = 0; i < keys.length; i++) {
        if (rank(keys[i], whitelist, counter) == -1) {
            StdOut.println(keys[i]);
        }
    }
    StdOut.println(counter);
}
Also used : Counter(edu.princeton.cs.algs4.Counter)

Aggregations

Counter (edu.princeton.cs.algs4.Counter)5 Counter (io.dropwizard.metrics5.Counter)4 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 Counter (com.automatak.dnp3.Counter)2 OutstationChangeSet (com.automatak.dnp3.OutstationChangeSet)2 CleanupDepositJob (edu.unc.lib.boxc.deposit.CleanupDepositJob)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 ControlConfig (net.solarnetwork.node.io.dnp3.domain.ControlConfig)2 ControlType (net.solarnetwork.node.io.dnp3.domain.ControlType)2 MeasurementConfig (net.solarnetwork.node.io.dnp3.domain.MeasurementConfig)2 MeasurementType (net.solarnetwork.node.io.dnp3.domain.MeasurementType)2 AnalogInput (com.automatak.dnp3.AnalogInput)1 AnalogOutputStatus (com.automatak.dnp3.AnalogOutputStatus)1 BinaryInput (com.automatak.dnp3.BinaryInput)1 BinaryOutputStatus (com.automatak.dnp3.BinaryOutputStatus)1 Channel (com.automatak.dnp3.Channel)1 DatabaseConfig (com.automatak.dnp3.DatabaseConfig)1 DoubleBitBinaryInput (com.automatak.dnp3.DoubleBitBinaryInput)1