Skip to main content
added 126 characters in body
Source Link
Expired Data
  • 4k
  • 1
  • 11
  • 34

VDM-SL[VDM-SL], 64 bytes

f(a)==forall y in set inds a&card{x|x in set inds a&a(x)=a(y)}=2

###Explanation

VDM works predominantly like second order logic statements.

forall y in set inds a                //Bind y to each of the indices of a
       
{x|x in set inds a&a(x)=a(y)}         //build a set of the indices of a who have the same
                                      //value as the value at y

card {...} = 2                        //and check the cardinality of that set is 2

###Since you can't TIO VDM here's output from a debug session

[VDM-SL]: https://raw.githubusercontent.com/overturetool/documentation/master/documentation/VDM10LangMan/VDM10_lang_man.pdf

VDM-SL, 64 bytes

f(a)==forall y in set inds a&card{x|x in set inds a&a(x)=a(y)}=2

[VDM-SL], 64 bytes

f(a)==forall y in set inds a&card{x|x in set inds a&a(x)=a(y)}=2

###Explanation

VDM works predominantly like second order logic statements.

forall y in set inds a                //Bind y to each of the indices of a
       
{x|x in set inds a&a(x)=a(y)}         //build a set of the indices of a who have the same
                                      //value as the value at y

card {...} = 2                        //and check the cardinality of that set is 2

###Since you can't TIO VDM here's output from a debug session

[VDM-SL]: https://raw.githubusercontent.com/overturetool/documentation/master/documentation/VDM10LangMan/VDM10_lang_man.pdf

deleted 131 characters in body
Source Link
Expired Data
  • 4k
  • 1
  • 11
  • 34

VDM-SL, 7764 bytes

f(a)=={card==forall x|xy in set power inds a&card x>1 and card{a(z)|zx|x in set inds a&a(x}=1}={2)=a(y)}=2

Works by calculating the set of all counts of elements, and checking that that set is exactly the set containing 2

VDM-SL, 77 bytes

f(a)=={card x|x in set power inds a&card x>1 and card{a(z)|z in set x}=1}={2}

Works by calculating the set of all counts of elements, and checking that that set is exactly the set containing 2

VDM-SL, 64 bytes

f(a)==forall y in set inds a&card{x|x in set inds a&a(x)=a(y)}=2
Source Link
Expired Data
  • 4k
  • 1
  • 11
  • 34

VDM-SL, 77 bytes

f(a)=={card x|x in set power inds a&card x>1 and card{a(z)|z in set x}=1}={2}

Works by calculating the set of all counts of elements, and checking that that set is exactly the set containing 2