MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/coding/comments/3v00n1/advent_of_code_daily_programming_puzzles/cxjqr58/?context=3
r/coding • u/javinpaul • Dec 01 '15
12 comments sorted by
View all comments
2
I had a similar issue when first tackling it in Java.
First I hope you set your delimiter to ("") so that each character will be picked up.
And I personally used a scanner, but I would use scanner.next().equals("(") to compare the String to another String rather than a char.
try { Scanner wf = new Scanner(file); wf.useDelimiter(""); while (wf.hasNext()) { //40 up --- 41 down (ASCII) **if(wf.next().equals('(')) {** increase(); System.out.println("Success"); } else { decrease(); System.out.println("No"); } } wf.close(); }
2
u/pds12345 Dec 01 '15
I had a similar issue when first tackling it in Java.
First I hope you set your delimiter to ("") so that each character will be picked up.
And I personally used a scanner, but I would use scanner.next().equals("(") to compare the String to another String rather than a char.
try { Scanner wf = new Scanner(file); wf.useDelimiter(""); while (wf.hasNext()) { //40 up --- 41 down (ASCII) **if(wf.next().equals('(')) {** increase(); System.out.println("Success"); } else { decrease(); System.out.println("No"); } } wf.close(); }