mirror of https://github.com/01-edu/public.git
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.
37 lines
710 B
37 lines
710 B
5 years ago
|
package main
|
||
5 years ago
|
|
||
|
import (
|
||
|
"reflect"
|
||
|
|
||
5 years ago
|
"github.com/01-edu/z01"
|
||
|
|
||
5 years ago
|
correct "./correct"
|
||
5 years ago
|
student "./student"
|
||
|
)
|
||
|
|
||
5 years ago
|
func challengeBytes(fn1, fn2 interface{}, args ...interface{}) {
|
||
5 years ago
|
st1 := z01.Monitor(fn1, args)
|
||
|
st2 := z01.Monitor(fn2, args)
|
||
|
if !reflect.DeepEqual(st1.Results, st2.Results) {
|
||
5 years ago
|
z01.Fatalf("%s(%08b) == %08b instead of %08b\n",
|
||
|
"SwapBits",
|
||
5 years ago
|
args[0].(byte),
|
||
|
st1.Results[0].(byte),
|
||
|
st2.Results[0].(byte),
|
||
|
)
|
||
|
}
|
||
|
}
|
||
|
|
||
5 years ago
|
func main() {
|
||
5 years ago
|
args := []byte{0x24, 0x14, 0x11, 0x22, 0xd2, 0x15, 0xff, 0x0, 0x35, 0x58, 0x43}
|
||
|
|
||
|
for i := 0; i < 10; i++ {
|
||
|
n := z01.RandIntBetween(0, 255)
|
||
|
args = append(args, byte(n))
|
||
|
}
|
||
|
|
||
|
for _, v := range args {
|
||
5 years ago
|
challengeBytes(student.SwapBits, correct.SwapBits, v)
|
||
5 years ago
|
}
|
||
|
}
|