Project Euler 19
@see http://projecteuler.net/index.php?section=problems&id=19
/**
* Copyright nitoyon ( http://wonderfl.net/user/nitoyon )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/blR0
*/
package{
import flash.display.Sprite;
import flash.text.*;
// @see http://projecteuler.net/index.php?section=problems&id=19
public class Eular extends Sprite{
private const days:Array = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
public function Eular() {
var ans:uint = 0;
var d:int = 1;
for (var i:int = 1900; i <= 2000; i++){
for (var j:int = 0; j < 12; j++){
if (i > 1900 && d == 0) ans++;
d += days[j];
if (i % 4 == 0 && (i % 100 != 0 || i % 400 == 0) && j == 1) d++;
d %= 7;
}
}
var t:TextField = TextField(addChild(new TextField()));
t.text = ans.toString();
}
}
}