Programming :: Reversal 1234 --> 4321 For Numbers Python?
Jun 27, 2011i need to write a program to reverse numbers example 2345 --> 5432i wrote this for my program
A=str(input("enter 4-digit #:"))
A1 = A[3:]
A2 = A[2:3]
[code]....
i need to write a program to reverse numbers example 2345 --> 5432i wrote this for my program
A=str(input("enter 4-digit #:"))
A1 = A[3:]
A2 = A[2:3]
[code]....
am writing a small search program for my class. I have decided to use indexing for my program. Ive researched online about indexing and how search engines do it. If im gonno do that I need to create inverted files to associate files to numbers ( numbers being the index of my paths ) . Now I was wondering what would be the best way to create an inverted file ? I was going to create sql tables using mysql api in C but then again there is no array data type or vectors to store few numbers in a single column in mysql and it is not advised to use Enum or SET
View 14 Replies View RelatedI want to be able to do
sudo ./program.py
instead of always having to do
sudo python program.py
What do I need to change?
I've already used line split stuff to transform my data into something like this in a text file:
Code:
['1', '1', '3', '20.7505207']
['2', '1', '3', '23.0488319']
['3', '1', '3', '-1.5768747']
['4', '1', '3', '-26.4772491']
[code]....
How can I get this on a python program so I can manipulate it as an array?
I have a function definition in a Python 2.x script which take a tuple as one of its arguments, but 2to3 has no answers nor any of my searching on how to represent the same in Python 3.x
Code:
def blah(self, (string1, string2))
I am still encountering problems getting the Broadcom 4321 chipset to work on my Fedora 13, even after using this guide, this guide and another guide on ndiswrapper.
To answer the standard questions:
Code:
Code:
Code:
Code:
and finally
Code:
But no wlan device or anything else.
I have some code that opens a directory and reads in the names of files which are e.g. 0001, 0002, 0003 up to 9999I need to get all these numbers and then generate a new number that is not one of these numbers already.here is my code to check the files in the directory
DIR *d;
struct dirent *dir;
int i = 0;
[code]....
write a script in bash or shell to add the numbers between and including two numbers
View 3 Replies View RelatedAs some of you know that I am new to this forum. I have another problem that I got stuck on. I have this file called "Fib.rbb" and my instructor told us to write an interpreter program by using Fib.rbb.
"You are to write an interpreter in Perl for Rongs Basic Basic (RBB) as explained in class. The BNF description for RBB and a test file called Fib.rbb are part of the RBB.zip file which is available in the Course Documents folder on blackboard. If you call your interpreter myIntp.pl, you would execute the program via perl myIntp.pl Fib.rbb
Code: Print "A few Fibonacci numbers:"
Looking for code to add 5 numbers in assembly? I want to use array for input of those 5 numbers. No problem if the output is 1 digit(0....9).
View 3 Replies View RelatedI am trying to extract 2 numbers from a same file and my goal is to print them both in another file, on the same line, separated with a space. I have to do that for 20 files and I would like to have therefore 20 lines like this in the output file. It would look like this :
Quote:
number1_file1 number2_file1
number1_file2 number2_file2
...
...
number_1_file20 number2_file20
So far, I did only extract one number and got an output file like this :
Quote:
number1_file1
number1_file2
...
...
number1_file20
And I did this by running a bash script with the following content :
Code:
#!/bin/bash
ls execution$1$2*.* | while read filename
do
cat $filename | grep -e "Total aborts:" | cut -d " " -f3 >> abort$1$2.dat
done
$1 and $2 are just strings to identify the different files I want to consider in this loop. This script works well to extract a number which is the 3rd field of a line starting with "Total aborts:".Now, how could I change this script to do what I mentioned above (i.e. extracting two numbers from two different lines) ? The second number is the 3rd field of a line starting with "Total throughput:"
I want the get the date of the oldest log in this directory and compare it with current date.Time of the each log can be seen before ".Z" prefix.I have written the following piece of code. However, it is not working for the following case:
LOGDAY=20101129
TODAY= 20101201
Difference is 72, which is not correct, since these are dates.
I'm trying to write a program that generates a random number and then tells if it is prime or not. I have doe some research about how to calculate prime and random numbers but I'm still having trouble. I don't really get how to calculate a prime number. I know a prime number is a number that is divisible by 1 and and itself. how to calculate a prime number in C?
View 10 Replies View RelatedI am struggling to understand why nawk matches values that are either 1 or 2 digits in length, but not 100 (3 digits).
Am I missing something obvious ? Should I use substr to remove the % ?
I am sure it's something to do with character and string matching behaviour with nawk.
Code:
I have a program that sends QByteArray datagrams over a udp socket. I would like to have 4 bytes of the datagram that contain a 32 bit integer. When saving numbers to the QByteArray, I have tried the static function number(int) and member function setNum(int), but they convert the integer to its decimal string representation and save that in the byte array. So if the number were 10, it takes 2 bytes, if it were 10,000,000 it takes 8 bytes. This wastes space, and makes it more difficult to get the number when it is packed with a few other pieces of data in the same datagram. Is there a standard way of doing this in Qt?
View 1 Replies View RelatedI'm playing around with some shell scripting and I've got a directory call CS005 and I'm trying to write a script to I can locate to the directory really quick and easy.
export CS005DIR=/home/stud/0/043234/CS005
Now I get this error
CS005DIR=/home/stud/0/043234/CS005 No such file or directory.
This is because I've got numerical values within my variable.
Is there a way to allow numbers for variable names?
If I do:
for i in $(cat names); do seq -f "$i%03.0f" 0 999; done > output5.txt
I got ( tail snipped):
997munt
998munt
999munt
If I do:
for i in $(cat names); do seq -f "%03.0f$i" 0 999; done > output4.txt
I got:
997Zygmunt
998Zygmunt
999Zygmunt
How I can get numbers from 000 to 999 appended like:
Zygmunt997
Zygmunt998
Zygmunt999
For eg: $NUMBEROFPASSES=6.19 to round up I use NUMBEROFPASSES=$(printf %.0f $NUMBEROFPASSES) What I need to do is round up from eg: 6.10 to be 7 and if lower than 6.10 round down to 6
View 5 Replies View RelatedI would like to create a small C tool. I encounter a problem of how to make a function to check an input chars contains numbers (started from the second element).
Some samples:
char *mychar= "a3547"; (The result of function checking this is true)
char *another_char = "t6548"; (The result of function checking this is true)
char *next_char = "appl3"; (The result of function checking this is false)
char *new_char = "b1aa3"; (The result of function checking this is false)
I am trying to generate sequence of number in the order of :
1
2
3
4
[Code]....
I have a text file with 4 columns and 18 rows. All are integers. I wish to find the average of first 12 numbers in the third column using 'awk'.
View 8 Replies View RelatedI'm learning c but then when i tried looping as i follow a tutorial, the numbers are wierd that it seems not right..
This is the example.
Quote:
When i run it, it outputs this.
Quote:
why?
I'm learning shell scripting using bash and I want to generate 4 floating point number with 5 decimal places and write them to a file and a variable. I've done all this except the $RAMDOM enviroment variable does not generate a float number but a integrer.
[code]...
I have lines in some files that look exactly as below, and the line numbers they occur in are always the same. (Lines 136-139)
W 0.00000000 0.00000000 2.00000000
W 0.50000000 0.50000000 2.50000000
W 0.00000000 0.00000000 3.00000000
[code]...
Can sed remove non-numerics (apart from an optional leading +) from phone numbers when prefixed with text that must be retained? The need is to make phone numbers exported from an Orage address book to a .ldif file suitable for gnokii to send to a mobile phone. Here are sample lines:
Code:
facsimiletelephonenumber: +91 (123) 1234567
telephoneNumber: +44 (123) 1234567
They have to end up as:
Code:
facsimiletelephonenumber: +911231234567
telephoneNumber: +441231234567
I could do it in awk but am curious to learn if sed can do it.
I have a directory with files like this:
Code:
And what I'd like is to have the files renamed like this:
Code:
How could I code it so that it removes the numerical part of the filename (at the beginning), even with different patterns (like the 01 - artist vs the 01-artist)?
I ran into it while google Segmentation Fault. I'm writing a simple C program that reads a file that counts each line and numbers it then writes to a file called sdout. I copyed my program mostly from the text book but im still having problems. Heres my code:
#include <stdio.h>
#include <stdlib.h>
void new_line(FILE *, FILE *);
int main(char *argv)
[Code]....
I just need to perform a simple operation of subtracting two numbers - that aren't whole numbers, i.e 200.56 - 67.24attempting to use expr i merely get "expr: non-numeric argument"
View 3 Replies View Relatedam trying to find a proper regex to match the two numbers in the following log entry.
Code:
15:08:16.142 INF Found 64468
15:08:16.142 ERR [Uniform test code=64469]
Basically the pattern I'm looking for will match the two different numbers spanned across two lines.Thought I need to use multi-line mode as follow but this doesn't match on [URL]...
Code:
/^($[0-9]{5}
[0-9]{5})$/m;
I am working on some minor programming projects. and wouldt like to keep track of them by version numbers. E.g. 1.0.0
Is there a tool or other method for automatically assigning version numbers to software ?
I am currently using Mercurial. as far as i can see it only assigns revision numbers. E.g. 5