#AoC 2022 | Day 22 | Solutions & Spoilers
601 messages · Page 1 of 1 (latest)
piss.
upside down c for me
my actual input looks like
##
#
##
#
so, uhh, great waste of 15+ minutes I guess
if everyone has the same shape and it's not the one in the test, then that actively disincentivizes checking on the test
because if I'd done all the work I'd done for the actual input, rather than the test, I'd be done right now
how? my code looks like a toddler was let lose on the kb
same
https://gyazo.com/2b49d21eaef90caaf064c49032b37d9c i'm still not done with p1 and i'm just visualizing it
because we wouldn't have to algorithmically figure out how to fold the cube
i see
same for robot day
the actual tc
that threw me
are answers in the hundred thousands
that was so lines didn't go off the screen, that was actually a bit understandable
yeah
my visualiser for folding
Same here
Wait did everyone get the same shape LOL
I'm ngl I just hardcoded the connections
Did anyone actually implement an algorithm to fold the net?
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
That is the worst code I have ever seen
thank you
Please tell me you didn't write that by hand
i did
💀
🧌
there's probably some fancy math shit
but i really don't want to figure it out rn
i am seriously at the point of desperation rn i didn't even exclude the debugging thingy https://paste.pythondiscord.com/ipaxitahex.py
help
what did your cube look like
01
2
34
5
damn
which for some reason didn't work 😭
how do you fold this
i skipped part 1 and i'm currently in the process of trying to skip part 2
i think everyone had that
look at my beautiful drawing
with all my arrows
🧌
im gonna go to sleep
i'm making a gif
day_22.py lines 113 to 120
face_connections=[
[(1, (1, 0)), (2, (0, 1)), (3, (1, 0)), (4, (1, 0))],
[(4, (-1, 0)), (2, (-1, 0)), (0, (-1, 0)), (5, (0, -1))],
[(1, (0, -1)), (4, (0, 1)), (3, (0, 1)), (0, (0, -1))],
[(4, (1, 0)), (5, (0, 1)), (0, (1, 0)), (2, (1, 0))],
[(1, (-1, 0)), (5, (-1, 0)), (3, (-1, 0)), (2, (0, -1))],
[(4, (0, -1)), (1, (0, 1)), (0, (0, 1)), (3, (0, -1))],
],```
Apparently I can't get it to spoiler that lol
it was not fun that the cube faces had an even number of characters
which screwed up some of my transformations
Is this normal? A part of the input is split with double lines and a part is not
wtf
That's whatever you're viewing it in
It's not double lines, it's being wrapped
weird wrapping then
considering the other lines weren't wrapped
but have the same number of chars
didn't annoy me much ngl
day_22.py line 28
"\n".join(f"{row:{max_len}}" for row in map.splitlines()),```
😒
how do you make sense of that
now we wait for someone to golf
I can't golf mine bc it uses numpy
Faces are numbered as ```
01
2
34
5
When moving off a face, look up from that table [face moving from][direction moving]
It tells you your new face and direction
mine is full vanilla but i need to add logic for generating the transformation and adjacency tables
Same here
doesn't everyone have the same shape input?
no
mine is not like this
oh no
yeah I thought so
ah
pretty much confirmed then
yeah
golf will be a bit easier
a lot easier imo, I don't even know where to get started on algorithmically folding a cube and linking its edges
I did a for num, dir in re.findall(r"(\d+)(R|L)", path): on the first problem and I took a second to think "is this going to bite me? Na..." and then it bit me because it ended with a number. If not for that mistake, I would've made the global leaderboard for part 1
ooo, now I kinda want to try the challenge to get this to work with any folding automatically... but that wouldn't be smart as it is 2 am local time now. I'm going to do the smart thing and go to bed.
It is double lines, I tried to copy it and the double lines stayed
that's the same for everyone right?
It's looking like it, yeah
the ascii art of someone slowly going insane
at least it wasn't an isocahedron or something
someone else strip'd the input? 👀
rust macros are fun, you can turn your structured notes into code 😄
Yeah macros are great for that
this one is hard
initially, but I immediately realized and only stripped trailing whitespace
That reminds me, I need to fix aoc_helper's example fetching stripping the front lol
I feel this one is hard implementation-wise, rather than being conceptually hard
i.e. it's obvious conceptually what to do, actually executing it and writing semi-sane code for it is the hard part 😛
I totally agree with that
i've spent quite a long time hard-coding and bug fixing the edges.
but it was almost impossible to debug.
I did get the edges correct, I'm so happy I did the macros to keep the cases readable
having mostly the same code duplicated 14 times would have been painful
and spending the time to make a diagram was quite helpful
think hard once to create the diagram, refer to the diagram N times later on
aoc 2023 day22 part 2 is gonna be like
You approach the strange input device, but it isn't quite what the monkeys drew in their notes. Instead, you are met with a strange-looking shape; each of its twenty-four faces is a square of 50x50 tiles.
To be fair, the monkeys' map does have 24 50x50 regions on it. If you were to carefully fold the map in four dimensions, you should be able to shape it into a hypercube!
I and sounds like a lot of other people did it pretty manually. I made a paper cube and number the sides like the numbers I assigned to the unfolded one. Then I carefully noted which other sides were on the top/bottom/left/right of each face. As long as you know which face to go to next when you leave off a certain side AND which incoming side of that face you'll be on, you can write a very complex and error prone translation formula. I had to do that twice, once for the input and once for the example because the input failed... turns out I had a dozen or so errors in my formulas that I had to overcome one at a time as I checked the example input one step at a time.
when in numpy you do np.where(arr == '.') is there a way to do np.where(col in my_list_of_things_to_search_for)
Please kill me.
Ugly solution is ugly.
Im still on pt 1 and I keep seeign these cubes... im not sure this is good
You bet!
Ill just keep doing pt1 blissfully unaware that pt2 looks like hell.
ok im on pt 2 - I did think that the map looked a bit like a slice of a map that could be folded up.
github copilot ai suggestion for pt2:
def pt_2(space, directions):
pass
"Can you do this problem?" "Pass"
i still want to clean up this solution: https://github.com/salt-die/Advent-of-Code/blob/main/2022/day_22.py
How are you handling the wrapping?
with portals
the positions are converted from the flat coordinates, to face specific coordinates
Are you splitting the thing up into faces?
yeah
Ah right! I cant decide an approach, I did consider doing a 3D numpy array at one point but I think that is a bad idea 😂
a (6, L, L) array would be better than a (L, L, L) array where most of it isn't used
though you could use numpy rotations with the (L, L, L) array
And just fill it with None if you ever hit a None you know youre in the wrong place I guess
seems excessive though
I think keeping it 2D and using portals is probably easier
When I initially started manually creating my object very similar to portals, I had a very similar amount of fields, but, being worried about making a typo somewhere in all that data, I realized that I could get away with just knowing the new face number. From there I figure out the entry side by iterating through the new side's entries in the same object to see where which side the old face comes from.
just started part2
welcome to pain
just entered hell
i don't know if i can do that with my faces --- they all use local coordinates
i could just store a connection and a rotation though
this is what i did
I also only stored some info about connections and rotations
if moving from one face into some invalid "face", then teleport to the correct cell and apply the relevant rotation
@solar tree this is what I'm working on too but I'm shit at math
I'm trying to figure out the transformation matrix for each faces to each faces
Agh
I made a mistake somewhere
somewhere in my 24 hard coded portals between faces
24??
6 faces, each with 4 edges
isn't that 12 ?
but sometimes you just go from one face to another w/o any portals lol
6 * 4 = 24
True but I have split up all my faces in what some may call "A huge fucking error"
ffff
it does make it easier to work out which edge you have come off though
Im nearly 80% sure that my code works, its just my portals are wrong
shit I need help with translation matrices
from what I've remember it should be
[1, 0, x]
[0, 1, y]
[0, 0, 1]
but I don't remember how to apply that to a 2D point
WHAT THE PISS
SOMEHOW
I ACCIDENTALLY STARTED AT THE RIGHT TOP CORNER INSTEAD OF THE LEFT TOP CORNER
AND IT WORKED FOR MY P1 TEST CASE
BUT NOT P2
WHA
LOOOL
oh i get it
Probably means you wrapped around and hit the wall you would have hit anyway
it's because you ram into a wall asap
yeah
but still
what the piss
p2_wrap = {}
for i in range(DIM):
p2_wrap[(1 + 2 * DIM, 1 + i, Dir.UP)] = (1 + DIM + i, 1 + DIM, Dir.RIGHT)
p2_wrap[(1 + 2 * DIM + i, 1, Dir.LEFT)] = (DIM - i, 1 + DIM, Dir.RIGHT)
p2_wrap[(1 + 3 * DIM + i, 1, Dir.LEFT)] = (1, 1 + DIM + i, Dir.DOWN)
p2_wrap[(4 * DIM, 1 + i, Dir.DOWN)] = (1, 1 + 2 * DIM + i, Dir.DOWN)
p2_wrap[(3 * DIM, 1 + DIM + i, Dir.DOWN)] = (1 + 3 * DIM + i, DIM, Dir.LEFT)
p2_wrap[(1 + 2 * DIM + i, 2 * DIM, Dir.RIGHT)] = (DIM - i, 3 * DIM, Dir.LEFT)
p2_wrap[(1 + DIM + i, 2 * DIM, Dir.RIGHT)] = (DIM, 1 + 2 * DIM + i, Dir.UP)
cleaner than i thought it would be
apply to [vx, vy, 1]
though why bother with matrices here?
just do the translations and 90 degree rotations 
Im done for today thi, I'll finish some other day
I feel dumb to ask but... how do you apply 90° rotations without matrix ?
*sight* I should have worked more in school
Are you trying to rotate a [[]] structure, or a (x, y) facing pair?
all rotations of a point:
(x, y), (y, -x), (-x, -y), (-y, x)
(that's for anti-clockwise, assuming +x is right and +y is down)
u.u I'm not bad at my job I swear, please don't judge me
right, what direction is left/right depends on your coordinate system
If you wanted to know for a structure, there's [*zip(*[iter(grid)]*len(grid))][::-1] and [*zip(*[iter(grid[::-1])]*len(grid))]
rn I have all my points in a "global" coordinate system, and I was about to have one coordinate system per face with its own transformation
(anti-clockwise and clockwise, respectively, assuming +x being right and +y being down, in a [y][x] 2d list)
I have a global one and apply transformations when the you exit the "valid" space
that's my idea too
i only use the global coordinates at the end to get the score
I only use the global coordinates
i'm on the fence about putting these faces in a raycaster
my 3d rendering is limited mostly to cubes
Dang
for now
planes aren't exactly 3d
i can render the polygons for the faces of the cube though -- but i don't have methods to interpolate textures to the deformed polygons -- and doing it in python will be too slow
the low res of a terminal limits how much stuff you want to draw though
Fair
i did do 3d for lava drops
render with braille characters, 2x4 per character
Yeah I saw that one on the SR, it's neat
I wonder if someone has made a text art font that replaces the dots in the braille characters with flush rectangles lol
Probably, right?
(btw if you want to render a braille character, it's super easy)
dunno, i was looking for unicode hexagons the other day, that would tile
U+2800 + (value)
where value is a byte
03
14
25
67
i have a braille video player and braille image widget already
"You begin the path in the leftmost open tile of the top row of tiles."
Alright, so shouldnt it be here?
im confused
How is that the top row
the most left point of the most up points
the uppitest most leftest
(that would be the one that they chose)
you have to uppitest first
Yes, which means that that is the thing being modified, so it comes after the modifier
The left-most of the top
thats even easier lol
Not the top-most of the left
right
'the uppitest-most leftest' means the most uppity of the leftest points
there are special rules to using uppitest
you obviously aren't familiar with them
i have the 10 volume text on using uppitest here at my desk
dunno i don't speak polish
but it depends on the face you're on, maybe it's the bottomest rightest
wow
today was weird
I ended up hardcoding the folding of the cube but not the edge links
there's a lot I could fix up on I think
like not having a 16 case match statement
thats so unlucky
because u showed me lazy thing
(\d+)(R|L)?
so this would have included the last number then
did anyone else do it with complex numbers?
I found them to be quite elegant in representing rotations as well as coordinates
i tried and it was working for the test input in p1
failed on actual input in p1
mine worked fine
i had this for pt1
lots of symmetry in this one
should make the golf interesting
That's why you use "\d+|L|R"
i did r'\d+|[LR]'
L|R is shorter
[LR] conveys that L and R are both turns
I ended up with (\d+)(R|L|)
ah makes even more sense
I kinda liked yours better
It would be, they're largely the same, but yours was conceptually cleaner, because it wasn't really R, L, or nothing, it was R or L which wasn't there. Also, I'm more comfortable with the greedy nature of ? knowing it'll grab as much as it can when it can. With R|L|, it'd still be the same, but its grabbing the R or L because its earlier in the list.
i thought ? is opposit of greedy
? has multiple meanings depending on the context. AFTER a *, +, or ? modifier it means nongreedy, but just as its own modifier, it means 0 or 1 with more as the preference
oh i see
how did you solve p2?
i dont really plan on doing it rn
but if i would i would have written conditionals so that my "cursor" moves through portals at the edges
whats the smarter way to do p2?
Maybe, but I couldn't think of one
i hardcoded the foldings of the cube in a dict that would give the new face and the new facing for each direction
that sounds like portals
but different
kinda
literally called my dictionaries portals for p1 and cube_portals for p2
finally fully automated today
something of a "if it doesn't work, shove another minus sign somewhere" approach
but it works!
and nothing is hardcoded except the size of each face (which is given in the problem)
why use a protocol? I was under the impression it's like an abstract base class but with the typing system, but you only use it once
the Map protocol is implemented by BasicMap, for part 1, and CubeMap, for part 2
nice
for p2, my original input was like
S#
#
##
#
I re-shape it into
#S#
#
#
#
every time when I move to the side, I rotate the cube to ensure the current side is at the top center position
god that sounds convoluted
how many lines is that lmao
I keep a separate dict for every face and sort them by their row and then their column
along with the top left element of each face
and then when I need to switch faces I take the complex vector of the original position from the original face and modify it to a new vector for the new face
Has anyone tried splitting the input into 6 lists and manipulating the lists instead of turning? These are small, it should take much time.
I hate 3d problems. They break my brain. This is hurts me as much as day 18 did.
just a multi dimensional list like map[y][x], and have one for reach side. Then rotate the maps when needed.
so like instead of rotating the person you rotate the entire face?
yes, and switch maps out when you hit the end of a list.
seems like it'd be the same complexity
and slower
and harder to think about
I liked my complex number method for rotations because it was easy to visualize
since I had to imagine the cube in my head
it is easier for me to think of it the way described it.
fair
I don't have much experience with 3d stuff either
which is why I stuck to 2d
the alternative would've been having a 3d numpy array and that felt really annoying
considering we aren't even using the entire inner cube
true
At the seam, convert the coordinate & direction to 3D, do the move, and then project back to 2D and continue there.
So close! You know the total surface area of the cube though; the size shouldn't be hard to find.
I should really start using classes. I don't know what I have against them, but when ever I try to use one, I end up getting rid of it.
i used to use classes a lot
but now i prefer just passing around lists and stuff
more of a functional person now ig
That's how I feel. It seems like so much extra typing.
i use the occasional attrs class for some stuff
I'm pleased with myself that I finally managed to solve part 2 without looking at spoilers... after lots of head scratching and drawing cubes on a whiteboard 😅
(Whiteboard needs a clean, I know...)
Yeah, I've settled into doing something similar. I have a few method-less dataclasses, and functions that operate on them. Sometimes I will make a function a method of a class if it feels natural, but often I can't decide which class the method should belong to, if you get what I mean 
I found figuring out how to represent the orientation of the cube tricky because it's not something I've done before. But I'm pretty satisfied with the representation I settled on (just a permutation of the corner numbers, essentially).
'Folding' the net was alright once I found this representation. I essentially rolled the cube over the net, if that makes sense
(to figure out how the corners of each square of the net correspond to the eight corners of the cube (you can see an example of this in the picture I posted)).
On to day 23...
I just kept a "canonical representative" of each face of the cube (top left corner) and then used the vector from the representative to the current point to determine the vector of the representative on the new face to the new point
I asked GPT to implement a net folding function for me and I don't think this works but I can't reason about it right now and I'm in bed
https://paste.pythondiscord.com/mocujapuga edit: replaced topaz paste with pydis paste
Can anyone with more brain power and/or a computer to hand confirm my suspicion lol
Wtf why is it so long
Finally finished part 2 of day 22 without any hardcoding!
Wrote the net folding algorithm all by myself
well chuffed
congrats
what was your approach? mine felt quite overcomplicated
but idk a better way
Oh mine was definitely complex as well
I represent the initial net as a list of Nones and number ids, like so
[None, None, 1 , None]
[2 , 3 , 4 , None]
[None, None, 5 , 6 ]
taking a leaf out of the AOC example
then I write an algorithm to match up all the edges of the different ids together
It's a hard problem
Which is why almost everyone gave up and just hardcoded it
Yeah I was close to that as well
but my self-imposed restriction is that I am not allowed to hardcode anything that could be derived from the input
anything in the description is fair game to be hardcoded but not from the input
that and my solution must work for both example and real input
yeah i stuck to it but it was definitely the hardest to code of all the days
that it was - this has been the biggest gulf between "I know what I need to do conceptually" and "I know what code I need to type in"
conceptually I knew exactly what I needed to do
but representing it in code, oh man...
This is a classic example of 'computers have no understanding of the axioms of the physical world (so you need to write them yourself)'
pretty much
This also
My impl was something like:
- make a list of the coordinates of each face
- for each face, determine which face they are joined to (in the net) in each of the four positions
- take one face and put it on the surface of a cube
- put the other faces it joins to in the relevant positions around it
- repeat for each of those faces until the cube is full
- then, use the faces each face is now adjacent to on the cube to make a mapping of which faces join to which others, in the original four positions
plus a bit more complicated stuff to work out your coordinates and direction when you walk on to a face
I figured out that that was the algorithm to use I just couldn't figure out how to implement it at 5AM
And didn't bother after the fact
my algorithm is as follows:
- make a list of the faces as described above
- join up the face edges of the faces already joined together in the net
- work out the "corners" of the edges - this is where one face in the net is joined to two others around a corner
- join up the edges that jut out straight from both directions of the corner
once I've done the above, I'm left with either one or two pairs of edges unpaired - if one pair of edges is unpaired, then just pair them (easy)
- if two pairs of edges is unpaired, work out their neighbours so that you can form two pairs, then pair them like the point above
not sure if that makes sense but that's how I did that
I don't think that's reliable
Think about a T-shaped net
123
4
5
6
After connecting the corners you'll be left with 5 and 6 sticking out, you need a loop
actually it's fine for that case
perhaps I need to explain my corner thing more
take the first corner, which is
1 2
4
so, I work out that 2 is a corner around 1 and 4
from there, I work out how far in each direction I can go along 1 and 4
I can go one along 1, and three along 4, (going through 4, 5, and 6)
then I pair the left edges of 4 5 6 with the edges around 1
Ahh I see
this is actually one of the easier to do
because you are only left with one unpaired at the end
top edge of 2 and bottom edge of 6
What happens with
12
34
56
?
That seems like the hardest case to parse with your algo
I am, yeah
Pasting large amounts of code
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
please do not comment on the style of the code itself, it's quite horrid
but I assure you it works :)
Lmao
462 lines
I mean you use Black it can't be that bad
yup - I allow myself that because of it :)
You can totally work that out as int((len([c for c in input if c not in '\n ']) / 6) ** 0.5)
i did the same
well it's parameterised
my unit tests pass in a different param
def test_monkey_map_simulation_2():
notes = """\
...#
.#..
#...
....
...#.......#
........#...
..#....#....
..........#.
...#....
.....#..
.#......
......#.
10R5L5R10L4R5L5
"""
mm = process_2.MonkeyMap(notes, face_size=4)
mm_it = iter(mm)
for _ in mm_it:
pass
assert str(mm) == """\
>>v#
.#v.
#.v.
..v.
...#..^...v#
.>>>>>^.#.>>
.^#....#....
.^........#.
...#..v.
.....#v.
.#v<<<<.
..v...#."""
assert mm.curr_pos == process_2.Coords(7, 5)
assert mm.curr_dir == process_2.Direction.UP
assert mm.password == 5031
that's an example of one of them
zip(itertools.count(1), map_str.splitlines())
Any reason you didn't justenumeratehere?
(ok? enumerate can handle that fine?)
I guess I could have used enumerate with step
AFAIK enumerate(x, n) is exactly equivalent to zip(count(n), x)
didn't think about it at the time
should also be fine to just find the greatest dimension and divide by 4 right?
Does that work?
yes, I think you are right here
That feels like that shouldn't work
I'm left with three unpaired pairs of edges
at the moment my algo wouldn't work for that, but it could be easily modified to
i can't make a net in my head it wouldn't work for but who knows
I would just pair as many as I could in a loop, going round and round til they were all parired
123
456
Tbf I had to google cube nets in order to find that lol
That's actually the only one that doesn't fit
soooo we could probably special case it
is that the only one where one dimension is more than twice the other
What if you get this cube net 🙃
lmao
width, height = max(map(len, lines)), len(lines)
short, long = (width, height) if width < height else (height, width)
if long > short * 2:
size = short // 2
else:
size = long // 4
```longer code than yours but more efficient
looking at the subreddit I feel super accomplished I did this algorithmically now
You should, it's tricky
i just can't even
my mind just can't comprehend how to rotate the faces of the cube for this to make sense
for just hard coding things?
I worked off of this diagram I drew
no i'm trying to do a cube with faces
but somehow an x rota for example isn't just the left and right face that get rotated + switching the active face
instead my current observation is that whatever face was on top now gets to the back rotated 2 times (or maybe 1 time because instead every face gets rotated idk)
weird
^ this was my algorithm if that helps
Ah nice👌 It took me ages to figure out how to do it.
took me ages as well lol
I think I only stared at the screen in horror for at least 10 minutes lol
part of me wishes there had been multiple cubes to resolve such that hardcoding would have been infeasible :3
Ah yeah. Although weirdly I don’t think I’d have the patience to hard code it.
I'd be worried that I did it wrong
and if you do it wrong, trying to debug and find out where you screwed up would become pretty difficult indeed
tbf hardcoding it wrong is a pain to debug as well
that's what I did
couldn't figure it out for like 2 hours
oh wait you guys are talking about hardcoding it not writing code for the net folding

I wish I were talking about folding I'm just trying to keep track of orientation
The way I did it is to label the corners of the cube 0 to 7, then rotating the cube is just a matter of permuting those numbers in some way. For example, you could start with the corners labelled like this: 0-----------1 |\ /| | 4-------5 | | | | | | 6-------7 | |/ \| 2-----------3 If you rotate it left, to view the face on the right, this is where all the corners would end up: 1-----------5 |\ /| | 0-------4 | | | | | | 2-------6 | |/ \| 3-----------7 If you rotate the original cube up, to view the bottom face, it would end up like this: ```
2-----------3
|\ /|
| 0-------1 |
| | | |
| 4-------5 |
|/ |
6-----------7
!eval Rotating the cube to the right is just the same as rotating it to the left three times. And rotating it down is the same as rotating it up three times: ```py
import numpy as np
CUBE = np.array([0, 1, 2, 3, 4, 5, 6, 7])
L = CUBE[[1, 5, 3, 7, 0, 4, 2, 6]]
R = CUBE[L][L][L]
U = CUBE[[2, 3, 6, 7, 0, 1, 4, 5]]
D = CUBE[U][U][U]
print(L)
print(R)
print(U)
print(D)
@fervent sail :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | [1 5 3 7 0 4 2 6]
002 | [4 0 6 2 5 1 7 3]
003 | [2 3 6 7 0 1 4 5]
004 | [4 5 0 1 6 7 2 3]
Say you have a net that looks like this: ```
+---+
| |
+---+---+---+
| | | |
+---+---+---+---+
| | |
+---+---+
First of all, pick a face to represent the original 'front' of the cube and label its corners: ```
0---1 0-----------1
| X | |\ /|
+---+---2---3 | 4-------5 |
| | | | | | | |
+---+---+---+---+ | 6-------7 |
| | | |/ |
+---+---+ 2-----------3
Then you can figure out what all the other corner numbers should be by walking around the net, and rotating the cube accordingly as you go. For example, to go down you rotate the cube up: 0---1 2-----------3 | | |\ /| +---+---2---3 | 0-------1 | | | | X | | | | | +---+---6---7---+ | 4-------5 | | | | |/ \| +---+---+ 6-----------7 To go left, you rotate the cube right: ```
0---1 0-----------2
| | |\ /|
+---0---2---3 | 1-------3 |
| | X | | | | | |
+---4---6---7---+ | 5-------7 |
| | | |/ |
+---+---+ 4-----------6
Then you just visit all the other faces using some kind of search: ```
0---1
| |
1---0---2---3
| | | |
5---4---6---7---3
| | |
4---5---1
Seems like a nice approach
Avoids the problem of “loose edges” like there was with my algo
Thanks!
that makes a lot of sense, I think i got something "easier" as an idea now but if I decide to implement it completely or my approach won't work I'll do it that way
thank you!
What do you have that’s easier? Curious to know :)
i was thinking of only moving right, and instead of changing the direction i rotate the face, since i'm only moving right i'll always know that the shared edge will be from right to left so i can rotate the next face until the edge i'm entering from is on the left
that might just shift the problem to input parsing, i don't know about that since i haven't had the time to work on it today
more basic is probably a better description than easier
bad = [[1,2,3,5], [4,2,0,5], [1,4,3,0], [4,5,0,2], [1,5,3,2], [4,1,0,3]]
:|
its called bad for a reason 😛
presumably it only works for the real input?
i'll figure mapping out once the rotation works
not the example one?
i really just want to know if x and y are correct and i'm just messing up rotation
kk. Will get to this in a little bit :)
FYI, sharing inputs in general is not recommended, and not necessary for this days' problem anyway since everyone's real input is the same net
as far as i read up on the topic individual inputs are fine and just the collection of inputs isn't really whats desired
but i guess it's not required to check what i was asking so I'll delete it
@gaunt scarab i've updated my code to be a little more readable in case you're looking at it
ah cool - is it on the same hastebin?
i edited the link
I was going to try and print the password at each step to compare with mine at each step
but I don't think I can even try that option with your program, can I?
you have some code after you iterate over all the instructions that occurs before you generate the password
yeah hmm
i'll try to rewrite it to do that every step
define step actually, between instruction types or litreally every move
either works for me
for me I can literally print out the password after every move
actually
ahhh i might already see the problem
hah
if your code can print out the x, y and direction after each instruction
then I can go and compare with my solution to see at which place your code would deviate from mine
alright this prints after every instruction i hope
and does weird stuff immediately
ok thats whack, i'll go back to figuring it out myself first
ok - let me know when you want me to look at stuff
yea i hope converting back is just the problem we'll see
alright, i still had a million bugs and in the end the best thing to do was map out the example real quick, but i finally finished d22
dw most people here hardcoded the map as well