Skip to main content
Became Hot Network Question
deleted 15 characters in body
Source Link
thesilican
  • 559
  • 2
  • 15

This is , shortest code in UTF-8 bytes wins.

This is , shortest code in UTF-8 bytes wins.

This is , shortest code wins.

Tweeted twitter.com/StackCodeGolf/status/1280562232435396608
Add test case
Source Link
thesilican
  • 559
  • 2
  • 15

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.

Standard loopholes and I/O rules apply.

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.

Relax output requirements
Source Link
thesilican
  • 559
  • 2
  • 15
/
  documents/
    document.docx
  downloads/
    zippedfile/
      notavirus.exe
    coolgoats.mp3
    zippedfile.zip
  pictures/
    myvacation.png
  • All directories names must end with a "/"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 orderDirectories and files should be listed in lexographical alphabetical order
    • The character "." lexographically comes before any alphabetical characterThe character "." lexographically comes before any alphabetical character
  • You may output the contents of directories in any order you wish
/
  documents/
    document.docx
  downloads/
    zippedfile/
      notavirus.exe
    coolgoats.mp3
    zippedfile.zip
  pictures/
    myvacation.png

Input 3: Alphabetical listing of directories and filesAlphabetical listing of directories and files no longer necessary

/
  a/
  b/
  c/
  a.txt
  aa.txt
  ab.txt
  b.txt
  c.txt
84
mkdir folder1
cd folder1
cd ../folder2
touch file.txt
/
  folder1/
    file.txt

This is , shortest code in UTF-8 bytes wins.

Edit: output requirements have been relaxed a little bit

/
  documents/
    document.docx
  downloads/
    zippedfile/
      notavirus.exe
    coolgoats.mp3
    zippedfile.zip
  pictures/
    myvacation.png
  • All directories names must end with a "/"
  • 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
/
  documents/
    document.docx
  downloads/
    zippedfile/
      notavirus.exe
    coolgoats.mp3
    zippedfile.zip
  pictures/
    myvacation.png

Input 3: Alphabetical listing of directories and files

/
  a/
  b/
  c/
  a.txt
  aa.txt
  ab.txt
  b.txt
  c.txt
8
mkdir folder1
cd folder1
cd ../folder2
touch file.txt
/
  folder1/
    file.txt

This is , shortest code in UTF-8 bytes wins.

/
  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
/
  documents
    document.docx
  downloads
    zippedfile
      notavirus.exe
    coolgoats.mp3
    zippedfile.zip
  pictures
    myvacation.png

Input 3: Alphabetical listing of directories and files no longer necessary

/
  a
  b
  c
  a.txt
  aa.txt
  ab.txt
  b.txt
  c.txt
4
mkdir folder1
cd folder1
cd ../folder2
touch file.txt
/
  folder1
    file.txt

This is , shortest code in UTF-8 bytes wins.

Edit: output requirements have been relaxed a little bit

added 121 characters in body
Source Link
thesilican
  • 559
  • 2
  • 15
Loading
deleted 25 characters in body
Source Link
thesilican
  • 559
  • 2
  • 15
Loading
added 127 characters in body
Source Link
thesilican
  • 559
  • 2
  • 15
Loading
Modify input to include number of commands
Source Link
thesilican
  • 559
  • 2
  • 15
Loading
Source Link
thesilican
  • 559
  • 2
  • 15
Loading