diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3932d5c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +**/part[12] diff --git a/ols.json b/ols.json new file mode 100644 index 0000000..90e2150 --- /dev/null +++ b/ols.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://raw.githubusercontent.com/DanielGavin/ols/master/misc/ols.schema.json", + "enable_document_symbols": true, + "enable_hover": true, + "enable_snippets": true +} \ No newline at end of file diff --git a/utils/utils.odin b/utils/utils.odin new file mode 100644 index 0000000..94e7f37 --- /dev/null +++ b/utils/utils.odin @@ -0,0 +1,29 @@ +package utils + +import "core:bufio" +import "core:fmt" +import "core:os" +import "core:strings" + +read_input_lines :: proc(allocator := context.allocator) -> []string { + lines := make([dynamic]string, allocator) + + scanner: bufio.Scanner + bufio.scanner_init(&scanner, os.to_stream(os.stdin)) + defer bufio.scanner_destroy(&scanner) + + for bufio.scanner_scan(&scanner) { + line := strings.clone(bufio.scanner_text(&scanner), allocator) + append(&lines, line) + } + + if err := bufio.scanner_error(&scanner); err != nil { + fmt.eprintfln("ERROR: Scanning input: %v", err) + } + + for len(lines) > 0 && len(lines[len(lines) - 1]) == 0 { + pop(&lines) + } + + return lines[:] +}