Skip to main content
deleted 220 characters in body
Source Link
Jonathan Allan
  • 110.1k
  • 7
  • 65
  • 282

Jelly,  15 18  1816 bytes

+3 bytes to fix bugs in my method.
-2 bytes thanks to miles (noting that n×(n-1)÷2 = nC2)

QL×’$⁼LẎQL©c2⁼Lȧ®
ŒPẎ€ÇÐfṪQLŒPÇ€Ṁ

Try it online!Try it online! forms the power-set of the edges in memory so is inefficient both in space and time (yep,that's O(2n) folks)!

QL×’$⁼LẎQL©c2⁼Lȧ® - Link 1, isClique?: list, flattenedEdgesedges  e.g. [1[[1,33],2[2,33],3[3,44],4[4,11],4[4,22],2[2,1]1]]
          - tighten                         ...from: [[1    [ 1,3]3 ,[2 2,3]3 ,[3 3,4]4 ,[4 4,1]1 ,[4 4,2]2 ,[2 2,1]]1 ]
 Q         - de-duplicate (gets unique ids)                [1,3,2,4]
  L        - length (get number of people involved)  4
   ©   4
    $- (copy to -the lastregister)
 two links as ac2 monad:
    - combinations of 2 (z-choose-2)   decrement       6
       L   - length (of edges)               3
  ×     - 6
  multiply        - equal?                           12
      L -1
 length (of flattenedEdges)      ® - recall value from register         12
     4
  - equal?     ȧ  - logical and                             4
   1
        - (Note: the number of edges of a clique of size n is n*(n-1) and we're
           -  guaranteed no repeated edges and that all edges are two distinct ids)

ŒPẎ€ÇÐfṪQLŒPÇ€Ṁ - Link: list of lists, edges
ŒP         - power-set (all possible sets of edges (as lists))
  Ẏ€       - tighten €ach (flattens each list of edges to a list of the ids)
     Ðf    - filter keep those for which this is truthy:
    Ç    Ç€  -   call last link (1) as a monad
       Ṫ   - tail (get the rightmost, note that ŒP is ordered by length)
        Q  - de-duplicate (get the uniquefor ids)€ach
         L - length (the number of friends in (one of the) largest clique(s))maximum

Jelly,  15  18 bytes

+3 bytes to fix bugs in my method.

QL×’$⁼L
ŒPẎ€ÇÐfṪQL

Try it online! forms the power-set of the edges in memory so is inefficient both in space and time (yep,that's O(2n) folks)!

QL×’$⁼L - Link 1, isClique?: list, flattenedEdges  e.g. [1,3,2,3,3,4,4,1,4,2,2,1]
                                    ...from: [[1,3],[2,3],[3,4],[4,1],[4,2],[2,1]]
Q       - de-duplicate (gets unique ids)                [1,3,2,4]
 L      - length (get number of people involved)        4
    $   - last two links as a monad:
       -   decrement                                   3
  ×     -   multiply                                    12
      L - length (of flattenedEdges)                    12
       - equal?                                        1
        - (Note: the number of edges of a clique of size n is n*(n-1) and we're
        -  guaranteed no repeated edges and that all edges are two distinct ids)

ŒPẎ€ÇÐfṪQL - Link: list of lists, edges
ŒP         - power-set (all possible sets of edges (as lists))
  Ẏ€       - tighten €ach (flattens each list of edges to a list of the ids)
     Ðf    - filter keep those for which this is truthy:
    Ç      -   call last link (1) as a monad
       Ṫ   - tail (get the rightmost, note that ŒP is ordered by length)
        Q  - de-duplicate (get the unique ids)
         L - length (the number of friends in (one of the) largest clique(s))

Jelly,  15 18  16 bytes

+3 bytes to fix bugs in my method.
-2 bytes thanks to miles (noting that n×(n-1)÷2 = nC2)

ẎQL©c2⁼Lȧ®
ŒPÇ€Ṁ

Try it online! forms the power-set of the edges in memory so is inefficient both in space and time (yep,that's O(2n) folks)!

ẎQL©c2⁼Lȧ® - Link 1, isClique?: list, edges  e.g. [[1,3],[2,3],[3,4],[4,1],[4,2],[2,1]]
          - tighten                              [ 1,3 , 2,3 , 3,4 , 4,1 , 4,2 , 2,1 ]
 Q         - de-duplicate (gets unique ids)          [1,3,2,4]
  L        - length (get number of people involved)  4
   ©       - (copy to the register)
    c2     - combinations of 2 (z-choose-2)          6
       L   - length (of edges)                       6
          - equal?                                  1
         ® - recall value from register              4
        ȧ  - logical and                             4
           - (Note: the number of edges of a clique of size n is n*(n-1) and we're
           -  guaranteed no repeated edges and that all edges are two distinct ids)

ŒPÇ€Ṁ - Link: list of lists, edges
ŒP    - power-set (all possible sets of edges (as lists))
  Ç€  - call last link (1) as a monad for €ach
     - maximum
added 1 character in body
Source Link
Jonathan Allan
  • 110.1k
  • 7
  • 65
  • 282

How?

QL×’$⁼L - Link 1, isClique?: list, flattenedEdges  e.g. [1,3,2,3,3,4,4,1,4,2,2,1]
                                    ...from: [[1,3],[2,3],[3,4],[4,1],[4,2],[2,1]]
Q       - de-duplicate (gets unique ids)                [1,3,2,4]
 L      - length (get number of people involved)        4
    $   - last two links as a monad:
   ’    -   decrement                                   3
  ×     -   multiply                                    12
      L - length (of flattenedEdges)                    12
     ⁼  - equal?                                        1
        - (Note: the number of edges of a clique of size n is n*(n-1) and we're
        -  guaranteed no repeated edges and that all edges are two distinct ids)

ŒPẎ€ÇÐfṪQL - Link: list of lists, edges
ŒP         - power-set (all possible sets of edges (as lists))
  Ẏ€       - tighten €ach (flattens each list of edges to a list of the ids)
     Ðf    - filter keep those for which this is truthy:
    Ç      -   call last link (1) as a monad
       Ṫ   - tail (get the rightmost, note that ŒP is ordered by length)
        Q  - de-duplicate (get the unique ids)
         L - length (the number of friends in (one of the) largest clique(s))

How?

QL×’$⁼L - Link 1, isClique?: list, flattenedEdges  e.g. [1,3,2,3,3,4,4,1,4,2,2,1]
                                    ...from: [[1,3],[2,3],[3,4],[4,1],[4,2],[2,1]]
Q       - de-duplicate (gets unique ids)                [1,3,2,4]
 L      - length (get number of people involved)        4
    $   - last two links as a monad:
   ’    -   decrement                                   3
  ×     -   multiply                                    12
      L - length (of flattenedEdges)                    12
     ⁼  - equal?                                        1
        - (Note: the number of edges of a clique of size n is n*(n-1) and we're
        -  guaranteed no repeated edges and that all edges are two distinct ids)

ŒPẎ€ÇÐfṪQL - Link: list of lists, edges
ŒP         - power-set (all possible sets of edges (as lists))
  Ẏ€       - tighten €ach (flattens each list of edges to a list of the ids)
     Ðf    - filter keep those for which this is truthy:
    Ç      -   call last link (1) as a monad
       Ṫ   - tail (get the rightmost, note that ŒP is ordered by length)
        Q  - de-duplicate (get the unique ids)
         L - length (the number of friends in (one of the) largest clique(s))
Post Undeleted by Jonathan Allan
added 1 character in body
Source Link
Jonathan Allan
  • 110.1k
  • 7
  • 65
  • 282

Jelly, 15 15  18 bytes

deleting while I think about salvaging from buggy test +3 bytes to fix bugs in my method.

FĠL€QLỊQL×’$⁼L
ŒPÇÐfṪLŒPẎ€ÇÐfṪQL

A monadic link taking the list of friendships (edges) and returning an integer.

Try it online! forms the power-set of the edges in memory so is inefficient both in space and time (yep,that's O(2n) folks)!

Jelly, 15 bytes

deleting while I think about salvaging from buggy test

FĠL€QLỊ
ŒPÇÐfṪL

A monadic link taking the list of friendships (edges) and returning an integer.

Try it online! forms the power-set of the edges in memory so is inefficient both in space and time (yep,that's O(2n) folks)!

Jelly,  15  18 bytes

+3 bytes to fix bugs in my method.

QL×’$⁼L
ŒPẎ€ÇÐfṪQL

A monadic link taking the list of friendships (edges) and returning an integer.

Try it online! forms the power-set of the edges in memory so is inefficient both in space and time (yep,that's O(2n) folks)!

Post Deleted by Jonathan Allan
added 64 characters in body
Source Link
Jonathan Allan
  • 110.1k
  • 7
  • 65
  • 282
Loading
Source Link
Jonathan Allan
  • 110.1k
  • 7
  • 65
  • 282
Loading