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 "testing" | |
const TesthowManyTime int = 10_000 | |
func BenchmarkAppendSice(b *testing.B) { | |
for i := 0; i < b.N; i++ { | |
useAppendSlice() | |
} |
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" | |
) | |
const howManyTime int = 1_000_000_000 |
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() { | |
array := []int{1, 2, 5, 6, 4, 5, 7} | |
fmt.Println(bruteForce(array, 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
func InterpolationSearch(array []int, key int) int { | |
var mid, low int = 0, 0 | |
var high int = len(array) - 1 | |
var valBig, valSmal int | |
for array[low] < key && array[high] > key { | |
valSmal = array[low] | |
valBig = array[high] | |
mid = low + ((key-valSmal)*(high-low))/(valBig-valSmal) | |
if array[mid] < key { |
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
func TwoCrystalBalls(array []int, target int) int { | |
step := int(math.Round(math.Sqrt(float64(len(array))))) | |
rbound := len(array) | |
for i := step; i < len(array); i += step { | |
if array[i] > target { | |
rbound = i | |
break | |
} | |
} |
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() { | |
b := []int{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 100, 159, 192, 350, 1230, 1341, 4533} | |
fmt.Println(BinarySearch(b, 31)) | |
fmt.Println(LinearSearch(b, 31)) |
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
$this->assertDatabaseHas('products', [ | |
'id' => 1, | |
'title' => $this->product->title, | |
]); | |
$this->assertSame($this->product->title, Product::first()->title); |
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
[$product, $product1, $product2] = Product::factory()->count(3)->create(); | |
$product = Product::factory()->create(); | |
$product1 = Product::factory()->create(); | |
$product2 = Product::factory()->create(); |