/** the drawing method displays 0/1 values by dedicated colors */
 protected void drawMatrixEntry(PrintWriter out, Pair xy, FullDomain list, FullDomain removed) {
   out.println("<!-- index " + xy.getX() + " " + xy.getY() + " domain " + list + " -->");
   unitSquareSVG(out, posX(xy), posY(xy), booleanColor(list, removed));
   if (list.isFixed()) {
     textSVG(out, posX(xy), posY(xy), list.getIntValue(), Colors.ASSIGNED_TEXT_COLOR);
   }
 }
  static String isitpossible(int a, int b, int c, int d) {
    Pair source = new Pair(a, b);
    Pair dest = new Pair(c, d);
    list.add(source);
    while (!list.isEmpty()) {
      Pair pair = list.poll();
      if (pair.getX() == dest.getX() && pair.getY() == dest.getY()) return "Yes";
      else {
        int sum = pair.getX() + pair.getY();
        if (sum <= Math.max(c, d)) {
          list.add(new Pair(sum, pair.getY()));
          list.add(new Pair(pair.getX(), sum));
        }
      }
    }

    return "No";
  }
Esempio n. 3
0
  public static void printPairList(
      List<Pair<Float>> list, String headerX, String headerY, OutputStreamWriter writer)
      throws TException {
    try {
      writer.append(headerX);
      writer.append(',');
      writer.append(headerY);
      writer.append('\n');

      for (@SuppressWarnings("rawtypes") Pair p : list) {
        writer.append(p.getX().toString());
        writer.append(',');
        writer.append(p.getY().toString());
        writer.append('\n');
      }

      writer.flush();
      writer.close();
    } catch (Exception e) {
      throw new TException(e.getMessage()).setUserMsg("unable to print");
    }
  }
Esempio n. 4
0
 public synchronized Pair getPair() {
   // Make a copy to keep the original safe:
   return new Pair(p.getX(), p.getY());
 }