邓心一 7 年 前
コミット
2a5d998690
5 ファイル変更95 行追加0 行削除
  1. BIN
      JPK_406.jar
  2. 14 0
      ascii.py
  3. 26 0
      ceasar.py
  4. 15 0
      get_url.js
  5. 40 0
      prime.py

BIN
JPK_406.jar


+ 14 - 0
ascii.py

@@ -0,0 +1,14 @@
+# coding: utf-8
+
+
+def ints2str(arr):
+    return ''.join(map(lambda n: chr(n), arr))
+
+
+def strs2ints(arr):
+    return map(lambda a: int(a), arr)
+
+
+arr = input('the ascii u wannt to decode: ').split(',')
+res = ints2str(strs2ints(arr))
+print(res)

+ 26 - 0
ceasar.py

@@ -0,0 +1,26 @@
+# coding: utf-8
+
+
+def ceasar(str, n):
+    res = ''
+    for c in str:
+        res += shift(c, n)
+    return res
+
+
+def shift(c, n):
+    if c >= 'a' and c <= 'z':
+        base = ord('a')
+    elif c >= 'A' and c <= 'Z':
+        base = ord('A')
+    else:
+        base = None
+    if base is None:
+        return c
+    else:
+        return chr((ord(c) + n - base) % 26 + base)
+
+
+str = input('the ceasar code u want to decode: ')
+for i in range(26):
+    print(ceasar(str, i + 1), '\n\n')

+ 15 - 0
get_url.js

@@ -0,0 +1,15 @@
+const xhr = new XMLHttpRequest()
+xhr.open('GET', 'http://www.wechall.net/challenge/training/programming1/index.php?action=request')
+xhr.send(null)
+xhr.onreadystatechange = function(){
+    const DONE = 4
+    const OK = 200
+    if (xhr.readyState === DONE) {
+        if (xhr.status === OK) {
+            const flag = xhr.responseText
+            window.location.href = 'http://www.wechall.net/challenge/training/programming1/index.php?answer=' + flag
+        } else {
+            console.log("Error: "+ xhr.status)
+        }
+    }
+}

+ 40 - 0
prime.py

@@ -0,0 +1,40 @@
+# coding: utf-8
+
+
+import math
+
+
+def sum_digits(n):
+    sum = 0
+    while n > 0:
+        sum += n % 10
+        n = int(n / 10)
+    return sum
+
+
+def is_prime(n):
+    if n % 2 == 0 and n > 2: 
+        return False
+    for i in range(3, int(math.sqrt(n)) + 1, 2):
+        if n % i == 0:
+            return False
+    return True
+
+
+def next_prime(n):
+    if n % 2 == 0:
+        n += 1
+    else:
+        n += 2
+    while not is_prime(n):
+        n += 2
+    return n
+
+
+a = next_prime(1000000)
+while not is_prime(sum_digits(a)):
+    a = next_prime(a)
+b = next_prime(a)
+while not is_prime(sum_digits(b)):
+    b = next_prime(b)
+print(str(a) + str(b))