Click here to Skip to main content
15,885,214 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Nuts and bolts - Programming contest Pin
#realJSOP30-Dec-20 3:20
mve#realJSOP30-Dec-20 3:20 
GeneralRe: Nuts and bolts - Programming contest Pin
PIEBALDconsult30-Dec-20 3:52
mvePIEBALDconsult30-Dec-20 3:52 
GeneralRe: Nuts and bolts - Programming contest Pin
Jörgen Andersson30-Dec-20 9:33
professionalJörgen Andersson30-Dec-20 9:33 
GeneralRe: Nuts and bolts - Programming contest Pin
PIEBALDconsult30-Dec-20 16:41
mvePIEBALDconsult30-Dec-20 16:41 
GeneralRe: Nuts and bolts - Programming contest Pin
Kornfeld Eliyahu Peter28-Dec-20 23:12
professionalKornfeld Eliyahu Peter28-Dec-20 23:12 
GeneralRe: Nuts and bolts - Programming contest Pin
Sander Rossel29-Dec-20 3:20
professionalSander Rossel29-Dec-20 3:20 
GeneralRe: Nuts and bolts - Programming contest Pin
Harrison Pratt29-Dec-20 4:20
professionalHarrison Pratt29-Dec-20 4:20 
GeneralRe: Nuts and bolts - Programming contest Pin
Harrison Pratt29-Dec-20 5:07
professionalHarrison Pratt29-Dec-20 5:07 
And if you want to elaborate and analyze the Nuts and Bolts as structures:

domains
    itemDOM = item(integer ID, integer Size).

class predicates
    matchItems : (itemDOM* Nuts, itemDOM* Bolts, tuple{itemDOM Nut, itemDOM Bolt}*) -> tuple{itemDom Nut, itemDOM BoltID}*.
clauses
    matchItems([], [], RevMM) = list::reverse(RevMM) :-
        !.
    matchItems(NN, BB, CurrItems) = MM :-
        item(IdN, SizeN) in NN,
        item(IdB, SizeB) in BB,
        SizeN = SizeB,
        !,
        UnmatchedNN = list::remove(NN, item(IdN, SizeN)),
        UnmatchedBB = list::remove(BB, item(IdB, SizeB)),
        MM = matchItems(UnmatchedNN, UnmatchedBB, [tuple(item(IdN, SizeN), item(IdB, SizeB)) | CurrItems]).
    matchItems(_, _, _) = [] :-
        exception::raise_error("Input lists contain an unmatched item or list lengths are unequal.").


And invoke the matching like this:

clauses
    run() :-
        write("\n\n", "Testing", "\n\n"),
        IDs = mkList(5, []), % create a list of 5 random integers
        NutItems = [ item(ID, ID * 100) || ID in IDS ], % set sizes to be 5 X the ID
        BoltItems = [ item(ID + 300, Size) || item(ID, Size) in NutItems ], % set Bolt IDs to 300 greater than Nut IDs
        MM = matchItems(NutItems, BoltItems, []),
        write(MM),
        write("\nPress [Enter] to exit"),
        _ = readLine(),
        !.

GeneralRe: Nuts and bolts - Programming contest Pin
Dan Sutton29-Dec-20 6:15
Dan Sutton29-Dec-20 6:15 
GeneralRe: Nuts and bolts - Programming contest Pin
Kirk 1038982129-Dec-20 10:41
Kirk 1038982129-Dec-20 10:41 
GeneralRe: Nuts and bolts - Programming contest Pin
James Lonero29-Dec-20 15:00
James Lonero29-Dec-20 15:00 
GeneralRe: Nuts and bolts - Programming contest Pin
PIEBALDconsult30-Dec-20 12:59
mvePIEBALDconsult30-Dec-20 12:59 
GeneralRe: Nuts and bolts - Programming contest Pin
OldDBA31-Dec-20 3:56
OldDBA31-Dec-20 3:56 
GeneralRe: Nuts and bolts - Programming contest Pin
PIEBALDconsult31-Dec-20 12:22
mvePIEBALDconsult31-Dec-20 12:22 
GeneralThought of the Day Pin
OriginalGriff28-Dec-20 4:39
mveOriginalGriff28-Dec-20 4:39 
GeneralRe: Thought of the Day Pin
W Balboos, GHB28-Dec-20 5:41
W Balboos, GHB28-Dec-20 5:41 
GeneralRe: Thought of the Day Pin
jeron128-Dec-20 5:57
jeron128-Dec-20 5:57 
GeneralRe: Thought of the Day Pin
Johnny J.28-Dec-20 21:56
professionalJohnny J.28-Dec-20 21:56 
GeneralRe: Thought of the Day Pin
jeron129-Dec-20 8:10
jeron129-Dec-20 8:10 
GeneralJust one well placed virtual function saves the day Pin
honey the codewitch28-Dec-20 4:08
mvahoney the codewitch28-Dec-20 4:08 
GeneralRe: Just one well placed virtual function saves the day Pin
Josh Gray228-Dec-20 4:57
Josh Gray228-Dec-20 4:57 
GeneralRe: Just one well placed virtual function saves the day Pin
honey the codewitch28-Dec-20 5:18
mvahoney the codewitch28-Dec-20 5:18 
GeneralRe: Just one well placed virtual function saves the day Pin
DRHuff28-Dec-20 5:27
DRHuff28-Dec-20 5:27 
GeneralRe: Just one well placed virtual function saves the day Pin
honey the codewitch28-Dec-20 5:33
mvahoney the codewitch28-Dec-20 5:33 
GeneralSynchro/Servo? Stepper? What? Pin
GenJerDan28-Dec-20 0:11
GenJerDan28-Dec-20 0:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.