fork download
  1. function twoLines(l1o,l2o) {
  2. // a -- b c -- d
  3. let r = 0
  4. for(let l1=1;l1<=l1o;l1++) {
  5. let l2 = (l1o + l2o - l1)
  6. for(let a=0;a<10-l2-1;a++) {
  7. /*let b = a + l1
  8.   console.log(b)
  9.   for (let c=b + 1;c <= (10 - l2);c++) {
  10.   let d = c + l2
  11.   console.log(`${a}--${b} (${b-a}) ${c}--${d} (${d - c})`)
  12.   r++
  13.   }*/
  14. r += (10 - l2) - (a + l1 + 1) + 1
  15. }
  16. }
  17. return r
  18. }
  19. let r = twoLines(2,2)
  20. console.log(`${r} перестановок`)
Success #stdin #stdout 0.02s 16840KB
stdin
Standard input is empty
stdout
42 перестановок