Advertisement
joric

Puzzle.java

Jan 17th, 2018
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.18 KB | None | 0 0
  1. // Levenstain never called! It's all in the repository! Watch the first chars in git show e0cfd6. -- Joric
  2.  
  3. // Decompiled by Jad v1.5.8d. Copyright 2001 Pavel Kouznetsov.
  4. // Jad home page: http://www.geocities.com/kpdus/jad.html
  5. // Decompiler options: packimports(3)
  6. // Source File Name:   Puzzle.java
  7.  
  8. import java.io.PrintStream;
  9. import java.util.Arrays;
  10. import java.util.Locale;
  11.  
  12. public class Puzzle
  13. {
  14.  
  15.     public Puzzle()
  16.     {
  17.     }
  18.  
  19.     public static void main(String args[])
  20.     {
  21.         if(args.length == 1)
  22.         {
  23.             System.out.println("A component of software configuration management, version control, also known as revision control or source control, is the management of changes to documents, computer programs, large web sites, and other collections of information.");
  24.             System.exit(0);
  25.         }
  26.         if(args.length == 2)
  27.         {
  28.             System.out.println("In computing, the diff utility is a data comparison tool that calculates and displays the differences between two files.");
  29.             System.exit(0);
  30.         }
  31.         if(args.length == 50)
  32.         {
  33.             System.out.println("This is a GIT repository you are in!");
  34.             System.exit(0);
  35.         }
  36.         System.out.println("Study the past if you would define the future. Go back and try again!");
  37.         System.out.println();
  38.         System.out.println(" * Run with a parameter for the hint");
  39.         System.out.println(" * Run with two parameters for the hint no two");
  40.         System.out.println(" * There just might be one more hint somewhere");
  41.     }
  42.  
  43.     public static int getLevenshteinDistance(CharSequence charsequence, CharSequence charsequence1)
  44.     {
  45.         if(charsequence == null || charsequence1 == null)
  46.             throw new IllegalArgumentException("Strings must not be null");
  47.         int i = charsequence.length();
  48.         int j = charsequence1.length();
  49.         if(i == 0)
  50.             return j;
  51.         if(j == 0)
  52.             return i;
  53.         if(i > j)
  54.         {
  55.             CharSequence charsequence2 = charsequence;
  56.             charsequence = charsequence1;
  57.             charsequence1 = charsequence2;
  58.             i = j;
  59.             j = charsequence1.length();
  60.         }
  61.         int ai[] = new int[i + 1];
  62.         int ai1[] = new int[i + 1];
  63.         for(int k = 0; k <= i; k++)
  64.             ai[k] = k;
  65.  
  66.         for(int i1 = 1; i1 <= j; i1++)
  67.         {
  68.             char c = charsequence1.charAt(i1 - 1);
  69.             ai1[0] = i1;
  70.             for(int l = 1; l <= i; l++)
  71.             {
  72.                 int j1 = charsequence.charAt(l - 1) != c ? 1 : 0;
  73.                 ai1[l] = Math.min(Math.min(ai1[l - 1] + 1, ai[l] + 1), ai[l - 1] + j1);
  74.             }
  75.  
  76.             int ai2[] = ai;
  77.             ai = ai1;
  78.             ai1 = ai2;
  79.         }
  80.  
  81.         return ai[i];
  82.     }
  83.  
  84.     public static int getLevenshteinDistance(CharSequence charsequence, CharSequence charsequence1, int i)
  85.     {
  86.         if(charsequence == null || charsequence1 == null)
  87.             throw new IllegalArgumentException("Strings must not be null");
  88.         if(i < 0)
  89.             throw new IllegalArgumentException("Threshold must not be negative");
  90.         int j = charsequence.length();
  91.         int k = charsequence1.length();
  92.         if(j == 0)
  93.             return k > i ? -1 : k;
  94.         if(k == 0)
  95.             return j > i ? -1 : j;
  96.         if(j > k)
  97.         {
  98.             CharSequence charsequence2 = charsequence;
  99.             charsequence = charsequence1;
  100.             charsequence1 = charsequence2;
  101.             j = k;
  102.             k = charsequence1.length();
  103.         }
  104.         int ai[] = new int[j + 1];
  105.         int ai1[] = new int[j + 1];
  106.         int l = Math.min(j, i) + 1;
  107.         for(int i1 = 0; i1 < l; i1++)
  108.             ai[i1] = i1;
  109.  
  110.         Arrays.fill(ai, l, ai.length, 0x7fffffff);
  111.         Arrays.fill(ai1, 0x7fffffff);
  112.         for(int j1 = 1; j1 <= k; j1++)
  113.         {
  114.             char c = charsequence1.charAt(j1 - 1);
  115.             ai1[0] = j1;
  116.             int k1 = Math.max(1, j1 - i);
  117.             int l1 = j1 <= 0x7fffffff - i ? Math.min(j, j1 + i) : j;
  118.             if(k1 > l1)
  119.                 return -1;
  120.             if(k1 > 1)
  121.                 ai1[k1 - 1] = 0x7fffffff;
  122.             for(int i2 = k1; i2 <= l1; i2++)
  123.                 if(charsequence.charAt(i2 - 1) == c)
  124.                     ai1[i2] = ai[i2 - 1];
  125.                 else
  126.                     ai1[i2] = 1 + Math.min(Math.min(ai1[i2 - 1], ai[i2]), ai[i2 - 1]);
  127.  
  128.             int ai2[] = ai;
  129.             ai = ai1;
  130.             ai1 = ai2;
  131.         }
  132.  
  133.         if(ai[j] <= i)
  134.             return ai[j];
  135.         else
  136.             return -1;
  137.     }
  138.  
  139.     public static int getFuzzyDistance(CharSequence charsequence, CharSequence charsequence1, Locale locale)
  140.     {
  141.         if(charsequence == null || charsequence1 == null)
  142.             throw new IllegalArgumentException("Strings must not be null");
  143.         if(locale == null)
  144.             throw new IllegalArgumentException("Locale must not be null");
  145.         String s = charsequence.toString().toLowerCase(locale);
  146.         String s1 = charsequence1.toString().toLowerCase(locale);
  147.         int i = 0;
  148.         int j = 0;
  149.         int k = 0x80000000;
  150.         for(int l = 0; l < s1.length(); l++)
  151.         {
  152.             char c = s1.charAt(l);
  153.             for(boolean flag = false; j < s.length() && !flag; j++)
  154.             {
  155.                 char c1 = s.charAt(j);
  156.                 if(c != c1)
  157.                     continue;
  158.                 i++;
  159.                 if(k + 1 == j)
  160.                     i += 2;
  161.                 k = j;
  162.                 flag = true;
  163.             }
  164.  
  165.         }
  166.  
  167.         return i;
  168.     }
  169.  
  170.     private static final String FIRST_HINT = "A component of software configuration management, version control, also known as revision control or source control, is the management of changes to documents, computer programs, large web sites, and other collections of information.";
  171.     private static final String SECOND_HINT = "In computing, the diff utility is a data comparison tool that calculates and displays the differences between two files.";
  172.     private static final String THIRD_HINT = "This is a GIT repository you are in!";
  173. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement