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 ruby | |
| def find_pair!(data, target) | |
| # We know we won't use a value greater than our target | |
| data.reject! { |i| i > target } | |
| # Sort it so we don't have to scan our list a bunch | |
| data.sort! | |
| # If our two biggest numbers are lower than the target, we're boned |
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
| // | |
| // fs_capabilities.m | |
| // | |
| // Created by Charles Francoise on 13/05/14. | |
| // Copyright (c) 2014 Charles Francoise. All rights reserved. | |
| // | |
| #include <stdio.h> | |
| #include <unistd.h> | |
| #include <errno.h> |
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
| // | |
| // fs_capabilities.m | |
| // | |
| // Created by Charles Francoise on 13/05/14. | |
| // Copyright (c) 2014 Charles Francoise. All rights reserved. | |
| // | |
| #include <stdio.h> | |
| #include <unistd.h> | |
| #include <errno.h> |
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 ruby | |
| # The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime. | |
| # There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79, and 97. | |
| #How many circular primes are there below one million? | |
| # | |
| require 'prime' | |
| candidates = [2] + Prime.each(1_000_000).reject { |p| p.digits.any? { |d| d.even? } } | |
| def siblings(int) |
OlderNewer