Skip to content

Commit

Permalink
Simplify code using lists:usort rather than sets, thanks to Ahmed Omar
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Pauley committed Mar 27, 2011
1 parent a02fbcd commit 1852c68
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions sudoku.erl
Expand Up @@ -40,9 +40,7 @@ peers(Square) ->
%% A unique list of squares (excluding this one)
%% that are also part of the units for this square.
NonUniquePeers = shallow_flatten([S || S <- units(Square)]),
PeerSet = gb_sets:from_list(NonUniquePeers),
PeersWithSelf = gb_sets:to_list(PeerSet),
lists:delete(Square, PeersWithSelf).
lists:delete(Square, lists:usort(NonUniquePeers)).

values(Puzzle, Square) ->
%% Returns the digit values for a given square
Expand Down

0 comments on commit 1852c68

Please sign in to comment.