From f8a9d72f0adee5582938868d6c7d8261294f6965 Mon Sep 17 00:00:00 2001 From: hamza Date: Thu, 16 Jun 2022 19:23:53 +0100 Subject: [PATCH] Subject(rot-arg-n):add README --- subjects/rotargn/README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 subjects/rotargn/README.md diff --git a/subjects/rotargn/README.md b/subjects/rotargn/README.md new file mode 100644 index 00000000..283e29bd --- /dev/null +++ b/subjects/rotargn/README.md @@ -0,0 +1,27 @@ +## rot-arg-n + +### Instructions + +Write a program that takes arguments from the command line and rotates them by the number in the first argument. +- If the number of arguments is less than 3 print (`'\n'`) +- If the first argument is not a number, the program should print `"Error\n"` +- If the first argument is negative, the program should print `"Error\n"` +- If the first argument is zero, the program should print the original arguments +- Prints the rotated arguments with a space between each argument and a newline at the end. + +### Usage + +```console +$ go run . | cat -e +$ +$ go run . 1 2 3 4 5 | cat -e +3 4 5 2$ +$ go run . 2 "Hello" "World" | cat -e +Hello World$ +$ go run . -1 2 3 4 5 | cat -e +Error$ +$ go run . 0 2 3 4 5 | cat -e +2 3 4 5$ +$ go run . 3 "Hello" "World" | cat -e +World Hello$ +``` \ No newline at end of file