Skip to content

Commit

Permalink
Solve Loteria in python
Browse files Browse the repository at this point in the history
  • Loading branch information
deniscostadsc committed Dec 26, 2023
1 parent ea7a538 commit 9b5406d
Show file tree
Hide file tree
Showing 6 changed files with 1,001 additions and 0 deletions.
18 changes: 18 additions & 0 deletions solutions/beecrowd/2473/2473.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import sys

for line in sys.stdin:
bet = set(map(int, line.split()))
lottery_result = set(map(int, input().split()))

numbers = len(bet & lottery_result)

if numbers == 6:
print('sena')
elif numbers == 5:
print('quina')
elif numbers == 4:
print('quadra')
elif numbers == 3:
print('terno')
else:
print('azar')
52 changes: 52 additions & 0 deletions solutions/beecrowd/2473/generate_in.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash

set -euo pipefail

TESTCASES=300

max_item=7
repeated_max_item=0
file_to_save_numbers=$(mktemp)

function pick_number {
picked_numbers_count=$(wc -l < "${file_to_save_numbers}")
if [[ ${picked_numbers_count} -eq 6 ]] || [[ ${picked_numbers_count} -eq 0 ]]; then
picked_number=$((RANDOM % max_item + 1))
echo "${picked_number}" > "${file_to_save_numbers}"
else
picked_number=$((RANDOM % max_item + 1))
while grep -Fxq "${picked_number}" "${file_to_save_numbers}"; do
picked_number=$((RANDOM % max_item + 1))
done
echo "${picked_number}" >> "${file_to_save_numbers}"

fi
echo "${picked_number}"
}

for _ in $(seq "${TESTCASES}"); do
for _ in {1..5}; do
picked_number=$(pick_number)
echo -n "${picked_number} "
done
picked_number=$(pick_number)
echo "${picked_number}"

for _ in {1..5}; do
picked_number=$(pick_number)
echo -n "${picked_number} "
done
picked_number=$(pick_number)
echo "${picked_number}"

if [[ ${max_item} -lt 10 ]] && [[ ${repeated_max_item} -lt 5 ]]; then
repeated_max_item=$((repeated_max_item + 1))
elif [[ ${max_item} -lt 10 ]] && [[ ${repeated_max_item} -eq 5 ]]; then
repeated_max_item=0
max_item=$((max_item + 1))
elif [[ ${max_item} -gt 99 ]]; then
max_item=99
else
max_item=$((max_item + 1))
fi
done
Loading

0 comments on commit 9b5406d

Please sign in to comment.