Register
|
Login
Home
News
Competitions
Practice
How to
Rankings
Calendar
Arena
CodeFu 2010
CodeFu'10 Highlights
Jazoon'10 Highlights
Schedule
Rules
Prizes
Results
Competitions
»
Main CodeFu Competitons
»
CodeFu 2010
»
Results
CodeFu 2010 Results
Final Round Results
Gocepp's solution for 200: TrainRoute, written in Java, submitted on 09.05.2010 12:51:01
public class TrainRoute { public String findActualSchedule(String plannedSchedule, String updates) { char []up=new char[50]; int []pos=new int [50]; boolean ima=false; int brojac=0; for (int i=0; i<updates.length(); i++) { ima=false; for (int j=0; j<brojac; j++) { if (updates.charAt(i)==up[j]) { pos[j]=i; ima=true; } } if (!ima) { up[brojac]=updates.charAt(i); pos[brojac]=i; brojac++; } i+=7; } int j=0; String konecen=""; for (int i=1; i<brojac; i++) for (int k=i; k>0; k--) { if (up[k]<up[k-1]) { char t; int r; r=pos[k]; t=up[k]; up[k]=up[k-1]; pos[k]=pos[k-1]; pos[k-1]=r; up[k-1]=t; } } boolean najden=false; for (int i=0; i<plannedSchedule.length(); i++) { if (i>0) konecen+=" "; najden=false; for (int s=0; s<brojac; s++) { if (plannedSchedule.charAt(i)==up[s]) { najden=true; j=s; } } if (!najden) { for (int k=0; k<7; k++) konecen+= plannedSchedule.charAt(i+k); } else { for (int k=0; k<7; k++) konecen+=updates.charAt(k+pos[j]); } i+=7; } return konecen; } }