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
/** | |
* Returns a given power of ten (10 ^ 0 = 1, 10 ^ 1 = 10, 10 ^ 2 = 100, etc.). | |
*/ | |
function powerOfTen( power ) { | |
var result = 1; | |
for ( i = 0; i < power; i++ ) { | |
result *= 10; | |
} | |
return result; | |
} |
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
/** | |
* <p>If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples | |
* is 23. | |
* | |
* <p>Find the sum of all the multiples of 3 or 5 below 1000. | |
* | |
* @author Adrian K. <[email protected]> | |
*/ | |
object ProjectEulerProblem001 { | |
def main( args : Array[String] ) : Unit = { |
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
// Prints to browser console (Chrome, Firefox), no explicit ifs. Starts from 1. | |
for(i=0;i++<100;console.log([['fizz'][i%3],['buzz'][i%5]].join('')||i)); // 72 characters | |
// Writes to array 'a', no explicit ifs. Starts from 1. | |
for(a,i=0;i<100;a[i++]=([['fizz'][i%3],['buzz'][i%5]].join('')||i)); // 68 characters | |
// Returns an array (Firefox only), no explicit ifs, no explicit loops. Starts from 0. | |
Array.apply([],Array(100)).map((e,i)=>[['fizz'][i%3],['buzz'][i%5]].join('')||i) // 80 characters |
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
# Most recent version of all records and creation date of the oldest version | |
# | |
# "id","version_since","version_until","content" | |
# "1","2010-06-01","2010-06-05","Initial text." | |
# "1","2010-06-05","2010-06-10","Modified text." | |
# "1","2010-06-10","2037-12-31","Final text." | |
# "2","2010-05-01","2010-05-31","Second initial text." | |
# "2","2010-05-31","2010-06-10","Modified second text." | |
# "2","2010-06-10","2010-06-15","Modified again second text." | |
# "2","2010-06-15","2037-12-31","Second final text." |
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
# Given such a DB structure (MySQL): | |
# | |
# Table: module_cms_articles | |
# | |
# id | version_since | version_until | creation_date | creator_id | title | lead | content | visible | |
# ----+---------------------+---------------------+---------------------+------------+-----------------------+-----------------+--------------------------+--------- | |
# 1 | 2010-05-12 19:57:05 | 2010-05-12 20:15:20 | 2010-05-12 19:57:05 | 1 | 1-st article | Introduction... | First article. | 0 | |
# 1 | 2010-05-12 20:15:20 | 2010-05-12 20:27:28 | 2010-05-12 19:57:05 | 1 | 1-st article | Introduction... | First article. Extended. | 0 | |
# 1 | 2010-05-12 20:27:28 | 2037-12-31 23:59:59 | 2010-05-12 19:57:05 | 1 | 1-st article modified | Introduction... | First Article. Extended. | 0 |
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
/** | |
* Calculates a compound interest (procent składany) for a given period of time | |
* with given annual interest rate, number of capitalizations and saving period. | |
* | |
* @param amount | |
* initial investment | |
* | |
* @param interestRate | |
* nominal annual interest rate (in decimal, so if interest rate is 5%, | |
* we give 0.05) |
NewerOlder