Created
November 23, 2016 15:03
-
-
Save rabellamy/b94fcb7fa4da3d12e9f184ae21fb6662 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"fmt" | |
"math" | |
"os" | |
"strconv" | |
) | |
func main() { | |
var n, d, index int | |
if _, err := fmt.Scan(&n, &d); err == nil { | |
if n >= 1 && n <= int(math.Pow(10, 5)) && d >= 1 && d <= n { | |
intergers := make([][]byte, n, n) | |
line := bufio.NewReader(os.Stdin) | |
nums, _ := line.ReadSlice('\n') | |
// Removes line feed character (10). | |
nums = nums[:len(nums)-1] | |
for _, num := range nums { | |
if num != 32 { | |
intergers[index] = append(intergers[index], num) | |
} else { | |
index++ | |
} | |
} | |
for i := 1; i <= d; i++ { | |
var n []byte | |
n = intergers[0] | |
intergers = append(intergers[:0], intergers[1:]...) | |
intergers = append(intergers, n) | |
} | |
for delta, interger := range intergers { | |
if s, err := strconv.Atoi(string(interger)); err == nil { | |
if delta != len(intergers)-1 { | |
fmt.Printf("%v ", s) | |
} else { | |
fmt.Printf("%v\n", s) | |
} | |
} | |
} | |
} else { | |
fmt.Println("?") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment