about summary refs log tree commit diff
path: root/codechef/chdiger.py
diff options
context:
space:
mode:
authorNguyễn Gia Phong <vn.mcsinyx@gmail.com>2019-03-13 09:13:11 +0700
committerNguyễn Gia Phong <vn.mcsinyx@gmail.com>2019-03-13 09:13:11 +0700
commit86fd670f4d4ac634a8c9740ff9129b589afcec1a (patch)
tree3d6e01efae1b4425f0815a0b213aca6331194818 /codechef/chdiger.py
parent477c426b55d168764a34873561f78b3c34b1f013 (diff)
downloadcp-86fd670f4d4ac634a8c9740ff9129b589afcec1a.tar.gz
Guess my rank is gonna plummet again
Diffstat (limited to 'codechef/chdiger.py')
-rwxr-xr-xcodechef/chdiger.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/codechef/chdiger.py b/codechef/chdiger.py
new file mode 100755
index 0000000..a3c83fb
--- /dev/null
+++ b/codechef/chdiger.py
@@ -0,0 +1,14 @@
+#!/usr/bin/env python3
+for _ in range(int(input())):
+    n, d = input().split()
+    n, d = [int(x) for x in n], int(d)
+    for i in range(-1, -1-len(n), -1):
+        if n[i] > d:
+            n[i] = d
+        else:
+            break
+    for i in range(i, -len(n), -1):
+        if n[i] < n[i-1]:
+            n.pop(i - 1)
+            n.append(d)
+    print(''.join(map(str, n)))