calcItti <- function( a, b ){
if( length( a ) > 0 ){
if( is.element( a[1], b ) ){
itti <<- itti + 1
b <- b[ -( ( which( b == a[1] ) )[1] ) ]
}
a <- a[-1]
Recall( a, b )
}
}
func <- function( a, b ){
itti <<- 0
calcItti( a, b )
return( itti == 2 )
}
cat( "[1,2,3], [5,6,7] -> " )
func( c( 1,2,3 ), c( 5,6,7 ) ) # FALSE
cat( "[1,1,1], [1,1,2] -> " )
func( c( 1,1,1 ), c( 1,1,2 ) ) # TRUE
cat( "[1,1,2], [2,2,1] -> " )
func( c( 1,1,2 ), c( 2,2,1 ) ) # TRUE
cat( "[9,8,9], [8,6,4] -> " )
func( c( 9,8,9 ), c( 8,6,4 ) ) # FALSE
cat( "[9,7,2], [2,2,9] -> " )
func( c( 9,7,2 ), c( 2,2,9 ) ) # TRUE
Y2FsY0l0dGkgPC0gZnVuY3Rpb24oIGEsIGIgKXsKCWlmKCBsZW5ndGgoIGEgKSA+IDAgKXsKCQlpZiggaXMuZWxlbWVudCggYVsxXSwgYiApICl7CgkJCWl0dGkgPDwtIGl0dGkgKyAxCgkJCWIgPC0gYlsgLSggKCB3aGljaCggYiA9PSBhWzFdICkgKVsxXSApIF0KCQl9CgkJYSA8LSBhWy0xXQoJCVJlY2FsbCggYSwgYiApCgl9Cn0KCmZ1bmMgPC0gZnVuY3Rpb24oIGEsIGIgKXsKCWl0dGkgPDwtIDAKCWNhbGNJdHRpKCBhLCBiICkKCXJldHVybiggaXR0aSA9PSAyICkKfQoKY2F0KCAiWzEsMiwzXSwgWzUsNiw3XSAtPiAiICkKZnVuYyggYyggMSwyLDMgKSwgYyggNSw2LDcgKSApICMgRkFMU0UKCmNhdCggIlsxLDEsMV0sIFsxLDEsMl0gLT4gIiApCmZ1bmMoIGMoIDEsMSwxICksIGMoIDEsMSwyICkgKSAjIFRSVUUKCmNhdCggIlsxLDEsMl0sIFsyLDIsMV0gLT4gIiApCmZ1bmMoIGMoIDEsMSwyICksIGMoIDIsMiwxICkgKSAj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