diff --git a/codejam/2016-qualification/a-1.ans b/codejam/2016-qualification/a-1.ans new file mode 100644 index 00000000..05249531 --- /dev/null +++ b/codejam/2016-qualification/a-1.ans @@ -0,0 +1,5 @@ +Case #1: INSOMNIA +Case #2: 10 +Case #3: 90 +Case #4: 110 +Case #5: 5076 diff --git a/codejam/2016-qualification/a-1.in b/codejam/2016-qualification/a-1.in new file mode 100644 index 00000000..74eaa927 --- /dev/null +++ b/codejam/2016-qualification/a-1.in @@ -0,0 +1,6 @@ +5 +0 +1 +2 +11 +1692 diff --git a/codejam/2016-qualification/a-2.ans b/codejam/2016-qualification/a-2.ans new file mode 100644 index 00000000..2f242c3c --- /dev/null +++ b/codejam/2016-qualification/a-2.ans @@ -0,0 +1,100 @@ +Case #1: INSOMNIA +Case #2: 10 +Case #3: 90 +Case #4: 110 +Case #5: 924 +Case #6: 1352 +Case #7: 90 +Case #8: 1099 +Case #9: 938 +Case #10: 903 +Case #11: 30 +Case #12: 92 +Case #13: 330 +Case #14: 1036 +Case #15: 910 +Case #16: 936 +Case #17: 369 +Case #18: 990 +Case #19: 2560 +Case #20: 1071 +Case #21: 792 +Case #22: 1390 +Case #23: 715 +Case #24: 900 +Case #25: 390 +Case #26: 830 +Case #27: 930 +Case #28: 90 +Case #29: 190 +Case #30: 749 +Case #31: 896 +Case #32: 1458 +Case #33: 506 +Case #34: 920 +Case #35: 590 +Case #36: 1560 +Case #37: 90 +Case #38: 952 +Case #39: 256 +Case #40: 970 +Case #41: 1309 +Case #42: 539 +Case #43: 1169 +Case #44: 390 +Case #45: 495 +Case #46: 1096 +Case #47: 918 +Case #48: 198 +Case #49: 2380 +Case #50: 2356 +Case #51: 203 +Case #52: 270 +Case #53: 552 +Case #54: 119 +Case #55: 1190 +Case #56: 1990 +Case #57: 784 +Case #58: 912 +Case #59: 90 +Case #60: 690 +Case #61: 9000 +Case #62: 564 +Case #63: 1910 +Case #64: 3192 +Case #65: 918 +Case #66: 900 +Case #67: 1085 +Case #68: 1048 +Case #69: 790 +Case #70: 1176 +Case #71: 870 +Case #72: 90 +Case #73: 945 +Case #74: 1136 +Case #75: 930 +Case #76: 70 +Case #77: 96 +Case #78: 190 +Case #79: 896 +Case #80: 570 +Case #81: 918 +Case #82: 5478 +Case #83: 476 +Case #84: 2625 +Case #85: 980 +Case #86: 924 +Case #87: 940 +Case #88: 180 +Case #89: 9000 +Case #90: 590 +Case #91: 560 +Case #92: 1296 +Case #93: 310 +Case #94: 790 +Case #95: 900 +Case #96: 396 +Case #97: 721 +Case #98: 920 +Case #99: 1970 +Case #100: 792 diff --git a/codejam/2016-qualification/a-2.in b/codejam/2016-qualification/a-2.in new file mode 100644 index 00000000..dc1cb743 --- /dev/null +++ b/codejam/2016-qualification/a-2.in @@ -0,0 +1,101 @@ +100 +0 +1 +2 +11 +84 +169 +18 +157 +134 +129 +3 +4 +33 +148 +91 +104 +41 +99 +160 +119 +132 +139 +65 +20 +39 +83 +186 +9 +38 +107 +112 +162 +46 +184 +118 +120 +5 +68 +16 +194 +187 +77 +167 +78 +55 +137 +34 +22 +140 +124 +29 +30 +92 +17 +170 +199 +98 +76 +6 +138 +125 +94 +191 +168 +102 +25 +155 +131 +79 +147 +174 +10 +105 +142 +93 +7 +8 +19 +128 +57 +153 +166 +28 +175 +196 +154 +188 +15 +200 +59 +35 +144 +31 +158 +180 +36 +103 +40 +197 +88 diff --git a/codejam/2016-qualification/a-3.ans b/codejam/2016-qualification/a-3.ans new file mode 100644 index 00000000..02701b5a --- /dev/null +++ b/codejam/2016-qualification/a-3.ans @@ -0,0 +1,100 @@ +Case #1: INSOMNIA +Case #2: 10 +Case #3: 90 +Case #4: 110 +Case #5: 5076 +Case #6: 4896048 +Case #7: 3593079 +Case #8: 846780 +Case #9: 4089375 +Case #10: 2825610 +Case #11: 2942160 +Case #12: 90 +Case #13: 1707815 +Case #14: 1839859 +Case #15: 1744029 +Case #16: 47036 +Case #17: 791760 +Case #18: 589869 +Case #19: 2490724 +Case #20: 1010597 +Case #21: 3559024 +Case #22: 2829757 +Case #23: 2634845 +Case #24: 30 +Case #25: 5999976 +Case #26: 1182650 +Case #27: 900000 +Case #28: 5478 +Case #29: 70 +Case #30: 932745 +Case #31: 900 +Case #32: 3859296 +Case #33: 1015670 +Case #34: 920 +Case #35: 9999910 +Case #36: 9999990 +Case #37: 1057900 +Case #38: 918 +Case #39: 3790500 +Case #40: 2069435 +Case #41: 5999964 +Case #42: 2294976 +Case #43: 547045 +Case #44: 4293084 +Case #45: 1960992 +Case #46: 2800845 +Case #47: 3930285 +Case #48: 3890778 +Case #49: 914200 +Case #50: 2936035 +Case #51: 2937548 +Case #52: 5999952 +Case #53: 2973090 +Case #54: 736240 +Case #55: 41725 +Case #56: 1793180 +Case #57: 95235 +Case #58: 90 +Case #59: 2495127 +Case #60: 2160455 +Case #61: 9000000 +Case #62: 900 +Case #63: 2590084 +Case #64: 4227490 +Case #65: 1449525 +Case #66: 477820 +Case #67: 9999930 +Case #68: 90 +Case #69: 1794702 +Case #70: 1631636 +Case #71: 1921710 +Case #72: 2023436 +Case #73: 223560 +Case #74: 2619625 +Case #75: 2139084 +Case #76: 487599 +Case #77: 4703545 +Case #78: 90000 +Case #79: 6999965 +Case #80: 1650972 +Case #81: 526764 +Case #82: 1782748 +Case #83: 90 +Case #84: 1652000 +Case #85: 1790425 +Case #86: 4209440 +Case #87: 640784 +Case #88: 2715633 +Case #89: 9999970 +Case #90: 2520968 +Case #91: 96 +Case #92: 2410785 +Case #93: 92 +Case #94: 9000000 +Case #95: 7999984 +Case #96: 9000 +Case #97: 4112535 +Case #98: 9000 +Case #99: 2356 +Case #100: 2180991 diff --git a/codejam/2016-qualification/a-3.in b/codejam/2016-qualification/a-3.in new file mode 100644 index 00000000..8e4a56f0 --- /dev/null +++ b/codejam/2016-qualification/a-3.in @@ -0,0 +1,101 @@ +100 +0 +1 +2 +11 +1692 +408004 +399231 +211695 +817875 +941870 +735540 +9 +341563 +262837 +249147 +11759 +197940 +84267 +622681 +144371 +889756 +404251 +526969 +3 +999996 +168950 +12500 +166 +7 +310915 +20 +482412 +203134 +40 +999991 +999999 +264475 +34 +758100 +413887 +999994 +286872 +109409 +715514 +653664 +933615 +786057 +648463 +182840 +587207 +734387 +999992 +594618 +147248 +8345 +448295 +13605 +5 +831709 +432091 +125000 +25 +647521 +845498 +207075 +119455 +999993 +10 +299117 +407909 +384342 +505859 +44712 +523925 +713028 +162533 +940709 +1250 +999995 +275162 +131691 +445687 +6 +236000 +358085 +841888 +80098 +905211 +999997 +630242 +8 +803595 +4 +1000000 +999998 +125 +587505 +200 +124 +726997 diff --git a/codejam/2016-qualification/a.rkt b/codejam/2016-qualification/a.rkt new file mode 100755 index 00000000..12bc0a4d --- /dev/null +++ b/codejam/2016-qualification/a.rkt @@ -0,0 +1,37 @@ +#!/usr/bin/env racket +;; https://codingcompetitions.withgoogle.com/codejam/round/0000000000201bee/0000000000201c8a +#lang racket +(require srfi/25) + +(define (number->digits n) + (define (iter n acc) + (match n + [0 acc] + [_ (iter (quotient n 10) (cons (modulo n 10) acc))])) + (iter n '())) + +(define (update-digits v digits) + (for-each (lambda (d) (vector-set! v d #t)) digits)) + +(define (all-digits? v) + (not (vector-memq #f v))) + +(define (process n) + (let ([v (make-vector 10 #f)]) + (define (iter n i) + (update-digits v (number->digits (* n i))) + (if (all-digits? v) + (* n i) + (iter n (+ i 1)))) + (iter n 1))) + +(define (main) + (let ([n (read)]) + (define (iter i) + (when (<= i n) + (let ([k (read)]) + (printf "Case #~a: ~a\n" i (if (zero? k) "INSOMNIA" (process k))) + (iter (+ i 1))))) + (iter 1))) + +(main) diff --git a/codejam/README.md b/codejam/README.md index 91dfe6e5..b7d1f953 100644 --- a/codejam/README.md +++ b/codejam/README.md @@ -52,6 +52,8 @@ There are solutions for the following [Google Code Jam](https://codejam.withgoog ([problem site](https://codingcompetitions.withgoogle.com/codejam/round/00000000002017f7/0000000000201878)) 1. [2017 Qualification Round - A. Oversized Pancake Flipper](2017-qualification/a.py) ([problem site](https://codingcompetitions.withgoogle.com/codejam/round/00000000002017f7/0000000000201847)) +1. [2016 Qualification Round - A. Counting Sheep](2016-qualification/a.rkt) + ([problem site](https://codingcompetitions.withgoogle.com/codejam/round/0000000000201bee/0000000000201c8a)) 1. [2014 Qualification Round - B. Cookie Clicker Alpha](2014-qualification/b.lisp) ([problem site](https://code.google.com/codejam/contest/2974486/dashboard#s=p1)) 1. [2014 Qualification Round - A. Magic Trick](2014-qualification/a.lisp)