fork download
  1. object Main extends App {
  2. def f(s:String)=(for(i<-0 until s.length/2)yield s(i)-s(s.length-i-1)).sum==0
  3.  
  4. println("True tests:")
  5. Array("1","6","11","141","1221","23281453796004414",
  6. "523428121656666655655556655656502809745249552466339089702361716477983610754966885128041975406005088"
  7. ) foreach { s => if (!f(s)) println("Test failed") else println("Test passed!")}
  8.  
  9. println("\nFalse tests:")
  10. Array("10","12","110","15421","5234095123508321",
  11. "6240911314399072459493765661191058613491863144152352262897351988250431140546660035648795316740212454"
  12. ) foreach { s => if (f(s)) println("Test failed") else println("Test passed!")}
  13. }
Success #stdin #stdout 0.17s 322496KB
stdin
Standard input is empty
stdout
True tests:
Test passed!
Test passed!
Test passed!
Test passed!
Test passed!
Test passed!
Test passed!

False tests:
Test passed!
Test passed!
Test passed!
Test passed!
Test passed!
Test passed!