Skip to content

Instantly share code, notes, and snippets.

@nickgarvey
Created July 11, 2014 04:42
Show Gist options
  • Save nickgarvey/e82dd9dc5b0f7c64ff6b to your computer and use it in GitHub Desktop.
Save nickgarvey/e82dd9dc5b0f7c64ff6b to your computer and use it in GitHub Desktop.
gear_ratio(N, T) :-
GEARS = [11, 12, 13, 14, 15, 16, 18, 20, 21, 22, 24, 30, 32, 36, 40, 42, 48, 54, 60, 64, 72, 84, 96, 108, 112, 120, 144, 168],
member(G1, GEARS), member(G2, GEARS), member(G3, GEARS), member(G4, GEARS),
G1 >= G2, G3 >= G4,
N < (G1 * G2)/(G3 * G4) * (1 + T),
N > (G1 * G2)/(G3 * G4) * (1 - T),
R is (G1 * G2)/(G3 * G4),
write('('),
write(G1), write('*'),
write(G2), write(')/('),
write(G3), write('*'),
write(G4), write(')'),
write('\nRatio = '), write(R), write(':1\n\n').
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment