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
--a binary number is represented as values in a table | |
t_bin = {1,0,0,0,0,0,0,0} | |
function bin_to_in(x) | |
r=0 | |
for k,v in pairs(x) do | |
r = r + (v*2^(8-k)) | |
end | |
return math.floor(r) | |
end |
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
function conv_to_bin(x) | |
t={} | |
if x>0 then | |
while x>0 do | |
table.insert(t,x%2) | |
x=math.floor(x/2); | |
end | |
end | |
if #t<32 then |
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 ( | |
"fmt" | |
) | |
func main() { | |
var a, b uint | |
a = 1 |
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 ( | |
"fmt" | |
"sync" | |
) | |
func test(n int, s []int, w *sync.WaitGroup) { | |
fmt.Println("start ", n) | |
for k, v := range s { |
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
local a={} | |
for i=1,5000 do | |
a[i]=math.random(0, 650000) | |
end | |
local function bs(t) | |
for k,v in pairs(t) do | |
for kk,vv in pairs(t) do | |
if k~=kk then |
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 "fmt" | |
func main() { | |
a := []int{1, 2, 4, 5} | |
b := []int{2, 5, 6, 7, 8, 9} | |
c := []int{} | |
bs := 0 | |
i := 0 |
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 ( | |
"fmt" | |
) | |
func binary_search(arr []int, item int) int { | |
max := len(arr) | |
low := 0 | |
for low <= max { |
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
l={} | |
for i=1,1000000 do | |
table.insert(l,i) | |
end | |
function b(t,i) | |
max=#t | |
low=1 | |
while low<=max do |
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 ( | |
"fmt" | |
"sync" | |
"time" | |
) | |
var arrTest = []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} |
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 ( | |
"context" | |
"errors" | |
"fmt" | |
"log" | |
"os" | |
"os/signal" | |
"syscall" |
NewerOlder