Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
adventofcode
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
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
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jonas Plewinski
adventofcode
Commits
33ac9dc2
Commit
33ac9dc2
authored
2 years ago
by
Jonas Plewinski
Browse files
Options
Downloads
Patches
Plain Diff
day 2
parent
a7d03b56
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
.idea/.gitignore
+8
-0
8 additions, 0 deletions
.idea/.gitignore
__init__.py
+0
-0
0 additions, 0 deletions
__init__.py
day2/day2.py
+16
-16
16 additions, 16 deletions
day2/day2.py
utilities.py
+4
-0
4 additions, 0 deletions
utilities.py
with
28 additions
and
16 deletions
.idea/.gitignore
0 → 100644
+
8
−
0
View file @
33ac9dc2
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
This diff is collapsed.
Click to expand it.
__init__.py
0 → 100644
+
0
−
0
View file @
33ac9dc2
This diff is collapsed.
Click to expand it.
day2/day2.py
+
16
−
16
View file @
33ac9dc2
import
..
/
util
.
py
import
utilities
as
ut
# Day 2 - Part 1
# Day 2 - Part 1
def
rock_paper_scissor_guide_result
():
def
rock_paper_scissor_guide_result
():
...
@@ -8,8 +9,7 @@ def rock_paper_scissor_guide_result():
...
@@ -8,8 +9,7 @@ def rock_paper_scissor_guide_result():
"
C X
"
:
6
,
"
C Y
"
:
0
,
"
C Z
"
:
3
}
"
C X
"
:
6
,
"
C Y
"
:
0
,
"
C Z
"
:
3
}
print
(
score_rps
)
print
(
score_rps
)
score
=
0
score
=
0
with
open
(
"
./input.dat
"
)
as
file
:
for
line
in
ut
.
read_line_by_line
(
"
input.dat
"
):
for
line
in
file
:
#print(line)
#print(line)
player1
,
player2
=
line
.
split
()
player1
,
player2
=
line
.
split
()
print
(
f
"
{
player2
}
:
{
score_rps
[
player2
]
}
"
)
print
(
f
"
{
player2
}
:
{
score_rps
[
player2
]
}
"
)
...
@@ -26,8 +26,7 @@ def rock_paper_scissor_guide_result2():
...
@@ -26,8 +26,7 @@ def rock_paper_scissor_guide_result2():
"
B X
"
:
1
,
"
B Y
"
:
2
,
"
B Z
"
:
3
,
"
B X
"
:
1
,
"
B Y
"
:
2
,
"
B Z
"
:
3
,
"
C X
"
:
2
,
"
C Y
"
:
3
,
"
C Z
"
:
1
}
"
C X
"
:
2
,
"
C Y
"
:
3
,
"
C Z
"
:
1
}
score
=
0
score
=
0
with
open
(
"
./input.dat
"
)
as
file
:
for
line
in
ut
.
read_line_by_line
(
"
input.dat
"
):
for
line
in
file
:
player1
,
result
=
line
.
split
()
player1
,
result
=
line
.
split
()
print
(
f
"
{
result
}
:
{
score_rps
[
result
]
}
"
)
print
(
f
"
{
result
}
:
{
score_rps
[
result
]
}
"
)
score
+=
score_rps
[
result
]
score
+=
score_rps
[
result
]
...
@@ -35,6 +34,7 @@ def rock_paper_scissor_guide_result2():
...
@@ -35,6 +34,7 @@ def rock_paper_scissor_guide_result2():
score
+=
game_rps
[
line
.
strip
()]
score
+=
game_rps
[
line
.
strip
()]
print
(
score
)
print
(
score
)
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
#rock_paper_scissor_guide_result()
#rock_paper_scissor_guide_result()
rock_paper_scissor_guide_result2
()
rock_paper_scissor_guide_result2
()
This diff is collapsed.
Click to expand it.
utilities.py
0 → 100644
+
4
−
0
View file @
33ac9dc2
def
read_line_by_line
(
filename
):
with
open
(
filename
)
as
file
:
for
line
in
file
:
yield
line
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