Questions tagged [find-occurrences]

435 questions
-1
votes
3 answers

Check the duplicate element in an array using set in python

Scan and check the numbers in an array if it is repeated, if true print yes, else print no So what I'm trying to do is convert them into a set (and list) a = [int(v) for v in input().split()] b = set(a) and check if the occurrence of an element in…
Codeer
  • 82
  • 9
-1
votes
1 answer

Find all occurences of a value in a list

I am trying to get the number of how many times player.userID shows in a list but I can't seem to figure out how, I have searched the internet for an hour now. class ConfigData { [JsonProperty(PropertyName = "Ban")] …
-1
votes
1 answer

Replace each nth occurrence of 'foo' and 'bar' by numerically respective nth line of a supplied file once time

I would like to use a single command line (I tried to do this with pipe and process substitution but unsuccessfully as explained below) to replace each nth occurrence of home_cool and home_cool01) by numerically respective nth line of a supplied…
7beggars_nnnnm
  • 697
  • 3
  • 12
-1
votes
1 answer

remove occurrence values from array Angular

I have an array that has multiple months of occurrence so I did this method to remove these occurrences but no truthly results, I don't know what my mistake I made let tab1:any=[month]; let tab2:any=[] let tab3:any=[] for (let index = 0; index <…
-1
votes
3 answers

Find the first occurrence of element from array in another array

I'm curious if there is a good way to find the first occurrence of element from array in another array. As result, the answer should be a null (if no elements from the first array in the second array) or this element. Ex.1: fromArr = ["Yellow",…
Haradzieniec
  • 9,086
  • 31
  • 117
  • 212
-1
votes
1 answer

Count occurence of list of couple in python and append result to new list with all the elements in the first list

I have this: list = [ (('hash1', 'hash2'), (436, 1403)), (('hash1', 'hash2'), (299, 1282)), (('hash2', 'hash3'), (1244, 30)), (('hash1', 'hash3'), (436, 1403)), (('hash3', 'hash4'), (299, 1282)), (('hash5', 'hash4'), (1244,…
CDixon
  • 21
  • 8
-1
votes
1 answer

Count cumulatively the occurrences of each element of a list

I have a list: selection_list=[3, 2, 3, 2, 2, 2] I want to count cumulatively the occurrences of each element, I want the output to be: ['1/2', '1/4' , '2/2', '2/4', '3/4', '4/4'] # 1/2 means: first occurrence of two dico={'selection':[],…
Isma Hène
  • 49
  • 5
-1
votes
1 answer

JavaScript: Print character with number of uninterrupted occurrences for each sequence of characters

This is not a duplicate of Counting the occurrences / frequency of array elements There are differences. I've got an array with chars: const data = ['a', 'a', 'b', 'x', 'x', 'x', 'a']; I need to count each sequence of characters and print character…
a1tern4tive
  • 422
  • 3
  • 11
-1
votes
1 answer

Find all occurrences of a "unknown" substring in a string with PHP

I have a string and I need to find all occurrences of some substrings in it but I know only initials chars of substrings... Ho can I do? Example: $my_string = "This is a text cointaining [substring_aaa attr], [substring_bbb attr] and [substring],…
icolumbro
  • 97
  • 3
  • 17
-1
votes
5 answers

Python: Is there a way to find and remove the first and last occurrence of a character in a string?

The problem: Given a string in which the letter h occurs at least twice. Remove from that string the first and the last occurrence of the letter h, as well as all the characters between them. How do I find the first and last occurrence of h? And how…
Ma Tabe
  • 11
  • 1
  • 1
-1
votes
1 answer

How to return dictionary with occurrence per word in a string (Python)?

How can I make a function (given a string sentece) that returns a dictionary with each word as key and the number of occurrence as the value? (preferably without using functions like .count and .counter, basically as few shortcuts as possible.) What…
Charlotte
  • 55
  • 1
  • 2
  • 7
-1
votes
1 answer

how to get value of a matching text field in shell script

I want to capture the first occurence value of a given text field by reading the whole file. How to achieve this in shell: Input line:
-1
votes
1 answer

Backward search implementation python

I am dealing with some string search tasks just to improve an efficient way of searching. I am trying to implement a way of counting how many substrings there are in a given set of strings by using backward search. For example given the following…
Joe Smith
  • 83
  • 1
  • 6
-1
votes
1 answer

Comparison of two dataframes

I have an excel table of 15200 lines, corresponding to a tree analyzed for its structures. I have all the structures in columns (48 structures), they have been counted on every tree. for example, the tree 12607 has 3 structures CV11, 1 structure…
C.L.
  • 3
  • 2
-1
votes
3 answers

Javascript Regex - must starts with letters can only have one occurrence of special character

I am new to Regular Expressions and trying to create one for a specific requirement per below : Must starts with letters a-Z or A-Z Can contain numbers 0-9 Can contain only allowed special characters i.e. @.-' Only one occurrence of above special…
user1483570
  • 51
  • 3
  • 10