Reputation
1,312
Top tag
Next privilege 2,000 Rep.
Edit questions and answers
Badges
1 7 13
Newest
 Fanatic
Impact
~12k people reached

  • 0 posts edited
  • 0 helpful flags
  • 3 votes cast
Apr
19
revised How to make complex objects immutable?
added 609 characters in body
Apr
19
answered How to make complex objects immutable?
Apr
18
comment What data type is this?
Clojure core.async has a channel with the same semantics that they call a "sliding buffer" which I think is a good name. There is also a "dropping buffer" channel which would have not put "D" into the list and kept "A" in.
Apr
13
comment Given a tree calculating Max Sum from top to bottom suing DFS? optimization?
Since this looks like homework, I will not tell you the efficient way to do it, however I will tell you that it is not to use a DFS or BFS and does not involve building a binary tree at all but instead to use a completely different strategy.
Apr
4
awarded  Fanatic
Mar
3
comment Best practice A.I. - check all possible moves or pick an objective?
Modern Chess and Go engines are actually very different. Chess behaves more closely with how you described (Searching to a particular depth, determining best moves and uncertainty and then analyzing the ones it believes to be good to a deeper depth). In Go, the search tree branches too quickly, and it is too difficult to rate a position so this technique is not strong. Go lends itself well to monte carlo techniques (play large numbers random games from the position and use win/loss statistics to figure out which moves seem to have led to wins regardless of the order played)
Mar
2
awarded  Yearling
Nov
20
comment Batching immutable object changes?
Since somebody mentioned Clojure, it actually has a feature specifically for this called transients clojure.org/transients so you could look into its internals. The gist of how to use it is you call transient on an existing persistent data structure which creates a transient version in O(1). You can then modify it using different functions than you would a persistent version. When finished you call persistent! to get a new persistent structure from the transient one in O(1). All subsequent attempts to modify the transient structure using the transient functions throw exceptions.
Sep
14
comment How are the tiles in WORDAMENT organized?
Well there's not going to be a "correct" answer for this. From your description Wordament appears to be a clone of Boggle which is a 'board' game which uses dice for the letters and the letters on each die they've chosen work surprisingly well. You could maybe use those. If you want your own algorithm using letter frequencies you could take a look at stackoverflow.com/questions/56692/random-weighted-choice of how to randomly choose from a list of weighted values. Something else you could consider is to hard-code some extra rules such as "at least 4 of the tiles must contain vowels."
Jul
1
comment Should I be using a composite key for this table?
If I'm reading your schema correctly, it is different than what I would think to make. I would think you would have tables Word(word_id, word), Ryhme(rhyme_id, sound), and RhymeWord(word_id, rhyme_id). The RhymeWord key can then be a composite of the word_id and rhyme_id. The problem with how you set it up is how do you know that bat rhymes with fat without entering a bunch of "duplicate" data or writing the bat-fat query differently than the cat-bat query.
Jun
14
comment Looking to simulate the rolling of a ball around a roulette wheel, while the resulting number is already known
In line with my previous comment where the idea is to calculate the final time/position of the ball and then afterwards manipulate the wheel so that the number you want meets it at the same time. Previously I suggested delaying the release of the ball to accomplish this. Another possibility is not delaying the release of the ball, but instead determine the appropriate deceleration of the wheel to make the number meet the ball.
Jun
14
comment Looking to simulate the rolling of a ball around a roulette wheel, while the resulting number is already known
Is delaying the release of the ball an option? If so, given any wheel speed and ball starting position/velocity you could run the simulation ahead of time to know which fixed time and position the ball would fall. Then it's just a matter of delaying the release of the ball until the number you want will be in the position you want when the ball actually falls which would be an easy calculation. At most the time you would have to wait for the wheel to make 1 rotation at it's initial speed.
Jun
4
comment Tail-recursive implementation of take-while
I'm going to agree that this should not be possible. With the other conditions, I think using reverse is the best you can do since it is big-o linear time and memory (proportional to the prefix which is the best you can do). Also since you're not producing a lazy sequence, the call to reverse is not making something eager which otherwise wouldn't have been.
May
28
revised Should data structures be integrated into the language (as in Python) or be provided in the standard library (as in Java)?
deleted 94 characters in body
Apr
30
comment Finding all subsets of a set running time
What does it mean to "Generate the subsets"? You could create a 'lazy sequence' of the subsets in constant time, however anything that iterates over all the subsets in any way must be at least O(2^n) because it involves iterating over O(2^n) sets. Generating possibly the most efficient representation of the sets (an integer of n bits where each bit represents the presence or absence of the nth item of the set) still requires you to generate O(2^n) integers.
Apr
28
revised Finding all subsets of a set running time
added 340 characters in body
Apr
28
answered Finding all subsets of a set running time
Apr
13
revised Evaluation order of expressions in Clojure?
added 518 characters in body
Apr
13
answered Evaluation order of expressions in Clojure?
Apr
9
answered how to design a stack without using java library or using list