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 c0cc854 commit ae3fa46Copy full SHA for ae3fa46
archive/w/wren/duplicate-character-counter.wren
@@ -0,0 +1,44 @@
1
+import "os" for Process
2
+
3
+var args = Process.arguments
4
5
+if (args.count != 1 || args[0] == "") {
6
+ System.print("Usage: please provide a string")
7
+ Fiber.suspend()
8
+}
9
10
+var chars = {}
11
+var order = []
12
+var dupes = false
13
14
+for (c in args[0]) {
15
+ if (chars[c] == null) {
16
+ chars[c] = 0
17
+ } else {
18
+ dupes = true
19
+ }
20
21
+ chars[c] = chars[c] + 1
22
23
+ var contains = false
24
+ for (a in order) {
25
+ if (c == a) {
26
+ contains = true
27
+ break
28
29
30
31
+ if (!contains) {
32
+ order.add(c)
33
34
35
36
+if (dupes) {
37
+ for (c in order) {
38
+ if (chars[c] > 1) {
39
+ System.print(c + ": " + chars[c].toString)
40
41
42
+} else {
43
+ System.print("No duplicate characters")
44
0 commit comments