Questions tagged [digits]

Questions dealing with getting, manipulating, or changing the digits of numbers

Use this tag for questions dealing with getting, manipulating, or changing the digits of numbers. More about digits on wikipedia

1098 questions
2
votes
3 answers

Exactly 4 digits validation in perl

I have a validation check when I pass the command line parameters to the perl program.I pass two years first passed argument should be lesser than the second passed argument and both the arguments should be only digits and also they should be…
Sunny
  • 175
  • 1
  • 4
  • 11
2
votes
2 answers

Why R format() function is not working properly to format a numeric vector?

This should be very simple. This vector: test = c(0.027, 0.01872169, 0.1869244, 0.6997091, 0.06764486, 0.1436803, 0.001610974, 0.5461064, 0.3066009, 0.002001355, 0.03864836, 0.391397, 0.5145854, 0.05524137, 0.01838195, 0.02019719, 0.346739,…
M. Beausoleil
  • 3,141
  • 6
  • 29
  • 61
2
votes
2 answers

How to get/check number of digits of a row in a df.query()?

I have a dataframe df like: number | col1 123 | a 1234 | b 567 | c I want to count how many rows have more or less than 3 digits in column "number". The column as dtype = int64. When I try: count = df.query( """ ... 'some other…
Vega
  • 2,661
  • 5
  • 24
  • 49
2
votes
2 answers

Find the sum of an even number from a list of integers

input-258345 output-14 ex-2+8+4=14 myList = input() result = 0 for i in myList: if not i % 2: result += i print(result) I am getting an error: if not i % 2: TypeError: not all arguments converted during string formatting
abhi
  • 31
  • 6
2
votes
3 answers

remove row if specific columns does not contain digit in pandas

I have the following pandas dataframe: >>>ID WKT 0 4272 Point(4.21189 3.1298) 1 2345 Point(None None) 2 1254 Point (3.8945 4.6712) ... I would like to remove rows that do no contain any digits in the 'WKT' column, like row 1. I saw that…
Reut
  • 1,555
  • 4
  • 23
  • 55
2
votes
0 answers

Numbers equal to the sum of powers of its digits, need faster python code

In Python, create a function finding all integers between 1 and 1.000.000.000, which are equal to the sum of k'th power of its digits for some k. Example: 4150 = 4^5 + 1^5 + 5^5 + 0^5. Here is my code working perfect until 1.000.000. However, it…
2
votes
1 answer

Digit extraction function

I have a Pandas series with 16000 rows with some apartments description. I try to write a function that takes a string and extracts a digit number of rooms. Some lines doesn't contain any information about rooms. line_example = "Apartment · 121m² ·…
audiotec
  • 121
  • 1
  • 10
2
votes
4 answers

Checking if two three digit numbers have any of there digits that are the same in Java

I'm trying to write a program in Java that checks if at least one digit of one of the numbers, matches one digit of the other number. For example, if the two numbers are 238 and 345 it should return a certain string. So far this is what I have, but…
2
votes
2 answers

RegEx Capture First String between Two Numbers

Trying to extract 1st match string between numbers: For example: testsfa13.4extractthis8488.9090testssffwwww ajfafs-sss133.6extractthis887878.222testtest522252.9thismore So far I have the following: [\d](.*?)[\d] However, the match includes the…
PaulP
  • 37
  • 3
2
votes
1 answer

How to get every unique digit combination regardless of digit placement

I couldn't find it anywhere and I'm not sure if this is even possible but is there a way to get every unique number combination regardless of the digit placement (so for example 123, 213, 231, 321 are all one combination because they have the same…
2
votes
2 answers

How can I add a zero to the left of a 1 digit integer in Objective C?

How can I add a zero to the left of a 1 digit integer ? Is there any objective C function to perform this? I am needing this so I can have only one NSDateFormat @"ddMMyyyy" thanks I want to add a zero to the left of an integer which is less than 10,…
HoNgOuRu
  • 717
  • 4
  • 13
  • 26
2
votes
1 answer

How can this regular expression corrected to extract series and image numbers from reports?

I'm looking to extract information from the following text examples: "(series 602 image 91)" or " series number 89 and image number 34" or "Series # 4, Image # 14" and looking to extract the numeric as value and series and image tags…
2
votes
2 answers

How can I break numbers into their digit values?

As part of a Roman numerals converter algorithm, I would like to break a given number into their digit values. What I precisely want to do is as follows: 1984 = 1000+900+80+4 It would be better to let you know where I will use the outcome. I will…
2
votes
4 answers

How to convert a character taken from a string to an int?

So i have a string containing numbers, and i want to take one of those numbers and convert it to an int like that : string s = "13245"; int a = stoi(s.at(3)); I have tried stoi : int a = stoi(s.at(3)); I have tried atoi : int a =…
lairv
  • 109
  • 5
2
votes
4 answers

C - turn 9 to 0

It's my first question here and I'm a beginner, the code is written in C (ANSI C). The code should return the digits as (n+1) for each digit in a recursive function.(123 -> 234; 801->912; 239->340) The problem is when the digit 9 appears and the…
AG19
  • 27
  • 4