Add editorconfig

This commit is contained in:
Ivan R. 2024-12-09 13:08:53 +05:00
parent 0632c7752b
commit 5affe5b40e
Signed by: lumin
GPG key ID: E0937DC7CD6D3817
9 changed files with 38 additions and 20 deletions

18
.editorconfig Normal file
View file

@ -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

View file

@ -94,10 +94,10 @@ defmodule Solution do
iex> Solution.get_rank("23432") iex> Solution.get_rank("23432")
3 3
iex> Solution.get_rank("A23A4") iex> Solution.get_rank("A23A4")
2 2
iex> Solution.get_rank("23456") iex> Solution.get_rank("23456")
1 1
""" """

View file

@ -3,7 +3,7 @@ defmodule Navigator do
Count steps for the first part. Count steps for the first part.
# Examples # Examples
iex> Navigator.count_steps(["R"], %{"AAA" => ["AAA", "ZZZ"], "ZZZ" => ["ZZZ", "ZZZ"]}) iex> Navigator.count_steps(["R"], %{"AAA" => ["AAA", "ZZZ"], "ZZZ" => ["ZZZ", "ZZZ"]})
1 1
""" """
@ -35,7 +35,7 @@ defmodule Navigator do
Count steps for the second part. Count steps for the second part.
# Examples # Examples
iex> Navigator.count_ghost_steps(["R"], %{"BBA" => ["BBA", "BBZ"], "BBZ" => ["BBZ", "BBZ"]}) iex> Navigator.count_ghost_steps(["R"], %{"BBA" => ["BBA", "BBZ"], "BBZ" => ["BBZ", "BBZ"]})
1 1
""" """
@ -72,7 +72,7 @@ defmodule Navigator do
iex> Navigator.pick_destination(["AAA", "BBB"], "L") iex> Navigator.pick_destination(["AAA", "BBB"], "L")
"AAA" "AAA"
iex> Navigator.pick_destination(["AAA", "BBB"], "R") iex> Navigator.pick_destination(["AAA", "BBB"], "R")
"BBB" "BBB"
""" """

View file

@ -13,7 +13,7 @@ defmodule Parser do
Parse instructions. Parse instructions.
# Examples: # Examples:
iex> Parser.parse_input(["LLR", "", "AAA = (AAA, ZZZ)", "ZZZ = (ZZZ, ZZZ)"]) iex> Parser.parse_input(["LLR", "", "AAA = (AAA, ZZZ)", "ZZZ = (ZZZ, ZZZ)"])
{["L", "L", "R"], %{"AAA" => ["AAA", "ZZZ"], "ZZZ" => ["ZZZ", "ZZZ"]}} {["L", "L", "R"], %{"AAA" => ["AAA", "ZZZ"], "ZZZ" => ["ZZZ", "ZZZ"]}}
""" """

View file

@ -64,7 +64,7 @@ defmodule Oasis do
Get a list of differences between values. Get a list of differences between values.
Examples: Examples:
iex> Oasis.get_diff([1, 3, 6, 10, 15, 21]) iex> Oasis.get_diff([1, 3, 6, 10, 15, 21])
[2, 3, 4, 5, 6] [2, 3, 4, 5, 6]
""" """

View file

@ -42,7 +42,7 @@ int main() {
} }
} else { } else {
bool found = false; bool found = false;
for (int i = l + 1; i <= r; i++) { for (int i = l + 1; i <= r; i++) {
if (arr[i] != arr[l]) { if (arr[i] != arr[l]) {
// Different number was found // Different number was found

View file

@ -31,10 +31,10 @@ let stat (s : string) : string =
| s -> ( | s -> (
let raw_results = List.map String.trim (String.split_on_char ',' s) in 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 res_in_seconds = List.map to_seconds raw_results in
let range_str = seconds_to_time (range res_in_seconds) 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 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 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 Printf.sprintf "Range: %s Average: %s Median: %s" range_str avg_str median_str
);; );;

View file

@ -11,15 +11,15 @@ def my_atoi(s)
if c >= '0' && c <= '9' if c >= '0' && c <= '9'
digit_was_scanned = true digit_was_scanned = true
conv = c.ord - '0'.ord conv = c.ord - '0'.ord
# Add new digit # Add new digit
res = res * 10 + conv * sign res = res * 10 + conv * sign
# Test overflow # Test overflow
return i32_max if sign > 0 && res > i32_max return i32_max if sign > 0 && res > i32_max
return i32_min if sign < 0 && res < i32_min return i32_min if sign < 0 && res < i32_min
# First '-' # First '-'
elsif c == '-' && sign_was_scanned == false && digit_was_scanned == false elsif c == '-' && sign_was_scanned == false && digit_was_scanned == false
sign_was_scanned = true sign_was_scanned = true
@ -28,23 +28,23 @@ def my_atoi(s)
# First '+' # First '+'
elsif c == '+' && sign_was_scanned == false && digit_was_scanned == false elsif c == '+' && sign_was_scanned == false && digit_was_scanned == false
sign_was_scanned = true sign_was_scanned = true
# Repeated '-' or '-' after number # Repeated '-' or '-' after number
elsif c == '-' elsif c == '-'
return res return res
# Repeated '+' or '+' after number # Repeated '+' or '+' after number
elsif c == '+' elsif c == '+'
return res return res
# Letters before number # Letters before number
elsif c != '+' && c != ' ' && digit_was_scanned == false elsif c != '+' && c != ' ' && digit_was_scanned == false
return 0 return 0
# Space after sign # Space after sign
elsif c == ' ' && sign_was_scanned elsif c == ' ' && sign_was_scanned
return res return res
# Letters after number # Letters after number
elsif digit_was_scanned == true elsif digit_was_scanned == true
return res return res

View file

@ -1,6 +1,6 @@
def find_intersection(a, b) def find_intersection(a, b)
a,b = b,a if a.min > b.min a,b = b,a if a.min > b.min
return [a.max, b.max].min - b.min if a.max > b.min return [a.max, b.max].min - b.min if a.max > b.min
0 0