What's Here?
- Members: 306,790
- Replies: 841,204
- Topics: 140,550
- Snippets: 4,465
- Tutorials: 1,166
- Total Online: 1,578
- Members: 111
- Guests: 1,467
|
's Contributions
|
Below are the tutorials, code snippets, and resources has submitted to dream.in.code. For more information on Kudos and contributing to dream.in.code visit: http://home.dreamincode.net/?p=about#kudos.
|
|
Tutorials
in (Last Comment: , Views: 5,706)
|
|
Code Snippets
|
 |
|
|
Submitted: November 11, 2008
Views: 326
|
|
|
 |
|
|
Submitted: July 4, 2009
Views: 64
given n and r, the sippets calculates the number of different permutations to choose r elements from n. The formula for P(n, r) = n!/(n-r)! but of course if n is large it will be very inefficient to compute the factorial first then plug it in the formula, instead we can use this property that P(n, r) = P(n, r-1)*n-(r-1) and that P(n, 0) = 1 and P(n, 1) = n. it can be done using an array and on each iteration we look at the previous cell which holds the value for p(n,k-1) or to save memory we can instead accumulate the result in a variable.
|
|
|
 |
|
|
Submitted: July 5, 2009
Views: 196
given n and r, the snippet calculates the number of different permutations to choose r elements from n elements. The formula for P(n, r) = n!/(n-r)! but of course if n is large it will be very inefficient to compute the factorial first then plug it in the formula, instead we can use this property that P(n, r) = P(n, r-1)*n-(r-1) and that P(n, 0) = 1 and P(n, 1) = n. it can be done using an array of size r and on each iteration we look at the previous cell which holds the value for p(n,i-1) or to save memory we can instead accumulate the result in a variable.
|
|
|
 |
|
|
Submitted: March 29, 2009
Views: 430
a snippet in PROLOG that checks if a number is prime or not
|
|
|
 |
|
|
Submitted: July 1, 2009
Views: 265
just a small snippet to compute the binomial Coefficient nCk..
mathematically to compute the binomial coefficient
ncK = n!/k!(n-k)! but if n is too large, computing it will be very inefficient, instead there's a recursive formula
nCk = (n-1)C(k-1)+(n-1)Ck, so this can be used in a dynamic programming approach...also to speed things up, binomial Coefficients have this identity that nCk = nC(n-k), so we can use this to minimize the number of terms computed
|
|
|
 |
|
|
Submitted: March 27, 2009
Views: 679
the predicate returns true if Y is the factorial of X
|
|
|
 |
|
|
Submitted: November 15, 2008
Views: 317
my solution to a problem that i solved on www.projecteuler.net...this method sums the even terms in the fibonacci series that aren't greater than n
|
|
|
 |
|
|
Submitted: March 25, 2009
Views: 1308
an example of the fibonacci series in prolog, the function will return true, if Y is the fibonacci value of X
|
|
|
 |
|
|
Submitted: April 9, 2009
Views: 546
a snippet that lists all the possible permutations of a list
|
|
|
 |
|
|
Submitted: March 25, 2009
Views: 577
a simple snippet in prolog to find the greatest common divisor of 2 numbers
|
|
|
 |
|
|
Submitted: April 20, 2009
Views: 324
the predicate insertionsort returns true if R is the sorted list of [H|T]
|
|
|
 |
|
|
Submitted: August 8, 2009
Views: 40
a snippet that evaluates and simplifies logical expressions
|
|
|
 |
|
|
Submitted: November 29, 2008
Views: 578
checks whether a string is a palindrome or not..a palindrome is a string that could be read backwards the same way it could be read forward
example:
mom
dad
|
|
|
 |
|
|
Submitted: January 3, 2009
Views: 2317
checks if the given string is a palindrome using recursion.
|
|
|
 |
|
|
Submitted: December 29, 2008
Views: 782
a small algorithm to find the prime factors of a number
|
|
|
 |
|
|
Submitted: April 21, 2009
Views: 382
the function isprime finds if the number is prime or not
|
|
|
 |
|
|
Submitted: April 9, 2009
Views: 252
a simple snippet to reverse a list in prolog
|
|
|
 |
|
|
Submitted: February 18, 2009
Views: 390
|
|
|
 |
|
|
Submitted: April 20, 2009
Views: 327
the predicate returns true if [X|Z] is the ordered representation of list R
|
|
|
 |
|
|
Submitted: September 15, 2009
Views: 57
finding all permutations of a string recursively
|
|
|
 |
|
|
Submitted: November 19, 2008
Views: 1853
this method takes an integer as an argument and returns the sum of digits in that integer.
Example:
if the integer is 123, the method will return 1+2+3 = 6.
|
|
|
 |
|
|
Submitted: March 29, 2009
Views: 483
a simple snippet to find the sum of digits of a given number in PROLOG
|
|
|
| |