public class run { public static void main ( String args[] ) { Robot robot = new Robot (args.length>0? args[0] : ""); int lcount = 0; int lpeek = 0; int rcount = robot.nbins()-1; int rpeek = rcount; if (rcount <= 0) { robot.report(); return; } while(robot.peek(lcount) == 'r' && lcount < rcount) lcount++; lpeek = lcount; while(robot.peek(rcount) == 'b' && rcount > lcount) rcount--; rpeek = rcount; while(true) { while ( robot.peek(lpeek) != 'r' && lpeek < rcount) lpeek++; if (lpeek <= rcount) { robot.swap(lpeek, lcount); if (lpeek == rcount) break; else lcount++; } } while(true) { while (robot.peek(rpeek) != 'b' && rpeek > lcount) rpeek--; if (rpeek >= lcount) { if (rpeek == lcount) { break; } else { robot.swap(rpeek, rcount); rcount--; rpeek--; } } } robot.report(); } }