Originally posted by tecknophreak Aren't there any C/C++/JAVA programers who want to represent?
Calling me out?
Heheh. I would, but I just accidentally deleted my whole hd. Partitioning error without backing up. (I know, I know... stupid idea)
I'm gonna be spending the next few days setting up my new Knoppix/Debian system. If no one has come up with anything, then I'll give it a shot.
While I'm here, I might as wel post another challenge. How about something simple :
Create a program that inputs a file, replaces all tabs with 3 spaces, and outputs it to another file.
Originally posted by Sepero While I'm here, I might as wel post another challenge. How about something simple :
Create a program that inputs a file, replaces all tabs with 3 spaces, and outputs it to another file.
Another moment to stretch my Python fingers again: (Amendments from Strike to follow )
Notes: use file, not open. Also, if you want to make it neater, you could have something like a NUM_SPACES constant variable and then just sub it with ' ' * NUM_SPACES
Notes: use file, not open. Also, if you want to make it neater, you could have something like a NUM_SPACES constant variable and then just sub it with ' ' * NUM_SPACES
Here is the perl way to the replace tab with three spaces challenge.
Other than opening the file, basically one line to replace and one to write to file.
Code:
#! /usr/sbin/perl
open (INFILE, "$ARGV[0]") or die "Cannot open file: $ARGV[0] $!";
open (OUTFILE, "> $ARGV[1]") or die "Cannot open file: $ARGV[1] $!";
while(<INFILE>) {
$_ =~ s/\t/ /g;
print OUTFILE "$_";
}
Okay... I've been working on this for a couple of days now, more off than on. It's a simple pattern matching sort of thing I call MatchScrabble. It works as follows:
A user enters a String of scrambled characters such as "garmrop." The application loads a wordList (a flat file in this case) against which it must find a possible matching word. The basic idea is to unscramble the word and see if exists in the word list. To continue the example -- say we have a wordList constructed as follows:
---------
program
entry
situation
telling
stop
progrom
tron
more
vortex
teeth
seriously
poor
people
pudding
stopping
starting
eating
drinking
--------
The user enters the string "garmrop." The application should attempt to find a match for this in the word list. In this case the match would be on the first entry: "program" so your app, given that input against that wordList, should return a match on the word 'program.' I'd like to make it efficient enough so that it scales to very long wordLists, eventually using the entries in the Oxford English Dictionary as the wordList.
Originally posted by Sepero Calling me out?
Heheh. I would, but I just accidentally deleted my whole hd. Partitioning error without backing up. (I know, I know... stupid idea)
I'm gonna be spending the next few days setting up my new Knoppix/Debian system. If no one has come up with anything, then I'll give it a shot.
While I'm here, I might as wel post another challenge. How about something simple :
Create a program that inputs a file, replaces all tabs with 3 spaces, and outputs it to another file.
Though this doesn't really fit into the programming challenge I'd use sed to accomplish this:
cat $file |sed 's/[TAB]/[3SPACES/' > $newfile
Sometimes the best programming is using the tools already present
"Useless Uses of Cat" How amusing Where's the list kept? Using cat is a bad habit of mine from working with compressed files all day (zcat $file | blah blah...). But! If there's a sed command line option that allows it to read a compressed file I'll change my ways
Originally posted by Ratboy68 Okay... I've been working on this for a couple of days now, more off than on. It's a simple pattern matching sort of thing I call MatchScrabble. It works as follows:
I cheated and used /usr/shared/dict/words as the dictionary, it can be modified to look where ever it wants, just add a -f /location to the args and look for it.
[edit]I don't want to hear anyone yelling at me about using "using namespace std;", cause it's just a little prog[/edit]
if (i_forgot && this_is_about_code)
language = c++;
Originally posted by tecknophreak [edit]I don't want to hear anyone yelling at me about using "using namespace std;", cause it's just a little prog[/edit]
Aww, come on! I want to yell at you about it! (... or, uh, something...)
Originally posted by hotleadpdx "Useless Uses of Cat" How amusing Where's the list kept?