SHARE
TWEET

Simple pandigital method

Nickster258 Sep 20th, 2016 44 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public static boolean isPan(String num) {
  2.     ArrayList<Character> chars = new ArrayList<Character>();
  3.     for (int i = 0; i<num.length(); i++) {
  4.         if (Integer.valueOf(Character.toString(num.charAt(i))) <= num.length()) {
  5.             if (!chars.contains(num.charAt(i))) {
  6.                 chars.add(num.charAt(i));
  7.             } else {
  8.                 return false;
  9.             }
  10.         } else {
  11.             return false;
  12.         }
  13.     }
  14.     return true;
  15. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top