This file contains hidden or 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
/* | |
* String constants (C syntax) | |
* Escape sequence \c is accepted for all characters c. Except for | |
* \n \t \b \f, the result is c. | |
* | |
*/ | |
\" { | |
string_buf_ptr = string_buf; | |
BEGIN(STRING); |
This file contains hidden or 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
/* | |
* The scanner definition for COOL. | |
*/ | |
/* | |
* Stuff enclosed in %{ %} in the first section is copied verbatim to the | |
* output, so headers and global definitions are placed here to be visible | |
* to the code in the file. Don't remove anything that was here initially | |
*/ | |
%{ |
This file contains hidden or 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
newpath | |
300.0 400.0 moveto | |
gsave | |
currentpoint translate | |
-241.66666666666669 0.0 rmoveto | |
108.33333333333334 0.0 rmoveto | |
gsave | |
currentpoint translate | |
-108.33333333333334 0.0 rmoveto | |
25.0 0.0 rmoveto |
This file contains hidden or 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
int is_valid_ref(char *arg) | |
{ | |
do { | |
if (!isdigit(*arg)) | |
return 0; | |
} while (*++arg); | |
return 1; | |
} |
This file contains hidden or 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
#!/usr/bin/env ruby1.9 | |
# Project Euler, Problem 57 | |
# | |
# It is possible to show that the square root of two can be expressed as an | |
# infinite continued fraction. | |
# | |
# sqrt(2) = 1 + 1/(2 + 1/(2 + 1/(2 + ...))) = 1.414213... | |
# | |
# By expanding this for the first four iterations, we get: |
This file contains hidden or 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
#!/usr/bin/env ruby1.9 | |
# Project Euler, Problem 36 | |
# | |
# The decimal number, 585 = 1001001001 (binary), is palindromic in both | |
# bases. | |
# | |
# Find the sum of all numbers, less than one million, which are palindromic | |
# in base 10 and base 2. | |
# |
This file contains hidden or 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
class Integer | |
def to_binary_s(n) | |
(n - 1).downto(0).inject("") {|str, i| str << self[i].to_s} | |
end | |
end |
This file contains hidden or 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
-- Project Euler, Problem 48 | |
-- | |
-- ========== | |
-- The series, 1^1 + 2^2 + 3^3 + ... + 10^10 = 10405071317. | |
-- | |
-- Find the last ten digits of the series, 1^1 + 2^2 + 3^3 + ... + 1000^1000. | |
-- ========== | |
-- | |
-- Lawrence Velazquez | |
-- 13 June 2011 |
This file contains hidden or 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
-- Project Euler, Problem 97 | |
-- | |
-- ========== | |
-- The first known prime found to exceed one million digits was discovered | |
-- in 1999, and is a Mersenne prime of the form 2^6972593 - 1; it contains | |
-- exactly 2,098,960 digits. Subsequently other Mersenne primes, of the | |
-- form 2^p - 1, have been found which contain more digits. | |
-- | |
-- However, in 2004 there was found a massive non-Mersenne prime which | |
-- contains 2,357,207 digits: 28433 * 2^7830457 + 1. |
This file contains hidden or 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
#!/usr/bin/env ruby1.9 | |
# Project Euler, Problem 12 | |
# | |
# The sequence of triangle numbers is generated by adding the natural | |
# numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = | |
# 28. The first ten terms would be: | |
# | |
# 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... | |
# |