Maybe by AWK: printing help diagonal matrix characters into line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Maybe by AWK: printing help diagonal matrix characters into line
# 8  
Old 05-08-2013
Crona688 ,
No this is not Homework. Perhaps you do not understand no one ll come up with such a bogus homework. It was my thinking to convert a crossword in a program. : ).
I made already horizontal and vertical lines to find the words ~35 out of 50 states located, remaing are hiding in the diagonal lines, Diagonal ways of crossword are tricky to match with, so I was checking for some ideas.
This was when in a place far away from my home and I was waiting 5+hrs doing nothing and someone handed me over a game paper to pass the time, I was thinking to program it. But seems it is not a good idea spending more time on it, as crosswords are meant for spending the time on that, not to be programmed. But if I spend some time I can iterate it in the other 3 sides , i am able to figured that out, from the code from RudiC. Thanks for visiting. Smilie

Last edited by rveri; 05-08-2013 at 01:01 AM..
# 9  
Old 05-08-2013
Quote:
Originally Posted by rveri
as crosswords are meant for spending the time on that, not to be programmed. But if I spend some time I can iterate it in the other 3 sides
You are probably right regarding the crosswords, but on the other hand if you can solve it with a program you will hone your programming skills, so the best solution might be to write the program first and then not to use it to solve crosswords. ;-))

I think "awk" and similar text filters are not well suited for this problem, because they generally read a file linewise from top to bottom. What you really need is a two-dimensional array of characters which you can search in every direction (not only downwards) using index-arithmetics. You can have such an array using "ksh93" or "bash" by using the substring function for the second index or you can use "perl" or similar languages (phyton, ruby, ...). Have fun programming.

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
# 10  
Old 05-08-2013
Bakunin,
Many Thanks , I ll try with ksh93 or bash , or perl.
Python not yet experienced. 2D Array ll be helpful in this case as well . Thank you for the logic & excellent reply.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Printing string from last field of the nth line of file to start (or end) of each line (awk I think)

My file (the output of an experiment) starts off looking like this, _____________________________________________________________ Subjects incorporated to date: 001 Data file started on machine PKSHS260-05CP ********************************************************************** Subject 1,... (9 Replies)
Discussion started by: samonl
9 Replies

2. Shell Programming and Scripting

awk printing output to new line

Hi I have a file profile.txt with the below input: {"atgUserId":"736f14c4-eda2-4531-9d40-9de4d6d1fb0f","firstName":"donna","lastName":"biehler","email":"schoolathome42@live.com","receiveEmail":"y es"}, {"atgUserId":"c3716baf-9bf8-42da-8a44-a13fff68d20f","firstName":"Gilberto... (6 Replies)
Discussion started by: ankur328
6 Replies

3. Shell Programming and Scripting

Matching and printing line with awk

Hi there, I'm trying to use awk to print out the entire line that contains a match to a certain regex and then append some text,plus the match to the end of the line. So far I have: awk -F: '{print "RG:Z:" $2}' file Which prints out the match I want plus the additional text, but I'm stuck... (3 Replies)
Discussion started by: jim_lad
3 Replies

4. Shell Programming and Scripting

Printing characters at specific position in line

Hi, I am trying to get an output like : +----------------------------------+ ----------- + + some variable substitution + some text + Is there a way I can specify in printf (in ksh) the particular position I want to print a character, and also repeat a character from... (1 Reply)
Discussion started by: neil.k
1 Replies

5. Shell Programming and Scripting

help printing two consecutive columns, every twenty in a large matrix

Hi, I'm having a problem printing two consecutive columns, as I iterate through a large matrix by twenty columns and I was looking for a solution. My input file looks something like this 1 id1 A1 A2 A3 A4 A5 A6....A20 A21 A22 A23....A4001 A4002 2 id2 B1 B2 B3 B4 B5 B6... 3 id3 ... 4 id4... (8 Replies)
Discussion started by: flotsam
8 Replies

6. Shell Programming and Scripting

diagonal matrix to square matrix

Hello, all! I am struggling with a short script to read a diagonal matrix for later retrieval. 1.000 0.234 0.435 0.123 0.012 0.102 0.325 0.412 0.087 0.098 1.000 0.111 0.412 0.115 0.058 0.091 0.190 0.045 0.058 1.000 0.205 0.542 0.335 0.054 0.117 0.203 0.125 1.000 0.587 0.159 0.357... (11 Replies)
Discussion started by: yifangt
11 Replies

7. Shell Programming and Scripting

printing last two characters of each line

Hello, any trick to print line number and last two characters of each line ? (4 Replies)
Discussion started by: Bashar
4 Replies

8. Shell Programming and Scripting

Printing a specific line using AWK

Hi, I have a script that fetches only specific information from fcinfo command. Below is a portion of the script. #!/usr/bin/ksh set -x HBA_COUNT=`sudo fcinfo hba-port | grep -i state | awk 'END{print NR}'` echo "$HBA_COUNT HBAs exist" echo '........' INDEX=1 while $INDEX -le... (2 Replies)
Discussion started by: jake_won
2 Replies

9. Shell Programming and Scripting

printing a line number using awk

Hi Chaps, I'm trying to print the line number of a comma delimited file where the second field in the line is blank using AWK. Here is the code I have so far where am I going wrong. It is the last column in the file. nawk -v x==0 'BEGIN {FS=",";OFS=","} x++ if ($2 == " ") print $x' bob.tst ... (3 Replies)
Discussion started by: rjsha1
3 Replies

10. Linux

Regarding Dot Matrix Printing

Hi all, What I want is that can we manage printing a text file on a Dot Matrix printer installed on a Linux machine and the printer should not take the normal A4 format, but should print only to the extent the text file has text in it. What happen usually is that when we give print comand to any... (0 Replies)
Discussion started by: aman_mlt
0 Replies
Login or Register to Ask a Question