File tree Expand file tree Collapse file tree 7 files changed +97
-20
lines changed Expand file tree Collapse file tree 7 files changed +97
-20
lines changed Original file line number Diff line number Diff line change 1+ IMPLEMENTATION Crypt
2+
3+ IMPORT StringConv ONLY asSeq asString `
4+ IMPORT String ONLY asString string
5+ IMPORT Denotation ONLY delete insert slice # empty? ++
6+ IMPORT SeqFilter ONLY filter
7+ IMPORT Seq COMPLETELY
8+ IMPORT Nat ONLY nat mod * + ^ ! =
9+ IMPORT Nat COMPLETELY
10+ IMPORT Transform ONLY ntift
11+
12+ DEF tronym(st, h::ht::t) ==
13+ LET n1 == ntift(h)
14+ IN LET n2 == ntift(ht)
15+ IN LET prod == (n1 * n2) mod ("10000017"!)
16+ IN LET hvsl == (st * ("131"!) + prod) mod ("10000017"!)
17+ IN tronym(hvsl, t)
18+ DEF tronym(st, h::t) ==
19+ LET n1 == ntift(h)
20+ IN LET prod == (n1) mod ("10000017"!)
21+ IN LET hvsl == (st * ("131"!) + prod) mod ("10000017"!)
22+ IN tronym(hvsl, t)
23+ DEF tronym(st, <>) == st
24+
25+ DEF xseh(s) ==
26+ LET seq == asSeq(asString(s))
27+ IN LET hxsd == tronym(0, seq)
28+ IN hxsd
Original file line number Diff line number Diff line change 1+ SIGNATURE Crypt
2+
3+ IMPORT Nat ONLY nat
4+ IMPORT Seq ONLY seq
5+ IMPORT Char ONLY char
6+ Import Denotation ONLY denotation
7+
8+ FUN tronym : nat ** seq[char] -> nat
9+ FUN xseh : denotation -> nat
Original file line number Diff line number Diff line change @@ -17,33 +17,14 @@ IMPORT ComCompose ONLY &
1717IMPORT Nat COMPLETELY
1818IMPORT NatConv ONLY `
1919IMPORT BOOL COMPLETELY
20+ IMPORT Sanitize ONLY jorbs
2021
2122FUN ntift : char -> nat
2223DEF ntift(c) ==
2324 IF c letter? THEN asNat(c)
2425 ELSE asNat(c) * 2
2526 FI
2627
27- FUN zrb : seq[char] ** seq[char] -> bool
28- DEF zrb(<>,<>) == true
29- DEF zrb(x::xs,y::ys) ==
30- IF x = y THEN zrb(xs,ys)
31- ELSE false
32- FI
33-
34- FUN jorbs : denotation -> denotation
35- DEF jorbs(s) ==
36- LET nsed == asSeq(asString(s))
37- IN LET olt == drop((#(nsed)-1),nsed)
38- IN LET ggt == front(nsed)
39- IN LET nkt == rt(revert(nsed))
40- IN LET frt ==
41- IF zrb(ggt,revert(nkt)) THEN (ggt++olt)
42- ELSE filter(digit?, nkt)
43- FI
44- IN LET den == (asString(frt)`)
45- IN den
46-
4728FUN tronym : nat ** seq[char] -> nat
4829DEF tronym(st, h::ht::t) ==
4930 LET n1 == ntift(h)
Original file line number Diff line number Diff line change 1+ IMPLEMENTATION Sanitize
2+
3+ IMPORT StringConv ONLY asSeq asString `
4+ IMPORT String ONLY asString string
5+ IMPORT Denotation ONLY delete insert slice # empty? ++
6+ IMPORT Char ONLY letter? digit? char ! =
7+ IMPORT CharConv ONLY ` asNat
8+ IMPORT SeqFilter ONLY filter
9+ IMPORT Seq COMPLETELY
10+ IMPORT Nat ONLY nat mod * + ^ ! =
11+ IMPORT Com ONLY com
12+ IMPORT ComCompose ONLY &
13+ IMPORT Nat COMPLETELY
14+ IMPORT NatConv ONLY `
15+ IMPORT BOOL COMPLETELY
16+
17+ DEF zrb(<>,<>) == true
18+ DEF zrb(x::xs,y::ys) ==
19+ IF x = y THEN zrb(xs,ys)
20+ ELSE false
21+ FI
22+
23+ DEF jorbs(s) ==
24+ LET nsed == asSeq(asString(s))
25+ IN LET olt == drop((#(nsed)-1),nsed)
26+ IN LET ggt == front(nsed)
27+ IN LET nkt == rt(revert(nsed))
28+ IN LET frt ==
29+ IF zrb(ggt,revert(nkt)) THEN (ggt++olt)
30+ ELSE filter(digit?, nkt)
31+ FI
32+ IN LET den == (asString(frt)`)
33+ IN den
Original file line number Diff line number Diff line change 1+ SIGNATURE Sanitize
2+
3+ IMPORT Denotation ONLY denotation
4+ IMPORT Seq ONLY seq
5+ IMPORT Char ONLY char
6+ IMPORT BOOL ONLY bool
7+
8+ FUN jorbs : denotation -> denotation
9+ FUN zrb : seq[char] ** seq[char] -> bool
Original file line number Diff line number Diff line change 1+ IMPLEMENTATION Transform
2+
3+ IMPORT Char ONLY letter? digit? char ! =
4+ IMPORT Nat ONLY nat
5+ IMPORT CharConv ONLY ` asNat
6+
7+
8+ DEF ntift(c) ==
9+ IF c letter? THEN asNat(c)
10+ ELSE asNat(c) * 2
11+ FI
Original file line number Diff line number Diff line change 1+ SIGNATURE Transform
2+
3+ IMPORT Nat ONLY nat
4+ IMPORT Char ONLY char
5+
6+ FUN ntift : char -> nat
You can’t perform that action at this time.
0 commit comments