Snipplr
http://snipplr.com/language/pseudocode
Recent snippets posted on Snipplr.comen-usTue, 07 Jul 2015 06:23:40 GMT(Pseudocode) Background behind uiscrollview - fabiosoft
http://snipplr.com/view/62669/background-behind-uiscrollview/
Technique to put background behind scroolview. (not tested) ]]>Fri, 20 Jan 2012 11:12:29 GMThttp://snipplr.com/view/62669/background-behind-uiscrollview/(Pseudocode) pseudo code for active state on nav - predikt
http://snipplr.com/view/56150/pseudo-code-for-active-state-on-nav/
]]>Wed, 06 Jul 2011 03:42:27 GMThttp://snipplr.com/view/56150/pseudo-code-for-active-state-on-nav/(Pseudocode) Matrix Theme for IDLE - mouseroot
http://snipplr.com/view/53202/matrix-theme-for-idle/
Simple Matrix theme for Idle ]]>Sun, 08 May 2011 16:28:29 GMThttp://snipplr.com/view/53202/matrix-theme-for-idle/(Pseudocode) Sample output from reducedparmat - stevejb
http://snipplr.com/view/51053/sample-output-from-reducedparmat/
]]>Thu, 24 Mar 2011 09:17:34 GMThttp://snipplr.com/view/51053/sample-output-from-reducedparmat/(Pseudocode) assignment - NerdGnome
http://snipplr.com/view/49260/assignment/
Background:
For several millennia, since the Greek school of Pythagoras in 500 B.C. in fact, mathematicians have been interested in Prime Numbers. Prime Numbers have once again become a hot topic in recent years because they are the foundation of most encryption algorithms for data security.
By definition: An integer greater than one is called a prime number if its only positive divisors (factors) are one and itself.
It has long been known that there are infinitely many prime numbers (Euclid, 300 B.C.), but another interesting question is how close together are the prime numbers, one from the next. Or, in other words, are there, for example, more or less primes between 1 and 100 than there are between 1001 and 1100? What about 1000001 and 1000100? Does the “density” of prime numbers increase or decrease as the numbers themselves get larger?
At first sight the primes seem to be distributed among the integers in rather a haphazard way. For example in the 100 numbers immediately before 10,000,000 there are 9 primes, while in the 100 numbers after there are only 2 primes. However, on a large scale, the way in which the primes are distributed is very regular. Legendre and Gauss both did extensive calculations of the density of primes. Gauss (who was a prodigious calculator) told a friend that whenever he had a spare 15 minutes he would spend it in counting the primes in a 'chiliad' (a range of 1000 numbers). By the end of his life it is estimated that he had counted all the primes up to about 3 million. Both Legendre and Gauss came to the conclusion that for large n the density of primes near n is about 1/log(n).
For more background on this fascinating subject, see http://www-gap.dcs.st-and.ac.uk/~history/HistTopics/Prime_numbers.html.
Assignment:
Write a C++ program to calculate and display the number of primes in the first 50 “chiliads”. Your results should be exactly as presented below, under testing.
Design Considerations:
I think you will find your program easier to structure and write if you break it down into functions with the following prototypes:
bool isPrime (long n);
// Returns true if n is a prime, else false
long primeCount (long x, long y);
// Returns the number of primes between x and y, inclusive.
This assignment is primarily an exercise in using heavily nested loops, and decomposing your program into several component functions. So it is a requirement that you use the functional decomposition suggested above, or something quite similar to it.
Deliverables:
Please name your file a05.cpp. Upload your program source code (a05.cpp file) as usual. Be sure to comment your code as required, and to acknowledge any sources of help you may have received. Your header comments should include the identification of the assignment and your name. It should also include a comment indicating any sources of help you may have received. If there were none, the line should read:
// Sources: None.
Points will be awarded for the following attributes of your solution:
a. If your program does not compile, you get only 3 points irrespective of what the error is.
b. If it compiles, I check and deduct points for the following:
i. Your file name must be a05.cpp
ii. Your header section must have “Sources:” line to include any sources you may have used.
iii. The quality of your source code (Form). In particular, pay attention to your indentation, capitalization, and so forth. Be sure to read the class C++ style guide before working on this problem. However, if you follow the style used in the book you will be fine!
iv. Your program must use functions and loops.
c. Program works as specified, and does not have the above mentioned deficits, full points will be awarded.
Testing:
The output of your program should be the following, according to my calculations!
Start End Number of Primes
1 1000 168
1001 2000 135
2001 3000 127
3001 4000 120
4001 5000 119
5001 6000 114
6001 7000 117
7001 8000 107
8001 9000 110
9001 10000 112
…
…
…
49001 50000 98
Total primes in the first 50 chiliads: 5133
Average number per chiliad: 102.66
Additional Exploration (not to be submitted for grading):
It might be interesting to modify your program to repeat Gauss’ lifetime of calculations. Apparently, he managed to calculate all the prime numbers up to 3 million.
Is your program capable of extending the above table to 3 million? How long does it take to calculate the number of primes in all the chiliads up to 3,000,000? How many such primes are there altogether (up to 3 million)? What is the average number per chiliad in this case?
How far can your program get in 1 hour of processing? I.e. How many chiliads can your program process in one hour? By the way, there is a famous algorithm for enumerating prime numbers. Google for the Sieve of Eratosthenes ]]>Sat, 19 Feb 2011 20:05:36 GMThttp://snipplr.com/view/49260/assignment/(Pseudocode) code - NerdGnome
http://snipplr.com/view/49257/code/
]]>Sat, 19 Feb 2011 19:11:47 GMThttp://snipplr.com/view/49257/code/(Pseudocode) TOPIC database format - TopcatSoftware
http://snipplr.com/view/47431/topic-database-format/
Specifications of the TOPIC database format, a standardized structure for plain text databases that's easy to read and edit in most text editors, and
easy to programmatically parse as well. ]]>Tue, 18 Jan 2011 18:54:44 GMThttp://snipplr.com/view/47431/topic-database-format/(Pseudocode) Perl in-place substitution as an alternative to sed - axolx
http://snipplr.com/view/39451/perl-inplace-substitution-as-an-alternative-to-sed/
]]>Tue, 24 Aug 2010 10:12:38 GMThttp://snipplr.com/view/39451/perl-inplace-substitution-as-an-alternative-to-sed/(Pseudocode) WEP Networks and Keys by dad's appartment - roflrazzi
http://snipplr.com/view/38163/wep-networks-and-keys-by-dads-appartment/
]]>Sun, 01 Aug 2010 01:21:31 GMThttp://snipplr.com/view/38163/wep-networks-and-keys-by-dads-appartment/(Pseudocode) Is skype connected to some IP\'s? - roflrazzi
http://snipplr.com/view/37600/is-skype-connected-to-some-ips/
]]>Mon, 19 Jul 2010 05:49:33 GMThttp://snipplr.com/view/37600/is-skype-connected-to-some-ips/(Pseudocode) assignment3 - skyhook322
http://snipplr.com/view/24853/assignment3/
main()
continueToEnter = “y”
Declare Integer nonGreen[12]
Declare Integer green[12]
Declare Integer savings[12]
months = [’January’, ‘February’, ‘March’, ‘April’, ‘May’, ‘June’, ‘July’, ‘August’, ‘September’, ‘October’, ‘November’, ‘December’]
def getGreen()
input (‘Enter the amount for”+months[0])
def calculations()
savings[1] = nonGreen[1] – green[1]
savings[2] = nonGreen[2] – green[2]
savings[3] = nonGreen[3] – green[3]
savings[4] = nonGreen[4] – green[4]
savings[5] = nonGreen[5] – green[5]
savings[6] = nonGreen[6] – green[6]
savings[7] = nonGreen[7] – green[7]
savings[8] = nonGreen[8] – green[8]
savings[9] = nonGreen[9] – green[9]
savings[10] = nonGreen[10] – green[10]
savings[11] = nonGreen[11] – green[11]
savings[12] = nonGreen[12] – green[12] ]]>Tue, 15 Dec 2009 17:11:21 GMThttp://snipplr.com/view/24853/assignment3/(Pseudocode) Draw a lasso rectangle - helloworlder
http://snipplr.com/view/18556/draw-a-lasso-rectangle/
start_loc.x and start_loc.y is the position where the dragging first began.
Note that the top, bottom, left , and right represents positions of the 4 lines, with the anchor point at either the top of the line if vertical or left if horizontal.
Also note that the variable top will not always represent the position of the top line and the bottom not always the bottom etc, but only if you imagine dragging a lasso box from the top left to the bottom right. It does not matter however, the lasso will work in any case. The naming just made it easier for me to code it. Just think about it a little and you'll get it. ]]>Wed, 19 Aug 2009 12:22:08 GMThttp://snipplr.com/view/18556/draw-a-lasso-rectangle/(Pseudocode) Bureaucracy - helloworlder
http://snipplr.com/view/17838/bureaucracy/
Simulates a bureaucracy. ]]>Mon, 03 Aug 2009 10:48:41 GMThttp://snipplr.com/view/17838/bureaucracy/(Pseudocode) 2D array to 1D array conversion - helloworlder
http://snipplr.com/view/17837/2d-array-to-1d-array-conversion/
Convert a coordinate (x,y) into the index for a 1D array. For example, the coordinate (3,1) would be at array index 8 if there are 5 columns.
Assumption: Arrays start at 0. ]]>Mon, 03 Aug 2009 10:15:45 GMThttp://snipplr.com/view/17837/2d-array-to-1d-array-conversion/