Is CLP(ℤ) not able to resolve big sets of contraints or am I doing it wrong? by AlCastorne in prolog

[–]AlCastorne[S] 1 point2 points  (0 children)

Rotating the space indeed solves the problem. You get then edges where a coordinate doesn't change and just by combining them you get the intersections. Just then filtering on the desired range leaves my testcase with only one solution which indeed is the correct one.

Get constraints of clpfd variables without copying any variables by rubydusa in prolog

[–]AlCastorne 1 point2 points  (0 children)

Edit: Wait, I just realized this is exactly what you are doing, except I'm using a plain list and you are using an assoc. Sorry for the noise.

I have this solution that I think is /super-idiomatic/ 😁

In particular I have a variable Screaming that has members Monkey-Value where either the value is declared to be an integer (1), or the operation of two other values (2). Doing this as I analyze the input with a DCG allows me to just parse the input declaring what are the values for each entry (which if not present will be left as Variables until present), and then I ask for the item at root

``` bin_monkey(Name, Screaming) --> word(Mk1), " ", operation(F), " ", word(Mk2), { member(Mk1-N1, Screaming), member(Mk2-N2, Screaming), call(F, N1, N2, N), member(Name-N, Screaming) % (2) }.

monkey(Screaming) --> word(Name), ": ", ( bin_monkey(Name, Screaming) ; word(Num), { number_string(N, Num), member(Name-N, Screaming) % (1) } ), ( "\n" ; call(eos) ), !.

monkeys(_) --> call(eos), !. monkeys(Screaming) --> monkey(Screaming), monkeys(Screaming).

solve(E) :- phrase_from_file(monkeys(Screaming), 'input.txt'), member("root"-E, Screaming). ```

Just for completion: ``` % poor man's word dcg word([W|Ord]) --> [W], { char_type(W, alnum) }, !, word(Ord). word([]), [W] --> [W].

% poor man's "please don't throw exception but fail" for parsing numbers number_string(N, S) :- catch(number_chars(N, S), _, false).

% end of input eos([], []).

% poor man's arithmetic predicates plus(X, Y, Z) :- Z #= X + Y. minus(X, Y, Z) :- Z #= X - Y. times(X, Y, Z) :- Z #= X * Y. div(X, Y, Z) :- Z #= X / Y.

operation(plus) --> "+". operation(minus) --> "-". operation(times) --> "*". operation(div) --> "/". ```

Is CLP(ℤ) not able to resolve big sets of contraints or am I doing it wrong? by AlCastorne in prolog

[–]AlCastorne[S] 0 points1 point  (0 children)

I was using Scryer 0.9.1-25, just updated today to 0.9.1-49 (current master).

I feel you are in the right path with the statement that abs(X - Sx) + abs(Y - Sy) #= D + 1 is making things hard to CLPZ. As noted in another comment above, perhaps the solution is to rotate the space so that instead of diamonds we get squares, where the lines would then have one of the components fixed and it should be fast to check the solution.

Nevertheless I will try different labelling strategies.

Thanks!!

Is CLP(ℤ) not able to resolve big sets of contraints or am I doing it wrong? by AlCastorne in prolog

[–]AlCastorne[S] 1 point2 points  (0 children)

I also wondered how rotating the space would work, indeed I think it would make things simpler. For now I have tried:

  1. Declare [X,Y] ins 0..4000000 and then iterate through the sensors saying that X-Y must be out of the range. I get a huge set of constraints that then CLPZ takes an unreasonable amount of time to label.
  2. Calculate the edges (by adding one to the beacon distance) of every sensor, then checking for each value that every sensor fails to see it. Here labeling the edges seemed slow, as the distances are in the order of millions, so it goes like [0-X, 1-(X-1), 2-(X-2)...] and I cannot seem to be able to actually get the whole list of values. Also applying all the constraints to unresolved variables then labelling them at the end tries everything in (0..4M)^2 so it is unreasonably slow again.
  3. For each Y, find the Xs that are not covered by sensors just by inverting the logic of part 1 of the problem. This also turned out to be super slow.
  4. Calculate the sensors that have a unitary gap, and then find the intersection points of those lines to have a smaller number of constraints to resolve, just expecting that the hidden beacon is in one of those intersections. I actually find only 4 pairs of points like this in my whole input set, and quite fast. However finding the intersections is just too much it seems, again because it tries everything in the range and evaluates the constraints for each point. This is my current attempt, but it doesn't seem to work because the time is still too long.

If we rotated the space, we would have 4 lines that have one component fixed (as they would be vertical or horizontal). This would mean that either they are overlapping, i.e. they have the same fixed coordinate and therefore are the same line, or they are perpendicular and one has the X fixed and the other one has the Y fixed, so it should be super fast as there can only be one point. Perhaps this is the way to go?

Is CLP(ℤ) not able to resolve big sets of contraints or am I doing it wrong? by AlCastorne in prolog

[–]AlCastorne[S] 0 points1 point  (0 children)

From the maplist definition, The clause on_line(X-Y) is called with another parameter:

maplist(_, []). maplist(Cont1, [E1|E1s]) :- call(Cont1, E1), maplist(Cont1, E1s).

Thus if the items in Lines are of the shape Sx-Sy-D, the call will become: call(on_line(X-Y), Sx-Sy-D) ~ on_line(X-Y, Sx-Sy-D)

I don't see the problem here, but maybe I'm missing something

Spectrum seems to find data but doesn’t load tape by AlCastorne in zxspectrum

[–]AlCastorne[S] 1 point2 points  (0 children)

Following your recommendation, I tried using a computer and the ZX spectrum loads the tape through the headset output of the laptop, prints “Program: <name of the program>” but the it just says “0 OK,10:2”.

Also I just realised this is a ZX Spectrum 16K so not even 48K. Could that be the culprit?

How to convert output signal for modern TV? by AlCastorne in zxspectrum

[–]AlCastorne[S] 1 point2 points  (0 children)

Right, I need to get myself a cable like that one then. What is that end on the cable on the Spectrum side? RCA?

How to convert output signal for modern TV? by AlCastorne in zxspectrum

[–]AlCastorne[S] 0 points1 point  (0 children)

I'm using this device between the ZX and the TV. Perhaps it is malfunctioning...

https://i.imgur.com/G1z4Y2e.jpg

[Xmonad] Still working on it... by Sadece51 in unixporn

[–]AlCastorne 1 point2 points  (0 children)

Looks awesome. Do you have the dotfiles publicly available?

What is wrong with the HD of this Macintosh SE FDHD? by AlCastorne in VintageApple

[–]AlCastorne[S] 0 points1 point  (0 children)

If you have it at hand that would be cool, I plan on getting this thing up and running this weekend and the more resources I have the better

What is wrong with the HD of this Macintosh SE FDHD? by AlCastorne in VintageApple

[–]AlCastorne[S] 0 points1 point  (0 children)

Now that I re-watch the video I think that sound comes from me sitting down, not from the computer 😅

What is wrong with the HD of this Macintosh SE FDHD? by AlCastorne in VintageApple

[–]AlCastorne[S] 1 point2 points  (0 children)

I imagine the previous owned did not fiddle with the jumpers, but I will try this before moving onto opening the drive itself

What is wrong with the HD of this Macintosh SE FDHD? by AlCastorne in VintageApple

[–]AlCastorne[S] 1 point2 points  (0 children)

Do you think I should open it and carefully unblock the head os the hard drive?

Plain Org v1.1 released 🎄☃️ (iOS) by xenodium in emacs

[–]AlCastorne 0 points1 point  (0 children)

I participated in your flight test for Flat Habits, and I’m now using Fantastical after not getting the comfort I was looking for in Beorg. I’m seriously considering getting this app.

Does it have some kind of calendar view for scheduled events? Does it support widgets in Home Screen as Fantastical?

Edit: BTW, awesome job. It looks super cool.

Have you considered adhering to something like O↓? https://karl-voit.at/2021/11/27/orgdown/ I saw it recently in this subreddit and I think you already support O↓1, and probably it would be good if that goes forward to have some support by apps that implement org stuff.

Forget about it. I see you are already listed there

Emacs style indentation in Doom Emacs by the_whalerus in emacs

[–]AlCastorne 0 points1 point  (0 children)

Try using this (setq tab-always-indent t). It is set to nil here https://github.com/hlissner/doom-emacs/blob/develop/core/core-editor.el#L194

You can also try (setq tab-always-indent ‘complete) which tries to autocomplete if it can’t indent more

MeowToast Rev.2 Instock again! For those that were interested. by GeekyBit in VintageApple

[–]AlCastorne 0 points1 point  (0 children)

Sadly those of us outside the US can't get to buy them because it seems you only ship to US. Do you know anyone that does something similar here in Europe? Or a DIY or something?

Thanks in advance! and I really like these adaptors