Register
|
Login
Home
News
Competitions
Practice
How to
Rankings
Calendar
Arena
CodeFu 2007
CodeFu'07 Highlights
Jazoon'07 Highlights
Schedule
Rules
Prizes
Results
Competitions
»
Main CodeFu Competitons
»
CodeFu 2007
»
Results
CodeFu 2007 Results
CodeFu Final Round Results
tomazi's solution for 300: Integer Pair, written in Java
public class IntegerPair { public int count(int N) { int c=0; for(int i=0; i<N/2; i++) { if(isOK(i,N-i)) c++; } return c; } boolean isOK(int a, int b) { boolean d=true, ok=true; char[] na=String.valueOf(a).toCharArray(); char[] nb=String.valueOf(b).toCharArray(); if(na.length==nb.length) d=false; int s=nb.length; int k=0; for(int i=0; i<s; i++) { if(na[k]!=nb[i]) { if(d) { d=false; } else { ok=false; k++; break; } } else k++; if(k==na.length) break; } if(s-k>1 && a!=0) ok=false; return ok; } }