Skip to content

Instantly share code, notes, and snippets.

@neelsmith
Last active March 28, 2016 12:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neelsmith/7fc5ae04ae58bcf3ac8a to your computer and use it in GitHub Desktop.
Save neelsmith/7fc5ae04ae58bcf3ac8a to your computer and use it in GitHub Desktop.
Print Shortest Common Supersequence of two strings of 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