text:
ASCII Airplane Banner
Given two inputs -- one of them a non-empty printable ASCII string (including space, excluding newline), the other being one of two distinct, consistent values of your choice (1 / 0, l / r, left / right, etc.) -- output an ASCII art airplane banner of the string, pointing either left or right. For consistency, I'll be using left and right throughout this challenge description.
The plane is either |-DI>-/ (left) or \-<ID-| (right). Since the banner is clear, it consists of the input string's characters separated by spaces, either left-to-right (left) or right-to-left (right), and surrounded by a box of the shape
    /--/
---<  <
    \--\

or
\--\
 >  >---
/--/

Note there must be one space between the beginning/end of the message and the >,< characters.
For example, here is the message HAPPY BIRTHDAY! and the direction left:
           /-------------------------------/
|-DI>-/---< H A P P Y   B I R T H D A Y ! <
           \-------------------------------\

Here is the message PPCG and the direction right. Note that the letters appear "backwards" when viewed from this side of the banner:
\---------\
 > G C P P >---\-<ID-|
/---------/

Rules

Leading or trailing newlines or whitespace are all optional, so long as the characters themselves line up correctly.
Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
If possible, please include a link to an online testing environment so other people can try out your code!
Standard loopholes are forbidden.
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

Slightly related.

JavaScript, 4 bytes: eval - Input a program that generates a left-facing plane for left, and a program that generates a right-facing plane for right.

Perl 5, 149 102 + 4 (-plF ) = 150 106 bytes
Shortened using tricks I've learned since the original answer.  Still scored using the rules in effect at the time of the question.
s/./--/g;$_=$"x11 ."/-$_/";$_.="
|-DI>-/---< @F <
".y|\\/|/\\|r;if(<>){y|<>|><|;$_=reverse;s|-/|-\\|}

Try it online!
Two line input. First is the message.  Second is 0 for left, 1 for right.

JavaScript (ES6), 141 138 bytes
String and direction are input via currying syntax.'/\n|-DI>-/---< ' for left, '/\n|-DI<-\\---> ' for right.
t=>p=>(r=`${s='           '}/${_='-'.repeat(t.length*2+1)}${p}${[...t].join` `} ${d=p[12]}
${s}\\${_}\\`,d>'<'?[...r].reverse().join``:r)

f=

t=>p=>(r=`${s='           '}/${_='-'.repeat(t.length*2+1)}${p}${[...t].join` `} ${d=p[12]}
${s}\\${_}\\`,d>'<'?[...r].reverse().join``:r)

console.log(f('HAPPY BIRTHDAY!')('/\n|-DI>-/---< '))
console.log(f('HAPPY BIRTHDAY!')('/\n|-DI<-\\---> '))

Ha, hard coding a section of the output seems like an exploitation of a loophole, but it seems fine based on the challenge as written.  Clever!

@RickHitchcock The ultimate loophole is eval... just provide left and right function sources as your two values of your choice. (I thought there was a meta on this but I can't find it.)

@Neil The eval "trick" would be this loophole in spirit, even if not explicitly stated. This answer here is kinda clever, though.

Yeah, I was debating whether to post eval as a serious answer. A workaround for future challenges like this might be to include inputs as part of the byte count.

V, 73, 65 bytes
Ó./&
É ÄÒ-ys$/YGpr\$.11>Hj|R|-DI>-/³-<A< ÀñkæG|æ}-r>$BR>³-\-<

Try it online!
Not the greatest score, but that's because almost half of this comes from reversing the output.
Hexdump:
00000000: d32e 2f26 200a c920 c4d2 2d79 7324 2f59  ../& .. ..-ys$/Y
00000010: 4770 725c 242e 3131 3e48 6a7c 527c 2d44  Gpr\$.11>Hj|R|-D
00000020: 493e 2d2f b32d 3c1b 413c 201b c0f1 6be6  I>-/.-<.A< ...k.
00000030: 477c e616 7d2d 723e 2442 523e b32d 5c2d  G|..}-r>$BR>.-\-
00000040: 3c                                       <

Takes the string as input to the buffer, and the direction as 0 for left and 1 for right as command line arguments.

05AB1E, 63 bytes
„\\S'-¹g·>×ýD∞2äθ‚11ú"|-DI>-/---<"¸¹ε²i∞θ}J'<«S«ð«J¸«Àε²i∞2äθ}»

Try it online!
Based off bugs that may get fixed in the future.

@MagicOctopusUrn possibly

@MagicOctopusUrn actually no it won't work like that...

@MagicOctopusUrn Try to change the 0 on the second line to a 1.

Ah, the leading space...

Charcoal, 44 40 39 35 bytes
|-DI>-/³↗<→/-ＬηＬη↙¹←< ¿Ｎ↷⁴‖Ｔ⮌⪫η ‖Ｂ↓

Try it online! Link is to verbose version of code. First input is 1 for right and 0 for left, second is banner string. Edit: Saved 1 byte by using ReflectButterfly(:Up) as ReflectButterfly(:Down) currently has a cursor positioning bug, but I saved a further 4 bytes by reversing the print direction, and now it doesn't matter which I use. 38 34 32 byte version if mirroring the banner was allowed:
|-DI>-/³Ｐ⪫⪫<<η ↘→\-ＬηＬη↖¹‖Ｂ↑¿Ｎ‖Ｔ

Try it online! Link is to verbose version of code. First input is 0 for right and 1 for left. Explanation:
|-DI>-/

Print the plane.
³↗<→/-ＬηＬη↙¹←<

Print the top half of the box (note trailing space).
¿Ｎ↷⁴‖Ｔ

If the second input is nonzero, reverse the print direction, otherwise reflect the plane and box.
⮌⪫η

Print the message with extra spacing (note trailing space). The cursor is at the far end of the box from the plane so the message needs to be reversed.
‖Ｂ↓

Reflect to get the bottom half of the box.

Verbose version seems to have issues.

@EriktheOutgolfer Deverbosifier was broken recently; TIO doesn't seem to have the fix yet.

Jelly, 68 65 bytes
“/\<“\/>”y
³K“|-DI>-/---< “ < ”j
LḤ‘”-x⁾//jṭ⁶x11¤Fµ,Ñj¢œs3U⁴¡YÑ⁴¡

Try it online!
Takes 1 for right, 0 for left.
-3 bytes thanks to @JonathanAllan (grr I always forget AB+ does the same as B+@A)

³K“|-DI>-/---< “ < ”j saves a byte; LḤ‘”-x⁾//jṭ⁶x11¤Fµ,Ñj¢œs3U⁴¡YÑ⁴¡ saves another 2 in the same fashion.

SOGL V0.12, 55 47 43 bytes
└"┐ξA∫`Ν┌r4≥‘┘¹§,{e⌡↔@¹"╝′‰‘┼}"-<-/ \”┼e?±↔

Try it Here!
0 for left and 1 for right

Charcoal, 56 bytes
 -8 bytes thanks to totallyhuman and Erik the Outgolfer!
≔⪫Ｓ θ≔⁺Ｌθ²η× ¹¹/η/⸿|-DI>-/³<× η<‖Ｂ↓ＦＮ«‖ＴＭ⁺η³→≔⮌θθ»↑↑Ｍη←θ

Try it online!
Fixing the cases dzaima mentioned took quite a toll on the byte count. 36 bytes if we are allowed to reverse characters like < and /.

In python, ' '.join(s) works. Surely that can be used in Charcoal?

@totallyhuman Join works on strings too.

Umm, I think it was totallyhuman who actually suggested that.

@EriktheOutgolfer Oh, I misinterpreted @totallyhuman's suggestion as making a call to Python's ' '.join in Charcoal. I'll credit both of you.

You've broken the ast processor...

Python 2, 137 136 133 bytes
lambda s,d:'{0}/{1}-/\n|-DI{3}-{4}---{5} {2} {5} \n{0}\\-{1}\\'.format(' '*11,'--'*len(s),' '.join(s),*list('></\\<>')[d::2])[::-d|1]

Try it online!
1 for right and 0 for left

135 bytes (-1 byte) by replacing 1-2*d with -d|1 (negate d xor 1).

Typo, it's not xor, it's bitwise or, in fact.

134 bytes with a little trick: *list('></\\<>')[d::2]

PHP, 175 bytes
[,$d,$s]=$argv;$f=str_repeat("--",strlen($s));$r="\-$f\
 ".join(" ",str_split("><"[$d].$s)).($d?" <---/->":" >---\-<")."ID-|
/-$f/           ";echo$d?strrev($r):$r;

Run with -nr, first argument = 0 for facing right or 1 for left and second argument=text
or try it online.

Corea, 51 bytes
"u *:>ip.j:l)X-'/S:>"
|-DI>-/---< V<
"h}>>`tHL`idF

Try it online!
Explanation
The program is composed of a few parts:
1: Initialization
"u *:>ip.j:l)X-'/S:>"
"..................."   execute the inside as code
 u                      repeat
   *                    a space, 11 times
    :                   duplicate this string
     >                  write this string to the content field
      i                 take a line of input
       p                push a space
        .j              insert that space after every character
          :l)           get (length(str) + 1)
             X-         repeat a hyphen that many times
               '/       push the "/" character
                 S      surround that string with the above character
                  :>    duplicate and write that string to the content field

2: raw text
The following text is outputted to the content field:
|-DI>-/---< V<

3: postamble
"h}>>`tHL`idF
"               execute until the end of the file
 h              mirror the previous string horizontally
  }             move the modified input string to the front of the stack
   >>           write the top two strings to the content field
     `   `id    do the inside `i`nput times
      tH        reflect the content field horizontally and vertically
        L       reverse the input string
            F   save the input string in a field (default: V)
                this replaces all Vs in the code with the input string

Perl 5, 126 bytes
124 bytes code + 2 for -pl.
s/./$& /g;$_=($q=$"x11 .'/-'.s/./-/gr."/
")."|-DI>-/---< $_<
".$q=~y|\\/|/\\|r;<>&&(y|<>|><|,$_=reverse,s/>/ >/,s|-/-|-\\-|)

Try it online!

Google Sheets, 210 Bytes
Anonymous worksheet function that takes input input as string from [A1] and int from range [B1] where 1 indicates that the plane is on the left and 0 indicates that the plane is on the right.
=If(B1,"           /","\")&Rept("-",2*Len(A1)+1)&If(B1,"/
","\
")&If(B1,"|-DI>-/---< "," > ")&RegexReplace(A1,"(.)","$1 ")&If(B1,"<
",">---\-<ID-|
")&If(B1,"           \","/")&Rept("-",2*Len(A1)+1)&If(B1,"\","/

Excel VBA, 198 Bytes
Anonymous VBE immediate window function that takes input as string from [A1] and int from range [B1] where 1 indicates that the plane is on the left and 0 indicates that the plane is on the right.
b=[B1]:a=StrConv(IIf(b,[A1],StrReverse([A1])),64):j=[Rept("-",2*Len(A1)+1)]:k="/"&j &"/":l="\"&j &"\":s=Space(11):?IIf(b,s &k,l):?IIf(b,"|-DI>-/---< "," > ")a;IIf(b,"<",">---\-<ID-|"):?IIf(b,s &l,k)

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Array Factorization
Given an array of positive integers, output a stable array of the distinct prime factors of these integers. In other words, for each integer in the input in order, get its prime factors, sort them, and append any primes not already in the output to the output.
Test Cases
[1,2,3,4,5,6,7,8,9,10] -> [2,3,5,7]
[10,9,8,7,6,5,4,3,2,1] -> [2,5,3,7]
[100,99,98,1,2,3,4,5] -> [2,5,3,11,7]
[541,60,19,17,22] -> [541,2,3,5,19,17,11]
[1,1,2,3,5,8,13,21,34,45] -> [2,3,5,13,7,17]
[6,7,6,7,6,7,6,5] -> [2,3,7,5]
[1] -> []
[8] -> [2]
[] -> []

Output can be as an array or list of integers or strings, delimited output, or any other standard means of outputting an ordered list of numbers.
This is code-golf, so shortest answer in bytes wins.

Sandbox

This is one of those challenges that I think is “too simple”. Almost every answer is gonna look like one of these: (a) a loop over the input, and Ye Olde Prime Factorization Code with a conditional append; (b) a chain of four built-ins. There just isn’t much room for creativity. Maybe the answers will prove me wrong, but I doubt it. There’s very little more to golf than prime factorization here, and that’s been done to death.

@Lynn it's trivial for golfing langs, but non-trivial for nearly everything else. Not sure if that's grounds for triviality here :/

Can you tell me which are "the distinct prime factors" of 1?

@Jenny_mathy there are none, therefore [1] -> [] - 1 is not prime.

Can we output as a list of strings (i.e.: ['2', '3', '5', '13', '7', '17'])?

@Mr.Xcoder Output can be as an array or list of integers or strings

Does the output list order matter?

@DigitalTrauma Yes. Otherwise it would just be "output the set of all prime factors of the input"

05AB1E, 3 bytes
Outputs as a list of Strings.
f˜Ù

Try it online!
2sable, 3 bytes
Yes, this also works in 2sable. Also returns a list of Strings.
f˜Ù

Try it online!

Hah... f U. Love it.

@MagicOctopusUrn Thanks :-)

Husk, 3 bytes
1 byte saved thanks to @Zgarb.
uṁp

Try it online!

Explanation

uṁp    Full program.

  p    Prime factors of each.
 ṁ     Map function over list and concatentate the result.
u      Unique.

Σ† can be ṁ.

@Zgarb Thanks a lot. As you can tell, it's my first Husk answer ever :)

It's nice to see new people using Husk. :)

@Zgarb It seems very nice (especially when it outgolfs Jelly :P)

Bash + GNU utilities, 37

21 bytes saved thanks to @muru (wow!)

factor|tr \  \\n|awk '!/:/&&!a[$0]++'

Try it online.

I think the nl|sort|... can be done using awk: awk '!a[$0]++' (print if not seen before; so order is never lost), saving 15 bytes. Then the sed command can be eliminated using a slightly longer awk one: factor|awk '!/:/&&!a[$0]++' RS='[ \n]+' (split records on spaces and newlines, skip records with :), saving another 4 bytes.

I just realised I can save another two bytes on the previous comment by using tr: factor|tr \  \\n|awk '!/:/&&!a[$0]++' (that's two spaces after the first backslash)

@muru awesome - thanks! (I wouldn't have been upset if you'd posted this as your own answer, that significantly out-golfed my original)

Pyth, 5 4 bytes
{smP

Try it here! or Verify all test cases.
Alternative: {sPM

Explanation

{smP      Full program with implicit input (Q).
  m       Map over the input.
   P      Prime factors.
 s        Flatten.
{         Deduplicate.

MATL, 6 bytes
"@Yfvu

Try it online!
Explanation:
"      % Loop over input
 @     % Push the array element
  Yf   % Prime factors
    v  % Concatenate entire stack vertically (does nothing the first iteration)
     u % Stably get distinct (unique, in MATLAB terminology) elements. Does so every loop but this is code golf, not fastest code.

Interesting MATL tidbits: generally, all functions apply to vectors (arrays) just as easily. But in this case, the number of factors is variable for each input, and Matlab and by extension MATL generally only deal in square matrices, so I had to use a for loop ".
Furthermore, MATL has two main concatenation operators: h and v, horizontal and vertical concatenation. Their behaviour differs significantly: v concatenates the entire stack, even if it has only one element like in our first iteration. h takes exactly two elements and will fail if only one is present, making it unsuitable for this application.

Brachylog, 6 bytes
ḋᵐ↔ᵐcd

Try it online!
Brachylog, 6 bytes
ḋᵐoᵐcd

Try it online!

Explanation

ḋᵐ       Map  with prime decomposition (which returns the factors in reverse order).
  ↔ᵐ     Reverse each (or oᵐ - order each).
    c    Concatenate (flatten).
     d   Deduplicate.

Jelly, 5 4 bytes
1 byte thanks to clap.
ÆfFQ

Try it online!

Not surprised .

Don't think you need to force vectorization on Æf, so you can probably drop a byte with ÆfFQ

@clap I'm an idiot...

PowerShell, 102 bytes
param($x)$a=@();$x|%{$a+=(2..($z=$_)|?{!($z%$_)-and'1'*$_-match'^(?!(..+)\1+$)..'}|sort)};$a|select -u

Try it online!
(Borrows factorization idea from TessellatingHeckler's answer over on "Get thee behind me Satan-Prime!")
Takes input as a literal array $x. Creates a new empty array $a. Loops over $x. Each iteration we loop from 2 up to the current number, checking whether that is a factor -and is prime, then |sort the output of that, and append it to $a. When we're done going through $x, we then output $a but |select only the -unique numbers thereof. This exploits the fact that the uniqueify goes left-to-right, keeping the first occurrence, which matches the problem description. Those numbers are left on the pipeline and output is implicit.

CJam, 11 bytes
{:mfe__&1-}

Function that takes array of ints and outputs array of ints.
Test Version

How would I differentiate output with multiple characters? At least for my (online) testing it outputs a string, not an array of ints.

As a function, it's output datatype is an array of ints. CJam automatically prints ths stack, and it prints arrays w/o delimters. I don't know if that's good enough for your purposes. If you want delimeters add S* inside the close bracket.

I believe stack-based langs can output by ToS anyway, so it's fine, I was just wondering. Thanks.

Gaia, 4 bytes
ḍ¦_u

Try it online!

Explanation

ḍ¦      Prime factors of each.
  _     Flatten the list.
   u    Remove duplicate elements.

Pyke, 4 bytes
MPs}

Try it here!

Explanation
MP       Prime factors of each.
  s      Flatten.
   }     Deduplicate.

Mathematica, 64 bytes
Select[DeleteDuplicates[First/@FactorInteger@#~Flatten~1],#>1&]&

input

[{100, 99, 98, 1, 2, 3, 4, 5}]

Select[#&@@@Gather[#&@@@Join@@FactorInteger@#],#>1&]&

Japt, 6 bytes
mk c â

Test it

Explanation
Implicit input of array U. Map (m) over it, getting the factors (k) of each element. Flatten (c), get the unique elements (â) and implicitly output.

Haskell, 77 bytes
import Data.List
x!y|y>x=[]|x`mod`y<1=y:(x`div`y)!y|1<2=x!(y+1)
nub.((!2)=<<)

Explanation:

the x!y operator returns a list of all prime factors of x that are greater than or equal to y
the (!2) function returns a list of all prime factors of its argument
the function on the last line implements the required functionality

Try it online.

Brachylog, 6 bytes
ḋᵐoᵐcd

Try it online!
Explanation
ḋᵐ         Map prime decomposition
  oᵐ       Map order
    c      Concatenate
     d     Remove duplicates

Fais for [10,9,8,7,6,5,4,3,2,1]. It should be [2, 5, 3, 7], not [2, 3, 5, 7]

You can fix that for +1 byte: ḋᵐoᵐcd

@Mr.Xcoder Thanks, fixed. Pretty non-sensical requirement imo though.

It's not really non-sensical, as it is a tiny, tiny bit less trivial. I posted my own answer too, but I used reversed first instead of order. Not sure why the prime factors are generated in reverse order?

@Fatalize well - the challenge is not "sorted distinct prime factors of the list," it's "iterate through the list and append distinct prime factors."

Ohm v2, 3 bytes
Yet another 3-byter (thanks to languages with auto-vectorization).
m{U

Try it online!

Explanation

m      Prime factors. Auto-vectorizes over the input.
 {     Flatten.
  U    Uniquify.

Python 3, 128 125 116 bytes
This is a pure Python solution. No packages. Thanks to Halvard for saving 9 bytes.
def f(l):y=[k for i in l for k in range(2,i+1)if i%k<1*all(k%x for x in range(2,k))];print(sorted({*y},key=y.index))

Try it online!
Python 2, 133 127 126 bytes
def f(l):y=sum([[k for k in range(2,i+1)if i%k<1*all(k%x for x in range(2,k))]for i in l],[]);print sorted(set(y),key=y.index)

Try it online!
Python 2, 142 138 134 bytes
l=input();r=[]
for i in sum([[k for k in range(2,i+1)if i%k<1*all(k%x for x in range(2,k))]for i in l],[]):r+=[i]*(i not in r)
print r

Try it online!
Very surprised there was no Python answer yet. Working on golfing.

116 bytes Python 3

@HalvardHummel Thanks

Deorst, 16 bytes
EDkE]EQFPkl1FeE_

Try it online!
Done with help from @Mr.Xcoder. This is way too long for a pseudogolfing language.
How it works
EDkE]EQFPkl1FeE_ - Full program, implicit input: [1,2,3,4,5]

ED               - Get divisors. Vectorizes. STACK = [[1], [1,2], [1,3], [1,2,4], [1,5]]
  k              - Turn off sorting for the next command
   E]            - Flatten the stack. STACK = [1, 1, 2, 1, 3, 1, 2, 4, 1, 5]
     EQ          - Deduplicate stack in place. STACK = [1, 2, 3, 4, 5]
       FP        - Filter by primality 1 is considered prime. STACK = [1, 2, 3, 5]
         k       - Turn off sorting for the next command
          l1     - Push 1. STACK = [1, 2, 3, 5, 1]
            Fe   - Filter elements that are equal to the last element. STACK = [2, 3, 5]
              E_ - Output the whole stack

Deorst, 16 bytes
EDkE]l1FeFPkEQE_

Try it online!
Done with help from @cairdcoinheringaahing in the Deorst chatroom (note that the solutions are different).

Explanation

EDkE]l1FeFPkEQE_   Full program.

ED                 Push the list of divisors of each element.
  k                Prevent the stack from reordering.
   E]              Flatten the stack.
     l1Fe          Remove 1s from the stack (because caird rushed and made 1 prime!) - Should be removed in future language releases.
         FP        Keep the primes.
           k       Prevent the stack from reordering.
            EQ     Deduplicate.
              E_   Output the result.

Vyxal, 3 bytes
ǐfU

Try it Online!
ǐ   # prime factors
 f  # flattened
  U # uniquified

Ruby -rprime, 50 bytes
->x,*r{x.map{_1.prime_division.map{|b,|r|=[b]}};r}

Attempt This Online!

Pyke, 4 bytes
mPs}

Try it here!
mP   -   map(factorise, input)
  s  -  sum(^)
   } - uniquify(^)

Ouch, I ninja'd you badly - Good we have different approaches :)

:P One byte difference. I think it's allowed though or at least according to the last consensus I read

Yes, duplicate answers, even byte-to-byte are allowed

Octave, 61 bytes
a=input('');b=[];for c=a(a>1)b=[b setdiff(factor(c),b)];end;b

Try it online!

MY, 17 bytes
⎕Ḋḟ’⊢f(‘53ǵ'ƒf(ū←

Try it online!
How?

⎕ evaluated input
Ḋ divisors (vectorizes/vecifies)
ḟ flatten
’⊢f(‘ decrement, filter, increment (removes 1)
53ǵ' the string 'P' in MY's codepage, which is primality testing. Sadly 0x35=53 is the 16th prime number, and there's not a command for pushing 16 to the stack >_< .
ƒ as a function
f( filter by that
ū uniquify
← output

C++, 118 bytes
[](auto n){decltype(n)r;for(int m:n)for(int i=1,j;i++<m;){j=m%i;for(int x:r)j|=!(i%x);if(!j)r.push_back(i);}return r;}

Needs to be passed the input in a std::vector<int>, returns another std::vector<int> for output.

J, 10 bytes
~.(#~*),q:

I'm sure some clever J-er could make this shorter.

Python 2, 88 119 103 bytes
Here we go. With the correct sorting.
def f(l,s=[]):[s.append(x) for x in sum([list(primefac(i)) for i in l],[]) if x not in s];print s
from primefac import*

Apperently I can't get it to work on TIO, because the package is not supported. It does run on my machine tho. Here are my Test outputs:
f([1,2,3,4,5,6,7,8,9,10],[])     #[2, 3, 5, 7]
f([10,9,8,7,6,5,4,3,2,1],[])     #[2, 5, 3, 7]
f([100,99,98,1,2,3,4,5],[])      #[2, 5, 3, 11, 7]
f([541,60,19,17,22],[])          #[541, 2, 3, 5, 19, 17, 11]
f([1,1,2,3,5,8,13,21,34,45],[])  #[2, 3, 5, 13, 7, 17]
f([6,7,6,7,6,7,6,5],[])          #[2, 3, 7, 5]
f([1],[])                        #[]
f([8],[])                        #[2]
f([],[])                         #[]

Somehow I was not able to make the function as a lambda-function. Whenever i try to return the list comprehention, it returns [None, None, ...]. If i am just overlooking something, could someone point that mistake out? Thanks for the feedback!

Edit:
Using Mr. Xcoders sorting algorithm I could cut down the code by 16 bytes. Thank you for that part.
from primefac import*
def f(l):a=sum([list(primefac(i))for i in l],[]);print sorted(set(a),key=a.index)

This doesn't appear to be correct. The second test case should output [2, 5, 3, 7]. The order of the outputs matters.

sorted(set().union(*map(primefac,l)))

The order of the outputs is important. Re-read the explanation, or look at other answers - I don't really know how else to explain it.

@Stephen. Updated routine, with correct output. It took me a while until i noticed the differences in each line. Focus while reading helps a lot.

@Simon save three bytes by getting rid of spaces after parens - s.append(x) for -> s.append(x)for, primefac(i)) for -> primefac(i))for, []) if-> [])if

You can save 1 byte: def f(l,s=[]):[s.append(x)for x in sum([list(primefac(i))for i in l],[])if~-(x in s)];print s

Braingolf, 7 bytes
&(p)u=;

Try it online!
Oh look, it's basically a chain of 4 built-ins
Explanation
&(p)u=;  Implicit input from commandline args
 (.)     Sandbox loop, sandboxes each item in a separate stack and runs the
         code within the loop.
&        Append the entire sandboxed stack when loop ends, rather than only the
         top of stack after each iteration
  p      Prime factors
    u    Unique
     =   Print stack
      ;  Suppress implicit output

Braingolf v2, 5 bytes
&pu=;

Try it online!
Braingolf's v2 interpreter doesn't have the "sandbox loop" (.) implemented yet, however due to more consistent modifier behavior, it's not needed for this challenge, as the greedy & modifier works directly on the prime factors p instruction, causing it to factorize every item on the stack.

Fails for [10,9,8,7,6,5,4,3,2,1]. - The order matters: you should return [2, 5, 3, 7] instead of [2, 3, 5, 7].

You can fix that for -1 byte though. Since K only makes harm here.

@Mr.Xcoder oh right yeah, didn't realise they were supposed to be in order of occurrence, not ascending order. Fixed

Actually, 5 bytes
♂y♂i╔

Try it online!
Explanation:
♂y♂i╔
♂y     prime factors of each element
  ♂i   flatten
    ╔  deduplicate (stable)

APL (Dyalog Extended), 4 bytesSBCS
∪∘∊⍭

Try it online!

Factor + math.primes.factors, 32 bytes
[ [ factors ] map-flat members ]

Try it online!

factors Get the prime factors of a number.
map-flat Apply a quotation to each member of a sequence, collecting the (non-scalar) results in a flat sequence of the same length.
members Remove duplicates.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Differences of MaxMin Divisor Pairs (DMDP)
Let's talk about divisors...
Leaving out perfect squares (for a moment), all positive integers can be expressed as the product of 2 of their divisors. Quick example for 126: Here are all the divisors of 126

As you can see all the divisors can be paired. Here are what we will call the Divisor Pairs:
[1, 126], [2, 63], [3, 42], [6, 21], [7, 18], [9, 14]
For this challenge we will need only the last pair of this list (which is the center pair of the picture):
[9,14].We will call this pair the MaxMin Divisor Pair.
The Difference of MaxMin Divisor Pair (DMDP) is the difference of the two elements of the pair which is [9,14]=5
One more example for 544. The divisors are:

[1, 2, 4, 8, 16, 17, 32, 34, 68, 136, 272, 544]

and DMDP(544)=15  because 32-17=15
What about the perfect squares? All perfect squares have DMDP=0
Let's take for example 64 with divisors

{1, 2, 4, 8, 16, 32, 64}

As you can see in this case the MaxMin Divisor Pair is [8,8] which has DMDP=0
we are almost done..
The Challenge
Given an integer n>0, output how many integers less than or equal to 10000, have DMDP less than n
Test Cases
input -> output
1->100 (those are all the perfect squares)
5->492
13->1201
369->6175
777->7264
2000->8478
5000->9440
9000->9888
10000->10000
20000->10000

This is code-golf.Shortest answer in bytes wins.

Wouldn't it make more sense to have the 10000 as a second, variable, input?

Yes, I thought about that but it would not add anything to the challenge. In this way I think it is easier for everybody to understand the challenge.

Related

JavaScript (ES7), 60 bytes
f=(n,i=1e4,j=i**.5|0)=>i?i%j?f(n,i,j-1):(i/j-j<n)+f(n,i-1):0

Probably exceeds your recursion limit, so you might prefer the iterative version for 70 bytes:
n=>[...Array(1e4)].map(g=(j=++i**.5|0)=>i%j?g(j-1):k+=i/j-j<n,i=k=0)|k

Java 8, 151 111 110 101 98 bytes
n->{int r=0,x=10000,i;for(;x-->0;r-=i-n>>-1)for(i=x;i-->1&&(x<i*i|x%i>0||(i=x/i-i)>i););return r;}

-10 bytes thanks to @Nevay.
-3 bytes thanks to @ceilingcat.
Explanation:
Try it here.
n->{                  // Method with integer as parameter and return-type
  int r=0,            //  Result-integer, starting at 0
      x=10000,        //  Index-integer `x` for the outer loop, starting at 10,000
      i;              //  Index-integer `i` for the inner loop, uninitialized
  for(;x-->0;         //  Loop `x` in the range (10000, 0]:
      r-=i-n>>-1)     //   If the MaxMin-Divisor Pair's difference is lower than the input,
                      //    add 1 to the result (after every iteration)
    for(i=x;i-->1     //   Inner loop `i` in the range (`x`, 1]:
        &&(x<i*i      //    If the current square of `i` is smaller than or equals to `x`,
           |x%i>0     //    and the current `x` is divisible by `i`:
           ||(i=x/i-i)//     Calculate the MaxMin-Division difference
             >i););   //     And stop the inner loop
  return r;}          //  After the loops, return the result

You can use for(i=1,i+=Math.sqrt(x);--i>0;)if(... to save 1 byte.

Don't have time to try it myself, but would it be shorter to have the inner loop start from x and have an extra variable for the current minimum?

101 bytes: n->{int r=0,x=10000,i;for(;x-->0;r-=i-n>>-1)for(i=x;i-->1;)if(x>=i*i&x%i<1){i=x/i-i;break;}return r;}

@Nevay Thanks again, really need to remember x>=i*i as alternative for using Math.sqrt, since this is the second time you've golfed that in my code.

Jelly, 13 bytes
1 byte thanks to Jonathan Allan.
ȷ4RÆDạU$Ṃ€<⁸S

Try it online!

ÆDạ"Ṛ$Ṃ saves you a byte over ÆDạ:@¥⁸Ṃ (I had ạ"ṚṂ...ȷ4RÆDÇ€<⁸S for 15 - too similar - EDIT: hmm or was it, no : involved... what do you think?)

@JonathanAllan I think you should post this 13-byter

Oh wow. nah you go for it, I saved you one byte that saves another 2!

Could you add an explanation?

R, 73 77 bytes

Thanks to @Guiseppe for the 4 bytes
sum(sapply(1:1e4,function(x)min(abs((w=which(x%%1:x<1))-rev(w))))<scan())

Try it online!
Have lost the vectorize function to calculate the DMDP and is now using a sapply over the function.  The truthies for items which are less than the input are summed for the result.

Ah, I didn't notice the DMDP is the min diff of that factor list! Very nice. I think sum(sapply(1:1e4,function(x)min(abs((w=which(x%%1:x<1))-rev(w))))<scan()) is a bit shorter

Mathematica, 64 bytes
Count[Divisors~Array~1*^4,a_/;#+a[[i=⌈Tr[1^a]/2⌉]]>a[[-i]]]&

Try it on Wolfram Sandbox
Usage
f = Count[Divisors~Array~1*^4,a_/;#+a[[i=⌈Tr[1^a]/2⌉]]>a[[-i]]]&

f[1]

100

f /@ {1, 5, 13, 369, 777, 2000, 5000, 9000, 10000, 20000}

{100, 492, 1201, 6175, 7264, 8478, 9440, 9888, 10000, 10000}

Explanation
Divisors~Array~1*^4

Generate the lists of divisors, from 1 to 10000. (the lists of divisors are sorted automatically)
Count[ ..., a_/; ... ]

Count the occurrences of elements a, such that...
#+a[[i=⌈Tr[1^a]/2⌉]]>a[[-i]]]

(input) + (left one of the middle element(s)) > (right one of the middle element(s))  If there is only one middle element, left = right.

05AB1E, 19 18 17 16 15 12 bytes
4°ƒNÑÂα{нI‹O

Try it online!
Explanation
4°ƒ            # for N in [0 ... 10**4] do:
   NÑ          # push divisors of N
     Â         # bifurcate
      α        # element-wise absolute difference
       {       # sort
        н      # pop the head (smallest difference)
         I‹    # is it smaller than the input?
           O   # sum the stack

MATL, 20 bytes
1e4:"@Z\2Y"dJ2/)G<vs

The code times out in TIO. Here's an example run with the offline compiler:
>> matl 1e4:"@Z\2Y"dJ2/)G<vs
> 13
1201

R, 91 bytes
function(n)sum(sapply(1:1e4,function(x,d=(1:x)[x%%1:x<1])diff(d[median(seq(d))+.5*0:1]))<n)

Takes a different (worse) approach to computing the DMDP than MickyT's solution by using array indexing and diff to compute it. Alas.
Try it online!

Mathematica, 78 bytes
(s=#;Tr[1^Select[Table[#2-#&@@Quantile[Divisors@i,{.5,.51}],{i,10^4}],#<s&]])&

Cases is 4 bytes shorter: Tr[1^Cases[Table[#2-#&@@Quantile[Divisors@i,{.5,.51}],{i,10^4}],s_/;s<#]]&. See this tip.

@ngenisis Count is even shorter: Count[Table[#2-#&@@Quantile[Divisors@i,{.5,.51}],{i,10^4}],s_/;s<#]&

Mathematica, 119 115 bytes
(n=#;Tr[1^Select[Last@#-First@#&/@(Take[Divisors@#,Round[{-.1,.1}+(1+Length@Divisors@#)/2]]&/@Range@10000),#<n&]])&

I finally got this thing working and I've been trying for the past half an hour. ._.
Example run

Cases is 4 bytes shorter: Tr[1^Cases[Last@#-First@#&/@(Take[Divisors@#,Round[{-.1,.1}+(1+Length@Divisors@#)/2]]&/@Range@10000),n_/;n<#]]&. See this tip.

@ngenisis actually Count is even shorter than Cases. Count[Last@#-First@#&/@(Take[Divisors@#,Round[{-.1,.1}+(1+Length@Divisors@#)/2]]&/@Range@10000),n_/;n<#]&

Also, 10^4 or 1*^4 is shorter than 10000, and /@Range@ is equaivalent to ~Array~.

Husk, 19 bytes
#ȯV<⁰Sz≠↔§f`¦ḣḣ□100

No TIO link, since it times out.
This version uses 100 in place of 10000 and finishes in a couple of seconds.
Explanation
Husk has no divisors built-in or support for scientific notation yet.
#ȯV<⁰Sz≠↔§f`¦ḣḣ□100  Input is n (accessed with ⁰).
               □100  Square of 100: 10000
              ḣ      Inclusive range from 1.
#                    Count number of elements for which
 ȯ                   this composition of 3 functions gives truthy result:
                       Argument k, say k = 12.
         §f`¦ḣ         Divisors of k:
             ḣ           Range: [1,2,3,..,12]
         §f              Filter by
           `¦            divides k: [1,2,3,4,6,12]
     Sz≠↔              Absolute differences of divisor pairs:
        ↔                Reverse: [12,6,4,3,2,1]
     Sz                  Zip with divisor list
       ≠                 using absolute difference: [11,4,1,1,4,11]
  V<⁰                  Is any of these less than n?

Japt, 25 19 17 bytes
L²õÈâ ®aX/ZÃd<UÃè

Test it

Explanation
Implicit input of integer U.
L²õ

Generate an array of integers (õ) from 1 to 100 (L) squared.
Èâ          Ã

Pass each through a function (where X is the current element) that generates an array of the divisors (â) of X.
®    Ã

Map over that array of divisors, where Z is the current element.
aX/Z

Get the absolute difference (a) of Z and X divided by Z.
d<U

Are any of the elements (d) in the resulting array less than U?
è

Count the truthy elements and implicitly output the result.

Ruby, 62 bytes
->n{(1..1e4).count{|x|(1..x).any?{|i|1>x%i&&x/i<=i&&i-x/i<n}}}

Try it online.

TI-BASIC, 46 bytes
Note that TI-BASIC is a tokenized language. Also, the E in line 2 is a small capital E, found by pressing 2ND+, .
Input A
DelVar DFor(B,1,E4
For(C,1,√(B
If not(fPart(B/C
B/C-C<A
End
D+Ans→D
End

Result will be in D, and Ans immediately after program execution. If it is to be displayed, adding two more bytes (newline and Ans) would suffice.

Python 2, 134 bytes
lambda i:len(filter(lambda n:n<i,[reduce(lambda x,y:y-x,[[x,n/x]for x in range(1,int(n**.5+1))if n%x<1][-1])for n in range(1,10001)]))

Try it online!
Eugh... need to do much better.

125 bytes (-9 bytes) using your current approach, but replacing len(filter(lambda n:n<i,...)) with sum(n<i for n in ....)

114 bytes based on Mr.Xcoder''s comment.

113 bytes based on ovs' comment.

Python 2, 83 bytes
A bit on the slow side, uses 5 seconds per test case
lambda x:sum(x>min(abs(y/t-t)for t in range(1,y+1)if y%t<1)for y in range(1,10001))

Try it online!

PHP, 94+1 bytes
for(;$n++<1e4;$c+=$d<$argn)if(($i=$n**.5)>~~$i){while($n%++$i);for($d=1;$n%--$i;)$d++;}echo$c;

Run as pipe with -nR or try it online.

VB.NET (.NET 4.5) 116 115 bytes
Function A(n)
For i=1To 10^4
Dim s As Byte=Math.Sqrt(i)
While i Mod s>0
s-=1
End While
A-=i/s-s<n
Next
End Function

Explanation:
A function that takes n as a parameter, and returns the result.
Starts at the square root, and looks for the nearest integer that evenly divides (will be the smaller of the MaxMin Divisor Pair). Then gets the larger of the pair (i/s), finds the difference, and compares against the input.

Golfing strategies used:

Dim is expensive, so the fewer variables I declare the better.
I start searching at the square root, but only want to look at integers. By declaring s as an integral type, it casts to the floor for me.
VB uses ^ as exponent. So while 10000 is 5 characters, 10^4 is only 4.
VB creates an automatic variable with the same name and type as the function definition (in my case A). At the end of the function, if there is no return, the value of the function variable will be returned instead. So I save characters by not declaring a separate variable and not using a return statement.
VB has very forgiving typing/casting. i is assumed Integer because I assigned a integer literal. A is assumed Object but as soon as I add an integer, it behaves like an Integer.
Rather than if checking the that the difference is satisfactory, add it directly to the result by casting the boolean to an integer. However, VB uses -1 for True, so subtract to get the correct sign.
Technically, we want Mod to not be 0. Taking the modulus of a negative number in VB.NET will give a negative result. But, everything is positive so I can save a byte by turning <> into >.
The largest number to check is 10000. The square root of that is 100. So I only need a Byte to store that, saving bytes in the declaration by using a shorter named type.

Try it online!

C# (.NET Core), 104 bytes
x=>{int o=0,i=1;for(;i<=10000;i++)for(int j=1;j<=i;j++)if(i%j<1&Math.Abs(j-i/j)<x){o++;break;}return o;}

Try it online!

Wolfram Language (Mathematica), 52 bytes
Boole@Array[AtomQ@√(4a+#^2)&,#,0,Or]~Sum~{a,1*^4}&

Try it online!
Slow.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Microgravity Ball
You are on an advanced intergalactic space station. A friend of yours who is minoring in the Study of Gravity just created a game that involves using microgravity as a way to move a ball around.
She hands you a small controller with four directional arrows on it and a maze like structure with a ball sitting to the left. She begins to explain how the game works.

You have 2 directional buttons, left < and right >.
You also have 2 gravity buttons, up ^ and down v (at least from your frame of reference)
You will use these arrow buttons to move the ball around on your screen.

"Now there are some rules that need to be followed." she says

All platforms must be traversed before getting to the cup \ /
Arrows < > ^ v will be used to specify movement of the ball
Gravity is ^ v (up & down). This moves the ball all the way to the next platform in that direction. (Distance is not calculated for up and down)
Losing the ball is bad! Don't fall over the edge, and don't switch gravity too soon such that your ball never reaches a platform
Movement is counted in steps of < >
The ball can enter the cup from any direction as long as Rule 1 is followed
You must specify direction of gravity so your ball doesn't float away
Movement may be random as long as Rule 1 and Rule 4 is followed
For cases that cannot be solved output False or Invalid

Simple Example of a ball, platform, and cup:
v
o
---\ /

v>

 o
---\ /

v>>

  o
---\ /

v>>>

   o
---\ /

v>>>>

---\o/

Example of traversing over the same platform again.
v

 o
 ----

\ /-------

v>

  o
 ----

\ /-------

v>>

   o
 ----

\ /-------

v>>>

    o
 ----

\ /-------

v>>>>

 ----
     o
\ /-------

v>>>>>

 ----
      o
\ /-------

v>>>>>>

 ----
       o
\ /-------

v>>>>>>>

 ----
        o
\ /-------

v>>>>>>>>

 ----
         o
\ /-------

v>>>>>>>><<<<<<<< # move all the way to the left to get to the cup

 ----

\o/-------

Example of switching gravity
v
   --/ \

o
----

v>
   --/ \

 o
----

v>>
   --/ \

  o
----

v>>>
   --/ \

   o
----

v>>>^
   --/ \
   o

----

v>>>^>
   --/ \
    o

----

v>>>^>>
   --/ \
     o

----

v>>>^>>>
   --/o\

----

Task
Your task is to create a program that will take an ASCII representation of a course as input. And output a string of arrows <>^v representing the direction and gravitational pull to move a ball o across all platforms into a cup.
Standard code golf rules apply
Test Cases
Input (A situation where gravity is being switched)
         ----   --/ \
---    --
o

  ------    -----

Output
^>>v>>>>>^>>>>>v>>>>^>>>

Input (A situation where direction is being switched)
       ---
o
----
    ---

     -----

    --\ /

Output
v>>>>>>^>>>v<<<<<v>>>

Input (A situation where you need to traverse over the same platform twice)
 o
 ------

  ------

 ------

\ /------

Output
v>>>>>><<<<<<>>>>>>><<<<<<

Bad Cases, Program should output Falsy for these
No way for the ball to get to the next platform
o
--- ---

Ball would float off into space
---
o
   ---

A situation where the ball gets to the cup, but all platforms don't get traversed.
o
----
    ----
        \ /----

Rule 1 makes this quite challenging... hmmm...

Will the puzzle always be solvable? Also, I think you should include a test case that requires backtracking.

Yes, puzzles should always be solvable. Gaps or jumps that lose the ball or situations that make the maze unsolvable won't be done.

@JungHwanMin Rule 1 is exactly why this is a challenge and not trivial.

I've never felt so far down a rabbit hole on a codegolf question

Related

So we don't have to handle impossible cases? Could you edit the post body to say so?

Pyth, 431 bytes
This is my first Pyth program (actually this is my first program in any code-golf language), which means it can be probably still improved.
Jmmck\:cd\%c.Z"xÚU±Ã@DÅ W,J áDPáÒV`ýüw{g$ÍÀÞÇr§o.÷å8èÝÇr{øºy{~1åõ:noßÃú/.yçíäÂ'ëL¢êF¸èÆ\ka´QÒnÒ@tãÒÁµÆ¾õö»bÍH¥¦$¨%5Eyîÿ}ó§ûrh³oÄåËÄqõ XÔHû"\_KYDrGHFN@JGIn=bm:d.*NHHRb)RHDiNTR.turNG.tT;M:jH)hh@JG0DXGHN=Ti+3qG\^HI!},GTK aK,GT aY+eKNI&!g5T}\EjT)N.q;D(GHNT)INIqHhT=ZrGhtTInZhtTXHZ+eTN))).?I&nHhTgGhtTXHhtT+eTH; aK,di2i1r0.z aY+eKk#=N.(Y0(6\vkN)(7\^kN)(8\v\<N)(9\v\>N)(10\^\<N)(11\^\>N

Try it here (the last testcase needs too long, it must be tested with a local Pyth installation).
Hex dump of the code (use xxd -r <filename> to decode):
00000000: 4a6d 6d63 6b5c 3a63 645c 2563 2e5a 2278  Jmmck\:cd\%c.Z"x
00000010: da55 8eb1 8ac3 400c 447f c58d 2057 2c99  .U....@.D... W,.
00000020: 4aa0 e144 50e1 d2ad 5660 87fd 84fc 7f77  J..DP...V`.....w
00000030: 7b67 1f24 cdc0 8319 de1c c772 a76f 2ef7  {g.$.......r.o..
00000040: e538 e8dd c772 7bf8 9eba 797b 7e31 e5f5  .8...r{...y{~1..
00000050: 8e3a 6e8f 6fdf c3fa 2f2e 0c79 e717 ede4  .:n.o.../..y....
00000060: c21f 27eb 8395 189a 4c15 140b a28d ea82  ..'.....L.......
00000070: 46b8 e8c6 5c05 1b6b 1d61 b490 0251 d28c  F...\..k.a...Q..
00000080: 6ed2 4087 74e3 1ad2 c1b5 c6be f5f6 1cbb  n.@.t...........
00000090: 6286 cd48 a5a6 24a8 2535 4579 eeff 7df3  b..H..$.%5Ey..}.
000000a0: 8a8a 1613 a7fb 7204 68b3 6fc4 e51b 160c  ......r.h.o.....
000000b0: 1304 cbc4 8a71 f57f 2058 d448 fb22 5c5f  .....q.. X.H."\_
000000c0: 4b59 4472 4748 464e 404a 4749 6e3d 626d  KYDrGHFN@JGIn=bm
000000d0: 3a64 2e2a 4e48 4852 6229 5248 4469 4e54  :d.*NHHRb)RHDiNT
000000e0: 522e 7475 724e 472e 7454 3b4d 3a6a 4829  R.turNG.tT;M:jH)
000000f0: 6868 404a 4730 4458 4748 4e3d 5469 2b33  hh@JG0DXGHN=Ti+3
00000100: 7147 5c5e 4849 217d 2c47 544b 2061 4b2c  qG\^HI!},GTK aK,
00000110: 4754 2061 592b 654b 4e49 2621 6735 547d  GT aY+eKNI&!g5T}
00000120: 5c45 6a54 294e 2e71 3b44 2847 484e 5429  \EjT)N.q;D(GHNT)
00000130: 494e 4971 4868 543d 5a72 4768 7454 496e  INIqHhT=ZrGhtTIn
00000140: 5a68 7454 5848 5a2b 6554 4e29 2929 2e3f  ZhtTXHZ+eTN))).?
00000150: 4926 6e48 6854 6747 6874 5458 4868 7454  I&nHhTgGhtTXHhtT
00000160: 2b65 5448 3b20 614b 2c64 6932 6931 7230  +eTH; aK,di2i1r0
00000170: 2e7a 2061 592b 654b 6b23 3d4e 2e28 5930  .z aY+eKk#=N.(Y0
00000180: 2836 5c76 6b4e 2928 375c 5e6b 4e29 2838  (6\vkN)(7\^kN)(8
00000190: 5c76 5c3c 4e29 2839 5c76 5c3e 4e29 2831  \v\<N)(9\v\>N)(1
000001a0: 305c 5e5c 3c4e 2928 3131 5c5e 5c3e 4e    0\^\<N)(11\^\>N

Explanation
The main idea for this program was to use regular expressions to modify the input. To save space all these regular expressions are contained in a compressed string. The first step in the program is to decompress the string and to split it int single regular expression and the corresponding replacement strings.
            .Z"..."     Decompress the string
           c       \_   Split the result into pieces (separator is "_")
  m    cd\%             Split all pieces (separator is "%")
 m ck\:                 Split all sub-pieces (separator is ":")
J                       Assign the result to variable J

The contents of variable J are then:
[[['\\\\ /', '=M='], ['/ \\\\', '=W=']],
 [[' (?=[V6M=-])', 'V'], ['o(?=[V6M=-])', '6']],
 [['(?<=[A9W=-]) ', 'A'], ['(?<=[A9W=-])o', '9'], ['(?<=[X0W=-])V', 'X'], ['(?<=[X0W=-])6', '0']],
 [['6V', 'V6'], ['0X', 'X0'], ['6-', '6='], ['0-', '0='], ['6M', 'VE'], ['0M', 'XE']],
 [['A9', '9A'], ['X0', '0X'], ['-9', '=9'], ['-0', '=0'], ['W9', 'EA'], ['W0', 'EX']],
 [['[MW-]']],
 [['[60]']],
 [['[90]']],
 [['V6', '6V'], ['V0', '6X'], ['X6', '0V'], ['X0', '0X']],
 [['6V', 'V6'], ['0V', 'X6'], ['6X', 'V0'], ['0X', 'X0']],
 [['A9', '9A'], ['A0', '9X'], ['X9', '0A'], ['X0', '0X']],
 [['9A', 'A9'], ['0A', 'X9'], ['9X', 'A0'], ['0X', 'X0']]]

KY   Set the variable K to an empty list

The function r applies regex substitutions from the list stored in J at the index G to all strings in the list H. It returns as soon as any of the strings was changed.
DrGH                         Define the function r(G,H)
    FN@JG              )     Loop for all entries in J[G]
             m:d.*NH         Regex substitution, replace N[0] with N[1] in all strings in list H
           =b                Store the result in variable b
         In         HRb      If b != H return b
                        RH   Return H

The function i is similar to function r with 2 differences. It applies the substitutions on a transposed list (vertical instead on horizontal). It also performs the substitutions repeatedly as long as anything is changed.
DiNT          ;   Define the function i(N,T)
           .tT    Transpose the list T
       urNG       Apply r(N,...) repeatedly as long as something changes
    R.t           Transpose the result back and return it

The function g checks if the regex from the list stored in J at the index G can by found in any string in the list H.
M             Define the function g(G,H)
     hh@JG    Get the single regex stored in J[G]
  jH)         Join all strings in H
 :        0   Check if the regex is found anywhere in the joined string

The rest of the code contains the actual program logic. It performs a breadth-first search for the possible movements until a solution is found. The position in the search tree is uniquely defined by the direction of the gravity and a modified copy of the program input. To avoid the processing of the same position again and again, processed positions are stored in the global list K. Positions which still have to be processed are stored together with the corresponding part of the solution in the list Y.
The modification of the input and initialization of K and Y is performed by the following code:
           .z          Get all input as a line list
     i2i1r0            Apply the regular expressions stored in J[0] horizontally, and the the ones from J[1] and J[2] vertically
   ,d                  Create a list with " " (represents "no gravity set") and the modifed input
 aK                    Append the result to the list K
                 eK    Retrieve the appended list again
                +  k   Append "" to the list (represents the empty starting solution)
              aY       Append the result to the list Y

The input modification does something like the following. The input:
         ----   --/ \
---    --
o

  ------    -----

is transformed to:
VVVVVVVVV----VVV--=W=
---VVVV--AAAXVVVXAAAA
9AXVVVVXAAAAXVVVXAAAA
AAXVVVVXAAAAXVVVXAAAA
AA------AAAA-----AAAA

The values have the following meaning:

- Platform which must be still visited
= Platform which doesn't need to be visited anymore
M Cup which can be entered with gravity set to "down"
W Cup which can be entered with gravity set to "up"
V Safe to move to this place with gravity set to "down"
A Safe to move to this place with gravity set to "up"
X Safe to move to this place regardless of the gravity setting
6 Ball on a place which would be marked as V
9 Ball on a place which would be marked as A
0 Ball on a place which would be marked as X

The logic is using regular expressions to perform the movements. In the example above, if the gravity would be set to "up", we can replace "9A" with "A9" with an regex to move the ball to the right. This means by trying to apply the regex we can find all possible movements.

The function X performs vertical ball movements based on the current gravity setting, stores the result in global lists K and Y, and checks if a solution was found.
DXGHN                                             ;   Define the function X(G,H,N)
        +3qG\^                                        Select the correct set of regular expressions based on the current gravity setting G (3 for "v" and 4 for "^")
     =Ti      H                                       Apply i(...,H) and store the result in T
               I!},GTK                                If [G,T] not in K
                       aK,GT                          Store [G,T] in K
                             aY+eKN                   Store [G,T,N] in Y
                                   I&!g5T}\EjT)       If J[5] not found in T and T contains "E" (all platforms visited and ball in cup)
                                               N.q    Print N and exit

The function ( implements checks for the 4 directional/gravity buttons. The gravity buttons can be pressed only if the current gravity would change and if the ball is in a safe place to change the gravity. The directional buttons can be pressed only if it is safe to move to the corresponding place.
D(GHNT)                                                    ;   Define the function ( (G,H,N,T)
       IN                           )                          If N is not empty (contains either "<" or ">" representing directional buttons)
         IqHhT                     )                           If H (gravity setting for which this test is performed) is equal T[0] (the current gravity)
              =ZrGhtT                                          Apply r(G,T[1]) and store the result in Z (G is the appropriate regex index for the combination of gravity and directional button, T[1] is the current modified input)
                     InZhtT       )                            If Z != T[1] (the regex operation changed something, meaning we found a valid move)
                           XHZ+eTN                             Call X(H,Z,[T[2],N])
                                     .?                        Else (gravity button pressed)
                                       I                       If ...
                                         nHhT                  H (new gravity setting) is not equal T[0] (current gravity setting)
                                        &                      ... and ...
                                             gGhtT             J[G] found in T[1] (ball is in an appropriate place to switch gravity)
                                                  XHhtT+eTH    Call X(H,T[1],[T[2],H])

Finally the main loop. The first element of Y is removed repeatedly, and checks for all possible moves are performed.
#                                                        Loop until error (Y empty)
 =N.(Y0                                                  Pop first element of Y and store it in the variable N
       (6\vkN)                                           Call ( (6,"v","",N)
              (7\^kN)                                    Call ( (7,"^","",N)
                     (8\v\<N)                            Call ( (8,"v","<",N)
                             (9\v\>N)                    Call ( (9,"v",">",N)
                                     (10\^\<N)           Call ( (10,"^","<",N)
                                              (11\^\>N   Call ( (11,"^",">",N)

Am I right in thinking that you assume that every input is solvable? Because the question still says unsolvable inputs should be detected, the comments, however, suggests that every input will be solvable. I am uncertain which is the case, though I think your code does not detect unsolvability.

@JonathanFrech If the input is unsolvable there will be no output. When all possibilities were checked, the Y list will be empty, the pop will throw an error and the # loop will end.

When you remove the cup from the input (/ \\), the puzzle becomes unsolvable (as you cannot reach the cup) yet your program still generates an output.

I did not mean what your program does, I ment that this unsolvable puzzle input generates an output.

@JonathanFrech You are right. I'm just trying to fix it, but I have encoding problems with the compressed string.

@JonathanFrech Fixed it.

Doesn't quite nail it on 2 of the Test Cases. But overall, I'm really impressed. Great job, If no-one can get another answer in, you will win the bounty :)

Input (A situation where direction is being switched)
Input (A situation where you need to traverse over the same platform twice)

@tisaconundrum Actually both of your solutions are wrong. In the case (A situation where direction is being switched) the ^ is 1 place too early, the ball would float into space, and the 2nd v is superfluous (the gravity is already set to down) (see here). In the case (A situation where you need to traverse over the same platform twice) you are missing a < at the end (see here).

@tisaconundrum Your testcase for (A situation where direction is being switched) is different from the animation below.


text:
Do the NP: find the largest clique
Background
At the time of writing this, the P vs NP problem is still unsolved, but you might have heard of Norbert Blum's new paper claiming proof that P != NP, which is already suspected to be erroneous (but we will see).
The problem discussed in this paper is the clique problem. At least that's what I read in a newspaper article, so correct me if I'm wrong, but in any case, I'd like you to write a program that solves the following variant:
The task
Assume we have a large school with lots of students. Each of these students has some friends at this school. A clique of students is a group consisting only of students who are friends with each other member.
Your program will receive pairs of students who are friends as its input. From this information, the program must find the size of the largest clique. Students are identified by integer IDs.
If you prefer mathematical terms, this means you're fed the edges of an undirected graph, identified by two nodes each.
Input
Your input will be a non-empty list of positive integer pairs, e.g. [[1,2],[2,5],[1,5]]. You can take this input in any sensible form, e.g. as an array of arrays, as lines of text containing two numbers each, etc ...
Output
The expected output is a single number n >= 2: the size of the largest clique. With the example input above, the result would be 3, as all students (1, 2 and 5) are friends with each other.
Test cases
[[1,2]]
=> 2

[[1,2],[3,1],[3,4]]
=> 2

[[1,2],[2,5],[1,5]]
=> 3

[[2,5],[2,3],[4,17],[1,3],[7,13],[5,3],[4,3],[4,1],[1,5],[5,4]]
=> 4 (the largest clique is [1,3,4,5])

[[15,1073],[23,764],[23,1073],[12,47],[47,15],[1073,764]]
=> 3 (the largest clique is [23,764,1073])

[[1296,316],[1650,316],[1296,1650],[1296,52],[1650,711],[711,316],[1650,52],
 [52,711],[1296,711],[52,316],[52,1565],[1565,1296],[1565,316],[1650,1565],
 [1296,138],[1565,138],[1565,711],[138,1650],[711,138],[138,144],[144,1860],
 [1296,1860],[1860,52],[711,1639]]
=> 6 (the largest clique is [52,316,711,1296,1565,1650])

You can use this (stupid) reference implementation (prints extra output with -d flag) for verifying the results of other test cases.
The rules

Your program doesn't need a defined result on invalid input. So you can assume that:

you will always get at least one pair of IDs
each pair consists of two different IDs
no pair appears twice (swapping the places of the IDs would still be the same pair)

Your algorithm isn't allowed to set an upper bound on input size. Purely technical limitations and limitations set by your language/environment (like stack size, computation time, etc) are of course inevitable.
Standard loopholes are forbidden.
This is code-golf, so the shortest code, measured in bytes, wins.
If your algorithm has polynomial time complexity, you score -1 immediately regardless of your code size, but in that case, you might want to submit your solution somewhere else. ;)

I would recommend removing rule 5, as it means that some people will score -1 regardless of the length of their code. You could however offer imaginary bonus points.

@cairdcoinheringaahing I bet nobody will be able to claim rule 5 ;)

I can almost guarantee that there will be someone who will do it (or try to), so it would simply be safer to remove it. If you want to reward people for doing it, you can offer a bounty to the shortest answer that does it it polynomial time.

@cairdcoinheringaahing if someone does it, the -1 is well deserved ;)

For reference, https://en.wikipedia.org/wiki/Clique_problem, specifically "Finding maximum cliques in arbitrary graphs"

@cairdcoinheringaahing If somebody managed to prove that P = NP, them having the automatic lowest score on a code golf problem is the least of our concerns. That said, Rule 5 doesn't really contribute much to the challenge, so I agree that it should be removed.

@Mego it merely contributes a joke and a tiny bonus to the 1M offered by CMI.

@FelixPalmen I still suggest removing it. That way a thousand-byte solution in polynomial time (assuming it's possible) would get a score of -1.

Well, I won't, in favor of the few people having some sense of "scientific humor". Please don't comment more suggestions concerning this, thanks :)

Can we assume that each edge is in sorted order?

@Mnemonic no, as seen in the test cases...

@Mnemonic If you are to assume that then you're going to assume one-way friendships...?

@EriktheOutgolfer They're undirected edges.  Order shouldn't matter.  But I could save two bytes if I didn't have to sort the indices.

@Mnemonic it was a joke btw...if you assume input is like [A is a friend of B, where A <= B, ...] but not vice versa then you're assuming one-way friendship

Could we take the input as an adjacency matrix?

@miles a "sensible form" is of course open to some creative ideas ... but the input should be pairs of friends. I'd say an adjacency matrix is too far from that, so no, sorry.

We need a fastest-code version of this question.

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Ç€Ṁ

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)!
How?
Ẏ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

Wow, explanation when you have time please

@EriktheOutgolfer I agree. I can probably add code to salvage...

Let us continue this discussion in chat.

16 bytes

@miles - nice, I just spent a while trying to get a 15 from that, I feel like it should be possible!

@JonathanAllan: "I just spent a while trying to get a 15 from that" if transforming the list of pairs to a flat list is all Ẏ does, you can drop it. Another answer already uses flat lists as input and I still consider this "sensible": the pairs are just implicated.

@FelixPalmen Without pairs in the input the power-set would be no good for purpose and the length "(of edges)" would need to be halved, so I cant get rid of the tighten.

@JonathanAllan ahh, ok :)

Mathematica, 34 bytes
Tr[1^#&@@FindClique[#<->#2&@@@#]]&

Basically FindClique does the job and "finds a largest clique in the graph g."
All the other stuff is converting input-list into graph
Input

[{{2, 5}, {2, 3}, {4, 17}, {1, 3}, {7, 13}, {5, 3}, {4, 3}, {4,
     1}, {1, 5}, {5, 4}}]

Output

4

Input

[{{1296, 316}, {1650, 316}, {1296, 1650}, {1296, 52}, {1650,
     711}, {711, 316}, {1650, 52}, {52, 711}, {1296, 711}, {52,
     316}, {52, 1565}, {1565, 1296}, {1565, 316}, {1650, 1565}, {1296,
     138}, {1565, 138}, {1565, 711}, {138, 1650}, {711, 138}, {138,
     144}, {144, 1860}, {1296, 1860}, {1860, 52}, {711, 1639}}]

Output

6

thanx @Kelly Lowder for -10 bytes

Of course Mathematica has a builtin for this.

Shave off 10 Bytes with Tr[1^#&@@FindClique[#<->#2&@@@#]]&

FindClique ಠ___ಠ

Jelly, 20 bytes
ŒPẎ€µQL’=ċÐ€`ẠµÐfṪQL

Try it online!
Of course this doesn't deserve the million :p
This would've beat Pyth, if not for the µ(...)µ and 2-byte Ðf.

Amazing. I may as well give up now.

@FelixPalmen brute force :p

@EriktheOutgolfer I didn't mean the runtime of the code ;)

@FelixPalmen I mean, brute force approach doesn't need much thinking :p

Gives a MemoryError with the largest test-case :( Of course still valid, this is a "technical limitation" -- but just out of curiosity, is there a way to increase available resources with jelly?

@FelixPalmen Nope, not Jelly alone.

J, 36 bytes
[:>./](#(]*[=2!])#@~.@,)@#~2#:@i.@^#

Try it online!
Runs in time O(2n) where n is the number of pairs.
A faster solution for 65 bytes is
3 :'$>{._2{~.@((+.&(e.&y)&<|.)@(-.,-.~)&>/#&,/:~@~.@,&.>/)~^:a:y'

Try it online!
Explanation
[:>./](#(]*[=2!])#@~.@,)@#~2#:@i.@^#  Input: list of pairs
                                   #  Length
                           2      ^   2^n
                               i.@    Range [0, 2^n)
                            #:@       Binary
                         #~           Copy
      (                )@             For each
                      ,                 Flatten
                   ~.@                  Unique
                 #@                     Length
        (       )                       Dyad with RHS at previous and LHS as next
               ]                          Get RHS
             2!                           Binomial coefficient, choose 2
            =                             Equals
           [                              Get LHS
          *                               Times
         ]                                Get RHS
       #                                Length
[:>./                                 Reduce using maximum

6502 machine code (C64), 774 703 bytes
(I just had to do this, my C64 can do everything ... hehe)
hexdump:
00 C0 A9 00 A2 08 9D 08 00 CA 10 FA A2 04 9D FB 00 CA 10 FA 20 54 C0 B0 20 AD
C9 C2 AE CA C2 20 92 C1 B0 31 8D 31 C0 AD CB C2 AE CC C2 20 92 C1 B0 23 A2 FF
20 FE C1 90 DB 20 6A C2 20 C1 C1 B0 05 20 6A C2 50 F6 A5 FB 8D D3 C2 20 43 C1
A9 CD A0 C2 20 1E AB 60 A2 00 86 CC 8E 61 C0 20 E4 FF F0 FB A2 FF C9 0D F0 10
E0 0B 10 0C 9D BD C2 20 D2 FF E8 8E 61 C0 D0 E5 C6 CC A9 20 20 D2 FF A9 0D 20
D2 FF A9 00 9D BD C2 AA BD BD C2 F0 5C C9 30 30 0E C9 3A 10 0A 9D CD C2 E8 E0
06 F0 4C D0 E9 C9 20 D0 46 A9 00 9D CD C2 E8 8E BC C0 20 EB C0 AD D3 C2 8D C9
C2 AD D4 C2 8D CA C2 A2 FF A0 00 BD BD C2 F0 0F C9 30 30 21 C9 3A 10 1D 99 CD
C2 C8 E8 D0 EC A9 00 99 CD C2 20 EB C0 AD D3 C2 8D CB C2 AD D4 C2 8D CC C2 18
60 38 60 A2 FF E8 BD CD C2 D0 FA A0 06 88 CA 30 0A BD CD C2 29 0F 99 CD C2 10
F2 A9 00 99 CD C2 88 10 F8 A9 00 8D D3 C2 8D D4 C2 A2 10 A0 7B 18 B9 53 C2 90
02 09 10 4A 99 53 C2 C8 10 F2 6E D4 C2 6E D3 C2 CA D0 01 60 A0 04 B9 CE C2 C9
08 30 05 E9 03 99 CE C2 88 10 F1 30 D2 A2 06 A9 00 9D CC C2 CA D0 FA A2 08 A0
04 B9 CE C2 C9 05 30 05 69 02 99 CE C2 88 10 F1 A0 04 0E D3 C2 B9 CE C2 2A C9
10 29 0F 99 CE C2 88 10 F2 CA D0 D9 C8 B9 CD C2 F0 FA 09 30 9D CD C2 E8 C8 C0
06 F0 05 B9 CD C2 90 F0 A9 00 9D CD C2 60 85 0A A4 09 C0 00 F0 11 88 B9 D5 C2
C5 0A D0 F4 8A D9 D5 C3 D0 EE 98 18 60 A4 09 E6 09 D0 01 60 A5 0A 99 D5 C2 8A
99 D5 C3 98 99 D5 C4 18 60 A6 0B E4 09 30 01 60 BD D5 C5 C5 0B 30 09 A9 00 9D
D5 C5 E6 0B D0 E9 A8 FE D5 C5 8A 29 01 D0 02 A0 00 BD D5 C4 59 D5 C4 9D D5 C4
59 D5 C4 99 D5 C4 5D D5 C4 9D D5 C4 A9 00 85 0B 18 60 A8 A5 0C D0 08 A9 20 C5
0D F0 21 A5 0C 8D 1E C2 8D 21 C2 A5 0D 09 60 8D 1F C2 49 E0 8D 22 C2 8C FF FF
8E FF FF E6 0C D0 02 E6 0D 18 60 86 0E 84 0F A5 0D 09 60 8D 54 C2 49 E0 8D 5F
C2 A6 0C CA E0 FF D0 10 AC 54 C2 88 C0 60 10 02 18 60 8C 54 C2 CE 5F C2 BD 00
FF C5 0E F0 04 C5 0F D0 E0 BD 00 FF C5 0E F0 04 C5 0F D0 D5 38 60 A2 00 86 FC
86 FD 86 FE BD D5 C4 A8 A6 FE E4 FC 10 11 BD D5 C7 AA 20 2B C2 90 14 E6 FE A6
FE E4 FC D0 EF A6 FD BD D5 C4 A6 FC E6 FC 9D D5 C7 E6 FD A6 FD E4 09 D0 16 A6
FB E4 FC 10 0F A2 00 BD D5 C7 9D D5 C6 E8 E4 FC D0 F5 86 FB 60 A0 00 84 FE F0
B5

Online demo
Usage: Start with sys49152, then enter the pairs one per line like e.g.
15 1073
23 764
23 1073
12 47
47 15
1073 764

Backsapce isn't handled during input (but if you use vice, just copy&paste your input into the emulator). Enter an empty line to start calculation.
This is too large to post an explanatory disassembly listing here, but you can browse the ca65-style assembly source. The algorithm is very inefficient, it generates every possible permutation of the nodes and with each of these greedily builds a clique by checking all the edges. This allows for a space efficiency of O(n) (kind of important on a machine with this little RAM), but has horrible runtime efficiency (*). The theoretical limits are up to 256 nodes and up to 8192 edges.

-71 bytes: optimized routine for checking edges and zeropage usage

There's a larger (883 805 bytes) version with better features:

visual feedback during calculation (each permutation of the nodes changes the border color)
uses bank switching to store the edges in the RAM "hidden" by the ROMs to conserve space
outputs the size and the nodes of the maximal clique found

Online demo
Browse source

(*) The last test case takes something between 12 and 20 hours (I was sleeping when it finally finished). The other test cases finish at worst within some minutes.

Python 2, 180 bytes
G=input()
m=0
L=len
for i in range(2**L(G)):
 u=[];p=sum([G[j]for j in range(L(G))if 2**j&i],u)
 for j in p:u+=[j][j in u:]
 m=max(m,L(u)*all(p.count(j)==L(u)-1for j in u))
print m

Try it online!
-2 thanks to shooqie.
-1 thanks to Mr. Xcoder.
-3 thanks to recursive.

You can save two bytes by assigning len to a variable

183 bytes. (x not in y) means 0**(x in y).

@Mr.Xcoder I knew there was a way to shorten it! Thanks!

I have never used that before, just a trick that crossed thorugh my mind a couple of days ago but couldn't find a use to it yet.

@Mr.Xcoder Doesn't matter, if it works then why not? :D BTW you can also replace 0** with -~-.

I believe [j]*0**(j in u) can be replaced with [j][j in u:] for -3.

@EriktheOutgolfer Now this is strange: This gave me again 2 with my msys2 installation of python on windows for the last test case ... but testing it on a linux machine (some older Debian), it indeed returned 6! Just wanted to let you know, I guess it's the same algorithm as the other answer? Looks like a strange case of "code ok, bug in execution environment" (or maybe undefined behavior, but I didn't think python had this concept ...)

@FelixPalmen Well, to be honest, I've never tried that with an "msys2" implementation of python or anything...on windows (which I rarely use) I just have the normal python installation.

@recursive hey that's clever!

@EriktheOutgolfer it just simplifies things as it comes with a linux-like package manager -- should be the same code though ... well, sorry for the hassle, it really seems to be buggy.

You should be able to assign range to a var as well e.g. R=range which will save 6 bytes.

@Scironic Tried that...won't save any.

Damn I miscounted - you are right.

Pyth, 19 bytes
l{ef.AqLtl{T/LTTsMy

Try it here.

Python 2, 102 bytes
def f(g):
 x=g
 while x:y=x;x=map(set,{tuple(u|v)for u in x for v in x if u^v in g})
 return len(y[0])

Try it online!

05AB1E, 19 bytes
æ€˜ʒDÙg<s{γ€gQP}θÙg

Try it online!

Let us continue this discussion in chat.

Pyth, 28 bytes
l{sSef<T.{SMQm.{ft{T.Cd2yS{s

Try it online
Explanation
l{sSef<T.{SMQm.{ft{T.Cd2yS{s
                         S{sQ  Get the distinct nodes in the (implicit) input.
                        y      Take every subset.
             m      .Cd2       Get the pairs...
                ft{T           ... without the [x, x] pairs...
              .{               ... as sets.
     f<T                        Choose the ones...
        .{  Q                   ... which are subsets of the input...
          SM                    ... with edges in sorted order.
    e                           Take the last element (largest clique).
l{sS                            Get the number of distinct nodes.

Python 3, 162 159 bytes
lambda x,f=lambda x:{i for s in x for i in s}:len(f(x))if all([(y,z)in x or(z,y)in x for y in f(x)for z in f(x)if y<z])else max(c(x.difference({y}))for y in x)

Try it online!
Function c takes vertices in the form of a set of sorted tuples ({(x,y),...} where x is less than y). A function called "entry" is in the TIO header to test with data in list of unsorted lists format. If clique, returns length. If not clique, returns max clique size of vertices, minus a vertice for each vertice in vertices. Exceeds time on last test case in TIO
Update: "or(z,y)in x" portion added to remove dependency on sortedness
"f=lambda x:{i for s in x for i in s}" instead of itertools.chain wrapped in set.
-minus 3 bytes thanks to @Jonathan Allen

You may not assume the input edges are sorted.

Aside - you do not need to name c, so can remove c= (you'd need to put c=\ at the end of the header and place the lambda at the top of the code block for TIO)

Also you can get rid of s and replace s(...) with {*...} allowing the removal of some spaces too.

@JonathanAllan thanks, sortedness fixed

Jelly, 28 bytes
œ^e³;U¤
Œcç/Ðfœ|Ṣ¥/€QµÐĿ-ịḢL

Try it online!
Faster solution that is able to solve the last test case in a second on TIO.

And what complexity does this have? If it's anything lower than O(2ⁿ) then it deserves $1,000,000.

@EriktheOutgolfer, you are wrong, there are algorithms which have O(1.1888ⁿ) runtime.

Adding to that, to be worth a million, the n may only appear in the bases :)

@FelixPalmen, or it can' t. Anyway, for million one of two statements must be proved.

@rus9384 "it can't" would need proof --- while finding a polynomial algorithm here would be instant proof that P=NP (the problem is NP complete) :)

@FelixPalmen, of course it would, but it can't be heuristics for the proof.

I believe this is O(1.414^n). You can see worse performance when the input is a complete graph.

Java + Guava 23.0, 35 + 294 = 329 bytes
import com.google.common.collect.*;
a->{int l=0,o=1,c,z=a.size();for(;o>0&l<z;){o=0;c:for(Iterable<int[]>s:Sets.combinations(a,l*(l+1)/2)){Multiset<Integer>m=TreeMultiset.create();for(int[]x:s){m.add(x[0]);m.add(x[1]);}c=m.elementSet().size();for(int e:m.elementSet())if (m.count(e)!=c-1)continue c;l+=o=1;break;}}return z<3?2:l;}

This algorithm is not graphing, but instead is generating all combinations of pairs, of a specific size. I feed all pair-combinations into a multiset and check that they all have the expected size (the number of unique entries - 1). If they do, I found a clique and I go look for a bigger one.
From the Guava library, I use the new combinations method, and the tool-collection-type Multiset.
Ungolfed
import com.google.common.collect.*;
import java.util.function.*;

public class Main {

  public static void main(String[] args) {
    ToIntFunction<java.util.Set<int[]>> f
        = a -> {
          int l = 0, o = 1, c, z = a.size();
          for (; o > 0 & l < z;) {
            o = 0;
            c:
            for (Iterable<int[]> s : Sets.combinations(a, l * (l + 1) / 2)) {
              Multiset<Integer> m = TreeMultiset.create();
              for (int[] x : s) {
                m.add(x[0]);
                m.add(x[1]);
              }
              c = m.elementSet().size();
              for (int e : m.elementSet()) {
                if (m.count(e) != c - 1) {
                  continue c;
                }
              }
              l += o = 1;
              break;
            }
          }
          return z < 3 ? 2 : l;
        };
    int[][][] tests = {
      {{1, 2}},
      {{1, 2}, {3, 1}, {3, 4}},
      {{1, 2}, {2, 5}, {1, 5}},
      {{2, 5}, {2, 3}, {4, 17}, {1, 3}, {7, 13}, {5, 3}, {4, 3}, {4, 1}, {1, 5}, {5, 4}},
      {{15, 1073}, {23, 764}, {23, 1073}, {12, 47}, {47, 15}, {1073, 764}},
      {{1296, 316}, {1650, 316}, {1296, 1650}, {1296, 52}, {1650, 711}, {711, 316}, {1650, 52}, {52, 711}, {1296, 711}, {52, 316}, {52, 1565}, {1565, 1296}, {1565, 316}, {1650, 1565}, {1296, 138}, {1565, 138}, {1565, 711}, {138, 1650}, {711, 138}, {138, 144}, {144, 1860}, {1296, 1860}, {1860, 52}, {711, 1639}}
    };
    for (int[][] test : tests) {
      java.util.Set<int[]> s = new java.util.HashSet<int[]>();
      for (int[] t : test) {
        s.add(t);
      }
      System.out.println(f.applyAsInt(s));
    }
  }
}

I'd be very surprised, see Finding maximum cliques in arbitrary graphs -- but it'll take me a while to analyze this code, I'm not too familiar with Java :)

@FelixPalmen  I liked this challenge so my answer will stay no matter what, but I'm totally okay with removing the "-1" if it's not a polynomial complexity. Then I should probably go review some books :P

"Combination of size x is polynomial" <- are you sure? I guess that's the method used. The return value is an AbstractSet with an iterator, and the following for loop will call this iterator x! times if I'm not mistaken...

Correction: as long as x < n (with n being the complete size of the input set), it's n!/(x!(n-x)!), still not polynomial :)

@FelixPalmen You're most likely right. Also, are you saying that if I make a combinations method that's X^n (which is entirely possible), I can get it? Meanwhile, I remove my claim of the "-1".

I don't think so because even with a function creating all the combinations in advance and doing that in polynomial time, you'd still have to iterate over the result of this (which has a size up to x!) ... or do I misunderstand your approach here?. As already commented a few times, if you can really do it, you'll be rich soon ;) (the current benchmark for the problem is O(1.888ⁿ) )

As I said, I might have to review books to properly understand polynomial complexity :)

C (gcc), 790 778 757 748 731 687 642 632 bytes
typedef struct F F;typedef struct{int c,p;F**m;}g;struct F{int d;g f;};g*a,S,y,q,*x=&y,*p=&q,Q;A(g*g,F*s){g->c++[g->m=g->c-g->p?g->m:realloc(g->m,(g->p+=32)*20)]=s;}i,c[999],b,j,k,l,*s;*B(d){s=0;for(i=S.c;i--;)s=S.m[i]->d-d?s:S.m[i];!s?s=calloc(5,4),*s=d,A(&S,s):0;s=s;}F*u,*v;E(){for(i=-1;b=++i<S.c;b&&A(x,S.m[i]))for(l=x->c;k=l--*b;b&=!k)for(j=(Q=x->m[l]->f).c;j--&&(k=Q.m[j]->d-S.m[i]->d););x->c>p->c?a=x,x=p,p=a:0;x->c=0;}main(){for(;~scanf("%d %d",&a,&b)&&A(&(u=B(a))->f,v=B(b))|~A(&v->f,u););for(E();b<S.c;)c[b]>=b?c[b++]=0:E(S.m[b]=a,S.m[i]=S.m[b],a=S.m[i=b%2*c[b]++]);for(printf("%d,",i=p->c);i--;)printf(" %d",p->m[i]->d);}

This is a slightly golfed version of the reference implementation. Thanks to @jdt for -5.
Try it online!
Slightly golfed less
typedef struct F F;
// student group
typedef struct{
  int c, // count
      p; // capacity
  F**m;  // members
}g;
// student
struct F{
  int d; // id
  g f;   // friends
};
g*a,S,y,q,*x=&y,*p=&q,Q;
A(g*g,F*s){
  g->c++[g->m=g->c-g->p?g->m:realloc(g->m,(g->p+=32)*20)]=s;
}
i,c[999],b,j,k,l,*s;
*B(d){
  s=0;
  for(i=S.c;i--;)
    s=S.m[i]->d-d?s:S.m[i];
  !s?
    s=calloc(5,4),
    *s=d,
    A(&S,s)
  :
    0;
  s=s;
}
F*u,*v;
E(){
  for(i=-1;b=++i<S.c;b&&A(x,S.m[i]))
    for(l=x->c;k=l--*b;b&=!k)
      for(j=(Q=x->m[l]->f).c;j--&&(k=Q.m[j]->d-S.m[i]->d););
  x->c>p->c?
    a=x,
    x=p,
    p=a
  :
    0;
  x->c=0;
}
main(){
  for(;~scanf("%d %d",&a,&b)&&A(&(u=B(a))->f,v=B(b))|~A(&v->f,u););
  for(E();b<S.c;)
    c[b]>=b?
      c[b++]=0
    :
      E(S.m[b]=a,S.m[i]=S.m[b],a=S.m[i=b%2*c[b]++]);
  for(printf("%d,",i=p->c);i--;)
    printf(" %d",p->m[i]->d);
}

Pyth, 17 bytes
l{seq#.c{sT2tySSM

Try it online!

SSM: Sort each edge, then sort the edges.

y: Form all subsets of edges, with each subset in sorted order. The subsets are ordered by increasing length.

t: Remove the first subset, which is the empty subset, as it would cause the program to crash.

q#: Filter over the subsets on the following resulting in an identical list of edges as the particular subset.

{sT: Sum the list and deduplicate, giving all vertices in any of the edges. If the subset was a clique, the vertices will be in sorted order.

.c ... 2: All distinct pairs of vertices, in sorted order.

e: The filter returns all cliques. Take the last clique, which is the largest clique.

{s: Sum and deduplicate, giving the vertices in the largest clique.

l: Length of the longest clique.

Apparently, during the brief window from May 2017 to Nov. 2017, during which this challenge was posted, sY returned an empty list, rather than 0, as it currently does, so the t could have been removed for -1 byte. Before and after, this would cause a crash. See commit 5b973af89b, which was the most recent commit when this challenge was posted.


text:
Make a ;#*:) interpreter
A few month back, I made a language called ;# (Semicolon Hash) and it started a little bit of a craze (it even got its own tag, as you can see). But, as with everything, the craze died down, and questions related to it stopped being posted.
However, a few people were annoyed at the lack of capability of ;# and this lead to someone creating a Turing complete version. Eventually, I decided to create ;# 2.0 with an extended set of commands:
; - Increment the accumulator
# - Modulo the accumulator by 127, output as ASCII character and reset the accumulator to 0
: - Open a while loop
) - Close a while loop. You can assume that all loops will be closed.
* - Take a byte of input, and add it to the accumulator. Input is recycled, so if the end of the input is reached, it wraps around to the start.

FYI: ;#*:) still isn't Turing complete
For example, a cat program would be
*:#*)

*     - Take a byte of input
 :  ) - While the input character is not a null byte...
  #   -   Print as character
   *  -   Take a byte of input

For this, the input must be terminated with a null byte, otherwise the program will repeat the input until the heat death of the universe.
and to add two numbers (input and output as char codes):
**#

*   - Take input (e.g. \x02); A=2
 *  - Take input (e.g. \x03); A=5
  # - Output A as character (\x05)

Your task is to interpret ;#*:). Your program/function will be given 2 inputs, the program and the program's input, and you have to interpret the given program.
A few rules:
1) Your program may not halt termination due to an error unless 2) happens. Output to STDERR is allowed, just so long as it doesn't affect the program's execution.
2) If the second input is empty (a ;#*:) program with no input) and * occurs in the code, you don't have to handle the error and can cause any kind of behaviour you want; summon Cthulhu, make Dennis lose his rep, anything you want.
3) All characters that aren't ;#*:) are ignored and have no effect on anything.
Nested loops can happen, and all loops will be closed, so ;:*:#*);) is valid code
This is a code golf, so shortest code wins.
Some tests to check your program against:
program, input (as ASCII characters; \xxx is a byte literal) => output

*#*:#*), "1" => 11111111...
**#, "12" => c
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#, "abc" => Hello, World!
*#, "" => undefined
Hello, World!, "" => (nothing)
*:#*):;#*)*#, "Hello,\x00World!" => Hello,W
*:#*), "Testing\x00" => Testing
*:#*), "Testing" => TestingTestingTestingTesting...
;:*:#*);*), "123\x00" => 223d3d3d...

And, to help you even more, this is an ungolfed reference implementation in Python. In this version, I have decided to make the * on empty input be ignored.
Good luck!

Is a transpiler allowed?

@Okx no, that'd be a separate challenge

Can you clarify Nested loops can happen when paired with You can assume that all loops will be closed?

Ummm, I love rule #2.

If it makes Dennis lose his rep then I'll be glad to have undefined behavior ;) somebody else be the #1 rep I like it

Someone, k

@ConorO'Brien at least I acknowledged you.

In R, the NUL character is no longer allowed in strings as of 3.1.3 so this challenge is impossible in newer versions of the language (and it truncated strings before, so this is probably impossible in older ones as well)

Hm, "while loop" means while(accumulator > 0) { ... }? It's not really specified in the challenge...

@Ramillies it is quite clear in the cat program example

Ruby, 147 144 bytes
Saved 3 bytes thanks to m-chrzan!
z=STDIN.read
eval ARGV[i=a=0].gsub(/./){|e|"#{{?;=>"a+=1",?#=>"putc(a%127);a=0",?:=>"while a>0",?)=>"end",?*=>"a+=z[i%=z.size].ord;i+=1"}[e]};"}

Try it online!
Program is taken from first command line argument.

You're not handling rule 3 - breaks on unexpected characters in the program.

@m-chrzan Oops, I forgot threeish chars, one sec

@m-chrzan Thanks again, fixed

Using string interpolation saves 3 bytes ("#{{...}[e]};").

Python 3, 261 253 bytes
-8 bytes thanks to @Mr.Xcoder
p,i=eval(input());a=k=c=z=0;j=[];m={}
for y in p:
 if':'==y:j+=[z]
 if')'==y:b=j.pop();m[b]=z;m[z]=b
 z+=1
while p[c:]:
 y=p[c];a+=';'==y
 if'*'==y:a+=ord(i[k%len(i)]);k+=1
 if'#'==y:print(end=chr(a%127));a=0
 if y in':)':c=[c,m[c]][(a>0)>(')'<y)]
 c+=1

Try it online!
Python 3, 253 bytes
Same length using exec
p,i=eval(input());a=k=c=z=0;j=[];m={}
for y in p:
 if':'==y:j+=[z]
 if')'==y:b=j.pop();m[b]=z;m[z]=b
 z+=1
while p[c:]:y=p[c];exec('a+=1 print(end=chr(a%127));a=0 a+=ord(i[k%len(i)]);k+=1 c=[c,m[c]][a<1] c=[c,m[c]][a>0] 1'.split()[';#*:)'.find(y)]);c+=1

Try it online!

Wouldn't switching to Python 2 save bytes?

@cairdcoinheringaahing print(end=...) would be pretty expensive in python2

253 bytes

252 (-1 byte) by using lexicographical comparison (sorry for golfing byte-to-byte).

@Mr.Xcoder this would not work as we need to ignore every character which is not in ";#*:)"

Oh  yeah, sorry.


text:
First spiral, then diagonal
Given a positive input number \$n\$, construct a spiral of numbers from \$1\$ to \$n^2\$, with \$1\$ in the top-left, spiraling inward clockwise. Take the sum of the diagonals (if \$n\$ is odd, the middle number \$n^2\$ is counted twice) and output that number.
Example for \$n = 1\$:
1

(1) + (1) = 2

Example for \$n = 2\$:
1 2
4 3

(1+3) + (4+2) = 4 + 6 = 10

Example for \$n = 4\$:
 1  2  3 4
12 13 14 5
11 16 15 6
10  9  8 7

(1+13+15+7) + (10+16+14+4) = 36 + 44 = 80

Example of \$n = 5\$:
 1  2  3  4 5
16 17 18 19 6
15 24 25 20 7
14 23 22 21 8
13 12 11 10 9

(1+17+25+21+9) + (13+23+25+19+5) = 73 + 85 = 158

Further rules and clarifications

This is OEIS A059924 and there are some closed-form solutions on that page.
The input and output can be assumed to fit in your language's native integer type.
The input and output can be given in any convenient format.
You can choose to either 0-index or 1-index, as I am here in my examples, for your submission. Please state which you're doing.
Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
If possible, please include a link to an online testing environment so other people can try out your code!
Standard loopholes are forbidden.
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

R, 43 34 bytes
function(n)(8*n^3-3*n^2+4*n+3)%/%6

Try it online!
The OEIS page lists the following formula for a(n):
(16*n^3 - 6*n^2 + 8*n + 3 - 3*(-1)^n)/12

However, I skipped right over that to get to the PROG section where the following PARI code is found:
floor((16*n^3 - 6*n^2 + 8*n + 3 - 3*(-1^n))/12))

Naturally, +3-3*(-1^n) is the same as +6 so we can simplify the linked formula, first by reducing it to
(16*n^3-6*n^2+8*n+6)/12 -> (8*n^3-3*n^2+4*n+3)/6

and using %/%, integer division, rather than / to eliminate the need for floor.

+3-3*(-1)^n is not really same as 6, although the difference is lost in integer division.

@fergusq you're right, but the formula given as the expression in PARI (which I base my solution on) has +3-3*(-1^n) which is the same as +6. I will update my answer to make that more obvious.

@Giuseppe It's +6 if n is odd, but +0 when n is even

@Bergi 3-3*(-1^n) is always 6 but 3-3*(-1)^n has that alternating behavior. The original formula has the latter, which makes the use of integer division unnecessary, as it is always divisible by 12

Ah, right. It's weird though that the original author overlooked this, isn't it?

Congrats on 7k (you had 6,999 before I upvoted)

Python 2, 30 bytes
Saved some bytes by porting Giuseppe's approach.
lambda n:((8*n-3)*n*n+4*n+3)/6

Try it online!
Python 2,  36  34 bytes
Saved some more bytes thanks to @LeakyNun.
lambda n:((8*n-3)*n*n+4*n+n%2*3)/6

Try it online!

36 bytes

34 bytes

@LeakyNun Thanks and Thanks.

30 bytes credits to Giuseppe for approach

@LeakyNun I was updating with that too

Mathematica, 19 bytes
((8#-3)#*#+4#+3)/6&

Try it online!
Saved some bytes by porting Giuseppe's approach.
Mathematica, 58 bytes
I always enjoy questions with given answers
thanx to oeis (for the nice question and answer)
LinearRecurrence[{3,-2,-2,3,-1},{0,2,10,34,80},2#][[#+1]]&

Wouldn't it be golfier to use the closed form?

many answers are using my simplification, so you may as well do the same

Mathematica, 19 bytes
((8#-3)#*#+4#+3)/6&

You can run it with the following syntax:
((8#-3)#*#+4#+3)/6&[5]

Where 5 can be replaced with the input.
You can Try it in the Wolfram Sandbox (Copy-Paste + Evaluate Cells)

Jelly, 11 10 bytes
1 byte thanks to Jonathan Allan.
⁽ø\DN2¦ḅ:6

Try it online!

8,-3,4,3 -> ⁽ø\DN2¦ to save one byte

SOGL V0.12, 25 15 14 bytes
8*3-**4.*+3+6÷

Try it Here!
Translation of Mr.Xcoder's Python answer which is using Giuseppe's approach. SOGL's not winning anything here :p

MATL, 21 bytes
tt2^Qw6Y3YL-wXytP+*ss

Try it online!

You can shorten a bit with UQG1YL-tP,wXds]+

Cubix, 33 bytes
I:u8**.../\*3t3n*3t+u@O,6+3+t3*4p

Try it online!
cube version:
      I : u
      8 * *
      . . .
/ \ * 3 t 3 n * 3 t + u
@ O , 6 + 3 + t 3 * 4 p
. . . . . . . . . . . .
      . . .
      . . .
      . . .

Implements the same algorithm as my R answer. I suspect this can be golfed down.

05AB1E,  13  12 bytes
Uses the same base-conversion technique as Leaky Nun's Jelly submission
Maybe there is a shorter way to create the list of coefficients?
-1 byte thanks to Datboi (use spaces ans wrap to beat compression(!))
8 3(4 3)¹β6÷

Try it online!
How?
8 3(4 3)¹β6÷               stack: []
8            - literal            ['8']
  3          - literal            ['8','3']
   (         - negate             ['8',-3]
    4        - literal            ['8',-3,'4']
      3      - literal            ['8',-3,'4','3']
       )     - wrap               [['8',-3,'4','3']]
        ¹    - 1st input (e.g. 4) [['8',-3,'4','3'], 4]
         β   - base conversion    [483]
          6  - literal six        [483,6]
           ÷ - integer division   [80]
             - print TOS           80

My 13s...
•VŠ•S3(1ǝ¹β6÷

•2ùë•₂в3-¹β6÷

•мå•12в3-¹β6÷

All using compressions to find the list of coefficients.

8 3(4 3)¹β6÷ to safe 1 byte (no fancy compression though)

Java 8, 24 bytes
n->((8*n-3)*n*n+4*n+3)/6

Port of @Giuseppe's R answer.
Note that /6 floors by default when calculating with integers in Java.
Try it here.

Excel, 35 30 bytes
Saved 5 bytes using Giuseppe's approach.
=INT((8*A1^3-3*A1^2+4*A1+3)/6)

First attempt:
=(8*A1^3-3*A1^2+4*A1+3*MOD(A1,2))/6

Evolved from a direct implementation of formula from OEIS (37 bytes):
=(16*A1^3-6*A1^2+8*A1+3-3*(-1)^A1)/12

+3-3*(-1)^A1 logic can be changed to 6*MOD(A1,2).
=(16*A1^3-6*A1^2+8*A1+6*MOD(A1,2))/12

Does not save bytes, but allows removal of a common factor for 2 bytes.

Gaia, 14 bytes
8×3⁻××@4×+3+6/

Try it online!

Pyth, 17 bytes
/+3+*^Q2-*8Q3*4Q6

Try it here.

Pyke, 14 bytes
8*3-**Q4*+3+6f

Try it here!

05AB1E, 14 bytes
8*3-**4I*+3+6÷

Try it online!

MATL, 12 bytes
[DcKI]6/iZQk

Try it at MATL Online!
Explanation
Same approach as Giuseppe's answer.
[DcKI]   % Push array [8, -3, 4, 3]
6/       % Divide each entry by 6
i        % Push input
ZQ       % Evaluate polynomial
k        % Round down. Implicitly display

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Draw diagonal positions of me squared
Based on the interpretation user @ThePirateBay made from the first version of my own challenge
Output diagonal positions of me squared
now I challenge you to make ASCII art that draws diagonal lines based on a square character matrix  based on a given number n.
Input
A number n.
Output
A square matrix of size n^2 which outputs diagonals represented by the adequate one of the \ X /chars. All other positions are to be fulfilled with # chars.
Examples:
1
X

2
\/
/\

3
\#/
#X#
/#\

4
\##/
#\/#
#/\#
/##\

5
\###/
#\#/#
##X##
#/#\#
/###\

There will be no accepted answer. I want to know the shortest code for each language.

@ThePirateBay: Thanks! Just published it!

Is outputting a list of lines ok?

@Mr.Xcoder What do you mean by "a list of lines"? Isn't my representation a list of lines?

No. I meant array, like ["\/", "/\"] for 2?

No. It is not valid. I specifically asked for [tag:ascii-art].

This isn't a dupe. Aside from Charcoal, not a lot of languages can be trivially modified to create a background of #'s. I'm voting to reopen.

The background of octothorpes, the X in the middle if input is odd and each line in the big X is as long as input, not double the size. I think it's not a dupe.

The output for even inputs makes this not a dupe (along with the other comments)

I believe this to still be a duplicate. Here is a trivial change made to the MATL answer on the duplicate question. NB: I don't even know MATL.

@H.PWiz: Can you prove the reasoning of making a trivial change to a Draw a big slash X answer holds true for a lot of languages?

No, but it works for all that indexed into a string that looked something like "\/X ", e.g This

Jelly, 14 bytes
⁼þµḤ+Ṛị“/\X#”Y

A monadic link taking a number and returning a list of characters; or a full program printing the result.
Try it online! or see [1-12] in one go.
How?
⁼þµḤ+Ṛị“/\X#”Y - Link: number, n
 þ             - outer product (implicit range build on left AND right from n) with:
⁼              -   is equal (yields a table of 0s except the main diagonal is 1s)
  µ            - monadic chain separation, call that I
   Ḥ           - double (change all the 1s to 2s)
     Ṛ         - reverse I (a table of 0s with 1s as the anti-diagonal)
    +          - add (vectorises to make a table of zeros with 2s on the diagonal,
               -      1s on the anti-diagonal and, if the meet, a 3 at the centre)
       “/\X#”  - literal list of characters ['/','\','X','#']
      ị        - index into (replaces... 1:'/'; 2:'\'; 3:'X'; and 0:'#')
             Y - join with newline characters
               - as a full program: implicit print

Clever approach!

Python 2, 83 bytes
n=input()
for i in range(n):l=['#']*n;l[i],l[~i]='\X/X'[i-~i==n::2];print''.join(l)

Try it online!
-3 thanks to Jonathan Frech and G B.

Your TIO link has a footer artifact.

@JonathanFrech I realized a version of mine was invalid and quickly rolled back...

I noticed... :P

Is not n/2.-.5 equivalent to ~-n/2.?

@JonathanFrech missed that

And if you multiply instead of dividing you can save another byte: n==1+i*2

@GB But that is equivalent to n==i-~i.

@JonathanFrech I think that works. EDIT: yep

I thought I could steal that for my ruby answer, but it doesn't work.

Ruby, 73 61 59 bytes
->n{(0...n).map{|x|w=?#*n;w[x],w[~x]=?\\,n==1+x*2??X:?/;w}}

Try it online!

Charcoal, 21 bytes
ＵＢ#Ｎν↗∕ν²×X﹪ν²‖ＢＯL﹪ν²

Try it online! Verbose version.

There's a neat trick to save two bytes by using multidirectional mirrors. In your case, either L or ¬ would work, but you would have to draw your line in a different direction of course.

Note that the deverbosifier allows you to omit the else, so what you're seeing there is "if v is odd, draw an X and reflect with overlap (so that the X is not itself reflected) otherwise reflect without overlap".

You can actually save a byte by using ReflectButterflyOverlap which takes a second parameter which is the amount of overlap. If you give it an overlap of 0 then you get a ReflectMirror and if you give it an overlap of 1 then you get a ReflectButterfly.

Try it online!

SOGL V0.12, 16 bytes
.↔╝Ζ #ŗ.2%?╬3←╬¡

Try it Here!
Finally got use out of the fact that palindromizating / or \ on the edge creates X (but this could be ~5 bytes less with a couple features I have had in mind for a while (e.g. that overlapping would overlap slashes too and palindomizating commands have the option to choose the overlap amount from the remainder of ceiling dividing))
Explanation:
.↔                push input ceiling-divided by 2 (. is required because SOGLs input is taken lazily)
  ╝               create a diagonal of that length
   Ζ #ŗ           replace spaces with hashes
       .2%?       if the input % 2 isn't 0
           ╬3       palindromize with 1 overlap
             ←      stop program
              ╬¡  [else] palindromize with 0 overlap

R, 68 bytes
write(c("#","\\","/","X")[(d=diag(n<-scan()))+d[n:1,]*2+1],"",n,,"")

Try it online!
Reads n from stdin. Creates a matrix of indices (d=diag(n))+d[n:1,]*2+1 to index into the vector of characters to print, which results in a vector of characters. write writes it as a matrix to "" (stdout) with n columns and separator "".

MATL, 14 bytes
'\/X#'iXytPE+)

Try it online!
Explanation: suppose the input is 3
'\/X#'               push this character string.
i                    read in input. stack is ['\/X#';3]
Xy                   push nxn identity matrix.
                     stack is ['\/X#'; [1 0 0 ; 0 1 0 ; 0 0 1]]
tP                   duplicate and flip left-right
                     stack is ['\/X#'; [1 0 0 ; 0 1 0 ; 0 0 1];
                                       [0 0 1 ; 0 1 0 ; 1 0 0]]
E+                   double TOS and add top 2 stack elements
                     stack is ['\/X#'; [1 0 2 ; 0 3 0 ; 2 0 1]]
)                    index; 1-based modular, so
                     1 -> \, 2 -> /, 3 -> X, 0 -> #
                     implicit output.

Javascript, 103 bytes
n=>{for(let i=n,j,s;i--;){s="";for(j=n;j--;)s+=i==j?n-j-1==j?"X":"\\":n-j-1==i?"/":"#";console.log(s)}}

Try it online!
A more readable version with spaces and breaks added:
n => {
  for (let i = n, j, s; i--;) {
    s="";
    for (j = n; j--;)
      s += i == j
        ? n - j - 1 == j
          ? "X"
          : "\\"
        : n - j - 1 == i
          ? "/"
          : "#";
    console.log(s)
  }
}

You can save a few bytes by using a return statement instead of logging it.

Thanks @StephenLeppik, but I thought I had to output the result? Would I have to include "\n" after each line?

You do have to output it, but on this site your return value is valid output.

Husk, 20 bytes
´Ṫ§o!"¦/X#"+=ȯD=←¹+ŀ

Try it online!

V, 24 bytes
Àé#ÀÄòr\jlò|òr/klòÇÜ/ãrX

Try it online!

Python 2, 133 bytes
def f(k,h="#"):s=[h*i+"\\"+h*(k-i*2-2)+"/"+i*h for i in range(k/2)];print"\n".join(s+k%2*[k/2*h+"X"+k/2*h]+[e[::-1]for e in s[::-1]])

Try it online!
A beautiful mess done on mobile :-). If you have golfing suggestions, you are welcome to edit in yourselves (and credit you!), because I will be sleeping :P.

Python 2, 122 bytes
def f(n):s='\\'+'#'*(n-2)+'/';return['x'][:n]if n<2else[s]+['#'+l+'#'for l in f(n-2)]+[s[::-1]]
print'\n'.join(f(input()))

Try it online!
A recursive aproach

Mathematica, 114 bytes
(s=#;F[x_]:=DiagonalMatrix[Table[x,s]];z=F@"\\"+Reverse@F@"/"//. 0->"#";If[OddQ@s,z[[t=⌈s/2⌉,t]]="X"];Grid@z)&

Perl 5, 81 bytes
for$i(0..($n=<>)-1){$_='#'x$n;s|.{$i}\K.|\\|;s%.(.{$i})$%/$1%;s%/%X% if!/\\/;say}

Try it online!

Canvas, 15 bytes
：：#×＊；＼：↔１１╋１１╋

Try it online!
could get it to 11 bytes if canvas's overlap function had a default setting but it doesn't so...

You don't need the starting ：： as the stack (practically) contains the inputs repeated forever. And yeah, I need to add a 1 byte built-in for １１╋

Mathematica, 99 bytes
FromCharacterCode[(2#+Reverse@#+2)&@DiagonalMatrix[45~Table~#]/.{2->35,137->88}]~StringRiffle~"\n"&

This uses a somewhat different technique from the other Mathematica solution. Also, we should probably start calling it the Wolfram Language at some point.