how do I add 3 points randomly to a list? - list

I have a list below community_card_suit, and I want to randomly add 3 points to any of the indexes, so for example the outcome looks like [0,3,0,0] or [0,1,1,1] or [1,2,1,0], etc.
community_cards_suit = [0,0,0,0]
Any idea how I would do this randomly?
Thanks

Related

how to create a list of a list in photon and print it as columns?

I am new to photon and I would like to know how I can create a list of elements in a list in order to print them on the terminal manually with a number in front of it.
lst = ["country", "inhabitants", "CO2-Emissions" ]
def make_header(lst):
first_column = []
for column_names in range(len(lst)):
first_column.append([])
for list in range(1):
column_names[first_column].append(list)
print(lst)
make_header(lst)
the output should be:
country
inhabitants
Co2 Emissions
Sadly I have no clue how to do that correctly. Could you give me a hint on that?
I want the columns displayed on the terminal as above.
I am not allowed to use maps, arrays, imports and other "fancy" and practical stuff so I approached for a nested loop.
Kind regards
Boris

PowerBi: I would like to know how many locations have a collection vs. the count of all items within a collection in a location...how do I do that?

Super new so please forgive me :-)
In Excel, I would have done an iterative sumif($a$1:a1) and then countifs( all the ones that say "1" vs. higher numbers:
example iterative
Blue 1
blue 2
green 1
red 1
purple 1
green 2
I have 2 tables(fields): FloorSamples(location,sku) and ItemData(sku, collection)
Here is the output I am looking for:
Collection #stores that have that collection
Since collections have multiple items to complete a group I receive this output instead:
Collection #items that have that collection label
If 12 locations have a collection, and there are 5 items per store that have that collection name, I would like it to return 12, not 60.
Assuming there is a many-to-one relationship between FloorSamples.sku and ItemData.sku, use this measure in a visual with Collections as a dimension (rows or axis), you will get what you're looking for.
DISTINCTCOUNT(FloorSamples[location])

counting up in list.generate, short flutter question

i recently started learning flutter and dart, so my apologies if this is a really simple problem, i am trying to generate a list with values from another list, as follows:
List transactions = List.generate(15, (index)=>{
“name”: names[1],
“dp”: “assets/cm1.jpeg”,
});
but i want the numbers 1 to increase by 1 with every new entry. so the list should be outputting the names in my names list 1 by 1 and cm1.jpeg, cm2.jpeg etc. similar to the i+1 code.
Thanks in advance!
You can use the index variable to get the index of the current element you are generating. So first element will run the generate method with an index value of 0, the second will have the value 1 and so on.
With this knowledge you can write something like:
List transactions = List.generate(15, (index)=>{
“name”: names[1 + index],
“dp”: “assets/cm${1 + index}.jpeg”,
});

how python print me each element when i use random?

I need a list of 8 elements and i want that python randomly import that elements in a list. But i need each of them elements in a list. Like this:
I need numbers of 0 to 4 in a list, but if I write:
s = []
for i in range(8):
s.append(random.randint(0,4))
print("s:", s)
python doesn't print me each of number at least once. Python print me like that:
s = [1,0,2,2,1,0,1,3]- in this list is 4 missing but i want all 5 numbers at least once in a list.
Please help me.
If you want to have a list of eight items, consisting of at least one each of the elements 0,1,2,3,4, then what you really want is a list of [0,1,2,3,4] and three additional random elements, all in random order:
import random
# start a list with one each of the desired elements
s = [0,1,2,3,4]
# add three more elements
for i in range(3):
s.append(random.randint(0,4))
# randomize the order of the elements in the list
random.shuffle(s)
print("s:", s)

Haskell - get n number of lists from a list of lists

Hey guys so I'm trying and get the n number of lists from a list of lists. I was wondering if there is a method in haskell that works similar to the "take" and "drop" method but instead if would work in my situation. For example:
Input = [ [1,2,3,4], [5,6,7,8], [9,1,2,3], [4,5,6,7], [8,9,1,2], [3,4,5,6] ]
I want to be able to take the first 3 elements from this list of lists and end up with something like this:
Output = [ [1,2,3,4], [5,6,7,8], [9,1,2,3]]
I also want to be able to drop the first 3 elements from this list of lists and end up with something like this:
Output = [[4,5,6,7], [8,9,1,2], [3,4,5,6]]
Is it possible to do something like this in haskell.? Can anyone point me into the right direction on how to tackle this problem. Thanks in advance.
take and drop do exactly that. They work the same for all element types, even if the element type is a list type.
Prelude> take 3 [[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16],[17,18,19,20]]
[[1,2,3,4],[5,6,7,8],[9,10,11,12]]
Prelude> drop 3 [[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16],[17,18,19,20]]
[[13,14,15,16],[17,18,19,20]]