PUEVD5LHJH2GUKOBNHZTGYW6YTIBZGE7AMAHPDMMGSCUQFULII2AC JFVDXTQS6OZQWXXRQ3I4HC7BBFXWQUWQO56C7AXQ35PMWUQI2MKAC F2NSN45RYCMFIJ4WVEKRTCORP2IEFSAWH3XNRAT2I55CNSBK6DUAC KZKRGZBWLSKWVN6ZKDGGK6W6EAQLMSKUEJBVMMZ2UD3TZERZKS7QC PBRYNWYOTORTAAYHMNGLU5KNAS4T5FCSEIWM656VQ7IZJ6P7NQ3QC U3DDUM6PNGQS3342RSZVDTLLZNS55EPHFVI36GWXHAJ23P5PVPDQC COS2T3FPTP6JB7UANIDCGVTW5T7HEAOSTNWI6JNVL6K3I6EOWJNQC var $elm$core$Dict$member = F2(function (key, dict) {var _v0 = A2($elm$core$Dict$get, key, dict);if (_v0.$ === 'Just') {return true;} else {return false;}});var $elm$core$Set$member = F2(function (key, _v0) {var dict = _v0.a;return A2($elm$core$Dict$member, key, dict);});var $elm$core$Basics$not = _Basics_not;
var $elm$core$Dict$sizeHelp = F2(function (n, dict) {sizeHelp:while (true) {if (dict.$ === 'RBEmpty_elm_builtin') {return n;} else {var left = dict.d;var right = dict.e;var $temp$n = A2($elm$core$Dict$sizeHelp, n + 1, right),$temp$dict = left;n = $temp$n;dict = $temp$dict;continue sizeHelp;}}});var $elm$core$Dict$size = function (dict) {return A2($elm$core$Dict$sizeHelp, 0, dict);};var $elm$core$Set$size = function (_v0) {var dict = _v0.a;return $elm$core$Dict$size(dict);};
var solveUrl = 'solve?id=1&size=' + ($elm$core$String$fromInt(model.size) + A3($elm$core$List$foldl,$elm$core$Basics$append,'',A2($elm$core$List$map,formatQueen,$elm$core$Set$toList(model.queens))));
var solveUrl = function (m) {return 'solve?id=1&size=' + ($elm$core$String$fromInt(m.size) + A3($elm$core$List$foldl,$elm$core$Basics$append,'',A2($elm$core$List$map,formatQueen,$elm$core$Set$toList(m.fixedQueens))));};var requestSolution = function (m) {return $elm$http$Http$get({expect: A2($elm$http$Http$expectJson, $author$project$Queens$ReceivedSolution, $author$project$Queens$solutionDecoder),url: solveUrl(m)});};
_Utils_update(model,{queens: A2($elm$core$Set$insert,_Utils_Tuple2(i, j),model.queens),status: $elm$core$Maybe$Nothing}),$elm$core$Platform$Cmd$none);
newModel,requestSolution(newModel));
var newModel = _Utils_update(model,{fixedQueens: A2($elm$core$Set$member,_Utils_Tuple2(i, j),model.solutionQueens) ? A2($elm$core$Set$insert,_Utils_Tuple2(i, j),model.fixedQueens) : A2($elm$core$Set$remove,_Utils_Tuple2(i, j),model.fixedQueens),solutionQueens: A2($elm$core$Set$remove,_Utils_Tuple2(i, j),model.solutionQueens),status: $elm$core$Maybe$Nothing});
_Utils_update(model,{queens: A2($elm$core$Set$remove,_Utils_Tuple2(i, j),model.queens),status: $elm$core$Maybe$Nothing}),$elm$core$Platform$Cmd$none);
newModel,requestSolution(newModel));
_Utils_update(model,{queens: A2($elm$core$Set$filter,function (_v1) {var x = _v1.a;var y = _v1.b;return (_Utils_cmp(x, size) < 0) && (_Utils_cmp(y, size) < 0);},model.queens),size: size,status: $elm$core$Maybe$Nothing}),$elm$core$Platform$Cmd$none);
newModel,($elm$core$Set$size(newModel.fixedQueens) > 0) ? requestSolution(newModel) : $elm$core$Platform$Cmd$none);
$elm$http$Http$get({expect: A2($elm$http$Http$expectJson, $author$project$Queens$ReceivedSolution, $author$project$Queens$solutionDecoder),url: solveUrl}));
requestSolution(model));
};var queen = function (_v0) {var i = _v0.a;var j = _v0.b;return A2($elm$svg$Svg$foreignObject,_List_fromArray([$elm$svg$Svg$Attributes$width($elm$core$String$fromInt(w)),$elm$svg$Svg$Attributes$height($elm$core$String$fromInt(w)),$elm$svg$Svg$Attributes$x($elm$core$String$fromInt(i * w)),$elm$svg$Svg$Attributes$y($elm$core$String$fromInt(j * w)),$elm$svg$Svg$Events$onClick(A2($author$project$Queens$RemoveQueen, i, j))]),_List_fromArray([A2($elm$html$Html$img,_List_fromArray([$elm$html$Html$Attributes$width(w),$elm$html$Html$Attributes$height(w),$elm$html$Html$Attributes$src('static/queen.svg')]),_List_Nil)]));
var queen = F2(function (color, _v0) {var i = _v0.a;var j = _v0.b;return A2($elm$svg$Svg$g,_List_Nil,_List_fromArray([A2($elm$svg$Svg$foreignObject,_List_fromArray([$elm$svg$Svg$Attributes$width($elm$core$String$fromInt(w)),$elm$svg$Svg$Attributes$height($elm$core$String$fromInt(w)),$elm$svg$Svg$Attributes$x($elm$core$String$fromInt(i * w)),$elm$svg$Svg$Attributes$y($elm$core$String$fromInt(j * w))]),_List_fromArray([A2($elm$html$Html$img,_List_fromArray([$elm$html$Html$Attributes$width(w),$elm$html$Html$Attributes$height(w),$elm$html$Html$Attributes$src('static/queen.svg')]),_List_Nil)])),A2($elm$svg$Svg$rect,_List_fromArray([$elm$svg$Svg$Attributes$x($elm$core$String$fromInt(i * w)),$elm$svg$Svg$Attributes$y($elm$core$String$fromInt(j * w)),$elm$svg$Svg$Attributes$width($elm$core$String$fromInt(w)),$elm$svg$Svg$Attributes$height($elm$core$String$fromInt(w)),$elm$svg$Svg$Attributes$fillOpacity('0.0'),$elm$svg$Svg$Attributes$stroke(color),$elm$svg$Svg$Events$onClick(A2($author$project$Queens$RemoveQueen, i, j))]),_List_Nil)]));});
var $elm$core$Dict$member = F2(function (key, dict) {var _v0 = A2($elm$core$Dict$get, key, dict);if (_v0.$ === 'Just') {return true;} else {return false;}});var $elm$core$Set$member = F2(function (key, _v0) {var dict = _v0.a;return A2($elm$core$Dict$member, key, dict);});
++ String.fromInt model.size++ (List.foldl (++) "" <| List.map formatQueen (Set.toList model.queens))
++ String.fromInt m.size++ (List.foldl (++) "" <| List.map formatQueen (Set.toList m.fixedQueens))requestSolution m =Http.get{ url = solveUrl m, expect = Http.expectJson ReceivedSolution solutionDecoder}
RemoveQueen i j-> ( { model | queens = Set.remove (i,j) model.queens, status = Nothing }, Cmd.none )ClearQueens-> ( { model | queens = Set.empty, status = Nothing }, Cmd.none )
RemoveQueen i j ->letnewModel ={ model| fixedQueens = if Set.member (i, j) model.solutionQueensthen Set.insert (i, j) model.fixedQueenselse Set.remove (i,j) model.fixedQueens, solutionQueens = Set.remove (i,j) model.solutionQueens, status = Nothing}in( newModel, requestSolution newModel )
Solve->( model, Http.get{ url = solveUrl, expect = Http.expectJson ReceivedSolution solutionDecoder
ChangeBoardSize size ->letnewModel ={ model| size = size, fixedQueens = Set.filter (\(x,y) -> x < size && y < size) model.fixedQueens, status = Nothing
Ok(sol) -> ( { model | status = Just Solved, queens = Set.fromList <| List.map (\l -> listToTuple l) sol}, Cmd.none )Err(err) -> ( { model | status = Just Unsolvable }, Cmd.none )
Ok(sol) ->( { model| status = Just Solved, solutionQueens = Set.fromList<| List.filter (\x -> not (Set.member x model.fixedQueens))<| List.map (\l -> listToTuple l) sol}, Cmd.none)
queen (i, j) = Svg.foreignObject[ Attr.width <| String.fromInt w, Attr.height <| String.fromInt w, Attr.x <| String.fromInt (i * w), Attr.y <| String.fromInt (j * w), Events.onClick (RemoveQueen i j)]<|[ img[ HAttr.width w, HAttr.height w, src "static/queen.svg"
queen color (i, j) = Svg.g[][ Svg.foreignObject[ Attr.width <| String.fromInt w, Attr.height <| String.fromInt w, Attr.x <| String.fromInt (i * w), Attr.y <| String.fromInt (j * w)]([ img[ HAttr.width w, HAttr.height w, src "static/queen.svg"][]]), Svg.rect[ Attr.x <| String.fromInt (i * w), Attr.y <| String.fromInt (j * w), Attr.width <| String.fromInt w, Attr.height <| String.fromInt w, Attr.fillOpacity "0.0", Attr.stroke color, Events.onClick (RemoveQueen i j)