This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
public class FileOutput { | |
public static void main(String[] args) { | |
FileOutputStream fos; | |
DataOutputStream dos; | |
try { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
numberOfUndos = ((changesPerDay * numberOfYears * daysInAYear) / numUndoLoops) / numberOfRacks; | |
for (numberOfYears) { | |
for (numberOfRacksPerYear) { | |
copyTemplateToPlan | |
for (int i = 0; i < numberOfDaysBetweenRacks / 3; i++) { | |
updateAsset | |
for (numberOfUndos) { | |
} | |
updatePlanContainment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
score([], DukesInDeck, DuchiesInDeck, Score) :- | |
Score is DukesInDeck*DuchiesInDeck. | |
score([duchy|Rest], DukesInDeck, DuchiesInDeck, Score) :- | |
Y is DuchiesInDeck+1, | |
score(Rest, DukesInDeck, Y, X), | |
Score is 3+X. | |
score([duke|Rest], DukesInDeck, DuchiesInDeck, Score) :- | |
Y is DukesInDeck+1, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
play(0, _, Deck, Deck) :- !. | |
play(_, 0, Deck, Deck) :- !. | |
% take a duchy | |
play(DukesRemaining, DuchiesRemaining, Deck, FinishedDeck) :- | |
X is DuchiesRemaining-1, | |
append([duchy], Deck, NewDeck), | |
play(DukesRemaining, X, NewDeck, FinishedDeck). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def score(dukes, duchies) | |
duchies*3 + dukes*duchies | |
end | |
def play(dukes, duchies) | |
dukes_in_deck = 0 | |
duchies_in_deck = 0 | |
while (dukes > 0 and duchies > 0) | |
if score(dukes_in_deck+1, duchies_in_deck) >= score(dukes_in_deck, duchies_in_deck+1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
max_deck(SetOfDecks, N, Set) :- | |
max_n(SetOfDecks, N, Max), | |
write(N),write(' -> '),write(Max), | |
decks_with_n_of(SetOfDecks, N, Max, SetOfDecksWithMaxAtN), | |
write(', '), length(SetOfDecksWithMaxAtN, L), write(L),nl, | |
M is N+1, | |
max_deck(SetOfDecksWithMaxAtN, M, Set). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
max_n([Deck|RemainingDecks], N, Max) :- | |
max_n(RemainingDecks, N, M), | |
nth_score(N, Deck, X), | |
X =< M, | |
Max is M, | |
!. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
decks_with_n_of([A|SetOfDecks], N, Max, SetOfDecksWithMaxAtN) :- | |
\+ nth_score(N, A, Max), | |
decks_with_n_of(SetOfDecks, N, Max, SetOfDecksWithMaxAtN). | |
decks_with_n_of([A|SetOfDecks], N, Max, SetOfDecksWithMaxAtN) :- | |
nth_score(N, A, Max), | |
decks_with_n_of(SetOfDecks, N, Max, R), | |
append([A], R, SetOfDecksWithMaxAtN). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nth_score(N, Set, Score) :- | |
tail(Set, N, Tail), | |
score(Tail, Score). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import akka.stm.*; | |
import java.util.concurrent.*; | |
import java.util.*; | |
public class TestStm { | |
public static Vector<Ref<Integer>> testStm(final int nitems, final int nthreads, final int niters) | |
throws Exception { | |
final Vector<Ref<Integer>> refs = new Vector<Ref<Integer>>(nitems); |
OlderNewer