Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Advent of Code 2023
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Falk Rehse
Advent of Code 2023
Commits
d16a2fde
Commit
d16a2fde
authored
Dec 11, 2023
by
Falk Rehse
Browse files
Options
Downloads
Patches
Plain Diff
Day 10-2 fixed
parent
c59d125e
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/day_10_2/mod.rs
+33
-33
33 additions, 33 deletions
src/day_10_2/mod.rs
src/main.rs
+3
-3
3 additions, 3 deletions
src/main.rs
with
36 additions
and
36 deletions
src/day_10_2/mod.rs
+
33
−
33
View file @
d16a2fde
...
@@ -23,7 +23,7 @@ pub fn solve_from_str(input: &str) -> i32 {
...
@@ -23,7 +23,7 @@ pub fn solve_from_str(input: &str) -> i32 {
let
mut
pos_0
=
(
start_x
,
start_y
);
let
mut
pos_0
=
(
start_x
,
start_y
);
let
mut
old_0
=
pos_0
;
let
mut
old_0
=
pos_0
;
//
map.insert((start_x, start_y), Tile::Pipe);
map
.insert
((
start_x
,
start_y
),
Tile
::
Pipe
);
let
(
move_0
,
move_1
)
=
get_valid_pipes
(
&
grid
,
start_x
as
usize
,
start_y
as
usize
);
let
(
move_0
,
move_1
)
=
get_valid_pipes
(
&
grid
,
start_x
as
usize
,
start_y
as
usize
);
mark_inside
(
move_1
,
pos_0
,
&
mut
map
);
mark_inside
(
move_1
,
pos_0
,
&
mut
map
);
...
@@ -34,7 +34,7 @@ pub fn solve_from_str(input: &str) -> i32 {
...
@@ -34,7 +34,7 @@ pub fn solve_from_str(input: &str) -> i32 {
break
;
break
;
}
}
//
map.insert(pos_0, Tile::Pipe);
map
.insert
(
pos_0
,
Tile
::
Pipe
);
let
tmp_0
=
pos_0
;
let
tmp_0
=
pos_0
;
...
@@ -179,34 +179,34 @@ fn mark_inside(dir: (i32, i32), pos: (i32, i32), map: &mut HashMap<(i32, i32), T
...
@@ -179,34 +179,34 @@ fn mark_inside(dir: (i32, i32), pos: (i32, i32), map: &mut HashMap<(i32, i32), T
if
!
map
.contains_key
(
&
(
pos
.0
,
pos
.1
-
1
))
{
if
!
map
.contains_key
(
&
(
pos
.0
,
pos
.1
-
1
))
{
map
.insert
((
pos
.0
,
pos
.1
-
1
),
Tile
::
Inside
);
map
.insert
((
pos
.0
,
pos
.1
-
1
),
Tile
::
Inside
);
}
}
//
if !map.contains_key(&(pos.0+1, pos.1-1)) {
if
!
map
.contains_key
(
&
(
pos
.0
+
1
,
pos
.1
-
1
))
{
//
map.insert((pos.0+1, pos.1-1), Tile::Inside);
map
.insert
((
pos
.0
+
1
,
pos
.1
-
1
),
Tile
::
Inside
);
//
}
}
}
,
}
(
-
1
,
0
)
=>
{
(
-
1
,
0
)
=>
{
if
!
map
.contains_key
(
&
(
pos
.0
,
pos
.1
+
1
))
{
if
!
map
.contains_key
(
&
(
pos
.0
,
pos
.1
+
1
))
{
map
.insert
((
pos
.0
,
pos
.1
+
1
),
Tile
::
Inside
);
map
.insert
((
pos
.0
,
pos
.1
+
1
),
Tile
::
Inside
);
}
}
//
if !map.contains_key(&(pos.0-1, pos.1+1)) {
if
!
map
.contains_key
(
&
(
pos
.0
-
1
,
pos
.1
+
1
))
{
//
map.insert((pos.0-1, pos.1+1), Tile::Inside);
map
.insert
((
pos
.0
-
1
,
pos
.1
+
1
),
Tile
::
Inside
);
//
}
}
}
,
}
(
0
,
1
)
=>
{
(
0
,
1
)
=>
{
if
!
map
.contains_key
(
&
(
pos
.0
+
1
,
pos
.1
))
{
if
!
map
.contains_key
(
&
(
pos
.0
+
1
,
pos
.1
))
{
map
.insert
((
pos
.0
+
1
,
pos
.1
),
Tile
::
Inside
);
map
.insert
((
pos
.0
+
1
,
pos
.1
),
Tile
::
Inside
);
}
}
//
if !map.contains_key(&(pos.0+1, pos.1+1)) {
if
!
map
.contains_key
(
&
(
pos
.0
+
1
,
pos
.1
+
1
))
{
//
map.insert((pos.0+1, pos.1+1), Tile::Inside);
map
.insert
((
pos
.0
+
1
,
pos
.1
+
1
),
Tile
::
Inside
);
//
}
}
}
,
}
(
0
,
-
1
)
=>
{
(
0
,
-
1
)
=>
{
if
!
map
.contains_key
(
&
(
pos
.0
-
1
,
pos
.1
))
{
if
!
map
.contains_key
(
&
(
pos
.0
-
1
,
pos
.1
))
{
map
.insert
((
pos
.0
-
1
,
pos
.1
),
Tile
::
Inside
);
map
.insert
((
pos
.0
-
1
,
pos
.1
),
Tile
::
Inside
);
}
}
//
if !map.contains_key(&(pos.0-1, pos.1-1)) {
if
!
map
.contains_key
(
&
(
pos
.0
-
1
,
pos
.1
-
1
))
{
//
map.insert((pos.0-1, pos.1-1), Tile::Inside);
map
.insert
((
pos
.0
-
1
,
pos
.1
-
1
),
Tile
::
Inside
);
//
}
}
}
,
}
_
=>
panic!
(),
_
=>
panic!
(),
};
};
}
}
...
...
This diff is collapsed.
Click to expand it.
src/main.rs
+
3
−
3
View file @
d16a2fde
mod
day_10_1
;
mod
day_10_1
;
mod
day_10_2
;
mod
day_10_2
;
mod
day_11_1
;
mod
day_11_2
;
mod
day_1_1
;
mod
day_1_1
;
mod
day_1_2
;
mod
day_1_2
;
mod
day_2_1
;
mod
day_2_1
;
...
@@ -18,8 +20,6 @@ mod day_8_1;
...
@@ -18,8 +20,6 @@ mod day_8_1;
mod
day_8_2
;
mod
day_8_2
;
mod
day_9_1
;
mod
day_9_1
;
mod
day_9_2
;
mod
day_9_2
;
mod
day_11_1
;
mod
day_11_2
;
mod
util
;
mod
util
;
...
@@ -28,7 +28,7 @@ use std::fs;
...
@@ -28,7 +28,7 @@ use std::fs;
fn
main
()
{
fn
main
()
{
let
input
=
fs
::
read_to_string
(
"input"
)
.expect
(
"Could not read input!"
);
let
input
=
fs
::
read_to_string
(
"input"
)
.expect
(
"Could not read input!"
);
let
solution
=
day_1
1
_2
::
solve_from_str
(
input
.trim_end
());
let
solution
=
day_1
0
_2
::
solve_from_str
(
input
.trim_end
());
println!
(
"Solution: {}"
,
solution
);
println!
(
"Solution: {}"
,
solution
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment