Compare commits

..

2 Commits

3 changed files with 36 additions and 2 deletions

24
array-sorter/.gitignore vendored Normal file
View File

@ -0,0 +1,24 @@
# ---> Go
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
*.txt
# Test binary, built with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# Dependency directories (remove the comment below to include it)
# vendor/
# Go workspace file
go.work

View File

@ -1,5 +1,13 @@
#!/bin/bash
FILE="./array-sorter"
echo {1..300} > ./numbers.txt
cat ./numbers.txt | tr ' ' "\\n" | shuf | tr "\\n" ' ' > ./random.txt
go run . $(cat ./random.txt)
if test -f ./array-sorter; then
echo "$FILE exists, running"
else
echo "$FILE doesn't exist, building"
go build -o $FILE .
fi
./array-sorter $(cat ./random.txt)

View File

@ -43,7 +43,9 @@ func sorter(arr []float64) (orderedArr []float64) {
//var numValue float64
sliced_arr := arr
// TODO: get the actual sorting working
// IT WAS THIS BASTARD WHO KEPT CAUSING OUT OF BOUNDS ERRORS
// I KEPT READING THE LENGTH OF THE ORIGINAL ARRAY INSTEAD OF THE
// ARRAY BEING SLOWLY EMPTIED
for i := 0; i < len(sliced_arr); {
// fmt.Printf("Current slice length: %v\n", sliced_arr)
// fmt.Println(orderedArr)