Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Post Closed as "Duplicate" by Dennis
Removed "in under 100 bytes"
Source Link
lirtosiast
  • 21.6k
  • 5
  • 53
  • 127

Cat "cat"-like program in fewer than 100 bytes of code

The mission is to implement a cat-like program (copy all stdinSTDIN to stdoutSTDOUT) in less than 100 bytes of code.

Rules:

  • You may only use standard libraries
  • Indentation must be either two spaces or a single tab (in languages which require indentation)
  • Scripts must use shebangs
  • The result of cat anything.txt | ./yourprogram | diff anything.txt - should be nothing and should not be an infinite loop

Go example (84 bytes)

package main
import (
  "os"
  "io"
)
func main() {
  io.Copy(os.Stdout,os.Stdin)
} 

C++ example (78 bytes)

#include<iostream>
using namespace std;
int main() {
  cout << cin.rdbuf();
}

Ruby example (44 bytes)

#!/usr/bin/env ruby
$stdout << $stdin.read

Shortest code (by bytes) wins.

Cat-like program in fewer than 100 bytes of code

The mission is to implement a cat-like program (copy all stdin to stdout) in less than 100 bytes of code.

Rules:

  • You may only use standard libraries
  • Indentation must be either two spaces or a single tab (in languages which require indentation)
  • Scripts must use shebangs
  • The result of cat anything.txt | ./yourprogram | diff anything.txt - should be nothing and should not be an infinite loop

Go example (84 bytes)

package main
import (
  "os"
  "io"
)
func main() {
  io.Copy(os.Stdout,os.Stdin)
} 

C++ example (78 bytes)

#include<iostream>
using namespace std;
int main() {
  cout << cin.rdbuf();
}

Ruby example (44 bytes)

#!/usr/bin/env ruby
$stdout << $stdin.read

Shortest code (by bytes) wins.

"cat"-like program

The mission is to implement a cat-like program (copy all STDIN to STDOUT).

Rules:

  • You may only use standard libraries
  • Indentation must be either two spaces or a single tab (in languages which require indentation)
  • Scripts must use shebangs
  • The result of cat anything.txt | ./yourprogram | diff anything.txt - should be nothing and should not be an infinite loop

Go example (84 bytes)

package main
import (
  "os"
  "io"
)
func main() {
  io.Copy(os.Stdout,os.Stdin)
} 

C++ example (78 bytes)

#include<iostream>
using namespace std;
int main() {
  cout << cin.rdbuf();
}

Ruby example (44 bytes)

#!/usr/bin/env ruby
$stdout << $stdin.read

Shortest code (by bytes) wins.

edited title
Link
Kokizzu
  • 1.5k
  • 11
  • 20

Cat-like program in fewer than 100 bytes of code

added 96 characters in body
Source Link
Kokizzu
  • 1.5k
  • 11
  • 20

The mission is to implement a cat-like program (copy all stdin to stdout) in less than 100 bytes of code.

Rules:

  • You may only use standard libraries
  • Indentation must be either two spaces or a single tab (in languages which require indentation)
  • Scripts must use shebangs
  • The result of cat anything.txt | ./yourprogram | diff anything.txt - should be nothing and should not be an infinite loop

Go example (84 bytes)

package main
import (
  "os"
  "io"
)
func main() {
  io.Copy(os.Stdout,os.Stdin)
} 

C++ example (78 bytes)

#include<iostream>
using namespace std;
int main() {
  cout << cin.rdbuf();
}

Ruby example (44 bytes)

#!/usr/bin/env ruby
$stdout << $stdin.read

Shortest code (by bytes) wins.

The mission is to implement a cat-like program (copy all stdin to stdout) in less than 100 bytes of code.

Rules:

  • You may only use standard libraries
  • Indentation must be either two spaces or a single tab (in languages which require indentation)
  • Scripts must use shebangs

Go example (84 bytes)

package main
import (
  "os"
  "io"
)
func main() {
  io.Copy(os.Stdout,os.Stdin)
} 

C++ example (78 bytes)

#include<iostream>
using namespace std;
int main() {
  cout << cin.rdbuf();
}

Ruby example (44 bytes)

#!/usr/bin/env ruby
$stdout << $stdin.read

Shortest code (by bytes) wins.

The mission is to implement a cat-like program (copy all stdin to stdout) in less than 100 bytes of code.

Rules:

  • You may only use standard libraries
  • Indentation must be either two spaces or a single tab (in languages which require indentation)
  • Scripts must use shebangs
  • The result of cat anything.txt | ./yourprogram | diff anything.txt - should be nothing and should not be an infinite loop

Go example (84 bytes)

package main
import (
  "os"
  "io"
)
func main() {
  io.Copy(os.Stdout,os.Stdin)
} 

C++ example (78 bytes)

#include<iostream>
using namespace std;
int main() {
  cout << cin.rdbuf();
}

Ruby example (44 bytes)

#!/usr/bin/env ruby
$stdout << $stdin.read

Shortest code (by bytes) wins.

Tweeted twitter.com/#!/StackCodeGolf/status/483111874830270464
added 5 characters in body
Source Link
Kokizzu
  • 1.5k
  • 11
  • 20
Loading
CORRECT GRAMMAR less -> fewer
Source Link
user16402
user16402
Loading
Post Reopened by Sylwester, Timtech, bwoebi, CommunityBot, Milo
Removed EDITs
Source Link
Jwosty
  • 3.6k
  • 2
  • 23
  • 36
Loading
Changed challenge to code-golf challenge. Edited tags appropriately. Edited winning criteria.
Source Link
Milo
  • 3k
  • 3
  • 15
  • 31
Loading
edited body
Source Link
Kokizzu
  • 1.5k
  • 11
  • 20
Loading
added 55 characters in body
Source Link
Kokizzu
  • 1.5k
  • 11
  • 20
Loading
Post Closed as "Needs details or clarity" by Tal, Glenn Randers-Pehrson, CommunityBot, Martin Ender, user3094403
added 27 characters in body
Source Link
Kokizzu
  • 1.5k
  • 11
  • 20
Loading
Source Link
Kokizzu
  • 1.5k
  • 11
  • 20
Loading