Skip to content

Instantly share code, notes, and snippets.

@henryhamon
Created January 24, 2022 23:35
Show Gist options
  • Save henryhamon/c071471722b876f56d5d8cb58ced4fd1 to your computer and use it in GitHub Desktop.
Save henryhamon/c071471722b876f56d5d8cb58ced4fd1 to your computer and use it in GitHub Desktop.
Code Golf: Only Paired Opposites
Class CodeGolf.PairedOpposites
{
ClassMethod Solve(opposites As %String) As %Integer
{
Quit ""
}
}
Class CodeGolf.Test.PairedOpposites Extends %UnitTest.TestCase
{
Method TestBasic()
{
Do $$$AssertEquals(##class(CodeGolf.PairedOpposites).Solve("1,-1,2,-2,3"), 3)
Do $$$AssertEquals(##class(CodeGolf.PairedOpposites).Solve("-3,1,2,3,-1,-4,-2"), -4)
Do $$$AssertEquals(##class(CodeGolf.PairedOpposites).Solve("1,-1,2,-2,3,3"), 3)
Do $$$AssertEquals(##class(CodeGolf.PairedOpposites).Solve("-110,110,-38,-38,-62,62,-38,-38,-38"), -38)
Do $$$AssertEquals(##class(CodeGolf.PairedOpposites).Solve("-9,-105,-9,-9,-9,-9,105"), -9)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment