Jump to content

ABC words: Difference between revisions

Added Go
(Added Wren)
(Added Go)
Line 98:
54. tabernacle
55. tablecloth</pre>
 
=={{header|Go}}==
<lang go>package main
 
import (
"bytes"
"fmt"
"io/ioutil"
"log"
)
 
func main() {
wordList := "unixdict.txt"
b, err := ioutil.ReadFile(wordList)
if err != nil {
log.Fatal("Error reading file")
}
bwords := bytes.Fields(b)
count := 0
fmt.Println("Based on first occurrences only, the ABC words in", wordList, "are:")
for _, bword := range bwords {
a := bytes.IndexRune(bword, 'a')
b := bytes.IndexRune(bword, 'b')
c := bytes.IndexRune(bword, 'c')
if a >= 0 && b >= 0 && c >= 0 && a < b && b < c {
count++
fmt.Printf("%2d: %s\n", count, string(bword))
}
}
}</lang>
 
{{out}}
<pre>
Based on first occurrences only, the ABC words in unixdict.txt are:
1: aback
2: abacus
3: abc
4: abdicate
5: abduct
6: abeyance
7: abject
8: abreact
9: abscess
10: abscissa
11: abscissae
12: absence
13: abstract
14: abstracter
15: abstractor
16: adiabatic
17: aerobacter
18: aerobic
19: albacore
20: alberich
21: albrecht
22: algebraic
23: alphabetic
24: ambiance
25: ambuscade
26: aminobenzoic
27: anaerobic
28: arabic
29: athabascan
30: auerbach
31: diabetic
32: diabolic
33: drawback
34: fabric
35: fabricate
36: flashback
37: halfback
38: iambic
39: lampblack
40: leatherback
41: metabolic
42: nabisco
43: paperback
44: parabolic
45: playback
46: prefabricate
47: quarterback
48: razorback
49: roadblock
50: sabbatical
51: snapback
52: strabismic
53: syllabic
54: tabernacle
55: tablecloth
</pre>
 
=={{header|Julia}}==
9,490

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.