Skip to content

Commit 09d1232

Browse files
huntober
1 parent a31d2b1 commit 09d1232

File tree

14 files changed

+140
-0
lines changed

14 files changed

+140
-0
lines changed

.idea/.gitignore

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/codeWars.iml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/profiles_settings.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

huntober2023/oct25.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# You will be given an array of numbers in which two numbers occur once and the rest occur only twice. Your task will be to return the sum of the numbers that occur only once.
2+
3+
# For example, repeats([4,5,7,5,4,8]) = 15 because only the numbers 7 and 8 occur once, and their sum is 15. Every other number occurs twice.
4+
5+
# repeats([4,5,7,5,4,8]),15)
6+
# repeats([9, 10, 19, 13, 19, 13]),19)
7+
# repeats([16, 0, 11, 4, 8, 16, 0, 11]),12)
8+
# repeats([5, 17, 18, 11, 13, 18, 11, 13]),22)
9+
# repeats([5, 10, 19, 13, 10, 13]),24)
10+
11+
# input array/list of numbers
12+
# positive and negative?, characters?
13+
# numbers can have 1 + occurrence
14+
# one number output
15+
16+
# initiate table
17+
# iterate over input array
18+
# if number doesn't exist in table, add
19+
# if number does exist in table + 1
20+
# add all key values
21+
22+
def repeats(input):
23+
# unique_num = list(filter(lambda n: input.count(n)==1, input))
24+
# return sum(unique_num)
25+
unique_num = list(filter(lambda n: input.count(n) == 1, input))
26+
return sum(unique_num)
27+
print(repeats([4,5,7,5,4,8]),15)

huntober2023/oct26.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Return the number of unique arrays that can be formed by picking exactly one element from each subarray.
2+
3+
# For example: solve([[1,2],[4],[5,6]]) = 4, because it results in only 4 possibilites. They are [1,4,5],[1,4,6],[2,4,5],[2,4,6].
4+
5+
# Make sure that you don't count duplicates; for example solve([[1,2],[4,4],[5,6,6]]) = 4, since the extra outcomes are just duplicates.
6+
7+
# solve([[1,2],[4],[5,6]]),4)
8+
# solve([[1,2],[4,4],[5,6,6]]),4)
9+
# solve([[1,2],[3,4],[5,6]]),8)
10+
# solve([[1,2,3],[3,4,6,6,7],[8,9,10,12,5,6]]),72)
11+
12+
13+
# array of arrays of only numbers
14+
# number outcome
15+
16+
# iterate over array input
17+
# convert each nested array to a set
18+
# multiply length
19+
20+
21+
def solve(arr):
22+
prod = 1
23+
for num in arr:
24+
prod *= len(set(num))
25+
return prod
26+
27+
28+
29+
30+
# print(solve([[1,2],[4],[5,6]]),4)
31+
print(solve([[1,2],[4,4],[5,6,6]]),4)
32+
print(solve([[1,2],[3,4],[5,6]]),8)
33+
print(solve([[1,2,3],[3,4,6,6,7],[8,9,10,12,5,6]]),72)

pythonExercises/.idea/.gitignore

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pythonExercises/.idea/inspectionProfiles/profiles_settings.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pythonExercises/.idea/misc.xml

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pythonExercises/.idea/modules.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pythonExercises/.idea/pythonExercises.iml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pythonExercises/.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)