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")
3
iex> Solution.get_rank("A23A4")
2
iex> Solution.get_rank("23456")
1
"""

View file

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

View file

@ -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"]}}
"""

View file

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

View file

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

View file

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

View file

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

View file

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