From f82ec1697508e329e4861911ebfc2f02cf10bb80 Mon Sep 17 00:00:00 2001 From: raul Date: Sat, 3 Feb 2024 14:21:38 +0100 Subject: [PATCH] Improved testing environment --- array-sorter/.gitignore | 24 ++++++++++++++++++++++++ array-sorter/gen-numbers.sh | 10 +++++++++- array-sorter/main.go | 4 +++- array-sorter/numbers.txt | 1 - array-sorter/random.txt | 1 - 5 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 array-sorter/.gitignore delete mode 100644 array-sorter/numbers.txt delete mode 100644 array-sorter/random.txt diff --git a/array-sorter/.gitignore b/array-sorter/.gitignore new file mode 100644 index 0000000..d51186b --- /dev/null +++ b/array-sorter/.gitignore @@ -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 + diff --git a/array-sorter/gen-numbers.sh b/array-sorter/gen-numbers.sh index 895f64a..9b92ceb 100755 --- a/array-sorter/gen-numbers.sh +++ b/array-sorter/gen-numbers.sh @@ -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) diff --git a/array-sorter/main.go b/array-sorter/main.go index caffb8f..4f857a7 100644 --- a/array-sorter/main.go +++ b/array-sorter/main.go @@ -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) diff --git a/array-sorter/numbers.txt b/array-sorter/numbers.txt deleted file mode 100644 index 186fc78..0000000 --- a/array-sorter/numbers.txt +++ /dev/null @@ -1 +0,0 @@ -1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 diff --git a/array-sorter/random.txt b/array-sorter/random.txt deleted file mode 100644 index e070b77..0000000 --- a/array-sorter/random.txt +++ /dev/null @@ -1 +0,0 @@ -103 105 121 273 11 62 26 84 265 285 27 78 279 212 252 118 230 36 31 211 257 87 236 177 144 97 218 122 107 40 68 207 129 175 117 160 90 113 225 42 269 13 168 220 41 243 180 99 127 24 201 7 52 176 255 221 299 98 104 54 248 139 153 29 289 155 60 284 242 140 237 79 227 192 19 206 165 214 170 17 270 182 109 111 58 44 281 12 196 173 156 189 288 276 184 261 110 163 181 66 259 61 32 287 162 143 193 250 195 280 77 75 292 240 228 171 123 48 244 258 185 251 28 37 204 158 254 224 234 209 293 131 253 63 125 233 260 134 76 106 179 14 72 223 50 264 190 119 45 116 132 146 15 115 199 174 47 226 268 267 200 18 25 154 215 30 9 164 57 208 16 216 290 33 272 197 74 51 81 278 274 91 151 92 59 249 21 136 108 100 300 71 186 4 277 235 282 246 23 142 241 102 85 133 124 217 126 147 96 38 135 22 286 39 283 120 128 296 55 169 93 202 247 80 20 10 130 83 86 198 161 114 157 213 203 53 46 148 294 166 183 159 49 266 34 94 275 188 178 82 101 73 149 238 187 210 297 229 137 8 239 112 271 89 152 138 67 145 150 141 3 172 231 88 298 222 295 95 56 69 43 219 5 205 167 291 70 64 263 256 65 262 245 35 191 2 232 1 6 194 \ No newline at end of file