1,922 questions
1
vote
3
answers
123
views
Counting number of rows up to a specified value by type and id
I have a dataset with id, test_date, test_type, test_result - like this:
ID
Test_Date
Test_Type
Test_Result
1
2024-03-21
A
Fail
1
2024-04-21
A
Fail
1
2024-04-30
A
Pass
1
2025-05-15
B
Fail
1
2025-05-31
...
2
votes
2
answers
85
views
How to count number of appearances in 3D cell
I have a cell 3x26x72 which contains a series of characters of size 1xN char. I would like to count the number of appearances of each serie of characters in the cell 1x26x72. I tried with "mode&...
3
votes
2
answers
204
views
How can I count lines of code in an R package?
How can I count the lines of code in an R package? I have two possible types of input:
The raw package code (my own package); I could point the function to the R folder that contains source code.
The ...
0
votes
6
answers
238
views
Trying to shift in a while loop
I need to create a program that can do this:
Input:
args2 one two three
Output:
You have entered 3 arguments:
#1: one
#2: two
#3: three
This is what I have so far:
#!/bin/bash
echo "You have ...
4
votes
1
answer
155
views
Algorithm to find the number of specific continuous substrings
I am trying to solve the following algorithmic problem:
Every day, Bob goes to work and does one of 26 possible tasks. The tasks are coded with the letters of the English alphabet from a to z. ...
0
votes
0
answers
54
views
How can I count how many times multiple items show up in a database? [duplicate]
I would like to count each multiple of the items in an array returned from a SQL query:
$results = $stmt->fetchALL(PDO::FETCH_ASSOC);.
So if there are 5 instances of John and 3 of Sue in the db, ...
2
votes
1
answer
183
views
What is the fastest way to compute number of 1 bits in an array of bytes?
I might be silly to ask this, but I search around in google and did not got an definite answer(maybe I should be more careful).
Given a series of bytes, what is the fastest way to know the number of 1 ...
0
votes
1
answer
44
views
Laravel withCount elements in related and subrealted table
I'm building application with Laravel, Inertiajs and Vue3.
There are three key tables in application: Operators, Locations and Terminals. Terminals belongs to Locations and Locations belongs to ...
0
votes
3
answers
114
views
google sheets formula to count years and year ranges presented different ways
I'm looking for an array formula that can count the number of years in each cell from a single column. Here's a link to a shared google sheet showing the input data in column E and the desired output ...
1
vote
1
answer
136
views
Where does my code fail? Longest sequence of alternating 0's and 1's
In an online exam for a programming job, I was asked to code, in python, a function that would receive an input list containing a sequence of 0's and 1's. The list always has at least one element, and ...
1
vote
3
answers
54
views
Count occurences (rows) between dates (SPSS)
I have data on surgeries, every row represent a patient with a performed surgery. I wish to answer the question: How many procedures has this surgeon performed in the last year (at that time of the ...
0
votes
3
answers
57
views
Why isn't the space complexity of program adding values to a letter keyed hash map linear? [closed]
Imagine a program that takes a string of length p as an argument, and counts each letter by adding 1 for every occurrence using a hash map that only uses the 26 letters of the English alphabet as keys....
-2
votes
2
answers
93
views
In my project i have to create a program that reads a file and counts the number of occurrences of a specific word
So far it reads the file and counts each word in the file, but i want it to count just the word "Ball". I'm wondering how can I do that. Here's what's in the text file and the code:
...
1
vote
0
answers
39
views
Counting Issue in Tableau
I am working with a live data stream in Tableau and don't have any control over the data. I am encountering an issue where I am getting two different values that should be the same. The first count is ...
1
vote
3
answers
73
views
Correctly count elements in comma-separated strings, as well as with 'and' and "and/or" in R, excluding certain cases
I have a dataframe that has a column that contains multiple Spanish words. What I want is to count the total number of elements that each row contains. I have the following dataframe as an example:
...
0
votes
1
answer
65
views
PineScript - Plot once when condition is met and only plot again when a condition in the opposite direction is met
I would like to plot when a condition, in either direction, is met and then only make the next plot when the condition is met in the opposite direction. My current code plots every time a condition is ...
1
vote
1
answer
130
views
How do I count blank an filled cells in each column in a .csv file?
What I want is to count the filled and blank cells in each column of a .csv file.
This is my code:
import pandas as pd
file_path = r"C:\Users\andre\OneDrive\Documentos\Farmácia\Python\...
0
votes
3
answers
126
views
How to update excel formula to work for all columns continuously to the right and not just the current 2 it's set up for
I have a Group History tab that I keep a record of what group each student gets put in. Screenshot of contents of Group History tab:
The other tab named History Matrix I've gotten to successfully ...
2
votes
1
answer
177
views
Count the number of integers in range [0,k] whose sum of digits equals s
Count the number of integers in range [0,k] whose sum of digits equals s. Since k can be a very large number, the solution should not be O(k). My attempt of a O(s log(k)) solution (log(k) is ...
0
votes
2
answers
87
views
Issue writing pyspark or sql query to conditionally count column
Trying to write a query that correctly creates and populates an ID column that counts until it encounters a new non-null value in the Data column, at which point it restarts at 1. Here's an example of ...
1
vote
2
answers
85
views
Tkinter - How to check a buttons' state; repeat for multiple buttons, and total the results?
I have made a digital version of a pen-and-paper game as my first major python practice project. You can see from the attached picture that the main board consists of buttons. They can be toggled ...
1
vote
0
answers
59
views
How to access and count section headers from a LangGraph state?
I'm working on a LangGraph project that will eventually generate reports automatically. I'm trying to count the total number of section headers, sub-section headers and sub-sub-section headers from ...
1
vote
0
answers
88
views
Algorithm to count k-edge even-regular subgraphs of a graph?
Given an undirected graph G which is not necessarily connected, I am looking for an algorithm (or formula) that counts the number of spanning subgraphs of G that is even-regular and contains exactly k ...
-1
votes
1
answer
68
views
distinct counting open incident tickets at any give point in time
morning all,
struggling to come up with a solution to this one.
basically i need to be able to distinct count the No of tickets (ID) open at any given time by date
i have a created date , an actual ...
0
votes
3
answers
136
views
Digit Frequency Program
Given a string s consisting of alphabets and digits, find the frequency of each digit in the given string.
I have tried it and my code is given below. Please explain why it's not working.
#include <...
1
vote
4
answers
146
views
How can I make sure my function is not overcounting the number of words?
I'm writing a function to count the number of words in a user-inputted string of text. Currently I've set it up for word_count to increment every time it hits a space or punctuation mark, but I know ...
0
votes
2
answers
71
views
REGEXP_COUNT buffer too small in Oracle SQL
I have the following SQL:
with q1 ( Tdata,Key) AS (
SELECT (XMLtype(pint.transportdata, nls_charset_id('AL32UTF8')))
, PINT.PAYMENTINTERCHANGEKEY
from bph_owner....
0
votes
1
answer
66
views
How to get a running count from a string value fields
I have a table that needs to be manipulated to have a rolling count. The issue I'm having is getting it to aggregate continually.
id |sent|read_at|created_at |sent_at |...
1
vote
4
answers
191
views
Formula for the Nth bit_count (or population count) of size M
I am interested in finding a simple formula for determining the nth time a particular bit_count occurs in the sequence of natural numbers. Specifically, what is the relationship between K and N in the ...
0
votes
0
answers
42
views
Implement object counting after tracking
Open video with OpenCV
I want to improve my object tracking algorithm to be counting object whenever the vehicle across the restrict line and do not want a duplicate data also and here the result of ...
-1
votes
1
answer
39
views
When I run a function to try and count the words in a text area, the function does not run
I have a function that counts words in a text area box(written in html), but when I try and run the function, though javascript or html, it does not run. I am new to javascript, so I might be missing ...
0
votes
1
answer
86
views
Aggregate discrete frequency table in smaller table with fewer intervals
I have a frequency table that contains 800 rows. Here is a similar table for example:
table<- data.frame(number = c(1:10),
units = c(800, 780,500, 430, 200, 189, 110, 86, 54, 31))...
1
vote
1
answer
117
views
Word Count in C
I have a word count program in C that excludes special characters and number digits:
int main(){
char str[100];
int i, j = 0;
int len;
char choice;
do {
printf("...
2
votes
3
answers
161
views
Counting consecutive columns that satisfy a condition in R
I'm working in RStudio with my dataset that contains the daily milk production of cows reared in different locations. Also, I have 5 columns with the temperature in the corresponding 5 previous days ...
2
votes
3
answers
163
views
Counting numbers greater and less than input using 4 variables
I got a request for help with exercise (dedicated for primary school students) to prepare a program that counts numbers greater and less than input with limitation to using 4 int variables.
Write a ...
0
votes
4
answers
79
views
Group rows of a 2d array by year-month value of date column and count occurrences in each group
So I have this code:
$avaDates = [
['date_starts' => '2024-03-01'],
['date_starts' => '2024-03-09'],
['date_starts' => '2024-04-05'],
['date_starts' => '2024-04-09'],
['...
0
votes
0
answers
29
views
Counting loops in Python when skipping numbers
How many loops will the following for loop have?
for i in range(1, 5, 2):
print(i, end=" ")
I know that the output is "1 3", but I'm not exactly certain how it goes through, ...
1
vote
1
answer
107
views
Number of the binary strings that have the given number of occurrences [closed]
How many binary strings exists that have exactly five occurrences of "00", three of "10", three of "01" and three of "11" ?
I tried to solve it using induction, ...
0
votes
2
answers
61
views
EXCEL Deadline-tracker: Counting "distance" of empty cells (in a row) until you reach an event
I want to display the number of weeks it takes until an event is happening for a certain Item (B4, B5, etc.). My timeline is in weeks on the x-axis increasing to the right. There are empty cells in ...
0
votes
1
answer
189
views
EXCEL- Trying to count specific dates between two but also in specicif Years. Excluding the days before or after the dates asked
I've been looking and searching for this for way too long. I made some dates and added some for tests which I will share.
I'm trying to count days between two dates, leaving it blank if a cell is ...
0
votes
3
answers
275
views
About CountIF Function
I'm new to Excel. I have an excel table and I want to make a formula to avoid manual process. Because sometimes it might be so sophisticated.
Here is the table I want to write formula. My main aim is ...
0
votes
1
answer
62
views
Win condition in game not working. Trouble finding subsequent elements in 2D Array
I have an issue with my Gomoku game win conditions, in which I iterate through the 2D array looking for symbols related to each player. I have the typical nested for loop that goes through the array ...
2
votes
1
answer
190
views
Counting the number of polygons containing origin in 2D
Suppose we have n points in 2D space in convex position. There are precisely choose(n, k) different convex k-gons (non-degenerate). Is there any existing algorithm that runs in O(n log n) time (for a ...
0
votes
1
answer
104
views
ProjectEuler Problem 17: I change this one line of code, and my answer changes drastically, even though I think it should work fine
I am working on Project Euler problem 17. I am supposed to write a program that will count up the total number of characters in the numbers 1-1000 written out. You ignore whitespace and hyphens. The ...
0
votes
0
answers
40
views
Counting Different cells that are the same for a list
I have to draw up panel setups for work and a lot of time goes into counting/listing how many of each panels there are, I've been looking into "count if" formulas and such with little ...
0
votes
2
answers
89
views
Count then calculate differences from first and previous rows after grouping, but ignoring text/character values in r
From the following data grouped by id and visit, which include a mix of numeric and text/character values, how to create these 3 new columns:
count_wotxt: count by id and visit but without ...
-1
votes
1
answer
83
views
Function or a loop for counting - R studio
I am practicing my R skills and I want to know if someone is skilled in functions or loops for counting. My idea is quite vague, but I can give an example.
For an example:
I have 4 book-shelves each ...
0
votes
0
answers
111
views
Unordered map in C++ not functioning as intended [duplicate]
The program I am trying to make takes an "n * n" square matrix grid of size "n * n" with values in the range [1,n²]. Each integer appears exactly once except a number 'a' which ...
1
vote
0
answers
63
views
Replacing counter with a function
Let n be an odd number. Suppose we have the sequence s:=n,n+2,n+4,⋯. The goal is to associate this sequence with two other sequences, a and b. I will show how a and b are related to the original ...
0
votes
3
answers
124
views
How can I check duplicated words within an Array and count them?
I just started programming with JAVA 2 months ago and currently I'm facing an exercise which I don't find the solution for. Until now I control (kind of) the following structures: if (else), do while, ...