Skip to main content
only improved the Try all test cases online
Source Link
manatwork
  • 20.7k
  • 5
  • 51
  • 81

jq, 30 characters

group_by(.)|map(length==2)|all

Sample run:

bash-5.0$ jq 'group_by(.)|map(length==2)|all' <<< '[7,13,9,2,10,2,4,10,7,13,4,9]'
true

Try it online!

Try all test cases online!Try all test cases online!

jq, 30 characters

group_by(.)|map(length==2)|all

Sample run:

bash-5.0$ jq 'group_by(.)|map(length==2)|all' <<< '[7,13,9,2,10,2,4,10,7,13,4,9]'
true

Try it online!

Try all test cases online!

jq, 30 characters

group_by(.)|map(length==2)|all

Sample run:

bash-5.0$ jq 'group_by(.)|map(length==2)|all' <<< '[7,13,9,2,10,2,4,10,7,13,4,9]'
true

Try it online!

Try all test cases online!

Source Link
manatwork
  • 20.7k
  • 5
  • 51
  • 81

jq, 30 characters

group_by(.)|map(length==2)|all

Sample run:

bash-5.0$ jq 'group_by(.)|map(length==2)|all' <<< '[7,13,9,2,10,2,4,10,7,13,4,9]'
true

Try it online!

Try all test cases online!