text:
Implement 1-dimensional version of Multi-Take
Background
Adám and I were once discussing a way to properly extend some features in Dyalog APL. I came up with the following extension to Take, a function that takes some front or back elements (and an analogous extension to Drop). We agreed that it was a good idea, but it was incredibly hard to come up with a piece of code that imitates the behavior.
While the original proposal operates on multi-dimensional arrays, this challenge's scope is limited to 1D arrays of numbers. Whenever I mention "array", it implies a 1D array.
The Take function ↑
↑ takes two arguments. One is the array A (of length L), and the other is a single integer N (which can be 0, positive, or negative).
The behavior depends on the value of N:

If 0 ≤ N ≤ L, ↑ takes first N elements of A from the start.
If -L ≤ N < 0, ↑ takes last -N elements of A from the end.
If N > L or N < -L, ↑ performs "overtake", appending (for positive N) or prepending (for negative N) zeros until the array's length becomes abs(N).

It can be thought of applying a Boolean mask to an infinitely zero-padded version of A:
For all cases, A = [1, 2, 3, 4, 5]

For N = 3: (positive simple take)
A     :  ... 0 0 1 2 3 4 5 0 0 ...
Mask  :  ... 0 0 1 1 1 0 0 0 0 ...  # Fill 1s from the start of the array
Result:          1 2 3              # Elements at 0 mask are removed from the array

For N = -4: (negative simple take)
A     :  ... 0 0 1 2 3 4 5 0 0 ...
Mask  :  ... 0 0 0 1 1 1 1 0 0 ...  # Fill 1s from the end of the array
Result:            2 3 4 5

For N = 7: (positive overtake)
A     :  ... 0 0 1 2 3 4 5 0 0 0 ...
Mask  :  ... 0 0 1 1 1 1 1 1 1 0 ...  # The mask overflows the input array
Result:          1 2 3 4 5 0 0

For N = -8: (negative overtake)
A     :  ... 0 0 0 0 1 2 3 4 5 0 0 ...
Mask  :  ... 0 1 1 1 1 1 1 1 1 0 0 ...  # The mask is filled from the end,
                                        # overflowing through the start
Result:        0 0 0 1 2 3 4 5

The proposed extension ("Multi-Take")
The extension allows N to be an array of integers [N1, N2, N3, ..., Nn]. It conceptually generates all the masks to apply to A using each of Ni, and combines all of them by logical OR. Then the mask is applied to A in the same sense as above, giving the resulting array (which may have some contiguous middle elements removed, or have padding in both directions).
Because the identity element for OR is 0, empty N gives all-zero mask, resulting in an empty array (which is equivalent to giving a single zero as N).
For all cases, A = [1, 2, 3, 4, 5]

For N = [1, -2]: (removing a contiguous region)
A        :  1 2 3 4 5
Mask (1) :  1 0 0 0 0  # Taking from start
Mask (-2):  0 0 0 1 1  # Taking from end
OR       :  1 0 0 1 1
Result   :  1     4 5  # [1, 4, 5]

For N = [8, -7]: (padding in both direction)
A        :      1 2 3 4 5
Mask (8) :  0 0 1 1 1 1 1 1 1 1  # Overtaking from start
Mask (-7):  1 1 1 1 1 1 1 0 0 0  # Overtaking from end
OR       :  1 1 1 1 1 1 1 1 1 1
Result   :  0 0 1 2 3 4 5 0 0 0  # [0, 0, 1, 2, 3, 4, 5, 0, 0, 0]

For N = [2, 4, 7]: (for multiple values of same sign, some are simply shadowed)
A        :  1 2 3 4 5
Mask (2) :  1 1 0 0 0 0 0
Mask (4) :  1 1 1 1 0 0 0
Mask (7) :  1 1 1 1 1 1 1
OR       :  1 1 1 1 1 1 1  # Same as simply N = 7 or [7]
Result   :  1 2 3 4 5 0 0  # [1, 2, 3, 4, 5, 0, 0]

For N = []: (empty N gives empty result)
A     :  1 2 3 4 5
Mask  :  (None)     # No mask to apply
OR    :  0 0 0 0 0  # Identity element of OR
Result:  (Empty)    # []

Challenge
Implement the extension, i.e. a program or function that takes an array of numbers A and an array of take amounts N, and outputs the modified array using the mechanism described above.
The "array" can be any sequential container type in your language of choice.
You can assume the elements of A are given in any common number type in your language of choice (or, if you're doing string I/O, represented in the most natural format for your language). Your program should be able to handle empty A and A containing zeros or duplicate elements.
You may assume A contains only integers even if your program accepts floating-point numbers as input.
Standard code-golf rules apply. The shortest code in bytes wins.
Test cases
# These test cases all share A = 1 2 3 4 5
# Should work for any 5-element array A' = a b c d e
# giving the output's 1 2 3 4 5 substituted with a b c d e respectively,
# even if A' contains duplicates or zeros
N = (empty)
Output = (empty)
N = 3
Output = 1 2 3
N = 0
Output = (empty)
N = -4
Output = 2 3 4 5
N = 7
Output = 1 2 3 4 5 0 0
N = -8
Output = 0 0 0 1 2 3 4 5
N = 0 0 0 0 0
Output = (empty)
N = 0 4 2 3
Output = 1 2 3 4
N = -2 -1 0 -7
Output = 0 0 1 2 3 4 5
N = 0 2 -2 1 -1
Output = 1 2 4 5
N = -7 -5 -3 -1 1 3 5 7
Output = 0 0 1 2 3 4 5 0 0

-------------------------
# Noteworthy edge cases
A = 1 4 3 4 5
N = 0 2 -2
Output = 1 4 4 5

A = 1 2 0 4 5
N = 7 -8
Output = 0 0 0 1 2 0 4 5 0 0

-------------------------
# These test cases share A = (empty)
N = (empty)
Output = (empty)
N = 0 0 0 0 0
Output = (empty)
N = 3 1 4
Output = 0 0 0 0
N = -3 -1 -4
Output = 0 0 0 0
N = 3 1 -4 -1 5
Output = 0 0 0 0 0 0 0 0 0 (9 zeros)

If I'm understanding correctly, only the N values with the largest absolute value have any bearing on the final result?

@Jonah Yes, except that positive and negative numbers should be considered separately.

I assume $A$ can also contain negative values?

@KevinCruijssen Yes.

May $A$ also contain floats? I suppose the answer is yes, so I've updated my answer accordingly. But there's some kind of subliminal message in the test cases that suggests otherwise. :p

@Arnauld Actually no, you may assume A contains only integers. This is because it is the default number type in many languages. If you can somehow exploit that, go ahead!

APL (Dyalog Unicode), 58 50 bytes
{{2⊃{⍵[⍒⍴¨⍵]}(⍺,⍵)A⍺(⍵,⍺↓⍨≢A)}/((⌈/,⌊/)0,⍵)↑¨⊂A←⎕}

Try it online!
What better way to implement this than in APL itself? That being said, some of the logic is nontrivial.
Anonymous function that takes N as the right argument and A in standard input.
-2 bytes thanks to @Bubbler
-1 byte thanks to @Adám
Explanation
Even though APL has the take function built-in, combining them requires a bit more work.
Firstly, as @Jonah noted, only the elements of N with the largest absolute value matter to the final result since all elements with smaller absolute value correspond to subarrays of those formed from higher absolute value. Aka, only the largest positive number and the most-negative negative number matter. We obtain those right off the bat with (⌈/,⌊/)0,⍵, where ⍵ is N. This produces a pair of the smallest number and the highest number in 0 appended to N. Appending 0 is important because it guarantees that the two numbers obtained are respectively non-positive and non-negative.
The convenient part is ↑¨⊂A←⎕, where we use APL's built-in take (↑) to obtain two arrays, one (call it m) counting backwards from the end, and one forwards from the start (call it M).
Here, it gets interesting. For non-trivial A, there are several cases to consider:

A =    1 2 3 4 5

1. M ⊆ m:
m: 0 0 1 2 3 4 5
M:     1 2 3
union: m

2. m ⊆ M:
m:         3 4 5
M:     1 2 3 4 5 0 0 0
union: M

3. Both m and M have 0s:
m: 0 0 1 2 3 4 5
M:     1 2 3 4 5 0 0 0
union: m,(the zeros of M)

4. Neither m nor M have 0s, but they overlap:
m:         3 4 5
M:     1 2 3 4
union: A

5. M and m do not overlap:
m:           4 5
M;     1 2
union: M,m

There are different ways to define the unions of the two arrays. For example, the union for case 3 could instead be (the zeros of m),M, but that is less useful for golfing due to precedence. Importantly, case 1 could analogously be defined as m,(the zeros of M) (same as case 3) since M has no zeros in case 1.
For cases 1 to 4, the union desired is the longest one out of A,M, and m,(the zeros of M). For example, in the example for case 2 , M has length 8, which is longer than the other two possibilities: A has length 5, and m,(the zeros of M) has length 6. This holds true for all four of these cases, so all we have to do is compute all 3 possibile unions, then take the longest one.
This evidently does not hold true for case 5. A always has more elements than the desired union, so it would always be selected over M,m. This is only one conditional, so it is not particularly difficult to add in a quick check. However, M,m is the longest in cases 1 to 4, so we can instead take the second-longest out of A,M, m,(the zeros of M), and M,m.
{{2⊃{⍵[⍒⍴¨⍵]}(⍺,⍵)A⍺(⍵,⍺↓⍨≢A)}/((⌈/,⌊/)0,⍵)↑¨⊂A←⎕}
{...}/(⌈/,⌊/)0,⍵}↑¨⊂A←⎕      ⍝ Compute m and M as discussed,
                             ⍝ then pass m as ⍺ and M as ⍵ to the following:
2⊃{⍵[⍒⍴¨⍵]} ⍝ Get the second-longest of:
 ⍺,⍵         ⍝ m,M
 A           ⍝ A
 ⍺           ⍝ M
 ⍵,⍺↓⍨≢A    ⍝ m,(the zeros of M)

Unfortunately, it doesn't work with duplicate elements in A (e.g. A←1 4 3 4 5 and N←0 ¯2 2).

@Bubbler Conveniently, my new golf shouldn't require the set intersection ∩, which was causing the problems ... almost done implementing.

@Bubbler Yep, it worked. Added A←1 4 3 4 5 and N←0 ¯2 2 as a new test case in the TIO link (You might want to add it to the question too).

...and when A has zeros (e.g. A←1 2 0 4 5 and N←7 ¯8). I think changing ⍺[⍸0=⍺] to ⍺↓⍨≢A will fix it.

@Bubbler Yes, it does and saves 2 bytes. Strange how these bugfixes tend to be golfier.

That's a clever way to unify all the cases btw. When two of the arrays are of equal length, they are identical, so it's fine to pick any of them.

(⊂A←⎕)↑⍨¨(⌈/,⌊/)0,⍵ has a parenthesised left argument to a ⍨ed function, which means you can save a byte by un-⍨ing: ((⌈/,⌊/)0,⍵)↑¨⊂A←⎕

Is there any particular reason you take A in standard input instead of as left argument?

@Adám I first referenced A in an inner dfn, which would have required an extra byte to pass as left argument. It's +0 bytes, so I feel no need to change it and the test caller.

JavaScript (ES6),  103 97  96 bytes
Expects (A)(N).
a=>b=>Object.keys(g=x=>x&&g(g[x<0?a.length+x++:--x]=x),b.map(g)).sort((a,b)=>a-b).map(i=>~~a[i])

Try it online!
How?
When it's called with \$x>0\$, the helper function \$g\$ creates a key in its own underlying object for each value in the range:
$$[x - 1, x - 2, ..., 0]$$
When it's called with \$x<0\$, it does the same thing with the range:
$$[L + x, L + x + 1, ..., L - 1]$$
where \$L\$ is the length of the input array \$a\$.
When it's called with \$x=0\$, it does nothing.
g = x =>               // x = input
  x &&                 // stop the recursion if x = 0
  g(                   // otherwise, do a recursive call:
    g[                 //   create a new key in g:
      x < 0 ?          //     if x is negative:
        a.length + x++ //       use a.length + x and post-increment x
      :                //     else:
        --x            //       use x, pre-decremented
    ] = x              //   the value associated to this key doesn't matter,
                       //   so we just use the argument for the next call
  )                    // end of recursive call

We sort all keys created by invoking \$g(x),x\in b\$ in ascending order and map the resulting indices to the values of \$a\$, forcing \$0\$'s when they are out of range.
a => b =>
  Object.keys(
    g = …,
    b.map(g)
  )
  .sort((a, b) => a - b)
  .map(i => ~~a[i])

Python 3, 113 103 bytes
def f(A,N):k=len(A);N+=0,;return[+(-1<i<k)and A[i]for i in sorted({*range(max(N)),*range(k+min(N),k)})]

Try it online!
Bit naive of an approach, but it works pretty well.
-10 bytes thanks to @ovs
Explanation
We generate the sets of all indices of m and M, 0-indexed relative to the start of A. A simple union of these two sets combines the two masks.
def f(A,N):
    k=len(A);
    N+=0,; # Append 0 to ensure that the min/max functions never error
    [
        +(-1<i<len(A))and A[i] # try to get the i-th element of A
        for i in sorted({  # sort the indices to appear in proper order
            # generate the indices
            # 0-indexed starting at the first element of A
            *range(max(N)), # the set of all indices of M¸union:
            *range(k+min(N),k) # the set of all indices of m
        })
    ]

111 bytes using a normal function and creating the indices of m using just a range.

And +(-1<i<len(A))and A[i] for another -1.

103 bytes by optimizing the second range a little further.

@ovs Good ideas. Annoyingly, "assignment expression cannot be used in a comprehension iterable expression," otherwise using Python 3.8 could save a few more bytes.

The code you're displaying isn't what's there if you follow the TIO link.

@Noodle9 fixed.

Charcoal, 34 bytes
⊞η⁰Ｅ⁻±⌊ηＬθ0ＩΦθ∨‹κ⌈η›⁻⊕κＬθ⌊ηＥ⁻⌈ηＬθ0

Try it online! Link is to verbose version of code. Explanation:
⊞η⁰

Much like the other answers, a 0 is pushed to the take list, so that the maximum is at least 0 and the minimum is at most 0.
Ｅ⁻±⌊ηＬθ0

Print 0s for each element taken before the first.
ＩΦθ∨‹κ⌈η›⁻⊕κＬθ⌊η

Print those elements which fall in either the positive or negative range.
Ｅ⁻⌈ηＬθ0

Print 0s for each element taken after the last.

05AB1E, 28 26 bytes
εÝ¨yd≠iIg+<]˜êεIg‹yd*iyèë¾

Inputs in the order \$N,A\$.
Try it online or verify all test cases.
Explanation:
ε              # Map each value `y` in the (implicit) input-list `N` to:
 Ý             #  Push a list in the range [0,`y`]
  ¨            #  Remove the last value to make the range [0,`y`)
   yd≠i        #  If `y` is negative:
       Ig+     #   Add the input-length of `A` to each value
          <    #   And decrease each value by 1
]              # Close the if-statement and map
 ˜             # Flatten the list of indices
  ê            # Sort and uniquify these indices
   ε           # Map each index `y` to:
    Ig‹        #  Check if `y` is smaller than the input-length of `A`
       yd      #  Check if `y` is non-negative (>= 0)
         *i    #  If both are truthy:
           yè  #   Index `y` into the (implicit) input-list `A`
          ë    #  Else:
           ¾   #   Push a 0 instead
               # (after which the resulting list is output implicitly)

Clojure, 90 bytes
#(for[j(sort(set(for[i %2 x(range(Math/abs i))](if(< i 0)(+(count %)i x)x))))](get % j 0))

Try it online!
Takes input in the order: data, indices
Ungolfed
#(for [j
  (->
    ; for each i in indices generate a range from 0 to abs(i)
    (for [i %2 x (range (Math/abs i))]
      ; for negative indices add the offset = length(data) + i
      (if (< i 0) (+ (count %) i x) x))
    set ; keep unique values
    sort)] ; sort in ascending order
  ; for each j, get the jth item in data, or 0 if out of bounds
  (get % j 0))


text:
Shortest Python 3 for sum of arithmetic progression
Input: from STDIN number of vertices in Graph \$2 \leq N \leq 100\$.
Rules: [Code size] = max ([code length without spaces, tabs and newlines], [total code length divided by 4])
Math formulation: In the graph of N vertices, between each pair of vertices can be 3 road states:

there is no road
there is a road from A to B
there is a road from B to A

Find the number of different graphs on given vertices.
We can apply next formula (number of different road states in pow of pairs number): $$\huge3 ^ {\frac{n(n - 1)}{2}}$$.
My Python 3 37 bytes solution here:
n = int(input())
print(3 ** ((n ** 2 - n) // 2))

I know that exists 34 bytes solution. Then I started to think about 1 liner, and find next formula for sum of arithmetic progression, which use N only once:
$$\frac{(2n - 1) ^ 2}{8} - \frac18$$
Unfortunately the code only increased:
x = 2 * int(input()) - 1
print(3 ** ((x ** 2 - 1) // 8))

This is not enough, but n**2 = n*n.

If someone knows how to make inline latex formula, pls edit my question. I don't know why it's not working here.

@mypronounismonicareinstate I looked at this formula for 3 hours and did not see an elephant, thank you.

Does the title really match the challenge text?

@LuisMendo I'm not sure, but it's the main part of this code which you can make shorter.

Note that your 2nd formula can be turned into a 38-byte one-liner. But of course, that's still too long.

@Arnauld I think you can remove the -1 too, but 36 bytes is still too long.

Can the output be produced as a whole-number float like 27.0?

@xnor No, only int allowed.

Python 3, 34 bytes (not counting the newline)
Uses the conventional formula for the sum of the arithmetic progression (\$\frac{n(n-1)}2\$) and the trick that n-1 = ~-n (but with higher operator precedence). This way, one pair of parentheses can be omitted.
n=int(input())
print(3**(n*~-n//2))

Try it online!

Is it possible to get real binary representation of -n? How many bits it use? Because for n = -6, bin(n) give me '-0b110'. I'm trying to understand how is it working.

@Evgeny You may want to read the Wikipedia article on two's complement. Flipping all bits of n simply results in -n-1. (of course, that's what flipping all bits does in languages with machine-word-sized integers, but in many other languages ~ has the same behaviour)

Tank you. It's impossible to solve the problem without this sacred knowledge.

@Evgeny Is Python 3 mandatory? Based on your question title I assume it is, but if not, this could be 2 bytes shorter in Python 2 (print a instead of print(a) and / instead of // which uses integer division implicitly on integers).

@KevinCruijssen int(...) is also not necessary. (if this is a problem from acmp.ru, like OP's previous question, then Python 3 seems to be mandatory)

@KevinCruijssen yes, only Python3 allowed.

Python 3, 34 bytes
print(3**sum(range(int(input()))))

Try it online!
In Python 2 this is just print 3**sum(range(input())) for 28.

Why does this answer have five times as many upvotes as mine? (I think they're mostly the same) Am I doing something wrong? (note: the question I am trying to ask is not "where are my upvotes" but "what am I doing wrong or what can I do better")

I posted this because it was a one-liner, which OP said they started thinking about. I'm not sure why it has so many more upvotes as I would not class this as a "better" code-golf solution (given the altered scoring mechanism), just an alternative one. You've certainly done nothing wrong.

source: Stack Exchange

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

sort: votes


text:
Implement a UNIX file system and command line parser
Description
Your task is to implement a simple UNIX command parser and file system. Your program will have to implement a file system that can be modified via commands.
The starting directory of your file system is an empty root directory /, with no subdirectories or files. Your program must be capable of handling the following commands:
Commands
cd <dirpath> - Change the current directory

<dirpath> will be a list of directory names or "..", seperated by "/"
e.g. cd ../folder1/folder2 means to navigate up one directory level, then descend into folder1, then descend into folder2
If the directory path is not valid, then the command will do nothing

touch <filename> - Create a new file

e.g. touch me.txt creates a file called me.txt in the current directory
Filenames will only contain characters a-z and "."

Filenames will contain "." at least once
"." will never be the first or last character in a file name

If a file already exists with the same name in the current directory, nothing happens

mkdir <dirname> - Create a new directory

e.g. mkdir photos creates a new photos directory in the current directory
Directory names will only contan characters a-z
If a directory already exists with the same name in the current directory, nothing happens

rm [-r] <filename-or-dirname> - Remove a file or directory

e.g. rm hello.mp3 removes a file named hello.mp3 in the current directory
e.g. rm -r documents removes a folder named documents in the current directory, and all of its contents
If rm tries to delete a directory without the -r flag, nothing will happen

However rm will delete a file even with the -r flag

If the specified directory or file cannot be found, nothing happens

Tree output
Your program will output the following tree-like representation of the current file system using spaces as indentation. For example:
/
  documents
    document.docx
  downloads
    zippedfile
      notavirus.exe
    coolgoats.mp3
    zippedfile.zip
  pictures
    myvacation.png

All directories names must end with a "/" no longer necessary
You may use any number of spaces to indent the tree (minimum 1)
Directories must be listed before files in the same directory
Directories and files should be listed in lexographical alphabetical order

The character "." lexographically comes before any alphabetical character

You may output the contents of directories in any order you wish

Challenge
Create a program that accepts a series of commands, and outputs a tree-like representation of the current file system.
Input
The first line of input will be an integer N. Following will be N lines, each containing a command as described above.
You may feel free to omit the number N from your input if it is not necessary
Slight variations are allowed (using commas to seperate commands, input as a list etc) as long as it's reasonable
Output
The contents of the current file system in a tree-like representation, as described above.
Test Cases
Input 1: Simple example from earlier
15
mkdir documents
cd documents
touch document.docx
cd ..
mkdir downloads
cd downloads
touch coolgoats.mp3
touch zippedfile.zip
mkdir zippedfile
cd zippedfile
touch notavirus.exe
cd ../..
mkdir pictures
cd pictures
touch myvacation.png

Output 1:
/
  documents
    document.docx
  downloads
    zippedfile
      notavirus.exe
    coolgoats.mp3
    zippedfile.zip
  pictures
    myvacation.png

Input 2:
Incorrect commands and edge cases
12
mkdir folder1
mkdir folder1
mkdir folder2
rm folder1
rm -r folder2
cd ..
cd ../folder1
cd folder1/folder2
touch file.txt
touch file.txt
touch file2.txt
rm -r file2.txt

Output 2:
/
  folder1
  file.txt

Input 3:
Alphabetical listing of directories and files no longer necessary
8
mkdir b
mkdir c
mkdir a
touch c.txt
touch aa.txt
touch b.txt
touch a.txt
touch ab.txt

Output 3:
/
  a
  b
  c
  a.txt
  aa.txt
  ab.txt
  b.txt
  c.txt

Input 4:
Partially correct cd should not be parsed (Suggested by @Arnauld)
4
mkdir folder1
cd folder1
cd ../folder2
touch file.txt

Output 4:
/
  folder1
    file.txt

Input 5:
Partially correct cd should not be parsed (Suggested by @Abigail)
3
mkdir foo
cd bar/../foo
touch file.txt

Output 5:
/
  foo
  file.txt

Standard loopholes and I/O rules apply.
This is code-golf, shortest code wins.
Edit: output requirements have been relaxed a little bit

I would suggest allowing for a more flexible output that would still convey the tree-like structure! Other than that, good job!

@RGS what kind of flexibility would you suggest?

"in UTF-8 bytes" — languages that use no more than 256 distinct characters, but have their own character set, are to be punished?

It seems like we only need to parse the path for the cd command and will never be given something like touch ../foo/bar. Can you confirm that?

"You may use any number of spaces to indent the tree" ― even zero?

@Arnauld yes touch and mkdir will only ever be given file or folder names, no path parsing necessary ;)

@Adám I will clarify the spaces for indenting the tree, thanks for pointing it out. Also, what is the standard rule for scoring code golf? I always thought it was just UTF-8 bytes

"Filenames will contain "." at least once". That's not very UNIX like. ""." will never be the first or last character in a file name". Neither is this.

Starting from an empty state, followed by mkdir foo, does cd bar/../foo descend into foo, or is this an illegal path and thus nothing happens?

@Abigail cd bar/../foo is not valid because bar doesn't exist. I will add that as a test case

Explaination for mkdir: "Directory names will only contan characters a-z"

@MrSiliconGuy Sorry, I missed that rule. Some of your test cases have digits in file names and directory names. Is this intentional?

oops, definitely not. Thanks for pointing that out

@MrSiliconGuy Look here for our default policy on counting bytes.

@Arnauld that's unecessary, touch description - Filenames will contain "." at least once so names for dirs and files will never overlap

What happens if I try to cd .. while in the root directory?  Or if I try to cd ../../../../.. while in /foo/bar?  Using @Abigail's example, if I'm in / and directories /foo and /baz exist, is cd baz/../foo legal?

Bash, 133 86 bytes
(for i;{
$i
[[ $PWD =~ , ]]||cd ->~/e
})
tree --dirsfirst|sed '$d;s#[^0-Z.]# #g;1c /'

-2 bytes thanks to @Dom Hastings (removing spaces around ||)
-6 bytes thanks to @Dom Hastings (removing eval  before $i and using # as a sed delimiter)
-12 bytes thanks to @ilkkachu (combining the seds).
-5 bytes thanks to @chepner (=~, $PWD and sed c command)
Takes input where each argument is a command, e.g. script 'mkdir A' 'cd A' 'touch B'
Must be called from an empty directory with name containing ,, such that this directory is the only directory containing , on the system.
The code itself is 85 bytes, +1 byte for specifying the directory name.
Try it online!.
How it Works
(         # start a subshell
for i;do  # for each argument
 $i          # run that command (rm [-r], touch, and mkdir
             # behave exactly as specified)
             # unfortunately cd can leave the directory, so...
 if [[ $PWD != *,* ]];then  # if we left the directory
                              # (i.e. the directory now no longer contains a comma)
    cd - > ~/e                     # cd to the directory from before the command
                                   # if this is successful, it outputs the new directory to stdout
                                   # so, redirect stdout to a file we can edit
                                   # piping to : didn't work without more bytes
                                   # It would be nice to not have to do this, but
                                   # redirecting the final `tree` output to a file included that file half the time
 fi
done
) # end subshell, returning to the initial directory (corresponding to '/')
tree --dirsfirst  # tree does most of the work for us
                  # outputs nearly the desired output, but it looks like
                  # .
                  # ├── A
                  # │   └── B.txt
                  # └── F
                  # 2 directories, 1 file

 | sed '
   $d;              # remove the last line ("2 directories, 1 file")
   s#[^0-Z.]# #g;   # replace all characters that are not digits, letters, or '.' with a space
   1c /             # replace the initial '.' with a '/'
 '

I think you should be able to remove the spaces ariund && for -2!

This is pretty clever, using built-in bash to do all the work for you

Can you somehow use chroot here?

@mypronounismonicareinstate I was just looking at this too, but i needed to alias in the commands... Might be a mechanism there (although needs root) Also, the 3 in mp3 is stripped, so you need to add 0-9 into your sed arg: Try it online!

Also, to avoid escaping the / you can use another delimiter: sed s#^\.#/# and \A instead of quotes and ^, it's also possible to just call $i instead of eval (I think anyway, this test case works) and cd - should take you back if you've left ,: Try it online!

@DomHastings Yes, just $i works. I had cd -, but the hard part was redirecting its output since it outputs the location it returns to. The \A would be more bytes than ^ since quotes were unnecessary anyway (and the \ would itself have to be escaped in that case).

tree --dirsfirst|sed '/,/d;s/[^0-Z.]/ /g;s#^\.#/#' should work with at least GNU sed. Or even sed '$d;s/[^0-Z.]/ /g;s#^\.#/#' if it's just the last line you want to remove, not any lines with a ,. (d is for delete, /,/ is a regular regex condition and $ for the last line)

You can knock off a couple more bytes; replace the call to pwd with the parameter $PWD, and use =~ match the regular expression , instead of pattern-matching.

Replace 1s#.#/# with 1c\<nl>. to save another couple bytes (<nl> is a literal newline).

@chepner The \<nl> is unnecessary for the c command, saving another 2.

Python 2, 358 ... 280 277 bytes
thanks to randomdude999 for -3 bytes and a bugfix.
Input is a list of commands, where each command is represented by a 2-tuple as (cmd, args). Test cases can be transformed using this Retina program.
K=T={}
for c,a in input():
 try:exec"T[a]=1|x=a<'.';if x or T[a]<2:del T[a[3*x:]]|T[a]=T.get(a,{'..':T})|E=T\nfor p in a.split('/'):E=E[p]\nT=E".split('|')[hash(c)%6]
 except:1
def p(t,i):
 for k in sorted(t,cmp,t.get,1):
	if'..'<k:print i+k;t[k]>1!=p(t[k],i+' ')
p({'/':K},'')

Try it online!
Explanation
K=T={}

The file system is represented by a dictionary, where K points to the root directory, and T points to the current directory. Each sub-directory contains a reference to its parent directory under the key '..', which allows for easy execution of cd ... Files are represented by the integer 1.
for c,a in input():
 try:exec"""<touch>|<rm>|<mkdir>|<cd>""".split('|')[hash(c)%4]
 except:1

This loop executes the commands, the right code to execute is selected using the hash of the command (see table below). The execution is wrapped in try/except to catch exceptions that occur in invalid cd and rm calls.
┌───────┬──────────────────────┬─────────────┐
│   cmd │            hash(cmd) │ hash(cmd)%6 │
├───────┼──────────────────────┼─────────────┤
│    cd │    12672076131114255 │           3 │
│ mkdir │ -4476162622565762260 │           2 │
│    rm │    14592087666131641 │           1 │
│ touch │  7353934562497703448 │           0 │
└───────┴──────────────────────┴─────────────┘

# touch
T[a]=1

Creates a new file called a in the current directory.
# rm
x=a<'.'
if x or T[a]<2:del T[a[3*x:]]

If a starts with '-r', x is set to True. If x is True or we want to delete just a file (dicts are greater than integers in Python 2), the object can be deleted.
# mkdir
T[a]=T.get(a,{'..':T})

If the current directory already has an item called a, do nothing. Otherwise create a new subdirectory in the current directory with name a with a parent reference to the current directory.
# cd
E=T
for p in a.split('/'):E=E[p]
T=E

If p is equal to '..', E['..'] points to the parent directory of E. Otherwise E[p] is the subdirectory p in E. The current directory is only updated if all steps have completed without error.
# Function that formats and prints the file system
# t - dictionary representing a part of the file system
# i - current indentation
def p(t,i):
 # Iterate over the keys sorted ...
 # ... on the values, where dicts (directories) ...
 # ... are larger than `1` (files) ...
 # ... and reverse
 for k in sorted(t,cmp,t.get,1):
  # if k is not 0 (a parent reference) ...
  # print the name of k ...
  # and, if k is a directory, call p recursively
  if k:print i+k;t[k]>1!=p(t[k],i+' ')

Fails for [('mkdir', 'foo'), ('cd', 'foo'), ('touch', 'bar'), ('cd', '..'), ('mkdir', 'foo')]: mkdir should do nothing if the directory already exists, but it always recreates it.

@randomdude999 thanks for notifying me, I should've read the rules more thoroughly. This is now fixed.

Alright, now let's get golfing :) The hashes modulo 6 are exactly 3,2,1,0 for "cd","mkdir","rm","touch" respectively, so you can split touch and mkdir, saving 1 byte. You can use a single-line string for the exec and use \n or ; instead of newlines, saving 2 bytes, for a total of 277. try it online!

JavaScript (ES6),  268 265 254  248 bytes
Expects an array of strings. Returns a single linefeed-separated string.
a=>a.map(o=r=s=>([[c],s,e]=s.split` `,c>'m'?c>r?o[s]=1:o[e||+o[s]&&s]=0:c<'m'?o=s.split`/`.every(s=>o=o[s]-2?0:o[s],q=o)?o:q:o[s]=o[s]||{'..':o}))&(g=(o,i)=>[0,1].map(t=>{for(k in o)(v=o[k],t?v^1:v-2|k<S)||(S+=i+k,t||g(v,i+' '))}))(r,`
 `,S=`/`)||S

Try it online!
How?
Part 1: parse the commands and build the tree
The file tree is described by an object whose keys are the file names and whose values are:

0 for a deleted entry
1 for a file
another object for a directory

Each directory (except the root) contains a default .. entry pointing to the parent directory.
a.map(                   // main loop
  o =                    // o is the current object
  r =                    // r is the root object
  s => (                 // for each string s in a[]:
    [[c], s, e] =        //   split it into c = first character of the command,
      s.split` `,        //   s = first argument, e = second argument
    c > 'm' ?            //   if c is greater than 'm':
      c > r ?            //     if c is greater than 's':
        o[s] = 1         //       touch: create a file whose name is s
      :                  //     else:
        o[               //       rm:
          e ||           //         use e if it exists (meaning that -r was used)
          +o[s] && s     //         or use s if o[s] is a file
        ] = 0            //       mark this entry as deleted
    :                    //   else:
      c < 'm' ?          //     if c is less than 'm':
        o =              //       cd:
          s.split`/`     //         split the path
          .every(s =>    //         for each string s in the path:
            o =          //           update o:
              o[s] - 2 ? //             if o is a file or a deleted entry:
                0        //               abort
              :          //             else:
                o[s],    //               update o to o[s] (may be undefined)
            q = o        //           q = backup of o
          ) ?            //         if all entries were truthy:
            o            //           confirm the update
          :              //         else:
            q            //           restore o to q
      :                  //     else:
        o[s] = o[s] ||   //       mkdir: create a directory whose name is s,
               {'..': o} //       provided that it doesn't already exist
  )                      //
)                        // end of map()

Part 2: build the output string
( g =                    // g is a recursive function taking:
  (o, i) =>              //   o = current object, i = indentation string
  [0, 1].map(t => {      //   for t = 0 and t = 1:
    for(k in o)          //     for each key k in o:
      (                  //
        v = o[k],        //       v = value
        t ?              //       if we are listing files:
          v ^ 1          //         abort if v is not equal to 1
        :                //       else (listing directories):
          v - 2 |        //         abort if v is a file or a deleted entry
          k < S          //         or the directory name is '..'
      ) || (             //       if the above test was falsy:
        S +=             //         append to S:
          i + k,         //           indentation + key
        t ||             //       if we are listing directories:
          g(v, i + ' ')  //         do a recursive call
      )                  //     implicit end of for()
  })                     //   end of map()
)(r, `\n `, S = `/`)     // initial call to g

I'm not sure if it's mandatory, but your answer is missing the leading line with / in that output, that the test cases and other two answers have.

@KevinCruijssen I think it previously did not appear in all example outputs, which is why I thought it was not mandatory. Now fixed at no cost anyway.

(@KevinCruijssen Looking at the post history, the / has actually always been there in all examples. I guess I just misread them.)

mkdir foo; cd foo; touch bar.txt; cd ..; mkdir foo (with the semicolons replaced by newlines of course) fails: mkdir should do nothing if the directory already exists, but in this case, it's re-created.

@randomdude999 Thank you for reporting this. Now fixed.

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


text:
Are they collinear?
Task
Write a program/function that when given three 2d points in cartesian coordinates as input outputs a truthy value if they are collinear otherwise a falsey value
Three points are said to be collinear if there exists a straight line that passes through all the points
You may assume that the coordinates of the three points are integers and that the three points are distinct.
Scoring
This is code-golf so shortest bytes wins
Sample Testcases
(1, 1), (2, 2), (3, 3) -> Truthy
(1, 1), (2, 2), (10, 10) -> Truthy
(10, 1), (10, 2), (10, 3) -> Truthy
(1, 10), (2, 10), (3, 10) -> Truthy
(1, 1), (2, 2), (3, 4) -> Falsey
(1, 1), (2, 0), (2, 2) -> Falsey
(-5, 70), (2, 0), (-1, 30) -> Truthy
(460, 2363), (1127, 2392), (-1334, 2285) -> Truthy
(-789, -215), (-753, -110), (518, -780) -> Falsey
(227816082, 4430300), (121709952, 3976855), (127369710, 4001042) -> Truthy
(641027, 3459466), (475989, 3458761), (-675960, 3453838) -> Falsey

May we take the input points as complex numbers?

Are three points guaranteed to be distinct?

@fireflame241 yes complex numbers as input is acceptable

@Bubbler the three points are guaranteed to be different updated the question to reflect that

Octave, 21 bytes
Takes a matrix [x1, y1; x2, y2; x3, y3] as input.
@(a)~det([a,[1;1;1]])

Try it online!

You can shorten to @(a)~det([a,e(3,1)]) (the output is suject to floating-point errors even with your current approach)

JavaScript (Node.js), 39 bytes
(a,b,c,d,e,f)=>a*d+c*f+e*b==b*c+d*e+f*a

Try it online!
Accepts input as (x1, y1, x2, y2, x3, y3). Uses the shoelace formula to determine if the enclosed area is 0.
Explanation
The shoelace formula states that, the area of a polygon can be calculated using the coordinates of its vertices. Specifically, assuming the vertices are \$P_1, P_2, \cdots, P_n\$ so that \$P_1P_2, P_2P_3, \cdots, P_{n-1}P_n, P_nP_1\$ are the edges of the polygon, then the area \$A\$ can be calculated with
$$A=\frac{1}{2}\left|(x_1y_2+x_2 y_3+\cdots+x_{n-1}y_n+x_ny_1)-(y_1x_2+y_2x_3 +\cdots+y_{n-1}x_n+y_nx_1)\right|$$
where \$(x_n,y_n)\$ are the coordinates of \$P_n\$.
Taking \$n=3\$, we have the formula for the area of a triangle with coordinates \$(x_1,y_1)\$, \$(x_2,y_2)\$ and \$(x_3,y_3)\$:
$$A=\frac{1}{2}\left|(x_1y_2+x_2y_3+x_3y_1)-(y_1x_2+y_2x_3+y_3x_1)\right|$$
Three points are collinear if and only if the triangle constructed by these points has a zero area (otherwise, one of the points lies away from the line segment between the other two points, giving a non-zero area to the triangle). Since we only need to check whether the area is 0, the 1/2 and the absolute can be ignored. This boils down to checking whether
$$(x_1y_2+x_2y_3+x_3y_1)-(y_1x_2+y_2x_3+y_3x_1)=0$$
or after rearranging terms
$$x_1y_2+x_2y_3+x_3y_1=y_1x_2+y_2x_3+y_3x_1$$

I love this.  It's exactly the same length as (c-a)*(f-b)==(d-b)*(e-a) (which seemed more intuitive to me), but now I've been introduced to the 'shoelace formula' that I'd never heard of before!

Jelly, 4 bytes
_ÆḊ¬

Try it online!
Takes the differences [(a-b), (a-c)] via automatic vectorization of a-[b-c] then checks if the determinant (ÆḊ) is 0 (¬).

APL (Dyalog Unicode), 9 8 bytes
0=11○÷.-

Try it online!
-1 byte thanks to @Jo King.
Takes one complex number (A) on the left, and two complex numbers (B and C) on the right. APL automatically maps scalars, so A - B C gives (A-B)(A-C). Then divide between the two ÷., and check if the result's imaginary part 11○ is zero 0=.
Uses ⎕DIV←1, so if division by zero would occur (because A=C), ÷ returns 0 instead, which obviously has imaginary part of zero, giving truthy as a result.

Would cause a division by zero if A=C. Maybe check if the phases 12○ are equal or (A-B)*conjugate of (A-C) is real.

@fireflame241 Phase equal doesn't work because the two can be in opposite direction. Multiplying conjugate sounds good, and is also free from possible float inaccuracies (should work at the cost of 2 bytes).

"Uses ⎕DIV←1" - this is necesssary and is code (not a flag making a different "language") so shouldn't it be part of the byte count?

@JonathanAllan It is a system setting, which can be set outside the interpreter as an environment variable. Not counting system setting in code length is also mentioned here.

@JoKing Of course it does.

(For the lazy: "[not including system settings in the byte count] is justified by the existence of systems where the needed setting is default.")

Python 2, 39 bytes
lambda a,b,c:(a-b)*(a-c-(a-c)%1*2)%1==0

Try it online!
Input: the 3 points as 3 complex numbers
Output: True or False.
How
Let the 3 points be \$(a,A), (b,B), (c,C)\$
The 3 points are colinear iff \$(a-b)*(A-C)=(A-B)*(a-c)\$. Note that this formula doesn't have division, and thus won't have floating point issue.
Consider the following complex multiplication:
$$ \big((a-b)+(A-B)i\big) * \big((a-c)-(A-C)i\big)$$
The imaginary part of the result is:
$$(a-c)(A-B)-(a-b)(A-C)$$
which must be \$0\$ for the 3 points to be colinear.
Let a, b, c be the complex representation of the 3 points, then the condition above is equivalent to:
t = (a-b) * (a-c).conjugate()
t.imag == 0

Instead of using imag and conjugate, we can take advantage of the fact that all points are integers. For a complex number t where both the real and imaginary parts are integers, t%1 gives the imaginary part of t. Thus:
t % 1 == t.imag * 1j
t - t % 1 * 2 == t.conjugate()

Old solution that doesn't use complex number
Python 3, 43 bytes
lambda a,A,b,B,c,C:(a-b)*(A-C)==(A-B)*(a-c)

Try it online!
Input: the 2 coordinates of the first point, then the 2nd point, then the 3rd point.
Output: True or False.

This should work theoretically, but doesn't because of floating point imprecision:
Python 3, 34 bytes
lambda a,b,c:((a-b)/(a-c)).imag==0

Try it online!
Input: 3 points, each represented by a complex number
Output: True or False.

J, 13 7 bytes
0=-/ .*

Try it online!
Uses the determinant. J's generalized determinant u .v is defined for non-square matrices, still multiplying (*) each x value with the difference of the other two y values (-/), finally reducing that result (-/). -/ .* calculates the determinant, check if it is 0=.

Change ,. to , by taking the input transposed.

@Bubbler it's even simpler. :-)

R, 22 bytes
function(x)lm(1:3~x)$d

Try it online!
Finally a challenge which calls for lm!
The function lm performs linear regression. Here, we are using the input x as covariates, and 1 2 3 as observations (any vector of length 3 would do).
The output is an object with many components; of interest here is df.residual (which can be accessed with the unambiguous abbreviation $d), the residual degrees of freedom. This number corresponds to the number of observations minus the number of parameters being estimated. Now:

if the points are not collinear, the regression proceeds normally, estimating 3 parameters, so df.residual == 0.
if the points are collinear, there is an identifiability issue and only 2 parameters can be estimated (the last will be given as NA), so df.residual == 1.

Note that the final test case fails due to numerical precision issues.

Wolfram Language (Mathematica), 20 19 bytes
Det@{#2-#,#3-#}==0&

Try it online!

R, 27 bytes
function(m)!det(cbind(1,m))

Try it online!
Port of alephalpha's Octave answer.

Bah!  You beat me by 22 bytes within 11 seconds!

Well, it's just a different approach that, btw, I have learned just now :D

22 bytes using lm: https://codegolf.stackexchange.com/a/206894/86301 :-)

det(diff(m)) would work, I think

@Giuseppe, not really, the penultimate test case already gives a quite noticeable deviation from zero: TIO

I think that's still just a numerical precision issue since R "upgrades" integer to double once it gets past 32 bits. Assuming an arbitrary precision integer type, it should work, although I haven't been able to test that fully, since diff doesn't play nicely with gmp::as.bigz

Raku, 21 19 bytes
{!im [/] $^a X-@_:}

Try it online!
Takes input as three complex numbers and returns a boolean. Note that if the last and first points are identical (which is disallowed in the challenge spec), then the division operation would return NaN for dividing by zero, which boolifies to True for some reason, so this would fail.

R, 49 bytes
function(p,q=p-p[,1])q[1,3]*q[2,2]==q[2,3]*q[1,2]

Try it online!
How?

Subtract first point from the other two:
if points are on a line, the line must now pass through (x=0,y=0)
so we check that the gradient=y/x is identical for both other points: y2/x2==y3/x3
but to avoid dividing by zero, we rearrange: y2x3==y3x2

Edit:

which, thanks to Kirill, alephalpha and Wikipedia, I've now discovered is simply the determinant of the matrix (x2,y2,x3,y3)
so, for only 29 bytes: function(p)!det(p[,-1]-p[,1])

05AB1E, 18 17 27 21 bytes
-Dн_iIн¹нQë`s/Uн¹н-X*¹θ+IθQ

Try it online!
Verify All Test Cases!
-1 byte due to remembering implicit input exists and that variable assignment pops values
+10 due to bug fix regarding vertical lines :-(
-6 thanks to the wonderful @Kevin, who always manages to golf my 05AB1E answers! :D. Go and upvote his posts!
Explained
Before we even begin to look at the program, let's take a look at the maths needed to see if three points are collinear. Let our first point have co-ordinates \$(x_1, y_1)\$, our second point have co-ordinates \$(x_2, y_2)\$ and our third point have co-ordinates \$(x_3, y_3)\$.
If the three points are collinear, then point three will lie on the line formed by joining points one and two. In other words, \$x_3\$, when plugged into the equation formed by the line joining points 1 and 2, gives \$y_3\$.
"But what's the line between point 1 and 2?" I hear you ask. Well, we use the good old "point-graident" method to find the line's equation:
$$
y - y_1 = m(x - x_1), m = \frac{y_2 - y_1}{x_2 - x_1}\\
y - y_1 = \frac{y_2 - y_1}{x_2 - x_1}(x - x_1)
$$
Now, we add \$y_1\$ to both sides to get an equation where plugging in an x value gives a single y value:
$$
y = \frac{y_2 - y_1}{x_2 - x_1}(x - x_1) + y_1
$$
Substituting \$x\$ for \$x_3\$ and \$y\$ for \$y_3\$ gives an equality that determines if three points are collinear.
Alright, time for the code (as explained by Kevin).
-                     "[x2-x1, y2-y1]"\
 V                    "pop and store it in variable `Y`"\
  ¹-                  "[x3-x1, y3-y1]"\
    н                 "Pop and leave only x3-x1"\
     Yн_i             "If x2-x1 from variable `Y` == 0:"\
         _            " Check if the x3-x1 at the top == 0"\
        ë             "Else:"\
         Y`s/         " Divide (y2-y1) by (x2-x1) from variable `Y`"\
             *        " Multiply it by the x3-x1 at the top"\
              ¹θ+     " Add x1"\
                 Q    " Check [x3 == this value, y3 == this value] with the implicit third input"\
                  θ   " And only keep the last one: y3 == this value"\

@KevinCruijssen I accidentally left the X0Q from a previous explanation. But still, yes, it should be _ instead.

I still have to verify all test cases (I'll try to write a test suite in a bit), but I think this 21 byter should work without changing your formula.

Here the same 21 byter with comments.

Here a test suite for all test cases. :) PS: I would make my explanation a bit prettier in your answer with actual comments, haha. ;) I only used "..."\  in the 05AB1E code because that's the only way I know to add comments inside a program

@KevinCruijssen https://codegolf.stackexchange.com/q/6467/78850

Oh, thank you! :) Tbh, I enjoy golfing other people's answers as much as writing answer myself. Glad I could help, and thanks for the bounty!

@KevinCruijssen No worries. It seems only fair given the amount of times I've had to write "-x bytes thanks to @Kevin"!  ;P

C# (Visual C# Interactive Compiler), 39 bytes
(a,A,b,B,c,C)=>(b-a)/(B-A)==(c-a)/(C-A)

Try it online!

This is interesting.  I notice that it only works if you declare the input variables as doubles, otherwise it gives a divide-by-zero error when A equals B or C.  So I'm wondering whether the variable declaration needs to be included in the byte count...?

The requirement for doubles is obviously removed by rearranging like this...

AWK, 45 bytes
{print!($2*$3+$4*$5+$6*$1-$1*$4-$2*$5-$3*$6)}

Try it online!
Near-identical to Rich Farmbrough's Perl answer, but the syntax seemed better-suited to AWK than Perl.  Thanks Rich!

I extracted some common factors, and saved a few bytes.

@Rich Farmbrough Well done!  That would bring the AWK clone to 42 bytes, although copying you a second time seems sneaky so I'm leaving it here in the comment section...

Shaping the code like this will save 3 more bytes: $0=!($2*($3-$5)+$4*($5-$1)+$6*($1-$3))e

@PedroMaimere - Nice golfing!  I didn't think of redefining $0 and using a dummy variable to force output...  You should post this yourself!  It's nice to have some more AWK competition!

@DominicvanEssen don't worry. It's a common technique. In fact, it is also described in Tips for golfing in Awk.

Charcoal, 21 bytes
ＮθＮηＮζ⁼×⁻ηＮ⁻θＮ×⁻ηＮ⁻θζ

Try it online! Link is to verbose version of code. Takes input as six integers and outputs a Charcoal boolean, i.e. - for collinear, nothing if not. Uses @SurculoseSputum's original formula. Explanation:
Ｎθ                      Input `a`
  Ｎη                    Input `A`
    Ｎζ                  Input `b`
         η              `A`
        ⁻               Minus
          Ｎ             Input `B`
       ×                Multiplied by
            θ           `a`
           ⁻            Minus
             Ｎ          Input `c`
      ⁼                 Equals
                η       `A`
               ⁻        Minus
                 Ｎ      Input `C`
              ×         Multiplied by
                   θ    `a`
                  ⁻     Minus
                    ζ   `b`
                        Implicitly print

[Excel], 37 bytes
=0=MDETERM(A1:C3+{0,0,1;0,0,1;0,0,1})

Example:

[Google Sheets], 27 bytes
=0=MDETERM({A1:B3,{1;1;1}})

Try it online!

Perl 5, 3562 bytes
sub d{($a,$b,$c,$d,$e,$f)=@_;$b*($c-$e)+$d*($e-$a)+$f*($a-$c)}

Try it online!
I've put the wrapping on as explained in the comments, and golfed the original "guts"  down by picking out some common factors
$b*($c-$e)+$d*($e-$a)+$f*($a-$c)
(--First attempt --)
$b*$c+$d*$e+$f*$a-$a*$d-$c*$f-$e*$b

Try it online!

Not sure if this follows the rules (where are they?) for header and footer, as much trying out "tio" as anything.
This takes the test text as per the question and outputs the exact same text!  In other words it's equivalent to while(<>){print}, provided you feed it a crib sheet.  If you remove (or change) the answers from the input, it will supply them.

I don't know Perl very well, but this seems like it takes input as predefined variables, which is not permitted since it would make this a snippet rather than a program/function. You can fix this e.g. by turning it into a full program (taking input from STDIN or other allowed in the linked meta) or including the full function header (sub det etc) in the code. Btw, welcome back to Code Golf!

Nice, but I think that the syntax works even better in AWK (which automatically divides the variables up in exactly the way you've used)...  so I've stolen the approach, with acknowledgment.

The consensus for submissions are either full programs or functions, of which this is neither. Valid input/output formats are listed here. Usually people use headers to assign anonymous functions which are then called in the footer, possibly with some formatting of the input

Your actual submission be this at 83 bytes (though this is obviously golfable)

Husk, 7 bytes
EẊoF/z-

Try it online!

Vyxal, 4 bytes
v-ÞḊ

Try it Online!
Outputs 0 for truthy and any other integer for falsy. Port of fireflame241's Jelly answer. Add ¬ at the end to get 1 for truthy and 0 for falsy.


text:
Find the perfect square!
Your task is to turn a square root like this:
√12

into a form like this:
2√3

For our purpose, we only need to output the left number here:
2

Test cases
4  -> 2
9  -> 3
12 -> 2
13 -> 1
108-> 6

Specifications

You may assume for the input that \$n>0\$. \$n\$ has to be as large as possible.
If the number is already a perfect square, do this:

√4 = 2√1 -> 2

If the number doesn't contain perfect squares, do this:

√13 = 1√13 -> 1

Related: Simplify a square root, which has you return both parts of a√b.

I think that n=0 is an exceptional edge case that would be better to disallow, since 0 can be expressed as 0√b or a√0 for any a or b. And if we consider simplest form to mean taking a as big as possible in a√b, there's no limit on how big a can be.

For reference, this is A000188.

Hmm...  it isn't clear to me from the challenge whether we need to supply the largest a if there is more-than-one a√b solution (as implied by xnor), or whether any a is Ok.  If the former, I'll need to add one more byte to my answer.  Suggest test case 108 to clarify (√108 = 2√27, and 3√12, as well as 6√3).

@DominicvanEssen Although it was indeed not clear from the challenge description prior, and 108 is a nice additional test case. If either the lowest or highest (or any) $a$ would be allowed, an output of 1 would suffice for every possible input, since $1\sqrt{b}$ would be valid - in which case I could have a 0-byte solution in Retina. ;)

You provide an example and you provide test cases but you don't actually describe what it is that we're supposed to be doing here (I had to derive it from the existing solutions).

Possible duplicate of Simplify a square root

@KevinCruijssen I think you'll find that ^ is a 1-byte solution...

the result is max quadratic inside factor of a number

Why was this closed as unclear? All things in the comments have been address. n=0 has been removed as edge case, and it mentions "$n$ has to be as large as possible." so we know we're looking for the maximum.

@Neil Woops, you're indeed correct. Forgot we had to take input, haha. xD

@KevinCruijssen I think what happened is that the question got 3 unclear votes before it was clarified, and then two votes as duplicate (but unclear was still the majority close reason)

Japt -mx,  4  3 bytes
Crossed out &nbsp4;  is no longer 4 :)
²vN

My first Japt answer. :)
Port of my first 5-byter 05AB1E answer, but with smart use of Japt's flags for the range and sum.
-1 byte thanks to @Shaggy thanks to the shortcuts list: p)/p␠ to ²
Try it online.
Explanation:
-m       # Convert the (implicit) input-integer to a ranged list [0, input)
  ²      # Square each value in the list, and implicitly close the function
   vN    # Check which values are divisible by the input (1 if truthy; 0 if falsey)
     -x  # After which the sum is calculated of the resulting list
         # (before the result is output implicitly)

These Japt flags should be counted as part of the code :(

@mypronounismonicareinstate No, they don't. Flags used to count towards the byte-count in the past, but they now count as different languages (i.e. Japt is a different language than Japt -mx) since Dec. 2017.

I know that this is the current consensus, but flags like this are the exact reason why command line flags used to be counted.

Welcome to Japt! :) Looks like you were posting as I was fighting with the SE app; I'll delete mine momentarily. Couple of quick tips: 1. a space is enough to close a single method in Japt (although the ) doesn't make a difference here 2. There's a shortcut for   p2<space> which will allow you to get this down to 3 bytes.

@mypronounismonicareinstate, consensus is consensus ;) If you don't like this one then you can have your say by downvoting it at https://codegolf.meta.stackexchange.com/a/14339/

@Shaggy There is only one answer there, and I'm not willing to write another one. There is also a consensus at https://codegolf.meta.stackexchange.com/a/5076 (and I don't think embedding merely half of the code in the "implementation" makes it much better)

@mypronounismonicareinstate I agree that putting everything in flags and posting a 0-byte answer isn't very good sports (although technically allowed now). But with Japt and similar languages using flags like Perl, C# Visual Compiler, etc. the amount of flags that can be used is pretty limited, and are for a specific builtins (range and sum in this case), so I personally don't see a difference tbh. Some languages always sum implicitly at the end by default; Japt does it with a flag; 05AB1E does it with a single byte O; and with a verbose language you'll have to use .sum() or a manual loop.

@Shaggy Out of curiosity: is o²mvN x what should be used without those two flags? Or is there a shorter way without changing the actual method?

You can run each element through a function as you're summing so õ²xvU would do it for 5 bytes, Kevin.

@Shaggy Ah, of course.. Just put the x at the position of the m to sum the mapped "v",N values, thanks. And both o ($[0,n)$) and õ ($[1,n]$) indeed work in this case, although technically -m is equal to o. :) I'll see if I can do a few more easy challenges in Japt before trying something a bit more complex perhaps.

@KevinCruijssen, I'll keep an eye out for them, so.

@Shaggy You need to fix your header generation to put a space after the # as CommonMark now requires.

05AB1E, 9 6 5 bytes
LnIÖO

Try it online or verify all test cases.
Previous 9 6 bytes approach:
LR.ΔnÖ

-3 bytes thanks to @ovs.
Try it online or verify all test cases.
Explanation:
L       # Push a list in the range [1, (implicit) input]
 n      # Take the square of each value in the list
  IÖ    # Check which squares are divisible by the input (1 if truthy; 0 if falsey)
    O   # And sum those checks
        # (after which this sum is output implicitly as result)

L       # Push a list in the range [1, (implicit) input]
 R      # Reverse it to [input, 1]
  .Δ    # Find the first value in this list which is truthy for:
    n   #  Square the current value
     Ö  #  Check if the (implicit) input is evenly divisible by this square
        # (after which the found value is output implicitly as result)

Sadly there's no inverse to Ó; the best I could do was Ó2÷ā<ØsmP, which is as long as your first answer, but hopefully more efficient at least.

@Neil Yeah, when I saw the Jelly answer of Jonathan I was indeed looking for a port as well and had that exact same Ó2÷ā<ØsmP. I like this challenge, because there are quite a few slightly different approaches to get the same answers. :) And it's indeed unfortunate there isn't an inverse of Ó in this case.

Jelly, 5 bytes
Ḷ²%ċ0

Uses the formula from the OEIS: the number of solutions to $$x^2 \equiv 0 \ (\mathrm{mod} \ n)$$
Explanation:

implicit input
range 0..n-1,
square each
modulo input (I got this part to work via trial and error)
count zeroes
implicit print

Try it online!

An upvote of my 6 byter bought me here, didn't know of this method. You can do it in four bytes with ḍ²€S TIO. That is, square each of the implicit [1..n] with ²€, check if n divides each with ḍ (same result for n² as you'd get for 0²), then sum with S.

@JonathanAllan nice; I'll never understand Jelly

Brachylog,  8 6 5 bytes
-1 thanks to Unrelated String
f↔∋√ℕ

Try it online!
How it works
f↔∋√ℕ
    ℕ output is a natural number (≥0) that is
   √  the root of … (Brachylog gives the negative root first)
  ∋   an element …
f↔    in the reverse factors list (so search starts with bigger values)

Alternative version with prime factors, 10 bytes
{ḋp⊇~j×}ᵘ⌉

Try it online! or verify all test cases.
How it works
{ḋp⊇~j×}ᵘ⌉
         ⌉  take the maximum of …
{      }ᵘ   all unique …
      ×       multiplications of …   10
    ~j        halves of …            [2,5]
   ⊇          ordered subsets from … [2,5,2,5]
  p           the permutations of …  [2,5,2,5,3]
 ḋ            the prime factors      [2,2,3,5,5]

-1 byte. Funnily enough, that only occurred to me after I'd tried substituting in ~^₂ for the same byte count...

JavaScript (ES6), 27 bytes
f=(n,k=n)=>n/k%k?f(n,k-1):k

Try it online!
How?
We recursively look for the greatest \$k\le n\$ such that \$\dfrac{n}{k}\equiv 0\pmod k\$, which is guaranteed to be satisfied for \$k=1\$ in the worst case.
This is a more golf-friendly way of testing \$\dfrac{n}{k^2}\equiv 0\pmod 1\$.

Jelly, 6 bytes
ÆE:2ÆẸ

A monadic Link accepting a positive integer which yields a positive integer.
Try it online! Or see the first 100.
How?
ÆE:2ÆẸ - Link: integer, X          e.g. 9587193
ÆE     - factorisation vector (X)       [0,1,0,4,3] (since 2°×3¹×5°×7⁴×11³=9587193)
  :2   - integer divide by two          [0,0,0,2,1]
    ÆẸ - evaluate factorisation vector  539         (since 2°×3°×5°×7²×11¹=539)

Gaia, 5 bytes
(this was produced by trying a bunch of languages from https://github.com/ETHproductions/golfing-langs until I found one that had the most useful built-ins for this problem)
dụ⁇)u

Explanation:
d     divisors
 ụ⁇   keep only squares
   )  take last
    u square root

Try it online! (example stolen from the Jelly answer)

Python 2, 37 bytes
n=i=input()
while n%i**2:i-=1
print i

Try it online!
38 bytes
lambda n:sum(x*x%n<1for x in range(n))

Try it online!
Based on the solution of my pronoun is monicareinstate, counting the number of solutions to  \$x^2 \equiv 0 \ (\mathbb{mod}\ n)\$ for \$x\$ from \$0\$ to \$n-1\$.

CP-1610 machine code,  20  17 DECLEs1 ≈ 22 bytes
As per the exception described in this meta answer, the exact score is 21.25 bytes (170 bits)
A routine expecting the input number in R0 and returning the result in R3.
1D2     |         CLRR    R2
1C9     |         CLRR    R1
0D1     | @@loop  ADDR    R2,     R1
00A     |         INCR    R2
084     |         MOVR    R0,     R4
10C     | @@sub   SUBR    R1,     R4
10C     |         SUBR    R1,     R4
114     |         SUBR    R2,     R4
22E 004 |         BGT     @@sub
20C 001 |         BNEQ    @@next
093     |         MOVR    R2,     R3
141     | @@next  CMPR    R0,     R1
226 00D |         BLE     @@loop
0AF     |         JR      R5

How?
The CP-1610 has no multiplication, no division, no modulo. We want to implement an algorithm that relies on additions and subtractions exclusively.
We start with \$k=0\$. At each iteration, we update \$j\$ in such a way that:
$$j = \frac{k(k-1)}{2}$$
The good thing about this formula is that it's very easy to compute iteratively: we just need to add \$k\$ to \$j\$ and increment \$k\$ afterwards.
In order to test whether \$n\$ is divisible by \$k^2\$, we initialize a variable \$x\$ to \$n\$ and subtract \$k^2\$ until \$x\le 0\$.
We do not explicitly store \$k^2\$, but it can be easily obtained with:
$$2j+k=k(k-1)+k=k^2$$
Each time we end up with \$x=0\$, we update the final answer to \$k\$.
We stop when \$j\$ is greater than \$n\$.
Here is a link to an implementation of the algorithm in low-level JS.
Full commented test code
        ROMW    10                ; use 10-bit ROM width
        ORG     $4800             ; map this program at $4800

PNUM    QEQU    $18C5             ; EXEC routine: print a number
MULT    QEQU    $1DDC             ; EXEC routine: signed multiplication

        ;; ------------------------------------------------------------- ;;
        ;;  main code                                                    ;;
        ;; ------------------------------------------------------------- ;;
main    PROC

        SDBD                      ; set up an interrupt service routine
        MVII    #isr,   R0        ; to do some minimal STIC initialization
        MVO     R0,     $100
        SWAP    R0
        MVO     R0,     $101

        EIS                       ; enable interrupts

        MVII    #$200,  R3        ; R3 = backtab pointer
        SDBD                      ; R4 = pointer to test cases
        MVII    #@@tc,  R4

@@loop  MVI@    R4,     R0        ; R0 = next test case
        TSTR    R0                ; stop if it's 0
        BEQ     @@done

        PSHR    R4                ; save R4
        PSHR    R3                ; save R3
        CALL    pSquare           ; invoke our routine
        MOVR    R3,     R0        ; copy the result into R0
        PULR    R3                ; restore R3
        CALL    print             ; print the result
        PULR    R4                ; restore R4
        B       @@loop            ; go on with the next test case

@@done  DECR    R7                ; done: loop forever

        ;; test cases
@@tc    DECLE   4, 9, 12, 13, 108, 300, 800, 900
        DECLE   0

        ENDP

        ;; ------------------------------------------------------------- ;;
        ;;  prints the result of a test case                             ;;
        ;; ------------------------------------------------------------- ;;
print   PROC

        PSHR    R5                ; save the return address on the stack

        MVII    #4,     R1        ; R1 = number of digits
        MOVR    R3,     R4        ; R4 = backtab pointer
        ADDI    #5,     R3        ; advance by 5 characters for the next one
        PSHR    R3                ; save R3
        CLRR    R3                ; R3 = attributes (black)
        CALL    PNUM              ; invoke the EXEC routine
        PULR    R3                ; restore R3

        PULR    R7                ; return

        ENDP

        ;; ------------------------------------------------------------- ;;
        ;;  ISR                                                          ;;
        ;; ------------------------------------------------------------- ;;
isr     PROC

        MVO     R0,     $0020     ; enable display
        MVI     $0021,  R0        ; color-stack mode

        CLRR    R0
        MVO     R0,     $0030     ; no horizontal delay
        MVO     R0,     $0031     ; no vertical delay
        MVO     R0,     $0032     ; no border extension
        MVII    #$D,    R0
        MVO     R0,     $0028     ; light-blue background
        MVO     R0,     $002C     ; light-blue border
        MVO     R0,     $002C     ; light-blue border

        JR      R5                ; return from ISR

        ENDP

        ;; ------------------------------------------------------------- ;;
        ;;  our routine                                                  ;;
        ;; ------------------------------------------------------------- ;;
pSquare PROC

        CLRR    R2                ; R2 = k
        CLRR    R1                ; R1 = k(k - 1) / 2

@@loop  ADDR    R2,     R1        ; add R2 to R1
        INCR    R2                ; k++

        MOVR    R0,     R4        ; start with R4 = n

@@sub   SUBR    R1,     R4        ; subtract 2 * (k(k - 1) / 2) = k² - k
        SUBR    R1,     R4        ; from R4
        SUBR    R2,     R4        ; subtract k from R4
        BGT     @@sub             ; until R4 is less than or equal to 0

        BNEQ    @@next            ; did we reach exactly 0? ...

        MOVR    R2,     R3        ; ... yes: update R3

@@next  CMPR    R0,     R1        ; go on while R1 is less than or
        BLE     @@loop            ; equal to R0

        JR      R5                ; return

        ENDP

Output
This is the output for the following test cases:
4, 9, 12, 13, 108, 300, 800, 900

screenshot from jzIntv

1. A CP-1610 opcode is encoded with a 10-bit value (0x000 to 0x3FF), known as a 'DECLE'.

Haskell, 30 bytes
f n=sum[0^mod(x^2)n|x<-[1..n]]

Try it online!
Based on the solution of my pronoun is monicareinstate, counting the number of solutions to  \$x^2 \equiv 0 \ (\mathbb{mod}\ n)\$ using the range from 1 to n.
Haskell, 32 bytes
f n=until((<1).mod n.(^2))pred n

Try it online!
Start with n and repeatedly take the predecessor, until it satiafies this condition: when we square it and take the original n modulo it, the result is less than 1, that is equal to 0.

Retina 0.8.2, 26 bytes
.+
$*
((^1|11\2)+)\1*$
$#2

Try it online! Link includes test cases. Explanation:
.+
$*

Convert to unary.
((^1|11\2)+)

Find the largest square number...
\1*$

... that divides the input...
$#2

... and output its root.
Bonus 63-byte version that for an input of √1, √2, √3, √4, √5, √6, √7, √8, √9... outputs 1, √2, √3, 2, √5, √6, √7, 2√2, 3... etc. (Previous bonus version did not handle √1 correctly.)
\d+
$*
r`(?=^.(\3)+)(.)\3*((1$|11\4)+)
$#4$2$#1
\D1$

^1(\D)
$1

Try it online!

Damn you beat me to Retina, and with a much more elegant solution :o

Wolfram Language (Mathematica), 13 bytes
√#/._^_:>1&

Try it online!
For an integer argument, √ (Sqrt) returns in the desired a√b form (unless the argument was a perfect square).
Then, /._^_:>1 matches Power expressions and replaces them with 1. As a√b expands to Times[a,Power[b,1/2]], it becomes Times[a,1]=a.

wow, excellent +1

A Mathematica answer with no letters? What kind of sorcery is this?

C (gcc), 44 33 32 bytes
i;f(n){for(i=n;n%(--i*i););n=i;}

Try it online!

R, 44 (crossed-out) 36 33 32 30 bytes
((n=scan()):1)[!n%%(n:1)^2][1]

Try it online!
Or, a completely-different 25 byte approach based on equivalence to 'number of solutions to x^2==0(mod n)' (as pointed-out by my pronoun is monicareinstate), but that wasn't my own idea and hence seems to me to be cheating:
sum(!(1:(n=scan()))^2%%n)

Pari/GP, 15 bytes
n->core(n,1)[2]

Yes, there is a build-in.

core(n,{flag=0}): unique squarefree integer d dividing n such that n/d is a square. If (optional) flag is non-null, output the two-component row vector
[d,f], where d is the unique squarefree integer dividing n such that n/d=f^2 is a square.

Try it online!

Java 10, 43 40 bytes
n->{for(var c=n++;c/--n%n>0;);return n;}

Inspired by @Arnauld's JavaScript answer, so make sure to upvote him!
Try it online.
Explanation:
n->{                // Method with double as both parameter and return-type
  for(var c=n       //  Create a copy `c` of the input `n`
             ++     //  Then increase `n` by 1
      ;             //  Continue looping as long as:
       c/--n        //   (decrease `n` by 1 first before every iteration with `--n`)
                    //   `c` divided by `n`
            %n>0;)  //   is NOT a multiply of `n` nor 0
  ;return n;}       //  After the loop: return the modified `n` as result

CJam, 15 bytes
q~_{_*1$%!},,\;

Try it online!
Uses the new method in Kevin Cruijssen's 05AB1E answer.

CJam, 21 bytes
This is my old approach to the problem, pre-Kevin Cruijssen's new method which I don't understand
q~mF{[~2/]}%{~#}%{*}*

Try it online!

Explanation
q~                     Translate input into a CJam object (allows for easier testing)
  mF                   Factorise with exponents
    {     }%           For each factor
      ~2/              Halve the exponent [and round down]
     [   ]             Capture the base & exponent in an array
            {  }%      For each transformed factor
             ~#        Expand the base and exponent into b^e
                 {*}*  Multiply all the transformed factors together

This approach removes all single factors (those that would make up the radical part) whilst halving the paired factors (equivalent to square rooting the integer part).

CJam, 23 bytes
A CJam port of Kevin Cruijssen's 05AB1E answer
q~_,(;{_*1$\%0>!},\;)\;

Try it online!

Charcoal, 15 12 bytes
Now based on @someone's formula.
ＮθＩＬΦθ¬﹪×ιιθ

Try it online! Link is to verbose version of code. For each number from 0 to the input, calculates whether its square is divisible by the input, and takes the number of matches.
Alternative version, also 12 bytes:
ＮθＩΣＥθ¬﹪×ιιθ

Try it online! Link is to verbose version of code. For each number from 0 to the input, calculates whether its square is divisible by the input, and takes the sum of the results.
Alternative version, also 12 bytes:
ＮθＩ№Ｅθ﹪×ιιθ⁰

Try it online! Link is to verbose version of code. For each number from 0 to the input, calculates the remainder when its square is divisible by the input, and counts the number of zeros.

Pyth, 9 bytes
ef!%Q^T2S

Try it online!
ef!%Q^T2S
        S   Create range from 1 to (implicit) input
 f          Filter keep from the above, as T, where:
     ^T2      Square T
   %Q         Mod the input with the above
  !           Logical NOT
e           Take the last (largest) element of the filtered list, implicit print

Husk, 9 bytes
-1 byte thanks to Razetime!
▲fo¬%1m√Ḋ

Try it online! or Try all cases!
Commented
▲          -- the maximum of ...
 fo        -- ... filter on the next two functions composed
   ¬       --     - boolean negate / (== 0)
    %1     --     - modulo 1
      m√   -- ... map square root on ...
        Ḋ  -- ... the list of divisors

-1

perl -MList::Util=max -pl, 34 bytes
$n=$_;$_=max grep!($n%$_**2),1..$n

Try it online!
This finds the largest square which properly divides the input number. Very inefficient as it tries all numbers from 1 up to the input.

Ruby, 29 bytes
->n,x=n{x-=1while n%x**2>0;x}

Try it online!

J, 12 bytes
1#.0=[|2^~i.

Try it online!

Arn, 12 10 bytes
·£æ9Š3nòy├

Try it!
Explained
Unpacked: +v{!(v^2%}\~
Uses the formula from the OEIS page: the number of solutions to \$x^2≡0 (\mod n)\$
              ~     1-range (inclusive) to
                _   variable initialized to STDIN; implied
            +\      folded with addition after
v{                  mapping with block (key of v)
  !                 Boolean NOT
    (               Begin expression
          v
        ^           exponentiated by
          2         two
      %             mod
        _           implied
    )               End expression; implied
}                   End block

Whitespace, 71 bytes
[S S S N
_Push_0][S N
S _Duplicate_0][T   N
T   T   _STDIN_as_integer][T    T   T   _Retrieve_input][S N
S _n=Duplicate_input][N
S S N
_Create_Label_LOOP][S T S S T   N
_Copy_0-based_1st_input][S T    S S T   N
_Copy_0-based_1st_n][S N
S _Duplicate_n][T   S S N
_Multiply][T    S T T   _Modulo][N
T   S S N
_If_0_Jump_to_Label_PRINT_RESULT][S S S T   N
_Push_1][T  S S T   _Subtract][N
S N
N
_Jump_to_Label_LOOP][N
S S S N
_Create_Label_PRINT_RESULT][T   N
S T _Print_as_integer]

Letters S (space), T (tab), and N (new-line) added as highlighting only.
[..._some_action] added as explanation only.
Try it online (with raw spaces, tabs and new-lines only).
Port of @Sok's Pyth answer, so make sure to upvote him! Whitespace doesn't have decimals, so his/her approach is ideal for Whitespace since it doesn't use square-root nor regular division, but only integers.
Explanation in pseudo-code:
Integer n = STDIN as integer
Integer r = n
Start LOOP:
  Integer s = r * r
  If(n % s == 0):
    Jump to Label PRINT
  r = r - 1
  Go to next iteration of LOOP

Label PRINT:
  Print r as integer to STDOUT
  (implicitly stop the program with an error: no exit defined)

bc, 52 bytes
define f(n){for(i=n;i--;){if(!(n%(i*i))){return i}}}

Try it online!

Retina, 123 72 bytes
.+                        We convert the input into unary
$&*_ $&*_                 and create a copy for factor checking
{` (_+)                   START LOOP: We square the input by multiplying
$& $.1*$1                 its string representation by its length
(?=^.* (_+) (_+))\2+ .+   We check if the square is a factor of the input
$.1                       if so we replace the whole text with the current counter
 (_*)_.*                  Otherwise we decrement the counter by one
 $1                       ---
-- IMPLICIT LOOP END --
-- IMPLICIT OUTPUT --

Try it online!

This approach is essentially a port of Kevin Cruijssen's 05AB1E answer.
It checks all the numbers from the input downwards until it finds a number whose square divides the original.

-51 bytes: Many thanks to Neil, whose suggestion helped me to cut off a ridiculous amount of code.
I've also switched from separating with newlines to separating with spaces because . is anti-newline.

You should consider adding a TIO link. There are probably opportunities for golfing this down, both in minor tweaks such as using { for +( but also maybe more complex simplifications such as using Retina 1's * operator do perform squaring.

Line 2: * defaults to $&*_. This means that you don't need the $& at the start or the _ at the end.

Line 3: You can use {`_+$ instead (use $& instead of $1 on line 4)

Line 5: This looks like it could be easily simplified if you arrange the numbers in reverse order i.e. use i*i i n instead of n i i*i.

Lines 7-8: I think _ _+$ and a blank line 8 works. (Note that is is pre-reversal so it would be ^_+ _ if you reversed the order as suggested by my previous comment.)

Thank you for the golfs, I had no clue that * defaulted to $&*_ and the changes to 5&7-8 are really clever, I'll apply them soon

MathGolf, 5 bytes
╒²k÷Σ

Port of my 5-byter 05AB1E answer.
Try it online.
Explanation:
╒      # Push a list in the range [1, (implicit) input]
       # (could alternatively be `r` for a range [0, input) )
 ²     # Square each value in this list
  k÷   # Check which values are evenly divisible by the input (1 if truthy; 0 if falsey)
    Σ  # And sum those checks
       # (after which the entire stack joined together is output implicitly as result)

APL(NARS), 23 chars, 46 bytes
{√⍵÷×/(∪a)/⍨2∣≢¨⊂⍨a←π⍵}

test:
  f←{√⍵÷×/(∪a)/⍨2∣≢¨⊂⍨a←π⍵}
  f 4
2
  f 9
3
  f 12
2
  f 13
1
  f 108
6
  f 2×2×2×2×2×3×3
12

comment:
{√⍵÷×/(∪a)/⍨2∣≢¨⊂⍨a←π⍵}
                    π⍵  factor argument
                  a←    save that in a list "a" of prime factors
                ⊂⍨      partition "a" in a list of list each element is ugual factors found
            2∣≢¨        to each element of list of list find if number of elements is odd
    ×/(∪a)/⍨           so choice in ∪a the elements appear in list of list as odd and multiple them
  ⍵÷                   divide the argument for the number of factor contained odd times
 √                     make sqrt of that

TI-Basic, 16 bytes
sum(not(fPart(seq(I²/Ans,I,1,Ans-1

Port of this answer. Takes input in Ans. Output is stored in Ans and is displayed.

Thunno 2 S, 4 bytes
R²$Ḋ

Try it online!
Port of Kevin Cruijssen's 05AB1E answer.
Explanation
R²$Ḋ  # Implicit input
R     # Push [1..input]
 ²    # Square each value
  $   # Push the input again
   Ḋ  # Check for divisibility
      # Sum the resulting list
      # Implicit output

Nekomata, 4 bytes
Ď√‼Ṁ

Attempt This Online!
Ď√‼Ṁ
Ď       Divisors
 √      Integer square root; fails if not a perfect square
  ‼     Remove failed values
   Ṁ    Maximum

Racket, 57 bytes
(define(p x[n x])(if(= 0(modulo x(sqr n)))n(p x(- n 1))))

Try it online!

Explanation
After receiving input, we create a recursive loop that iterates n from the input x to 1. At each iteration we check whether the input x is divisible by the square of n. If it is, we return n. Note that this loop will never reach 0 as all divisible by n when is \$n = 1\$.
$$
  p(x, n=x) =
  \begin{cases}
    n & x \mod n^2 = 0 \\
    p(x, n-1) & otherwise
  \end{cases}
$$
(define (perfect-square x [n x])
  (if (zero? (modulo x (sqr n)))
      n
      (perfect-square x (- n 1))))

What I learnt today
Cool thing I learnt about define is the way we can set default arguments to equal previous arguments. If we write (p 5), both x and n will be set to 5. Saves a ton of bytes. The first draft for this idea was to use a let statement:
(define (p x)
  (let loop ([n x])
    ...))

Documentation

\$x^2 \equiv 0 \mod n\$ (A000188)
Racket's define
Racket's modulo

Have wonderful week ahead!


text:
A long long time ago, in a galaxy ... right here
Task
Given a positive integer return the geologic era and period it was that many million years ago.
Input/output
The input is a string or integer; the output is a string. Eras and periods are separated by slashes (/). Input will always be between 0 and 542 inclusive
Data
The possible outputs for eras and periods and their corresponding time periods (in millions of years) are:

Cenozoic 0 - 66

Quaternary 0 - 3
Neogene 4 - 23
Paleogene 24 - 66

Mesozoic 67 - 252

Cretaceous 67 - 145
Jurassic 146 - 201
Triassic 202 - 252

Paleozoic 253 - 542

Permian 253 - 299
Carboniferous 300 - 359
Devonian 360 - 419
Silurian 420 - 444
Ordovician 445 - 485
Cambrian 486 - 542

Submissions will be scored by byte count. Lowest byte count wins.
Test cases
314 -> Paleozoic/Carboniferous
0 -> Cenozoic/Quaternary
542 -> Paleozoic/Cambrian
100 -> Mesozoic/Cretaceous

I suppose that by "The inpt [sic] is a string or integer" you mean that we can choose, not that we have to handle both. If so, then specifying "integer" is enough, e.g. taking number via stdin is indistinguishable from taking the string representation of that same number.

Welcome to the site! I've edited your question slightly, to improve the format. I've added in a couple more test cases, as well as the constraint "Input will always be between 0 and 542 inclusive", as requiring erroring on invalid input is usually something to avoid when writing challenges. Furthermore, I'd recommend allowing the output to be in any clear format, rather than requiring the era and period to be separated by a /, as again, strict I/O formats are generally best avoided. (cont.)

(cont.) Finally, for your next challenge, I'd highly recommend using the Sandbox so that you can refine the specifics and get preliminary feedback before posting. Hope you enjoy CGCC!

@cairdcoinheringaahing Removing rules listed in "things to avoid when writing challenges" is explicitly not allowed

@cairdcoinheringaahing thanks!

@Abigial I didn't change them back. Someone else did.

@Abigail, nor did Matt change them in the first place.

@matt, that's far far too soon to be accepting a solution.

For future reference, I would recommend against challenges that require a large amount of hard-coded values.

@Beefster just curious : why?

@EricDuminil Challenges are considerably more interesting when there is a discernable pattern than when the optimal solution involves compressing a dictionary lookup or table of some sort.

@Beefster Maybe you could open a discussion on Meta instead of comments here? That way, you'll very likely get a better feedback on your suggestion.

Befunge-93, 537 bytes
&:"C"`#v_"neC">,,,"/ciozo",,,,,,:4`#v_"auQ",,,"yranret">,,,,,,,@
*54+65:<   >  ^"Mes"_v#!`*+3          >#>#             ^#
 "leogene"<^"ale","P"<     v_v#`*64:<>        "enegoeN"^
,,,"Cre"< ^ ,,"Pa"_v#!`"C":< >       ^^"taceous"
`*2"e":_^#`*+*5545:<v_v#
 ,"T"_v#!`*+*543+65:< >"J","cissaru"  ^"riassic"
*"d"3:<v_v#!`
"rmian"< >:"x"3*`!#v_:"F"6*`#v_"D",v  ^"Pe"
"ous",,,,,,"Carbon"<         :        ^"ifer"
"enovian"                          <  ^
"brian","C"_v#`*"Q"6_v#`*"Y"5<        ^"am"
"an",,,"Ord"<        >"S","nairuli"   ^"ovici"

Try it online!
This is basically a giant if/elsif/if chain (or rather, two of them), one for the era, and one for the period.

Jelly,  74  73 bytes
“¥Þ+O83/<<ı)‘Ä>⁸Sµ:3»1;ị"“¥nq9r&t\“¥Ḅr¶4ḍẏżæœġẓÆ$Ụ>¬ḞḂṂĊƁÄ`zṚƥṀȯ4N»Ḳ€¤j”/

A monadic Link accepting number in \$[0,542]\$ which yields a list of characters (or a full program which prints the result).
Try it online!
How?
“...‘Ä>⁸Sµ:3»1;ị"“...“...»Ḳ€¤j”/ - Link: integer, N        e.g. 100
“...‘                            - list of code page indices    [4,20,43,79,56,51,47,60,60,25,41]
     Ä                           - cumulative sums              [4,24,67,146,202,253,300,360,420,445,486]
      >⁸                         - greater than N?              [0,0,0,1,1,1,1,1,1,1,1]
        S                        - sum                          8
         µ                       - start a new monadic chain, call that X
          :3                     - integer divide (X) by 3      2
            »1                   - maximum of that and 1        2
              ;                  - concatenate with X           [2,8]
                            ¤    - nilad followed by link(s) as a nilad:
                 “...“...»       -   list of compressed strings ["Paleozoic Mesozoic Cenozoic","Ordovician Silurian Devonian Carboniferous Permian Triassic Jurassic Cretaceous Paleogene Neogene Quaternary Cambrian"]
                          Ḳ€     -   split each at spaces       [["Paleozoic","Mesozoic","Cenozoic"],["Ordovician","Silurian","Devonian","Carboniferous","Permian","Triassic","Jurassic","Cretaceous","Paleogene","Neogene","Quaternary","Cambrian"]
                "                - zip with:
               ị                 -   index into (modular)       ["Mesozoic","Cretaceous"]
                             j”/ - join with a '/'              "Mesozoic/Cretaceous"

Java (JDK), 260 bytes
n->(n<67?"Cen":n<253?"Mes":"Pale")+"ozoic/"+"QuaternaryNeogenePaleogeneCretaceousJurassicTriassicPermianCarboniferousDevonianSilurianOrdovicianCambrian".split("(?=[A-Z])")[(n=java.util.Arrays.binarySearch("B‘ÉüīŧƣƼǥȞ".toCharArray(),(char)n))<0?~n:n]

Try it online!

Contains invisible characters. The binary search String is actually: "\u0003\u0017\u0042\u0091\u00c9\u00fc\u012b\u0167\u01a3\u01bc\u01e5\u021e".

J, 195 bytes
Assumes that input is 0-542, otherwise ~+7 bytes.
(Cen`Mes`Pale{~66 252&I.);@,'ozoic/';Quaternary`Neogene`Paleogene`Cretaceous`Jurassic`Triassic`Permian`Carboniferous`Devonian`Silurian`Ordovician`Cambrian{~(+/\3 20 43 79 56 51 47 60 60 25 41)I.]

Try it online!

Python 3, 273 264 bytes
lambda y:(['Cen']*67+['Mes']*186+['Pale']*290)[y]+'ozoic/'+(['Quaternary']*4+['Neogene']*20+['Paleogene']*43+['Cretaceous']*79+['Jurassic']*56+['Triassic']*51+['Permian']*47+['Carboniferous']*60+['Devonian']*60+['Silurian']*25+['Ordovician']*41+['Cambrian']*57)[y]

Try it online!

JavaScript (Node.js),  226  221 bytes
n=>(Buffer('!%5LpYTP]]:JZ').some(c=>(n-=c-34)<j++,j=1),a='CenMesPaleQuaternaryNeogenePaleogeneCretaceousJurassicTriassicPermianCarboniferousDevonianSilurianOrdovicianCambrian'.match(/.[a-z]+/g))[j>8?2:j/6|0]+'ozoic/'+a[j]

Try it online!

Charcoal, 148 bytes
Ｎθ§⪪Cen Mes Pale¦ ⁺‹θ⁶⁷‹θ²⁵³ozoic§⪪”↶0s⟧↶'⪪Q⟧⪪⪫(cＩ‹qκyＱυ⌕↖↙″⁼R¤´⁵σι↙¡Ｚ⟧+]IΦc№M⁰$✂%¹νν⬤～[Ｚ⊕←⊘↖τF¤Ｈ>¹Sk◨ⅈγδ；§⟦⬤▶%↨Φ；{θi∕Ｎβ” ＬΦＩ⪪”)¶5″⁶vρ⁶Ｓ⊘l²Ｋκ～y”³‹ιθ

Try it online! Link is to verbose version of code. Explanation:
Ｎθ

Input the year.
§⪪Cen Mes Pale¦ ⁺‹θ⁶⁷‹θ²⁵³

Print one of the three era prefixes depending on the year.
ozoic

Print the era suffix.
§⪪”...” ＬΦＩ⪪”...”³‹ιθ

Extract the years that the periods end from a compressed list of padded years and count how many periods have ended before the input year and index into a compressed list of names of periods to print the current period. (Padding the years to three digits saves 4 bytes overall due to not needing any separators.)

05AB1E, 127 125 124 bytes
.•TćFh/>ytTOb•#ć«•Í‡,®ǝ₁êË2•80в.¥I›©₆12ªèOè.•Hα^B·´‘›∞ÕΣHÄ±[šyZÙΣpK5|´Ø·ëu"dw$мïjéåpºöÒ@’»©\I›¼ä^и9ΣßƒôƶI<Ægª6XyrмÏ•#®Oè'/ý™

Try it online or verify all test cases.
Explanation:
.•TćFh/>ytTOb• # Push compressed string "ozoic cen pale mes"
 #             # Split it on spaces: ["ozoic","cen","pale","mes"]
  ć            # Extract head; pop and push remainder-list and first item separated
   «           # Append this head to each item in the list:
               #  ["cenozoic","paleozoic","mesozoic"]
•Í‡,®ǝ₁êË2•    # Push compressed integer 3656627291841362083337
 80в           # Convert it to base-80 as list: [4,20,43,79,56,51,47,60,60,25,41,57]
    .¥         # Undelta this list: [0,4,24,67,146,202,253,300,360,420,445,486,543]
      I›       # Check for each whether it's larger than the input-integer
               # (1 if truthy; 0 if falsey)
        ©      # Store this list of checks in variable `®` (without popping)
₆              # Push builtin 36
 12ª           # Convert it to a list of digits, and append 12: [3,6,12]
    è          # Index those into the checks (to get those for [67,253,543])
     O         # Sum those checks to get the amount of truthy values
      è        # Index it into the string-list (modulair 0-based,
               # so 3 indexes into "cenozoic")
.•Hα^B·´‘›∞ÕΣHÄ±[šyZÙΣpK5|´Ø·ëu"dw$мïjéåpºöÒ@’»©\I›¼ä^и9ΣßƒôƶI<Ægª6XyrмÏ•
              "# Push compressed string "quaternary cambrian ordevician silurian devonian carboniferous permian triassic jurassic cretaceous paleogene neogene"
 #             # Split it on spaces: ["quaternary","cambrian","ordevician","silurian","devonian","carboniferous","permian","triassic","jurassic","cretaceous","paleogene","neogene"]
  ®            # Push the list of checks from variable `®`
   Oè          # Do the same as we did earlier
'/ý           '# Join the two words on the stack with "/" delimiter
   ™           # And titlecase both words in this string
               # (after which the result is output implicitly)

See this 05AB1E tip of mine (sections How to compress strings not part of the dictionary?, How to compress large integers?, and How to compress integer lists?) to understand how the compression works.

APL (Dyalog Unicode) 18.0, 213 bytes
(0 4 24 67 146 202 253 300 360 420 445 486 543⍸⎕)⊃⊃,/1(⌷,¨↓)¨(9⍴4↑1)⊂(∊∘⎕A⊂⊢)'Cenozoic/QuaternaryNeogenePaleogeneMesozoic/CretaceousJurassicTriassicPaleozoic/PermianCarboniferousDevonianSilurianOrdovicianCambrian'

Try it online! (uses c as a polyfill for ⊂ since TIO has not upgraded to 18.0 yet)

Hello again! :)

perl -pl, 270 251 bytes
@a=((Cenozoic)x67,(Mesozoic)x186,(Paleozoic)x290);@b=((Quaternary)x4,(Neogene)x20,(Paleogene)x43,(Cretaceous)x79,(Jurassic)x56,(Triassic)x51,(Permian)x47,(Carboniferous)x60,(Devonian)x60,(Silurian)x25,(Ordovician)x41,(Cambrian)x57);$_=$a[$_].$".$b[$_]

Try it online!
This creates two arrays with 543 elements each. Finding the era and period is then just a matter of indexing in the arrays.
Edit: The challenge was changed; we can now assume the input is between 0 and 542 inclusive. So we don't need to test the input anymore. And we don't require a slash between era and period either.

You don't need the temporary arrays @a & @b, just index directly into the lists.  Also, removing the string "ozoic" from each of the entries in the first list saves some bytes: 230 bytes

Actually removing the list that @a represents altogether saves a few more bytes: 222

Down to 202 using @Xcali's solution and compressing the list a bit: Try it online!

JavaScript (Node.js), 339 bytes
f=(a)=>{g=(b,q,w)=>{for(i=0;;i++){if(a<q[i])return w[i]}}
x=[67,253,543]
y=['Cenozoic/','Mesozoic/','Paleozoic/']
n=[4,24,67,146,202,253,300,360,420,445,486,543]
m=['Quaternary','Neogene','Paleogene','Cretaceous','Jurassic','Triassic','Permian','Carboniferous','Devonian','Silurian','Ordovician','Cambrian']
console.log(g(a,x,y)+g(a,n,m))}

Try it online!
simplest solution to start golfing

Shortened by 36 bytes: https://tio.run/##LY5LT4RAEITv/ApuM5NFg8CyQsQLnkx8RW/Gw@xsQ8aw07PNI1HCb8cBOXW@6qqu/paDbBVp210ZPME8VwWXorgf64LjMiskbn1tfBS64vLOCoKuJ8ef9mvybDGmh5yVYFgQ7eOcPUHLgizLcvYqG2CTdynGJGdvveyAjKQf53P8DFiDARYs6cW54U2SumuuQirA3p2Kwihnjz3JttVq6/ggvWEchi4OdNbSPRCnjkpJRzS6AlrzSeS0BxictFiSZJ@zd9309I@3rv6FTjhotQrr56U8H9f95Ck0LTZw3WDNa27FjuEvauWzXc0vQkxzxdODmP8A

Whitespace, 1841 1830 1819 bytes

Try it online!
For some reason it doesn't work quite right on TIO, try it using the IDE I wrote it in, Whitelips
Explanation
Since the only conditionals in whitespace are jump-if-negative and jump-if-zero, I figure out if the inputed number minus the number for the era plus one is negative, then jump to the respective label and push the era onto the stack. I then jump into a loop that prints the entire stack. (loops until it reaches a -1, which I push at the very start of the program.) I save repetive bytes by pushing "ogene" and then "Ne" or "Pale", "ozoic/" and then "Mes" or "Cen", etc.

Typo? and then Ner ... but Nerogene isn’t a period.

@matt good catch! misread my handwriting, changing to ne. . .

FEU, 268 bytes
u/x
m/x{486}x*/"Cambr#/x{445}x*/"Ordov%#/x{420}x*/"Silur#/x{360}x*/"Devon#/x{300}x*/"Carbonifer&/x{253}x*/"Perm#/x{202}x*/'Tri,/x{146}x*/'Jur,/x{67}x*/'Cretace&/x{24}x*/- 0/x{4}x*/-N0/x*/-Quaternary/0/eogene/-/Cen!/,/ass%/'/Mes!/&/ous/#/ian/"/ e!/!/ozo%\//%/ic/ /Pal/g

Try it online!
Basically just compression.

Io, 417 bytes
Port of Noodle9's Python answer.
method(y,("Pale "repeated(67).."Mes "repeated(186).."Pale "repeated(290))split at(y).."ozoic/"..("Quaternary "repeated(4).."Neogene "repeated(20).."Paleogene "repeated(43).."Cretaceous "repeated(79).."Jurassic "repeated(56).."Triassic "repeated(51).."Permian "repeated(47).."Carboniferous "repeated(60).."Devonian "repeated(60).."Silurian "repeated(25).."Ordovician "repeated(41).."Cambrian "repeated(57))split at(y))

Try it online!

PHP with -r, 261 bytes
Lots of ternary operators is the shortest solution I've found. Then golfed for some redundant suffixes. Only twice the amount of bytes needed to spell out each era uncompressed.
$a=$argv[1];echo($a<67?Cen:($a<253?Mes:Pale)).'ozoic/'.($a<4?Quarternary:($a<24?Neogene:($a<67?Paleogene:($a<146?Cretaceous:($a<202?Jurassic:($a<253?Triassic:($a<300?Permian:($a<360?Carboniferous:($a<420?Devon:($a<445?Silur:($a<486?Ordovic:Cambr))).ian))))))));

Try it online!

Ruby, 317 bytes
->a{a<31?"Cenozoic/"+(a<4?"Quaternary":(a<24?"Neogene":(a<67?"Paleogene":""))):a<253?"Mesozoic/"+(a<146?"Cretaceous":(a<202?"Jurassic":(a<253?"Triassic":""))):a<543?"Paleozoic/"+(a<300===a ?"Permian":(a<360 ?"Carboniferous":(a<420?"Devonian":(a<445===a ?"Silurian":(a<486 ?"Ordovician": (a<543?"Cambrian":"")))))):""}

Try it online!

05AB1E, 235 bytes
67‹i’¦ì€¸zo¾ã/’™?¹4‹i’QuâìÒÇry’?ë¹₂Í‹i’ÖÌž¹’™?ë’æ§ož¹’™?}}ë¹253‹i’€á€Êzo¾ã/’™?¹145‹i’±ƒˆÆÁàÔºs’™?ë¹т·Ì‹i’JÒ¢í„¾ã’?ë’Æ×í„¾ã’™?}}ë’æ§¢äo¾ã/’™?¹3т*‹i’„œéên’™?ë¹₆T*‹i’®´€¬²¡Ôºs’™?ë¹420‹i’Ùç·‹’™?ë¹445‹i’¯ë„¹´€¤’™?ë¹486‹i’€—€·É²·‹’™?ë’§è¢°’™?

Try it online!
   i                                                         # if
                                                             # implicit input
67‹                                                          # is less than 67
                ?                                            # then output without trailing newline
    ’¦ì€¸zo¾ã/’™                                             # "Cenozoic/"
                    i                                        # if
                 ¹                                           # first item from input history
                  4‹                                         # is less than 4
                               ?                             # then output without trailing newline
                     ’QuâìÒÇry’                              # "Quaternary"
                                ë    i                       # elif
                                 ¹                           # first item from input history
                                    ‹                        # is less than
                                  ₂                          # 26
                                   Í                         # - 2 = 24
                                             ?               # then output without trailing newline
                                      ’ÖÌž¹’™                # "Neogene"
                                              ë              # else
                                                       ?     # output without trailing newline
                                               ’æ§ož¹’™      # "Paleogene"
                                                        }}   # end if statement (2x)
ë     i                                                      # elif
 ¹                                                           # first item from input history
  253‹                                                       # is less than 253
                   ?                                         # then output without trailing newline
       ’€á€Êzo¾ã/’™                                          # "Mesozoic/"
                         i                                   # if
                    ¹                                        # first item from input history
                     145‹                                    # is less than 145
                                      ?                      # then output without trailing newline
                          ’±ƒˆÆÁàÔºs’™                       # "Cretaceous"
                                       ë     i               # elif
                                        ¹                    # first item from input history
                                            ‹                # is less than
                                         т                   # 100
                                          ·                  # * 2 = 200
                                           Ì                 # + 2 = 202
                                                       ?     # then output without trailing newline
                                              ’JÒ¢í„¾ã’      # "Jurassic"
ë                                                            # else
          ?                                                  # output without trailing newline
 ’Æ×í„¾ã’™                                                   # "Triassic"
           }}                                                # end if statement (2x)
             ë                                               # else
                         ?                                   # output without trailing newline
              ’æ§¢äo¾ã/’™                                    # "Paleozoic"
                               i                             # if
                          ¹                                  # first item from input history
                              ‹                              # is less than
                           3т*                               # 3 * 100 = 300
                                        ?                    # then output without trailing newline
                                ’„œéên’™                     # "Permian"
                                         ë     i             # elif
                                          ¹                  # first item from input history
                                              ‹              # is less than
                                           ₆                 # 36
                                            T*               # * 10 = 360
                                                            ?# then output without trailing newline
                                                ’®´€¬²¡Ôºs’™ # "Carboniferous"
ë     i                                                      # elif
 ¹                                                           # first item from input history
  420‹                                                       # is less than 420
              ?                                              # then output without trailing newline
       ’Ùç·‹’™                                               # "Devonian"
               ë     i                                       # elif
                ¹                                            # first item from input history
                 445‹                                        # is less than 445
                                ?                            # then output without trailing newline
                      ’¯ë„¹´€¤’™                             # "Silurian"
                                 ë     i                     # elif
                                  ¹                          # first item from input history
                                   486‹                      # is less than 486
                                                   ?         # then output without trailing newline
                                        ’€—€·É²·‹’™          # "Ordovician"
                                                    ë        # else
                                                            ?# output without trailing newline
                                                     ’§è¢°’™ # "Cambrian"
                                                             # implicit end if statement (5x)