Questions tagged [counter]
A Counter is a container(/bag/multiset/etc.) that keeps track of how many times equivalent values are added.
5,189
questions
-1
votes
2
answers
67
views
Counter with clearInterval, not restarting after button click
There is a word-translation card page which includes:
A 3-second countdown that runs immediately after the page loads and when you move to a new word after press the 'Correct' button.
Word and his ...
0
votes
3
answers
48
views
Casting Counter() to dict or list
I have a problem (more lined out here (Best way to compare multiple key values [lists] and return multiples?))
Short summary:
Now I have several lists I want to compare, filtering out values that are ...
-1
votes
1
answer
44
views
My score counter is being inconsistent for a dice game
I'm just starting to learn JavaScript (with HTML), and so I'm trying to make a Dice Game from the course I'm doing. The two functions, ranGen1 and ranGen2 basically just generate a random number (1-6) ...
0
votes
1
answer
36
views
How to properly make a photo counter, Python
I have a question, I want to make a counter for myself but I have a problem with the code.
# Counter Next button
self.index = 2 # clicked picture (index number in the list)
self.counterUp += ...
1
vote
2
answers
46
views
Trying to design an 8-bit reloadable down counter
Task: Designing a 8-bit downcounter which takes an initial input value and start the downcount, and when count becomes 8'b0000_0000, it should automatically set to input value.
Ex: If given input is 8'...
1
vote
1
answer
42
views
How to calculate the maximum sum in a reverse way in pandas list
I have this list:
balance = [300,400,250,100,50,1,2,0,10,15,25,20,10,1,0,10,15]
I need to calculate the maximum consecutive increase in balance over a certain period of time.
The first element on the ...
0
votes
6
answers
41
views
count of sublists containing item for all items
I'm looking for a more efficient/pythonic way of doing this.
l = [[0,0],[1,0],[4,5,1],[2,3,5],[0,4]]
set_l = set([i for sl in l for i in sl])
sublists_containing_item_count = [sum([1 for x in l if i ...
0
votes
1
answer
43
views
Trouble with While loop for a color guessing game
Having difficulty with this assignment, here is the instructions we we're provided with.
create a program the user to guess your favorite color. Using a while loop, if the user didn’t guess your ...
3
votes
3
answers
38
views
How do I create a function which will return a dictionary with two functions in that will increment/decrement a count in Python?
I've been tasked with creating a function "make_counter" which takes a number as its only argument. It should return a dictionary containing two functions that can be invoked to increment ...
1
vote
1
answer
28
views
How to make a auto counter to print pages
I have two macros one to sort the excel sheet by account number and one to print the page and put a pdf in a folder the first macro that sorts it needs a reference in a cell that goes based off ...
1
vote
1
answer
21
views
JavaScript 'score counter' to work across various pages on website
I'm trying to 'gamify' my website to engage learners. I am still incredibly new to JavaScript so I apologize in advance. There are dozens of similar articles, but none that match my needs closely and ...
0
votes
0
answers
24
views
How to increase Post Views Counter plugin's views count using the REST API?
I am making an Android app using Rest API and getting data from my WordPress website.
I have implemented a post views functionality on my app and I am using the Post Views Counter plugin on my ...
0
votes
1
answer
28
views
Python collections.Counter: "AttributeError: 'Counter' object has no attribute 'total'"
As the title says, I'm getting
>> Counter({'red': 2, 'blue': 1}).total()
AttributeError: 'Counter' object has no attribute 'total'
even though it definitely does? Really at a loss here, thanks ...
-1
votes
1
answer
55
views
Counting elements with tolerance
I have a long list of values (here below a shortened version) that I need to count:
ed = [ 0.52309 , 3.1443 , 16.5789 , 24.0643 , 9.70981 , 1.71983 ,
16.3453 , 14.1901 , 22.0353 , 1....
0
votes
1
answer
53
views
increment counter for a specific list item in Flutter
Good evening, As in my example image, below, I want to increase or decrease the quantity on button click for a single item in the listing. If I increment the counter in setState(), it is incremented ...
1
vote
1
answer
18
views
How can I adjust the slider correctly?
I want to create a basic slider with javascript. There are images and when I click left and right buttons the images must be changed.
My code doesn't work. Where is my problem? No image changes even ...
0
votes
0
answers
33
views
Problem using data passed by localStorage in a counter
I´m trying to make a counter of days, pass that to another page with localStorage and then keep counting them when they click a button, the info reaches the other page, shows me the previous number of ...
0
votes
1
answer
22
views
Console Logging a setInterval counter outputs every number up till the current one
I am making a counter to update a progress bar as time goes on.
I decided to use a setInterval function to update the counter every second, which would then update the progress bar, but the bar was ...
1
vote
1
answer
26
views
Google sheet automatic addition of the number of items
hello to all who are able to help me I apologize in advance because I know it's somewhere on stackoverflow but I can't find it
I need it to automatically assign me a number to the selected column
(do ...
1
vote
1
answer
51
views
How can I count the number of times I call a loss function?
I personalized my own Huber loss function in the way (https://goodboychan.github.io/python/coursera/tensorflow/deeplearning.ai/2022/02/08/01-Tensorflow2-Custom-Loss-Function.html) suggests:
def ...
0
votes
0
answers
16
views
Message to a user that Application 2 needs to be run first before running Application 1 the second time in Python
I have a main.py and delete.py scripts. After running main.py, before running main.py again, delete.py needs to be run first. Is there a way like a counter that a user will be warned or stopped that ...
0
votes
0
answers
54
views
Microcontroller input state counter problem
I am doing a major embedded project of making a GM counter. As a main microcontroller I am using a PIC32MK1024MCM064. I wont bore you with details, but I need to implement following algorithm:
When ...
-5
votes
1
answer
41
views
How i can do simple counter?
How can I make a "counter", and after this counter reaches for example 3, I had the function executed.
When I call the function "this", 3 and more times, "if this >= 3:&...
-1
votes
0
answers
15
views
making chrome extension to access counters in web pages
i tried writing chrome extensions that can manipulate counters in any website but they aren't working as needed . who has an examble
my code is here :
`// Find the counter element
const counterEl = ...
0
votes
1
answer
33
views
How to use Ajax in Laravel 9 for store value from a auto-increment counter in real-time?
Here my point, i'm creating a auto-increment counter using Javascript on my main page in Laravel 9.
<script>
var counter = {{ $number}};
var counterNode = document....
0
votes
2
answers
35
views
PineScript - Adding to counter in IF statement
I am grabbing a session range (highest high and lowest low) and during a given period I want to see if that highest high or lowest low is exceeded and if so add +1 to a counter. I only want to add +1 ...
0
votes
1
answer
20
views
Counter is not working as intended crossing high or low of session
I have a time session set, and I grab the highest high and lowest low of that session.
In a following time session (after the highest high and lowest low are established) I want to mark the first time ...
0
votes
1
answer
17
views
Equivalent of insert or update in DynamoDB for counting
I'm trying to keep track of hits from IP addresses.
Typically, in a SQL database, you could do something along the lines of:
CREATE TABLE website_hits
(
ip VARCHAR(45) PRIMARY KEY,
hits ...
-1
votes
1
answer
20
views
Counter sum filtered counts
The result should sum over a counter like counter.total(), but only on certain elements in the counter. The elements should be filtered by their keys, I would imagine something like the following code ...
0
votes
0
answers
39
views
How to create a Counter object or a defaultdict in PoweShell
I am writing a PowerShell script that examines a collection of objects and counts how many times various properties are seen. In Python, I would use a Counter object, but PowerShell doesn't seem to ...
1
vote
1
answer
59
views
render a variable foreach in react
On React (Next.js), I am trying to make a counter for adding records to the PostgreSQL database (>30,000 records) (for import from EXELL). The addition procedure works quite quickly, but I still ...
0
votes
0
answers
29
views
React setState counter function is acting strange
I'm having trouble implementing a simple counter update in react. I have a quantity state to update my shopify cart. There is an increment and decrement function. In the beginning, the quantity is set ...
-1
votes
0
answers
34
views
grafana Prometheus query to calculate increase in counter value for each day
increase(counter_metric[24h]) is showing increase at midnight i.e counter increase for current day does not come under today but tomorrow.
grafana image currently
-2
votes
1
answer
37
views
Converting Counter method to dictionary returns error
I am trying out the Counter method in python and then convert to dictionary. However, the list of elements is very large (~4200 elements). So the function is supposed to print the element and its ...
0
votes
0
answers
24
views
CSS counter problem in Firefox - ul interferes with ol > li counter in Firefox
ol {
counter-reset: item;
}
ol>li {
counter-increment: item;
}
<ul>
<li>ul 1 test 1</li>
<li>ul 1 test 2</li>
<li>ul 1 test 3</li>
</ul>
&...
0
votes
2
answers
36
views
cs50/pset1/credit Can't figure out how to use a digit counter without changing the initial variable [closed]
The digit counter works, displaying thhe correct number of digits, however my variable (number) changes from the initial input. I need it to stay the same because I use it later on in he code to test ...
0
votes
0
answers
97
views
Adding Counter on repeated pairs
I'm trying to put a counter on pair of every mac and ip received . while debugging the counter showing how many times i got an entry but printing it showing 0 everytime
import pyshark
from collections ...
2
votes
2
answers
48
views
counter for unique values found along the vector
first of all let me say that I have searched a lot for this basic question, but none of the answers found seems to do the job. If this specific question has already an answer, please excuse me.
I want ...
0
votes
0
answers
23
views
Is there a processor to convert prometheus data types?
I admit this may be a bit of a stupid question, however, we're in a bit of a pickle. Essentially, we have a paid web-based application that hosts (what they claim to be) prometheus metrics. There are ...
0
votes
0
answers
27
views
Word Frequency Counter encounters error on first letter
def byFreq():
filename = open("alice.txt", "r", encoding="utf-8-sig")
infile = filename.read()
words = infile.split()
return len(words)
def count_words(...
-2
votes
1
answer
56
views
How Do I Prevent My Counter From Resetting Back To 0?
I'm creating a program that is like a pet bunny simulator. In the program, you are faced with four days (a method for each of these days) and in these days you are asked to make decisions. For example,...
-1
votes
2
answers
49
views
How do i remove single element from counter and return is as a list?
Given a list and a number, create a new list that contains each number of list at most N times, without reordering.
For example if the input number is 2, and the input list is [1,2,3,1,2,1,2,3], you ...
0
votes
1
answer
83
views
Prometheus increase function working wrongly
I am measuring the number of times api is called using counter metric, and then using promql to write queries. I called the api 3 times. Increase function giving incorrect answers
query :- metric[10m:...
1
vote
0
answers
32
views
Toggling LEDs in a respond to a counter at different scenarios
I am trying to toggle leds on and off based on two scenarios.
a counter.(input from two buttons - one for counting up and the other for counting down)
a specific time for led to be ON
if counter is ...
2
votes
2
answers
59
views
Use Counter to count unique values in multiple lists
I have a list of lists and I'm trying to use Counter to get the number of unique words across all of the lists.
[[‘My’,
‘name’,
‘is’,
‘Joe’],
[‘My’,
‘name’,
‘is’,
‘Sally’],
[‘My’,
‘name’,
‘is’,
...
0
votes
0
answers
66
views
Yolo V5 counting objects that trespass two lines
I'm self learning python programmer with beginning/intermediate knowledge. I'm trying to write a code to identify the 'holes' in a strawberry field and I`m using the yolov5 on a custom dataset.
I ...
1
vote
1
answer
47
views
Counting how many times a substring occurs in a string
The university has asked me to write code in x86 assembler that counts how many times a substring is contained in a string. For example, how many times does the string "QWWQQWWQQW" contain ...
0
votes
0
answers
54
views
how to count in django templates
Hi I am trying to count infringement inside templates. The results I am getting for 'a' the counter is 1 1 (two separate values) instead of total count of 2 or 1 1 1 instead of a total of 3. Please ...
0
votes
0
answers
30
views
Counter resets everytime I use a specific command
I made a bot that got some diffrent features. The bot is able to count everytime I use a specific command, and adds it to a personal counter of that member that uses the command. It also got a ...
0
votes
1
answer
24
views
How do I use a for loop counter as the input to a function? [duplicate]
I am having an issue with a Python program I have made. It involves the tkinter module and the for loop.
Here is my code:
from tkinter import Button
def action(n):
print(n)
for num in range(...