We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 27464e9 commit 4cdaf4aCopy full SHA for 4cdaf4a
archive/t/tcl/rot13.tcl
@@ -0,0 +1,26 @@
1
+
2
+proc usage {} {
3
+ puts "Usage: please provide a string to encrypt"
4
+ exit 1
5
+}
6
7
+if {$argc != 1} { usage }
8
+set input [lindex $argv 0]
9
+if {$input eq ""} { usage }
10
11
+proc rot13 {text} {
12
+ set upper "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
13
+ set lower "abcdefghijklmnopqrstuvwxyz"
14
15
+ set map {}
16
17
+ for {set i 0} {$i < 26} {incr i} {
18
+ lappend map [string index $upper $i] [string index $upper [expr {($i+13)%26}]]
19
+ lappend map [string index $lower $i] [string index $lower [expr {($i+13)%26}]]
20
+ }
21
22
+ return [string map $map $text]
23
24
25
+puts [rot13 $input]
26
0 commit comments