ABC words: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (→{{header|Raku}}: neaten up output) |
(Added C# version, allows user specified pattern) |
||
Line 110: | Line 110: | ||
55: tablecloth |
55: tablecloth |
||
</pre> |
</pre> |
||
=={{header|C#|CSharp}}== |
|||
Takes an optional command line for other character combinations. User can specify any reasonable number of unique characters. Caveat: see discussion page for issue about specifying repeated characters. |
|||
<lang csharp>class Program { |
|||
static void Main(string[] args) { int bi, i = 0; string chars = args.Length < 1 ? "abc" : args[0]; |
|||
foreach (var item in System.IO.File.ReadAllLines("unixdict.txt")) { |
|||
int ai = -1; foreach (var ch in chars) |
|||
if ((bi = item.IndexOf(ch)) > ai) ai = bi; else goto skip; |
|||
System.Console.Write("{0,3} {1,-18} {2}", ++i, item, i % 5 == 0 ? "\n" : ""); |
|||
skip: ; } } |
|||
} |
|||
</lang> |
|||
{{out}} |
|||
Without command line arguments: |
|||
<pre> 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> |
|||
With command line argument "alw":<pre> 1 afterglow 2 airflow 3 alewife 4 allentown 5 alleyway |
|||
6 allow 7 allowance 8 alway 9 always 10 baldwin |
|||
11 barlow 12 bartholomew 13 bungalow 14 caldwell 15 candlewick |
|||
16 cauliflower 17 fallow 18 foamflower 19 galloway 20 gallows |
|||
21 galway 22 halfway 23 hallow 24 halloween 25 hallway |
|||
26 malawi 27 mallow 28 marlowe 29 marshmallow 30 mayflower |
|||
31 metalwork 32 railway 33 sallow 34 saltwater 35 sandalwood |
|||
36 shadflower 37 shallow 38 stalwart 39 tailwind 40 tallow</pre> |
|||
=={{header|FreeBASIC}}== |
=={{header|FreeBASIC}}== |