Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dsprog
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Manuel Bucher
dsprog
Commits
2d41e901
Commit
2d41e901
authored
6 years ago
by
Manuel Bucher
Browse files
Options
Downloads
Patches
Plain Diff
code cleanup
parent
297a2b7d
Branches
Branches containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
check
+5
-0
5 additions, 0 deletions
check
loesung.c
+5
-6
5 additions, 6 deletions
loesung.c
visualize.py
+7
-4
7 additions, 4 deletions
visualize.py
visualize_result.py
+7
-4
7 additions, 4 deletions
visualize_result.py
with
24 additions
and
14 deletions
check
+
5
−
0
View file @
2d41e901
#!/bin/bash
#!/bin/bash
if
[
$#
-eq
0
]
;
then
echo
"Usage: check <input file>"
exit
0
fi
./loesung <
$1
| ./check_result
$1
./loesung <
$1
| ./check_result
$1
This diff is collapsed.
Click to expand it.
loesung.c
+
5
−
6
View file @
2d41e901
...
@@ -55,7 +55,7 @@ typedef struct Field {
...
@@ -55,7 +55,7 @@ typedef struct Field {
uint32_t
num_odd
;
uint32_t
num_odd
;
}
Field
;
}
Field
;
//
returns 0 if successful, nonzero if failed
//
gibt 0 zurueck, wenn Initialisierung Erfolgreich durchgelaufen ist
int
field_init
(
Field
*
this
)
{
int
field_init
(
Field
*
this
)
{
memset
(
this
,
0
,
sizeof
(
Field
));
memset
(
this
,
0
,
sizeof
(
Field
));
this
->
tiles
=
malloc
(
sizeof
(
Tile
));
this
->
tiles
=
malloc
(
sizeof
(
Tile
));
...
@@ -64,7 +64,8 @@ int field_init(Field *this) {
...
@@ -64,7 +64,8 @@ int field_init(Field *this) {
return
this
->
tiles
==
0
;
return
this
->
tiles
==
0
;
}
}
// if an error occurs, all memory get freed
// fuegt p_tile zum dynamischen Array hinzu, im Fehlerfall muss immernoch
// der reservierte Speicher speicher freigegeben werden
int
field_push
(
Field
*
this
,
Tile
*
p_tile
)
{
int
field_push
(
Field
*
this
,
Tile
*
p_tile
)
{
if
(
this
->
size
==
this
->
num_tiles
)
{
if
(
this
->
size
==
this
->
num_tiles
)
{
if
(
this
->
size
==
1u
<<
31
)
return
1
;
// catch overflow
if
(
this
->
size
==
1u
<<
31
)
return
1
;
// catch overflow
...
@@ -196,10 +197,8 @@ int field_neighbours(Field *this) {
...
@@ -196,10 +197,8 @@ int field_neighbours(Field *this) {
top
=
begin_line
;
top
=
begin_line
;
begin_line
=
cur
;
// neue Zeile
begin_line
=
cur
;
// neue Zeile
}
}
// ermitteln der Zeilen-Beziehung
// ermitteln der Zeilen-Beziehung, nur wenn obere Zeile ein ueber der aktuellen ist
if
(
begin_line
!=
1
&&
t
[
top
].
x
<
t
[
begin_line
].
x
-
1
)
{
if
(
t
[
top
].
x
==
t
[
cur
].
x
-
1
)
{
// Zeilensprung => Warten bis zur naechsten Zeile angekommen
}
else
if
(
t
[
top
].
x
==
t
[
cur
].
x
-
1
)
{
// finden, ob paar nach oben existiert O(n) fuer alle Nachbarn nach oben/unten.
// finden, ob paar nach oben existiert O(n) fuer alle Nachbarn nach oben/unten.
for
(;
t
[
top
].
y
<
t
[
cur
].
y
&&
top
<
begin_line
;
top
++
);
for
(;
t
[
top
].
y
<
t
[
cur
].
y
&&
top
<
begin_line
;
top
++
);
...
...
This diff is collapsed.
Click to expand it.
visualize.py
+
7
−
4
View file @
2d41e901
...
@@ -2,9 +2,12 @@
...
@@ -2,9 +2,12 @@
import
sys
import
sys
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
import
numpy
as
np
import
numpy
as
np
inp
=
sys
.
argv
[
1
]
def
load
():
def
main
():
if
len
(
sys
.
argv
)
!=
1
:
print
(
"
Usage: visualize <input file>
"
)
return
inp
=
sys
.
argv
[
1
]
f
=
open
(
inp
)
f
=
open
(
inp
)
xs
=
[]
xs
=
[]
ys
=
[]
ys
=
[]
...
@@ -16,6 +19,6 @@ def load():
...
@@ -16,6 +19,6 @@ def load():
plt
.
scatter
(
xs
,
ys
,
marker
=
"
s
"
)
plt
.
scatter
(
xs
,
ys
,
marker
=
"
s
"
)
plt
.
show
()
plt
.
show
()
while
True
:
if
__name__
==
"
__main__
"
:
load
()
main
()
This diff is collapsed.
Click to expand it.
visualize_result.py
+
7
−
4
View file @
2d41e901
...
@@ -2,9 +2,12 @@
...
@@ -2,9 +2,12 @@
import
sys
import
sys
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
import
numpy
as
np
import
numpy
as
np
inp
=
sys
.
argv
[
1
]
def
load
():
def
main
():
if
len
(
sys
.
argv
)
!=
1
:
print
(
"
Usage: visualize <output file>
"
)
return
inp
=
sys
.
argv
[
1
]
f
=
open
(
inp
)
f
=
open
(
inp
)
xs
=
[]
xs
=
[]
ys
=
[]
ys
=
[]
...
@@ -19,6 +22,6 @@ def load():
...
@@ -19,6 +22,6 @@ def load():
plt
.
plot
(
xs
,
ys
,
marker
=
"
s
"
)
plt
.
plot
(
xs
,
ys
,
marker
=
"
s
"
)
plt
.
show
()
plt
.
show
()
while
True
:
if
__name__
==
"
__main__
"
:
load
()
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
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