Last active
March 28, 2016 12:13
-
-
Save neelsmith/7fc5ae04ae58bcf3ac8a to your computer and use it in GitHub Desktop.
Print Shortest Common Supersequence of two strings of characters
This file contains 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
/* Compute Shortest Common Supersequence of two strings of characters, | |
* and print it to stanard output. | |
* | |
* Example: | |
* | |
* groovy scs.groovy 'Dr Rock-and-Roll Star' 'Doctor Rock Star' | |
* | |
* prints | |
* | |
* Doctor Rock-and-Roll Star | |
* | |
*/ | |
@GrabResolver(name='beta', root='http://beta.hpcc.uh.edu/nexus/content/repositories/releases') | |
@Grab(group='edu.holycross.shot', module='listutils', version='1.1.0') | |
import edu.holycross.shot.listutils.ListDiff | |
String usage = "Usage: groovy scs.groovy STRING1 STRING2" | |
if (args.size() != 2) { | |
System.err.println usage | |
System.exit(-1) | |
} | |
ListDiff ldiff = new ListDiff(args[0],args[1]) | |
println ldiff.scs.join("") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment