Thursday, December 18, 2008

Two for one fun

No new pictures until Firday night most likely, so here's a couple puzzles you can use to waste two days worth of time. +/-

For both of these the letters A through I represent the numbers 1 through 9. No numbers are repeated. Each circled number is the sum of the numbers it touches. There's only one combination that works for each of these. Find which number each letter represents.

5 comments:

  1. I got it once again with a simple Prolog program.

    Too Easy.

    add(A,B,C,D,E,F,G,H,I) :-
    fd_domain([A,B,C,D,E,F,G,H,I], 1, 9),
    fd_all_different([A,B,C,D,E,F,G,H,I]),
    A + B + F + E #= 21,
    B + C + F + G + H #= 33,
    C + D + H + I #= 20,
    E + F + G #= 15,
    G + H + I #= 17,
    fd_labeling([A,B,C,D,E,F,G,H,I]).

    adds(A,B,C,D,E,F,G,H,I) :-
    fd_domain([A,B,C,D,E,F,G,H,I], 1, 9),
    fd_all_different([A,B,C,D,E,F,G,H,I]),
    A + B + C + G #= 22,
    B + C + D + E #= 24,
    C + D + G + H + I #= 34,
    I + D + E + F #= 15,
    fd_labeling([A,B,C,D,E,F,G,H,I]).

    I will refrain from posting the solutions, so as not to spoil it for others.

    ReplyDelete
  2. Maybe I'll write C code for this instead. Prolog is just cheating for problems like this. Yesterday the challenge was just re-learning it.

    Actually, a brute force C program would be simple, too. Just a bunch of embedded loops and a conditional.

    ReplyDelete
  3. Are you at least curious to see if you can get it without a computer?

    ReplyDelete
  4. Here's that house puzzle I posted the other day:

    (Formatting sucks).

    % member(X,[X|_]).
    % member(X,[_|Ys]) :- member(X, Ys).

    first(X, [X|_]).

    left_of(X,Y,[X,Y|_]).
    left_of(X,Y,[_|Zs]) :- left_of(X, Y, Zs).

    next_to(X,Y,Zs) :- left_of(X, Y, Zs).
    next_to(X,Y,Zs) :- left_of(Y, X, Zs).

    middle(X,[_,_,X,_,_]).

    solve(Hs) :- Hs = [_,_,_,_,_],
    member([_, _, _, _, fish], Hs),
    member([brit, red, _, _, _], Hs),
    member([swede, _, _, _, dog], Hs),
    member([dane, _, tea, _, _], Hs),
    member([_, green, coffee, _, _], Hs),
    member([_, _, _, pallmall, bird], Hs),
    member([_, yellow, _, dunhill, _], Hs),
    member([_, _, beer, bluemaster, _], Hs),
    member([german, _, _, prince, _], Hs),
    first([norwegian, _, _, _, _], Hs),
    next_to([norwegian,_,_,_,_], [_,blue,_,_,_], Hs),
    next_to([_, _, _, blends, _], [_, _, water, _, _], Hs),
    next_to([_, _, _, _, horse], [_, _, _, dunhill, _], Hs),
    next_to([_,_,_,blends,_], [_,_,_,_,cat], Hs),
    middle([_,_,milk,_,_], Hs),
    left_of([_, green, _, _, _], [_, white, _, _, _], Hs).

    ReplyDelete
  5. And here's the solution:

    | ?- solve([A,B,C,D,E]).

    A = [norwegian,yellow,water,dunhill,cat]
    B = [dane,blue,tea,blends,horse]
    C = [brit,red,milk,pallmall,bird]
    D = [german,green,coffee,prince,fish]
    E = [swede,white,beer,bluemaster,dog] ?

    ReplyDelete