Skip to content

Instantly share code, notes, and snippets.

@itzwalsh
Last active March 5, 2019 03:45
Show Gist options
  • Save itzwalsh/69f782e68dc39d915a8047277bb1c8b8 to your computer and use it in GitHub Desktop.
Save itzwalsh/69f782e68dc39d915a8047277bb1c8b8 to your computer and use it in GitHub Desktop.
package terrainProject;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
import java.util.Comparator;
public class heightMap {
static int rows;
static int columns;
// private static Object point;
public static void main(String[] args) throws FileNotFoundException {
File mapNumbers = new File("terrain.dat");
@SuppressWarnings("resource")
Scanner sc = new Scanner(mapNumbers);
// System.out.println(Arrays.toString(arr));
int[][] arr = new int[rows][columns];
while (sc.hasNextLine()) {
String[] bounds = sc.nextLine().replaceAll("[()]", "").split(",");
rows = Integer.valueOf(bounds[0]);
columns = Integer.valueOf(bounds[1]);
// sc.nextLine();
for (int i = 0; i < (rows*columns); i++) {
int height = sc.nextInt();
Arrays.sort(arr, (a, b) -> Integer.compare(a[0], b[0]));
System.out.println("Top 5 Heights: " + height);
}
//Point p = new Point(rows, columns);
//System.out.println("Location: (" + p.x + ", " + p.y + ")");
}
}
}
(32,20)
175 436 -245 290 -889 -453 568 -361 -792 919 -344 299 713 710 -800 924 635 169 -516 -862
-311 862 -36 881 884 600 502 -951 -578 380 -392 556 -949 640 -77 -293 77 -164 537 -532
846 -813 73 -137 -633 736 60 561 -913 -978 299 372 66 398 262 -396 430 -32 -68 -520
-706 146 812 871 486 599 744 -402 -628 357 748 191 -184 -800 -164 -119 129 754 -628 -636
-370 -128 615 492 728 -204 -811 8 107 -790 774 -741 -212 -922 244 -324 322 610 -559 743
998 142 -533 174 -373 179 569 -452 -817 -828 -129 537 427 789 681 412 -234 -251 -120 -645
75 -752 264 -907 194 -323 -408 -434 120 171 -931 935 538 103 232 281 457 -584 525 -635
780 759 309 -132 -930 -593 -907 85 -274 610 -173 506 -797 151 -695 -769 -542 -878 10 -853
-653 -37 -655 -834 -46 896 520 -37 -655 786 587 -143 -50 908 754 346 -713 457 239 -889
94 588 -951 -422 -830 -712 545 -171 -145 25 340 808 -191 -269 693 490 -500 832 182 -819
-788 -528 745 -280 409 -73 379 -868 -801 -439 907 934 -324 -49 -732 -146 -352 -318 -213 -490
-549 -668 140 272 -151 -196 -206 -49 796 479 -566 217 376 240 -821 -910 -623 -39 -442 -466
-728 -760 -274 205 988 -752 331 -990 257 864 -275 -927 333 713 918 -509 -734 -91 245 -765
386 -570 -953 -851 843 -232 187 -725 -31 -623 -575 181 -833 -224 -705 -292 -285 -96 191 212
-353 -44 114 434 -271 -704 7 -844 856 -708 -504 503 467 -559 -86 -885 879 158 -189 556
489 -1000 991 307 44 -295 331 690 719 -715 -524 -883 -773 334 301 -96 726 51 658 992
-375 677 -487 -616 -862 -874 392 747 -960 835 -926 93 -496 -672 157 615 -462 -689 -291 -19
-808 128 -146 -407 550 360 10 11 373 -564 -393 620 432 811 -663 592 52 -403 793 -819
754 -82 -900 831 716 -96 -464 -889 -498 -37 432 935 176 -903 448 0 -504 463 -170 691
-359 450 293 777 248 144 203 90 903 642 -41 218 -96 -146 420 858 828 47 208 103
-279 275 -351 696 475 -347 507 -799 -302 -692 207 -501 518 940 -289 -897 -437 555 -663 389
174 70 818 -247 450 354 918 -38 561 508 530 81 -229 -187 172 -43 -710 418 318 -150
-502 309 881 448 -830 167 -152 648 -418 514 -650 504 870 281 922 67 -337 302 150 -228
829 826 350 36 -679 62 -172 -7 -608 792 -780 69 277 -402 884 -914 -736 -606 -932 -863
-906 584 242 433 -33 753 -889 956 105 -370 -32 -916 -610 856 102 403 51 -231 810 531
391 481 414 -36 659 379 -339 -542 -769 323 -727 -56 -93 19 290 667 721 -884 599 -789
-353 -320 222 -645 538 896 -131 -576 121 561 -273 84 824 -566 18 546 663 570 -663 381
252 830 -113 -340 -176 -157 -607 -99 793 -144 -392 -901 -840 -219 913 958 686 -645 -639 -951
-272 943 -892 696 720 152 954 520 423 -254 -541 -707 -366 77 238 739 169 767 122 868
173 136 49 856 -17 -581 -582 -631 871 -334 -388 -748 305 91 -42 345 -674 731 -404 619
116 930 438 -525 -631 435 619 820 -24 -708 14 804 -829 391 58 496 714 -806 66 -623
684 -799 597 -737 527 -784 210 -401 -525 -373 -199 -157 -611 277 240 -329 -325 267 35 -510
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment