Skip to content

Commit

Permalink
Second update as of 3 September 2024
Browse files Browse the repository at this point in the history
  • Loading branch information
RussellDash332 committed Sep 3, 2024
1 parent e4006f3 commit b048d06
Show file tree
Hide file tree
Showing 8 changed files with 496 additions and 236 deletions.
247 changes: 129 additions & 118 deletions README.md

Large diffs are not rendered by default.

434 changes: 316 additions & 118 deletions docs/index.html

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/Crypto Trouble/cryptotrouble.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
input();m=10**9+7;a=1;b=c=0;s=[*map(int,input())]
for i in s:t=[a,b,c];a,b,c=(a+t[-i%3])%m,(b+t[(1-i)%3])%m,(c+t[(2-i)%3])%m
print((a-pow(2,s.count(0),m))%m)
File renamed without changes.
11 changes: 11 additions & 0 deletions src/Digit Sum (2)/siffersumma.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
n = [*map(int, input())]; t = None
for i in range(len(n)-1, -1, -1):
if t: continue
if n[i]:
for j in range(i-1, -1, -1):
if n[j] < 9: t = (i, j); break
if t: n[t[0]] -= 1; n[t[1]] += 1; n[t[1]+1:] = sorted(n[t[1]+1:])
else:
s = sum(n)-1; n = [1]+[0]*len(n); p = len(n)-1
while s: u = min(9, s); s -= u; n[p] = u; p -= 1
print(''.join(map(str, n)))
11 changes: 11 additions & 0 deletions src/Eksplozija/eksplozija.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
def check():
if len(z) < len(t): return 0
for i in range(len(t)):
if t[i] != z[i-len(t)]: return 0
return 1
s, t = input(), input(); z = []
for i in s:
z.append(i)
if check():
for _ in range(len(t)): z.pop()
print(''.join(z) or 'FRULA')
5 changes: 5 additions & 0 deletions src/Magic Bitstrings/magicbitstrings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
while(p:=int(input())):
if p==2:print('Impossible');continue
v=[1]*p
for i in range(p):v[i*i%p]=0
print(''.join(map(str,v[1:])))
21 changes: 21 additions & 0 deletions src/Rainbow Numbers/rainbownumbers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import sys; sys.setrecursionlimit(10**5)
m = 998244353
a = [*map(int, input())]
b = [*map(int, input())]
a = [0]*(len(b)-len(a))+a
a[-1] -= 1; p = len(a)-1
while a[p] < 0: a[p] += 10; a[p-1] -= 1; p -= 1

def f(x):
n = len(x)
def bt(pos, prev, tie):
if pos == n: return 1
if tie: return pow(9, n-pos, m)
s = 0
for u in range(x[pos]):
if u == prev: continue
s += bt(pos+1, u, 1)
if x[pos] != prev: s += bt(pos+1, x[pos], 0)
return s%m
return bt(0, -1, 0)%m
print((f(b)-f(a))%m)

0 comments on commit b048d06

Please sign in to comment.