forked from abeaumont/competitive-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[codejam - 2016-qualification] Add Racket solution for C.
- Loading branch information
Showing
8 changed files
with
598 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Case #1: | ||
100111 3 2 5 2 7 2 3 2 11 | ||
100011 5 13 3 31 43 3 73 7 3 | ||
100001 3 2 5 2 7 2 3 2 11 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
1 | ||
6 3 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
Case #1: | ||
1000000010110101 3 2 3 2 7 2 3 2 3 | ||
1000000010110011 47 2 3 2 11 2 204311 2 3 | ||
1000000010101001 3 5 13 3 5 43 3 73 7 | ||
1000000010100111 5 2 3 2 37 2 5 2 3 | ||
1000000010100011 3 1259 421 3 5 8893 3 67 17 | ||
1000000010011101 3 2 3 2 7 2 3 2 3 | ||
1000000010011011 11 2 3 2 13 2 47 2 3 | ||
1000000010011001 7 1667 179 13 5 11 23 7 311 | ||
1000000010010111 3 2 3 2 7 2 3 2 3 | ||
1000000010010001 3 2 5 2 7 2 3 2 7 | ||
1000000010001001 5 2 7 2 1933 2 29 2 157 | ||
1000000010000101 3 2 5 2 7 2 3 2 11 | ||
1000000010000011 167 2 11 2 58427 2 23 2 839 | ||
1000000001111111 3 2 5 2 7 2 3 2 7 | ||
1000000001111101 7 19 43 17 55987 23 7 7 31 | ||
1000000001111011 31 557 7 19 23 1129 7 5441 241 | ||
1000000001111001 3 2 3 2 7 2 3 2 3 | ||
1000000001110101 5 2 3 2 37 2 5 2 3 | ||
1000000001110011 3 2 3 2 7 2 3 2 3 | ||
1000000001101101 3 2 3 2 7 2 3 2 3 | ||
1000000001101011 5 2 3 2 37 2 5 2 3 | ||
1000000001100111 3 2 3 2 7 2 3 2 3 | ||
1000000001100011 23 19 11 105491 5 47 11117 1787 127 | ||
1000000001100001 3 2 5 2 7 2 3 2 11 | ||
1000000001011111 59 113 7 157 19 1399 7 43 107 | ||
1000000001011101 17 2 3 2 1297 2 11 2 3 | ||
1000000001011011 3 2 3 2 7 2 3 2 3 | ||
1000000001011001 11 5 281 101 5 67 5 13 19 | ||
1000000001010111 5 2 3 2 37 2 5 2 3 | ||
1000000001010101 3 7 13 3 5 17 3 53 7 | ||
1000000001001111 3 2 3 2 7 2 3 2 3 | ||
1000000001001001 3 2 5 2 7 2 3 2 7 | ||
1000000001000011 3 2 5 2 7 2 3 2 11 | ||
1000000000111101 3 2 3 2 7 2 3 2 3 | ||
1000000000111011 17 2 3 2 73 2 17 2 3 | ||
1000000000110111 3 2 3 2 7 2 3 2 3 | ||
1000000000110101 23 17 11 23 5 299699 43 239 59 | ||
1000000000110001 3 2 5 2 7 2 3 2 11 | ||
1000000000101111 5 2 3 2 37 2 5 2 3 | ||
1000000000101011 3 7 13 3 5 43 3 73 7 | ||
1000000000100101 3 2 5 2 7 2 3 2 7 | ||
1000000000011111 3 2 3 2 7 2 3 2 3 | ||
1000000000011011 5 1567 15559 6197 5 5 1031 7 83 | ||
1000000000011001 3 2 5 2 7 2 3 2 11 | ||
1000000000010011 3 2 5 2 7 2 3 2 7 | ||
1000000000001101 3 2 5 2 7 2 3 2 11 | ||
1000000000001001 73 5 3 19 19 3 5 19 3 | ||
1000000000000111 3 2 5 2 7 2 3 2 11 | ||
1000000000000101 13 11 3 4751 173 3 53 109 3 | ||
1000000000000001 3 2 5 2 7 2 3 2 7 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
1 | ||
16 50 |
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
1 | ||
32 500 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env racket | ||
;; https://codingcompetitions.withgoogle.com/codejam/round/0000000000201bee/0000000000201b6d | ||
#lang racket | ||
(require math/number-theory) | ||
|
||
(define (process n j) | ||
(define (collect i s) | ||
(cons (format "~b" i) | ||
(map (lambda (x) | ||
(number->string (second (divisors (string->number s x))))) | ||
(range 2 11)))) | ||
(define (no-primes? s) | ||
(define (iter i) | ||
(cond ([> i 10] #t) | ||
([prime? (string->number s i)] #f) | ||
(else (iter (+ i 1))))) | ||
(iter 2)) | ||
(define (iter i k xs) | ||
(if (= k j) | ||
xs | ||
(let ([s (format "~b" i)]) | ||
(if (no-primes? s) | ||
(iter (+ i 2) (+ k 1) (cons (collect i s) xs)) | ||
(iter (+ i 2) k xs))))) | ||
(iter (+ (expt 2 (- n 1)) 1) 0 '())) | ||
|
||
(define (main n) | ||
(define (iter i) | ||
(when (<= i n) | ||
(printf "Case #~a:\n" i) | ||
(for-each (lambda (x) (printf "~a\n" (string-join x))) | ||
(apply process (map string->number (string-split (read-line))))))) | ||
(iter 1)) | ||
(main (string->number (read-line))) |
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