From 1536b13da5d2f494465324cc3ef85e086a49868d Mon Sep 17 00:00:00 2001 From: Ankur Sundara Date: Fri, 10 Mar 2017 23:53:45 -0600 Subject: [PATCH 1/7] Create problem.yml --- library/problem.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 library/problem.yml diff --git a/library/problem.yml b/library/problem.yml new file mode 100644 index 0000000..4d77da8 --- /dev/null +++ b/library/problem.yml @@ -0,0 +1,10 @@ +author: arxenix +title: library +category: Programming +autogen: false +programming: true +value: 75 + +test_cases: 10 +time_limit: 1000 +memory_limit: 256000 From afd661e85e27c55de486d9efda0e140d634b9ef1 Mon Sep 17 00:00:00 2001 From: Ankur Sundara Date: Sat, 11 Mar 2017 00:11:38 -0600 Subject: [PATCH 2/7] Update description.md --- library/description.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/description.md b/library/description.md index 1bab618..8d975aa 100644 --- a/library/description.md +++ b/library/description.md @@ -2,10 +2,10 @@ Your librarian has a 2-row bookshelf that can contain N books in each row. She w Input: the integer, N (1<=N<=2^1024) -Output: the number of ways you can place red-colored books and blue-colored books onto the bookshelf. Since this number might be really big, output it mod 10^9+7. +Output: the number of ways you can place red-colored books and blue-colored books onto a N-column bookshelf. Since this number might be really big, output it mod 10^9+7. Example: -Input: 3 +Input: 2 Your valid bookshelf layouts are: ``` From 55f65cac5d65f022893879b3cdc14aa96cf38024 Mon Sep 17 00:00:00 2001 From: Ankur Sundara Date: Sat, 11 Mar 2017 00:30:58 -0600 Subject: [PATCH 3/7] Create generator.py --- library/generator.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 library/generator.py diff --git a/library/generator.py b/library/generator.py new file mode 100644 index 0000000..ea66ed5 --- /dev/null +++ b/library/generator.py @@ -0,0 +1,11 @@ +import random +C = input() + +if C==1: + print 1 +elif C==2: + print 2 +elif C==3 or C==4: + print random.randint(3, 100) +else: + print random.randint(2**(C**3-1), 2**(C**3)) From 41cf2ab68a09a024d24c4cc48033f39135749382 Mon Sep 17 00:00:00 2001 From: Ankur Sundara Date: Sat, 11 Mar 2017 00:32:58 -0600 Subject: [PATCH 4/7] Create grader.py --- library/grader.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 library/grader.py diff --git a/library/grader.py b/library/grader.py new file mode 100644 index 0000000..fcccfc1 --- /dev/null +++ b/library/grader.py @@ -0,0 +1,39 @@ +x = input() + +mat = [[0,0,1,0],[0,1,0,1],[1,0,2,0],[0,2,0,1]] +mod = 10**9+7 + +def egcd(a, b): + if a == 0: + return (b, 0, 1) + else: + g, y, x = egcd(b % a, a) + return (g, x - (b // a) * y, y) + +def modinv(a, m): + g, x, y = egcd(a, m) + if g != 1: + raise Exception('modular inverse does not exist') + else: + return x % m + +def matmult(mtx_a, mtx_b, mod): + tpos_b = zip( *mtx_b) + rtn = [[ sum( ea*eb for ea,eb in zip(a,b))%mod for b in tpos_b] for a in mtx_a] + return rtn + +def trace(A): + return sum(A[j][j] for j in range(len(A))) + +def matpow(A, p): + ret = A + for bit in bin(p)[3:]: + ret = matmult(ret, ret, mod) + if bit=='1': + ret = matmult(ret, A, mod) + return ret + +inv4 = modinv(4, mod) +ans = trace(matpow(mat, x))%mod +ans = (ans * inv4)% mod +print ans From 8802d17a24b1cb6298f1bb8bdc13be5d0c2f15b3 Mon Sep 17 00:00:00 2001 From: Ankur Sundara Date: Sat, 11 Mar 2017 00:34:41 -0600 Subject: [PATCH 5/7] Fix grader.py --- library/grader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/grader.py b/library/grader.py index fcccfc1..b98e56c 100644 --- a/library/grader.py +++ b/library/grader.py @@ -1,4 +1,4 @@ -x = input() +x = input() + 1 mat = [[0,0,1,0],[0,1,0,1],[1,0,2,0],[0,2,0,1]] mod = 10**9+7 From fd1421bff5dc56c05f456373dfe588530e7128c6 Mon Sep 17 00:00:00 2001 From: Ankur Sundara Date: Sat, 11 Mar 2017 00:38:01 -0600 Subject: [PATCH 6/7] Update description.md --- library2/description.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library2/description.md b/library2/description.md index 9e733f0..449651a 100644 --- a/library2/description.md +++ b/library2/description.md @@ -28,3 +28,7 @@ Output: ``` 1 ``` + +Explanation: + +If you understand the word 'ok', you can understand the word 'blah'. If you understand 'ok' and 'blah', you can understand 'iz'. 'iz', and 'ok' lets you understand 'yiq'. 'yiq', 'iz', and 'blah' let you understand 'arggiq'. From f54973edc886cbdc2c1871ed898d8e4040730569 Mon Sep 17 00:00:00 2001 From: Jacob Magnuson Date: Sat, 11 Mar 2017 06:47:41 +0000 Subject: [PATCH 7/7] fix rsa3 and kill rsa4 --- fizz-buzz-1/description.md | 24 ++++++++++---- fizz-buzz-1/grader.py | 16 ++++++--- rsa3/description.md | 6 +--- rsa3/grader.py | 52 ------------------------------ rsa3/problem.yml | 12 +------ rsa4/description.md | 1 - rsa4/description.md.BACKUP.137.md | 8 ----- rsa4/description.md.BACKUP.20.md | 8 ----- rsa4/description.md.BASE.137.md | 1 - rsa4/description.md.BASE.20.md | 1 - rsa4/description.md.LOCAL.137.md | 5 --- rsa4/description.md.LOCAL.20.md | 5 --- rsa4/description.md.REMOTE.137.md | 0 rsa4/description.md.REMOTE.20.md | 0 rsa4/grader.py | 4 --- rsa4/problem.yml | 9 ------ rsa4/rsa3 | 2 -- rsa4/rsa4 | 2 -- things-add-up/problem.yml | 1 + things-dont-add-up/generator.py | 2 +- things-dont-add-up/grader.class | Bin 0 -> 960 bytes things-dont-add-up/grader.py | 1 - things-dont-add-up/problem.yml | 1 + 23 files changed, 34 insertions(+), 127 deletions(-) delete mode 100644 rsa4/description.md delete mode 100644 rsa4/description.md.BACKUP.137.md delete mode 100644 rsa4/description.md.BACKUP.20.md delete mode 100644 rsa4/description.md.BASE.137.md delete mode 100644 rsa4/description.md.BASE.20.md delete mode 100644 rsa4/description.md.LOCAL.137.md delete mode 100644 rsa4/description.md.LOCAL.20.md delete mode 100644 rsa4/description.md.REMOTE.137.md delete mode 100644 rsa4/description.md.REMOTE.20.md delete mode 100644 rsa4/grader.py delete mode 100644 rsa4/problem.yml delete mode 100644 rsa4/rsa3 delete mode 100644 rsa4/rsa4 create mode 100644 things-dont-add-up/grader.class delete mode 100644 things-dont-add-up/grader.py diff --git a/fizz-buzz-1/description.md b/fizz-buzz-1/description.md index 3eac10a..eda6cd1 100644 --- a/fizz-buzz-1/description.md +++ b/fizz-buzz-1/description.md @@ -1,9 +1,17 @@ -Write a program that outputs the numbers 1 through n, in incremental order, one per line. +Write a program that takes an integer `n` as input. -However, replace any line that is a multiple of 3 with "Fizz" and any that are a multiple of 5 with "Buzz". Any line that is a multiple of 3 and 5 should be written as "FizzBuzz". +Output the numbers 1 through `n`, in increasing order, one per line. + +However, replace any line that is a multiple of 3 with `Fizz` and any that are a multiple of 5 with `Buzz`. Any line that is a multiple of 3 and 5 should be written as `FizzBuzz`. The input will be the number of lines to write, n, followed by a linebreak. +Sample input: + +``` +17 +``` + Sample output: ``` @@ -12,14 +20,16 @@ Sample output: Fizz 4 Buzz - -... - +Fizz +7 +8 +Fizz +Buzz +11 +Fizz 13 14 FizzBuzz 16 17 - -... ``` \ No newline at end of file diff --git a/fizz-buzz-1/grader.py b/fizz-buzz-1/grader.py index d5a341a..4233db8 100644 --- a/fizz-buzz-1/grader.py +++ b/fizz-buzz-1/grader.py @@ -1,4 +1,12 @@ -def grade(random, key): - if key.find("PUT A NEW KEY HERE!!!!") != -1: - return True, "Correct!" - return False, "Nope." \ No newline at end of file +n = input() + +for i in range(1, n + 1): + if i % 3 == 0 and i % 5 == 0: + print 'FizzBuzz' + elif i % 3 == 0: + print 'Fizz' + elif i % 5 == 0: + print 'Buzz' + else: + print i + diff --git a/rsa3/description.md b/rsa3/description.md index c61c847..a01623f 100644 --- a/rsa3/description.md +++ b/rsa3/description.md @@ -1,5 +1 @@ -<<<<<<< HEAD -I found somebody's notes on their private RSA! Help me crack [this](${ciphertext_txt}). -======= -We came across another [message]($rsa3) that follows the same cryptographic schema as those other Really Scary Admin messages. Take a look and see if you can crack it. ->>>>>>> 93577ddee37a489cf0aa1a4b987d23a3bc3d2657 +We came across another [message]($rsa3) that follows the same cryptographic schema as those other RSA messages. Take a look and see if you can crack it. diff --git a/rsa3/grader.py b/rsa3/grader.py index 4f6a800..e9ca30f 100644 --- a/rsa3/grader.py +++ b/rsa3/grader.py @@ -1,56 +1,4 @@ -<<<<<<< HEAD -from cStringIO import StringIO - -flag = "wh3n_y0u_h4ve_p&q_RSA_iz_ez" - -def modx(base,exp,mod): - r = 1; - while (exp > 0): - if (exp % 2 == 1): - r = (r * base) % mod - base = (base * base) % mod - exp = exp/2 - return r - -def probprime(s): - if s%2==0: - s += 1 - smolprimes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] - while len(set([modx(i,s-1,s) for i in smolprimes])) != 1 or modx(2,s-1,s) != 1: - s+=2 - return(s) - -def get_problem(random): - # add Probable Prime function later - p = probprime(random.randint(3*10**79,4*10**79)) - q = probprime(random.randint(3*10**79,4*10**79)) - e = 3 - salt = "".join([random.choice("0123456789abcdef") for i in range(8)]) - return (p, q, e, salt) - -def generate_ciphertext(random): - p, q, e, salt = get_problem(random) - encoded = int(("easyctf{%s_%s}" % (flag, salt)).encode('hex'),16) - ciphertext = 'p: '+str(p)+'\n' - ciphertext += 'q: '+str(q)+'\n' - ciphertext += 'e: '+str(e)+'\n' - ciphertext += 'c: '+str(pow(encoded, e, p*q))+'\n' - - return StringIO(ciphertext) - -def generate(random): - return dict(files={ - "ciphertext_rsa1.txt": generate_ciphertext - }) - -def grade(random, key): - n, salt = get_problem(random) - if key.find("%s_%s" % (flag, salt)) >= 0: - return True, "Correct!" - return False, "Nope." -======= def grade(autogen, key): if key.find("tw0_v3ry_merrry_tw1n_pr1m35!!_417c0d") != -1: return True, "Really Superb! Applause!" return False, "RIP" ->>>>>>> 93577ddee37a489cf0aa1a4b987d23a3bc3d2657 diff --git a/rsa3/problem.yml b/rsa3/problem.yml index 8ff5a4d..10bc296 100644 --- a/rsa3/problem.yml +++ b/rsa3/problem.yml @@ -1,19 +1,9 @@ -<<<<<<< HEAD -title: RSA 1 -author: neptunia -hint: Go google RSA if you're stuck. -category: Cryptography -autogen: true -programming: false -value: 25 -======= author: blockingthesky title: RSA 3 hint: You might want to read up on how RSA works. category: Cryptography autogen: false programming: false -value: 70 +value: 135 files: - rsa3 ->>>>>>> 93577ddee37a489cf0aa1a4b987d23a3bc3d2657 diff --git a/rsa4/description.md b/rsa4/description.md deleted file mode 100644 index 2d61669..0000000 --- a/rsa4/description.md +++ /dev/null @@ -1 +0,0 @@ -We came across another [message]($rsa4) that follows the same cryptographic schema as those other RSA messages. Take a look and see if you can crack it. \ No newline at end of file diff --git a/rsa4/description.md.BACKUP.137.md b/rsa4/description.md.BACKUP.137.md deleted file mode 100644 index 68f5e9f..0000000 --- a/rsa4/description.md.BACKUP.137.md +++ /dev/null @@ -1,8 +0,0 @@ -<<<<<<< HEAD -<<<<<<< HEAD -I found somebody's notes on their private RSA! Help me crack [this](${ciphertext_txt}). -======= -We came across another [message]($rsa3) that follows the same cryptographic schema as those other Really Scary Admin messages. Take a look and see if you can crack it. ->>>>>>> 93577ddee37a489cf0aa1a4b987d23a3bc3d2657 -======= ->>>>>>> f9a58afef003d40f3ada9c1645eda26363521cf3 diff --git a/rsa4/description.md.BACKUP.20.md b/rsa4/description.md.BACKUP.20.md deleted file mode 100644 index 68f5e9f..0000000 --- a/rsa4/description.md.BACKUP.20.md +++ /dev/null @@ -1,8 +0,0 @@ -<<<<<<< HEAD -<<<<<<< HEAD -I found somebody's notes on their private RSA! Help me crack [this](${ciphertext_txt}). -======= -We came across another [message]($rsa3) that follows the same cryptographic schema as those other Really Scary Admin messages. Take a look and see if you can crack it. ->>>>>>> 93577ddee37a489cf0aa1a4b987d23a3bc3d2657 -======= ->>>>>>> f9a58afef003d40f3ada9c1645eda26363521cf3 diff --git a/rsa4/description.md.BASE.137.md b/rsa4/description.md.BASE.137.md deleted file mode 100644 index 6f6a960..0000000 --- a/rsa4/description.md.BASE.137.md +++ /dev/null @@ -1 +0,0 @@ -We came across another [message]($rsa3) that follows the same cryptographic schema as those other Really Scary Admin messages. Take a look and see if you can crack it. \ No newline at end of file diff --git a/rsa4/description.md.BASE.20.md b/rsa4/description.md.BASE.20.md deleted file mode 100644 index 6f6a960..0000000 --- a/rsa4/description.md.BASE.20.md +++ /dev/null @@ -1 +0,0 @@ -We came across another [message]($rsa3) that follows the same cryptographic schema as those other Really Scary Admin messages. Take a look and see if you can crack it. \ No newline at end of file diff --git a/rsa4/description.md.LOCAL.137.md b/rsa4/description.md.LOCAL.137.md deleted file mode 100644 index c61c847..0000000 --- a/rsa4/description.md.LOCAL.137.md +++ /dev/null @@ -1,5 +0,0 @@ -<<<<<<< HEAD -I found somebody's notes on their private RSA! Help me crack [this](${ciphertext_txt}). -======= -We came across another [message]($rsa3) that follows the same cryptographic schema as those other Really Scary Admin messages. Take a look and see if you can crack it. ->>>>>>> 93577ddee37a489cf0aa1a4b987d23a3bc3d2657 diff --git a/rsa4/description.md.LOCAL.20.md b/rsa4/description.md.LOCAL.20.md deleted file mode 100644 index c61c847..0000000 --- a/rsa4/description.md.LOCAL.20.md +++ /dev/null @@ -1,5 +0,0 @@ -<<<<<<< HEAD -I found somebody's notes on their private RSA! Help me crack [this](${ciphertext_txt}). -======= -We came across another [message]($rsa3) that follows the same cryptographic schema as those other Really Scary Admin messages. Take a look and see if you can crack it. ->>>>>>> 93577ddee37a489cf0aa1a4b987d23a3bc3d2657 diff --git a/rsa4/description.md.REMOTE.137.md b/rsa4/description.md.REMOTE.137.md deleted file mode 100644 index e69de29..0000000 diff --git a/rsa4/description.md.REMOTE.20.md b/rsa4/description.md.REMOTE.20.md deleted file mode 100644 index e69de29..0000000 diff --git a/rsa4/grader.py b/rsa4/grader.py deleted file mode 100644 index e9ca30f..0000000 --- a/rsa4/grader.py +++ /dev/null @@ -1,4 +0,0 @@ -def grade(autogen, key): - if key.find("tw0_v3ry_merrry_tw1n_pr1m35!!_417c0d") != -1: - return True, "Really Superb! Applause!" - return False, "RIP" diff --git a/rsa4/problem.yml b/rsa4/problem.yml deleted file mode 100644 index 17fc9de..0000000 --- a/rsa4/problem.yml +++ /dev/null @@ -1,9 +0,0 @@ -author: blockingthesky -title: RSA 4 -hint: You might want to read up on how RSA works. -category: Cryptography -autogen: false -programming: false -value: 130 -files: - - rsa3 diff --git a/rsa4/rsa3 b/rsa4/rsa3 deleted file mode 100644 index bda7c13..0000000 --- a/rsa4/rsa3 +++ /dev/null @@ -1,2 +0,0 @@ -{N : e : c} -{0x27335d21ca51432fa000ddf9e81f630314a0ef2e35d81a839584c5a7356b94934630ebfc2ef9c55b111e8c373f2db66ca3be0c0818b1d4eda7d53c1bd0067f66a12897099b5e322d85a8da45b72b828813af23L : 0x10001 : 0x9b9c138e0d473b6e6cf44acfa3becb358b91d0ba9bfb37bf11effcebf9e0fe4a86439e8217819c273ea5c1c5acfd70147533aa550aa70f2e07cc98be1a1b0ea36c0738d1c994c50b1bd633e3873fc0cb377e7L} \ No newline at end of file diff --git a/rsa4/rsa4 b/rsa4/rsa4 deleted file mode 100644 index bda7c13..0000000 --- a/rsa4/rsa4 +++ /dev/null @@ -1,2 +0,0 @@ -{N : e : c} -{0x27335d21ca51432fa000ddf9e81f630314a0ef2e35d81a839584c5a7356b94934630ebfc2ef9c55b111e8c373f2db66ca3be0c0818b1d4eda7d53c1bd0067f66a12897099b5e322d85a8da45b72b828813af23L : 0x10001 : 0x9b9c138e0d473b6e6cf44acfa3becb358b91d0ba9bfb37bf11effcebf9e0fe4a86439e8217819c273ea5c1c5acfd70147533aa550aa70f2e07cc98be1a1b0ea36c0738d1c994c50b1bd633e3873fc0cb377e7L} \ No newline at end of file diff --git a/things-add-up/problem.yml b/things-add-up/problem.yml index 02eefe1..5111e51 100644 --- a/things-add-up/problem.yml +++ b/things-add-up/problem.yml @@ -5,6 +5,7 @@ autogen: false programming: true value: 15 +grader_language: python test_cases: 10 time_limit: 1000 memory_limit: 256000 diff --git a/things-dont-add-up/generator.py b/things-dont-add-up/generator.py index 398325e..594e5b8 100644 --- a/things-dont-add-up/generator.py +++ b/things-dont-add-up/generator.py @@ -7,7 +7,7 @@ elif N == 1: elif N == 2: print '123 456 3\n5 7 11' elif N == 3: - print '1 10000000 16\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16' + print '1 10000000 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16' else: import random as r r.seed(N) diff --git a/things-dont-add-up/grader.class b/things-dont-add-up/grader.class new file mode 100644 index 0000000000000000000000000000000000000000..b56ab20a7687ebd69e366e2fea146fc3ea5cb842 GIT binary patch literal 960 zcmb7CJxmlq6#i!a=5BZ8?-*d=4g^sS&^r_2X+UUDlS@#HM@WQ*h6W!?HIL*<^U|jVBKb&At(}S}N+GJ(PV`!Z61MgO?yy#VD+{F?x zTG{mjhPL$l)QbDi&6eC?Ia>&;ey}_y51uN7Zt?z2cQvZ#=%dRy&T#ZIn1xEMTJ&!C zQpj4ax=UU)BUNmeuo#*n#aif>vW21>1YVWntc`ORkOgTQgBY?gjPo29Y-Et7w*ROw zG#zy_y}05PLx#i&Eix$cc?omJjuak02)#1#ayId2GQX0|2dlM^hV$I=7(++;#Dtuh z2i~JFAJC;_AL*-=8pTIKx5=L)p+wXx>HkBM#;PnTQ3F~!KRAnC#OU$lr+~bJMQGD5 zMJuCKAKC_cO#zusXhft+M;g#bF_p4cP@~+pw@~hGLfwWoHM|9VT*8EeoTlbF`QFAd7ORizk;UYHj0+$?PH15Rra;BQI zgeA;1^f_^1WpcKN340;64qKK|sLj+ZlKWhb5$-0X5M}d!g|7U+&<2dU&LX+(O&CJo z0+)U$(aiVg7YA8rk#*gK{p3i7GM8x`M>DRW1$iWJ2d$WcK!`RxK|7vO{EYbL=)g(N;seDWN$nHmzMuzR>5-b~mg{IZ!~kL(%^WR^K8^&v(LTg4G;p-C12~dm WJwKrDL;nfo7^Nsg(xZu}{kGqVXTJIX literal 0 HcmV?d00001 diff --git a/things-dont-add-up/grader.py b/things-dont-add-up/grader.py deleted file mode 100644 index d3c6fc3..0000000 --- a/things-dont-add-up/grader.py +++ /dev/null @@ -1 +0,0 @@ -# done in grader.java diff --git a/things-dont-add-up/problem.yml b/things-dont-add-up/problem.yml index e3cb42a..92241ac 100644 --- a/things-dont-add-up/problem.yml +++ b/things-dont-add-up/problem.yml @@ -5,6 +5,7 @@ autogen: false programming: true value: 210 +grader_language: java test_cases: 15 time_limit: 1000 memory_limit: 256000 \ No newline at end of file