You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
zainabdnaya 26e0588b66 PrinAndMiss 1 year ago
..
README.md PrinAndMiss 1 year ago

README.md

PrintAndMiss

Instructions

Write a function called PrintAndMiss() that takes a string and an integer and prints a string containing the characters until reaching the integer, then skipping that same number of characters, and repeats until the end of the string.

  • Prints the first half followed by newline \n.
  • If the string is empty retun Invalid Output.
  • If the integer is 0 ot it's negative return the string followed by a newline \n.

Expected function

func PrintAndMiss(arg string, loop int) string {
}

Usage

Here is a possible program to test your function:

package main

import (
	"fmt"
)

func main() {
	fmt.Print(PrintAndMiss("123456789", 3))
	fmt.Print(PrintAndMiss("abcdefghijklmnopqrstuvwyz", 3))
	fmt.Print(PrintAndMiss("", 3))
	fmt.Print(PrintAndMiss("hello you all ! ", 0))
	fmt.Print(PrintAndMiss("what is your name?", 0))
	fmt.Print(PrintAndMiss("go Exercise Print and Miss", -5))
}

And its output :

$ go run . | cat -e
123789$
abcghimnostuz$
Invalid Output$
hello you all ! $
what is your name?$
Invalid Output$