This file contains hidden or 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 shuffle | |
// Shuffle implements the Fischer-Yates shuffle | |
// algorith for generic slice types. | |
import ( | |
math/rand | |
time | |
) |
This file contains hidden or 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 "fmt" | |
// Q1. Write a function that takes in a number and | |
// returns the next number that is divisible by 7. | |
func next7(n int) int { | |
n++ | |
if n%7 == 0 { | |
return n |
This file has been truncated, but you can view the full file.
This file contains hidden or 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 deque | |
// A single element of the deque. | |
// The leftmost element has left = nil, | |
// and the rightmost element has right = nil. | |
type element struct{ | |
// The elements to the left and right of this one. | |
left, right *element | |
// The deque to which this element belongs. |
This file contains hidden or 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 stack | |
type element struct { | |
// Pointer to the next element in the list. | |
// The last element has next = nil. | |
next *Element | |
// The stack to which this element belongs. | |
stack *Stack | |
// The contents of this stack element. |
This file contains hidden or 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 ( | |
"flag" | |
"fmt" | |
"math/rand" | |
"os" | |
"time" | |
) |