Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
arc
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
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Buckworth, Titus Frederick Christian C
arc
Commits
79a905f1
Commit
79a905f1
authored
4 months ago
by
tbuckworth
Browse files
Options
Downloads
Patches
Plain Diff
came up with a solution to example 1
parent
7205a4e9
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
json_tests.py
+8
-4
8 additions, 4 deletions
json_tests.py
main.py
+0
-21
0 additions, 21 deletions
main.py
prolog/solution_1.pl
+70
-0
70 additions, 0 deletions
prolog/solution_1.pl
with
78 additions
and
25 deletions
json_tests.py
+
8
−
4
View file @
79a905f1
...
...
@@ -6,10 +6,10 @@ import numpy as np
from
main
import
load_task
,
grid2FOL
,
FOL2grid
,
FOL2prolog
,
prolog2FOL_array
class
MyTestCase
(
unittest
.
TestCase
):
class
TaskTester
(
unittest
.
TestCase
):
@classmethod
def
setUpClass
(
cls
):
cls
.
task
=
load_task
()
cls
.
task
=
load_task
()
#"data/training/0b148d64.json")
# Example of accessing input/output grids for the first example
cls
.
input_grid
=
cls
.
task
[
'
train
'
][
0
][
'
input
'
]
cls
.
output_grid
=
cls
.
task
[
'
train
'
][
0
][
'
output
'
]
...
...
@@ -25,10 +25,14 @@ class MyTestCase(unittest.TestCase):
def
test_print
(
self
):
out_prolog
=
FOL2prolog
(
self
.
out_preds
)
out_FOL_array
=
prolog2FOL_array
(
out_prolog
)
out_grid
=
FOL2grid
(
out_FOL_array
)
self
.
assertTrue
((
out_grid
==
self
.
output_grid
).
all
())
def
test_prolog_program
(
self
):
in_prolog
=
FOL2prolog
(
self
.
in_preds
)
with
open
(
'
prolog/input_example_1.pl
'
,
'
w
'
)
as
file
:
file
.
write
(
in_prolog
)
...
...
This diff is collapsed.
Click to expand it.
main.py
+
0
−
21
View file @
79a905f1
...
...
@@ -128,27 +128,6 @@ def load_jsons():
# Load a single ARC task
task
=
load_task
()
# Example of accessing input/output grids for the first example
input_grid
=
task
[
'
train
'
][
0
][
'
input
'
]
output_grid
=
task
[
'
train
'
][
0
][
'
output
'
]
# rgb_grid = array_and_plot_grid(input_grid)
array_and_plot_grid
(
output_grid
)
in_preds
=
grid2FOL
(
input_grid
,
"
input
"
)
out_preds
=
grid2FOL
(
output_grid
,
"
output
"
)
array_and_plot_grid
(
FOL2grid
(
out_preds
))
old_out_preds
=
copy
.
deepcopy
(
out_preds
)
np
.
random
.
shuffle
(
out_preds
)
[
np
.
random
.
shuffle
(
x
)
for
x
in
out_preds
]
assert
(
FOL2grid
(
out_preds
)
==
FOL2grid
(
old_out_preds
)).
all
()
out_grid
=
FOL2grid
(
out_preds
)
array_and_plot_grid
(
out_grid
)
return
def
load_task
(
json_file
=
'
data/training/0a938d79.json
'
):
...
...
This diff is collapsed.
Click to expand it.
prolog/solution_1.pl
0 → 100644
+
70
−
0
View file @
79a905f1
nrow
(
NR
):-
input_colour
(
NR
,
_
,
_
),
input_colour
(
R2
,
_
,
_
),
\
+
R2
>
NR
.
ncol
(
NC
):-
input_colour
(
_
,
NC
,
_
),
input_colour
(
_
,
C2
,
_
),
\
+
C2
>
NC
.
vertical_colour
(
C
,
Colour
):-
input_colour
(
R
,
C
,
Colour
),
R
is
0
,
\
+
Colour
is
'black'
.
vertical_colour
(
C
,
Colour
):-
nrow
(
NR
),
input_colour
(
NR
,
C
,
Colour
),
\
+
Colour
is
'black'
.
horizontal_colour
(
R
,
Colour
):-
input_colour
(
R
,
C
,
Colour
),
C
is
0
,
\
+
Colour
is
'black'
.
horizontal_colour
(
R
,
Colour
):-
ncol
(
NC
),
input_colour
(
R
,
NC
,
Colour
),
\
+
Colour
is
'black'
.
horizontal_diff
(
N
):-
horizontal_colour
(
R
,
_
),
horizontal_colour
(
R2
,
_
),
R2
>
R
,
N
is
R2
-
R
.
vertical_diff
(
N
):-
vertical_colour
(
C
,
_
),
vertical_colour
(
C2
,
_
),
C2
>
C
,
N
is
C2
-
C
.
remainder
(
N
,
D
,
R
):-
integer
(
X
),
R
is
N
-
X
*
D
.
output_colour
(
_
,
C
,
Colour
):-
vertical_colour
(
Cstart
,
Colour
),
vertical_diff
(
VD
),
C
>=
Cstart
,
VDtwo
is
2
*
VD
,
remainder
(
C
-
Cstart
,
VDtwo
,
R
),
R
==
0
.
output_colour
(
R
,
_
,
Colour
):-
horizontal_colour
(
Rstart
,
Colour
),
horizontal_diff
(
VD
),
R
>=
Rstart
,
VDtwo
is
2
*
VD
,
remainder
(
R
-
Rstart
,
VDtwo
,
Rem
),
Rem
==
0
.
output_colour
(
R
,
C
,
black
):-
\
+
output_colour
(
R
,
C
,
_
).
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