diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..e362a6e --- /dev/null +++ b/.editorconfig @@ -0,0 +1,18 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[{*.rb,*.js,*.ts,*.ex,*.ml}] +indent_style = space +indent_size = 2 + +[{*.rs,*.zig,*.py,*.c,*.cpp,*.h,*.kt,*.sql}] +indent_style = space +indent_size = 4 + +[Makefile] +indent_style = tab diff --git a/advent-of-code/2023/elixir/day_07/lib/solution.ex b/advent-of-code/2023/elixir/day_07/lib/solution.ex index 20cb4c0..799f6f4 100644 --- a/advent-of-code/2023/elixir/day_07/lib/solution.ex +++ b/advent-of-code/2023/elixir/day_07/lib/solution.ex @@ -94,10 +94,10 @@ defmodule Solution do iex> Solution.get_rank("23432") 3 - + iex> Solution.get_rank("A23A4") 2 - + iex> Solution.get_rank("23456") 1 """ diff --git a/advent-of-code/2023/elixir/day_08/lib/navigator.ex b/advent-of-code/2023/elixir/day_08/lib/navigator.ex index b779eab..b539a71 100644 --- a/advent-of-code/2023/elixir/day_08/lib/navigator.ex +++ b/advent-of-code/2023/elixir/day_08/lib/navigator.ex @@ -3,7 +3,7 @@ defmodule Navigator do Count steps for the first part. # Examples - + iex> Navigator.count_steps(["R"], %{"AAA" => ["AAA", "ZZZ"], "ZZZ" => ["ZZZ", "ZZZ"]}) 1 """ @@ -35,7 +35,7 @@ defmodule Navigator do Count steps for the second part. # Examples - + iex> Navigator.count_ghost_steps(["R"], %{"BBA" => ["BBA", "BBZ"], "BBZ" => ["BBZ", "BBZ"]}) 1 """ @@ -72,7 +72,7 @@ defmodule Navigator do iex> Navigator.pick_destination(["AAA", "BBB"], "L") "AAA" - + iex> Navigator.pick_destination(["AAA", "BBB"], "R") "BBB" """ diff --git a/advent-of-code/2023/elixir/day_08/lib/parser.ex b/advent-of-code/2023/elixir/day_08/lib/parser.ex index a4bec26..479553d 100644 --- a/advent-of-code/2023/elixir/day_08/lib/parser.ex +++ b/advent-of-code/2023/elixir/day_08/lib/parser.ex @@ -13,7 +13,7 @@ defmodule Parser do Parse instructions. # Examples: - + iex> Parser.parse_input(["LLR", "", "AAA = (AAA, ZZZ)", "ZZZ = (ZZZ, ZZZ)"]) {["L", "L", "R"], %{"AAA" => ["AAA", "ZZZ"], "ZZZ" => ["ZZZ", "ZZZ"]}} """ diff --git a/advent-of-code/2023/elixir/day_09/lib/oasis.ex b/advent-of-code/2023/elixir/day_09/lib/oasis.ex index c5ebec6..943f1f5 100644 --- a/advent-of-code/2023/elixir/day_09/lib/oasis.ex +++ b/advent-of-code/2023/elixir/day_09/lib/oasis.ex @@ -64,7 +64,7 @@ defmodule Oasis do Get a list of differences between values. Examples: - + iex> Oasis.get_diff([1, 3, 6, 10, 15, 21]) [2, 3, 4, 5, 6] """ diff --git a/codeforces/round-923/task-d/main.cpp b/codeforces/round-923/task-d/main.cpp index de5e183..ffc319e 100644 --- a/codeforces/round-923/task-d/main.cpp +++ b/codeforces/round-923/task-d/main.cpp @@ -42,7 +42,7 @@ int main() { } } else { bool found = false; - + for (int i = l + 1; i <= r; i++) { if (arr[i] != arr[l]) { // Different number was found diff --git a/codewars/ocaml/rank-up/statistics-for-an-athletic-association/main.ml b/codewars/ocaml/rank-up/statistics-for-an-athletic-association/main.ml index 4e5152c..c23df61 100644 --- a/codewars/ocaml/rank-up/statistics-for-an-athletic-association/main.ml +++ b/codewars/ocaml/rank-up/statistics-for-an-athletic-association/main.ml @@ -31,10 +31,10 @@ let stat (s : string) : string = | s -> ( let raw_results = List.map String.trim (String.split_on_char ',' s) in let res_in_seconds = List.map to_seconds raw_results in - + let range_str = seconds_to_time (range res_in_seconds) in let avg_str = seconds_to_time (int_of_float (avg res_in_seconds)) in let median_str = seconds_to_time (int_of_float (median res_in_seconds)) in - + Printf.sprintf "Range: %s Average: %s Median: %s" range_str avg_str median_str );; diff --git a/leetcode/0008-string-to-integer/main.rb b/leetcode/0008-string-to-integer/main.rb index 9d4f2f2..d0bd698 100644 --- a/leetcode/0008-string-to-integer/main.rb +++ b/leetcode/0008-string-to-integer/main.rb @@ -11,15 +11,15 @@ def my_atoi(s) if c >= '0' && c <= '9' digit_was_scanned = true conv = c.ord - '0'.ord - + # Add new digit res = res * 10 + conv * sign - + # Test overflow return i32_max if sign > 0 && res > i32_max return i32_min if sign < 0 && res < i32_min - - + + # First '-' elsif c == '-' && sign_was_scanned == false && digit_was_scanned == false sign_was_scanned = true @@ -28,23 +28,23 @@ def my_atoi(s) # First '+' elsif c == '+' && sign_was_scanned == false && digit_was_scanned == false sign_was_scanned = true - + # Repeated '-' or '-' after number elsif c == '-' return res - + # Repeated '+' or '+' after number elsif c == '+' return res - + # Letters before number elsif c != '+' && c != ' ' && digit_was_scanned == false return 0 - + # Space after sign elsif c == ' ' && sign_was_scanned return res - + # Letters after number elsif digit_was_scanned == true return res diff --git a/leetcode/0223-rectangle-area/main.rb b/leetcode/0223-rectangle-area/main.rb index 9a4242b..3e9a724 100644 --- a/leetcode/0223-rectangle-area/main.rb +++ b/leetcode/0223-rectangle-area/main.rb @@ -1,6 +1,6 @@ def find_intersection(a, b) a,b = b,a if a.min > b.min - + return [a.max, b.max].min - b.min if a.max > b.min 0