Created
March 23, 2013 10:53
-
-
Save kazua/5227305 to your computer and use it in GitHub Desktop.
世界で闘うプログラマ本の1-3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //write Kazua | |
| object worldproblem1_3 { | |
| def PermutationsCheck(chkstr1 : String, chkstr2 : String) : Boolean = { | |
| if (chkstr1.length != chkstr2.length) return false | |
| val chgchkstr1 = chkstr1.toList.sortWith((o1, o2) => o1.toString.compareToIgnoreCase(o2.toString) < 0).mkString | |
| val chgchkstr2 = chkstr2.toList.sortWith((o1, o2) => o1.toString.compareToIgnoreCase(o2.toString) < 0).mkString | |
| chgchkstr1.equals(chgchkstr2) | |
| } | |
| def main(args : Array[String]) { | |
| println(PermutationsCheck("abcgdjwp", "jagdwbpc")) | |
| println(PermutationsCheck("23de2546sfh", "d2f3e25s4h6")) | |
| println(PermutationsCheck("23de2546sfh", "d2f3e45s4h6")) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment