public static long solve(RectangularDungeon d) { // TODO: implementar algoritmo para determinar la cantidad total de // habitaciones existentes en el calabozo tipo matrix rectangular // Valor: 4 puntos // Restriccion: la cantidad de movimientos de tu solucion no debe // exceder 4 veces el de mi solucion; ver ejemplo en Main // para comparar tus resultados contra los mios // Ejemplo de interaccion: // d.GoThruDoor(Direction.SOUTH); int width = 1; int height = 1; while (d.GoThruDoor(Direction.EAST)) { ; } while (d.GoThruDoor(Direction.WEST)) { width++; } while (d.GoThruDoor(Direction.NORTH)) { ; } while (d.GoThruDoor(Direction.SOUTH)) { height++; } return(height * width); }
public static long solve(RectangularDungeon d) { int habitacion = 0; int habitacion2 = 0; int movimiento = 0; int reset = 0; // Obtener Altura for (bool movNorte = true; movNorte == true;) { movNorte = d.GoThruDoor(Direction.NORTH); if (movNorte == true) { habitacion += 1; } } habitacion = habitacion + 1; // Obtener Altura for (bool movSur = true; movSur == true;) { movSur = d.GoThruDoor(Direction.SOUTH); if (movSur == true) { habitacion2 += 1; } } habitacion2 = habitacion2 + 1; if (habitacion2 >= habitacion) { movimiento = habitacion2; } else { movimiento = habitacion; } habitacion = 0; habitacion2 = 0; for (bool movEste = true; movEste == true;) { movEste = d.GoThruDoor(Direction.EAST); if (movEste == true) { habitacion += 1; } } habitacion = habitacion + 1; for (bool movOeste = true; movOeste == true;) { movOeste = d.GoThruDoor(Direction.WEST); if (movOeste == true) { habitacion2 += 1; } } habitacion2 = habitacion2 + 1; if (habitacion2 >= habitacion) { reset = movimiento; movimiento = movimiento * habitacion2; if (movimiento == 0) { movimiento = habitacion2; } if (movimiento == 0) { movimiento = reset; } } else { movimiento = movimiento * habitacion; } // TODO: implementar algoritmo para determinar la cantidad total de // habitaciones existentes en el calabozo tipo matrix rectangular // Valor: 4 puntos // Restriccion: la cantidad de movimientos de tu solucion no debe // exceder 4 veces el de mi solucion; ver ejemplo en Main // para comparar tus resultados contra los mios // Ejemplo de interaccion: // d.GoThruDoor(Direction.SOUTH); return(movimiento); }