Re: Arithmetic error or function setup incorrectly
by Antonio Olivares
On Sunday, December 3, 2017, 9:48:17 PM CST, Jon LaBadie <jonfu(a)jgcomp.com> wrote:
Antonio,
Do you have control over the contents (format) of the data?
Here that would be "Soccer.dat".
If yes I'd suggest a format change. Separate the goals with
dashes (-) or commas (,) or whatever, just no something that
makes you think of them as numbers but as strings to be
converted to numbers later.
Assuming you used dashes teams 2 and 8 would be:
Team2 1 1-2
Team8 2-0-1 2-0-3
Your code could then use split(...) to put the goal counts into
an array. For example.
split($2, GF, "-")
split($3, GA, "-")
You would now have two arrays GF (Goals For) with up to 3 elements.
The first would be regulation, second overtime, third penalty kicks.
And of course the same for GA.
This would also eliminate a potential, but very rare problem,
Some team scores 10 goals in overtime. Your scheme would make
it look like 1 goal and 0 penalty kicks.
Jon
On Sun, Dec 03, 2017 at 12:46:16PM +0000, Antonio Olivares wrote:
> Dear Fedora users,
>
> I have a question regarding a set of data and an awk script that performs some actions, it calculates a GF(goals in favor) GA(goals against), and PTS for each game. Suppose the data is as follows:
>
> Soccer.dat
> Team. GF GA
> Team1 1 2
> Team2 1 1.2
> Team3 2 4
> Team4 3 0
> Team5 4 0
> Team6 3 2
> Team7 1 3
> Team8 2.01 2.03
> Team9 3.03 3.04
> Team10 0 7
> Team11 0.1 0.3
>
> In district play, if a team wins in regulation they earn 3 pts, if you lose 0 pts, if both teams tie in regulation, they play overtime, if they are still tied then penalty kicks decide the outcome of the game. The winners in OT/PKS get 2 pts, the loser get 1 pt.
>
> In Team2 we tied at 1 in regulation, but in OT, the other team scored 2 goals and beat us 3 to 1. The awk script attached inline calculates this, but outputs 1 2 when it should output 1 3. If there is another number in the hundredths place is we shot penalty kicks. I cannot copy the awk script. I will have to attach it. I would like to improve it by tallying a running total per column of GF GA PTS . Ideas are appreciated.
>
> The awk script creates a new integer from the decimal number given. The integer part and the fractional part are used to create the new numbers that end up in GF and GA.
>
> In one case when I put 1 1.2 the output should be 1 3 but it gives me 1 2. This is one of my questions. On the other hand if I put 0.1 and 0.3 it outputs 1 to 3 correctly. Do I have a mistake in my function? I use int($1) to get integer part and ($1-int($1)) to get fractional part.
>
>
> Best Regards,
>
>
> Antonio
> #!bin/sh
>
> # Check for arguments
> if [ $# -eq 0 ]; then
> echo "Usage: $(basename $0) filename"
> exit 1
> fi
>
> if [ ! -f $1 ]; then
> echo "File "$1" doesn't exist!"
> exit 0
> fi
>
> awk '
>
> NR == 1 {
> f[1]=-14; f[2] = f[3] = f[4] = f[5] = 3
> printf "%-14s %-3s %-3s %-3s %-3s\n",
> "OPPONENT", "GF", "GA", "DIF", "PTS"
> }
>
> NR >= 1 {
> F=$2+10*($2-int($2))-($2-int($2));
> A=$3+10*($3-int($3))-($3-int($3));
> tdif=F-A;
> dif=$2-$3
> difb=int($2)-int($3);
> if (dif >= 1 && int(dif) >= 1)
> pts=3;
> else if (dif > 0 && int(difb) >= 0)
> pts=2;
> else if (dif > -1 && int(difb) >= -1)
> pts=1;
> else
> pts=0;
> printf "%-14s %-3d %-3d %-3d %-3d \n",
> $1, F, A, tdif, pts }' $1
> _______________________________________________
> users mailing list -- users(a)lists.fedoraproject.org
> To unsubscribe send an email to users-leave(a)lists.fedoraproject.org
>>> End of included message <<<
--
Jon H. LaBadie jonfu(a)jgcomp.com
Dear Sir,
I do have control of the data. I just wanted to have a solution running from a shell script. I have an opendocument(*.odt) and excel spreadsheet that uses the decimal point and converts the decimal numbers to goals except in the hundredths place which is when we have to shoot penalty kicks(PK) to decide the game, but this is for my fellow coaches, they have to manually input the scores and put a * at the score indicating OT, PKS etc. Some may not understand it :(
My questing regarding the data is that in one case, I had in Team2Team2 1.0 1.2 which should give 1 3 but it output 1 2 :(I had to change to 0.1 and 0.3 and it correctly put the goals at 1 3 and awarded 1 pt for going into OT.
How do I fix the script to account for the new changes/examples? At the end of the running the script should tally up the GF and GA except in PKS those do not count in the DIF. So my soccer.dat would become as follows:
Soccer.dat-------------------------------
@Team1 1 2Team2 1-0 1-2Team3 2 4Team4 3 0@Team5 4 0Team1 3 1@Team2 1 3@Team3 4 3@Team4 3-0 3-1Team5 3 0
At the end of each line, the GF and GA will be adjusted and at the very end of the data, the script should report a running total of all GF and all GA and the PTS.
Thank you very much for your help!
Best Regards,
Antonio
6 years, 6 months
Changing runlevels at boot time
by Alex
Hi,
I have a fedora27 system that boots to a blank screen with the latest
kernels. This has been happening since the system was at least a
fedora26 system.
If I boot to multi-user first, then switch to graphical boot, it works fine.
Adding "3" to the grub command-line ("e" then append "3" to linux16
line, then ctrl-x to boot) does not work to boot the system to
multi-user as per the documentation. However, adding
"systemd.unit=multi-user.target" does.
Also, the rescue kernel also works, but lacks networking. What's the
difference between these two kernels or these two grub invocations?
Notice I've also disabled selinux for now.
Any ideas why the system would become unresponsive and boot to a blank
screen with the latest kernels?
menuentry 'Fedora (4.13.13-300.fc27.x86_64) 27 (Workstation Edition)'
--class fedora --class gnu-linux --class gnu --class os --unrestricted
$menuentry_id_option
'gnulinux-4.13.13-300.fc27.x86_64-advanced-dedb2196-1933-4fa3-b8bd-5123930308b9'
{
load_video
set gfxpayload=keep
insmod gzio
insmod part_msdos
insmod ext2
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root
--hint-bios=hd3,msdos1 --hint-efi=hd3,msdos1
--hint-baremetal=ahci3,msdos1 --hint='hd0,msdos1'
9522bf8d-db18-48e9-a7d9-ae9c52d4343d
else
search --no-floppy --fs-uuid --set=root
9522bf8d-db18-48e9-a7d9-ae9c52d4343d
fi
linux16 /vmlinuz-4.13.13-300.fc27.x86_64
root=UUID=dedb2196-1933-4fa3-b8bd-5123930308b9 ro security=0
initrd16 /initramfs-4.13.13-300.fc27.x86_64.img
}
menuentry 'Fedora (0-rescue-4289f41d85794f5ebc59779ac5cdcc51) 27
(Workstation Edition)' --class fedora --class gnu-linux --class gnu
--class os --unrestricted $menuentry_id_option
'gnulinux-0-rescue-4289f41d85794f5ebc59779ac5cdcc51-advanced-dedb2196-1933-4fa3-b8bd-5123930308b9'
{
load_video
insmod gzio
insmod part_msdos
insmod ext2
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root
--hint-bios=hd3,msdos1 --hint-efi=hd3,msdos1
--hint-baremetal=ahci3,msdos1 --hint='hd0,msdos1'
9522bf8d-db18-48e9-a7d9-ae9c52d4343d
else
search --no-floppy --fs-uuid --set=root
9522bf8d-db18-48e9-a7d9-ae9c52d4343d
fi
linux16 /vmlinuz-0-rescue-4289f41d85794f5ebc59779ac5cdcc51
root=UUID=dedb2196-1933-4fa3-b8bd-5123930308b9 ro security=0
initrd16 /initramfs-0-rescue-4289f41d85794f5ebc59779ac5cdcc51.img
}
6 years, 6 months
F27: how to disable packagekit to download updates
by Dario Lesca
How to I can disable packagekid to download update?
I do not use these packages downloaded uselessly from packagekit into
/var/cache/PackageKit/*/*/updates/... because I run sometimes when I
want and can, after, reboot, "sudo dnf update".
Unfortunately this command (dnf) do not use the rpm files download from
PackageKit but it downloads them again ... Sigh!
Many thanks
--
Dario Lesca
(inviato dal mio Linux Fedora 27 Workstation)
6 years, 6 months
Arithmetic error or function setup incorrectly
by Antonio Olivares
Dear Fedora users,
I have a question regarding a set of data and an awk script that performs some actions, it calculates a GF(goals in favor) GA(goals against), and PTS for each game. Suppose the data is as follows:
Soccer.dat
Team. GF GA
Team1 1 2
Team2 1 1.2
Team3 2 4
Team4 3 0
Team5 4 0
Team6 3 2
Team7 1 3
Team8 2.01 2.03
Team9 3.03 3.04
Team10 0 7
Team11 0.1 0.3
In district play, if a team wins in regulation they earn 3 pts, if you lose 0 pts, if both teams tie in regulation, they play overtime, if they are still tied then penalty kicks decide the outcome of the game. The winners in OT/PKS get 2 pts, the loser get 1 pt.
In Team2 we tied at 1 in regulation, but in OT, the other team scored 2 goals and beat us 3 to 1. The awk script attached inline calculates this, but outputs 1 2 when it should output 1 3. If there is another number in the hundredths place is we shot penalty kicks. I cannot copy the awk script. I will have to attach it. I would like to improve it by tallying a running total per column of GF GA PTS . Ideas are appreciated.
The awk script creates a new integer from the decimal number given. The integer part and the fractional part are used to create the new numbers that end up in GF and GA.
In one case when I put 1 1.2 the output should be 1 3 but it gives me 1 2. This is one of my questions. On the other hand if I put 0.1 and 0.3 it outputs 1 to 3 correctly. Do I have a mistake in my function? I use int($1) to get integer part and ($1-int($1)) to get fractional part.
Best Regards,
Antonio
6 years, 6 months
how to substitute mariadb to mysql while compiling
by François Patte
Bonjour,
I try to compile gerbera in order to test this dlna server. There is an
option to have mysql as a database but, mysql no longer exists on
fedora, so if I activate this option, the compilation fails.
Is there a way to substitute mariadb?
Thank you for any help.
--
François Patte
UFR de mathématiques et informatique
Laboratoire CNRS MAP5, UMR 8145
Université Paris Descartes
45, rue des Saints Pères
F-75270 Paris Cedex 06
Tél. +33 (0)6 7892 5822
http://www.math-info.univ-paris5.fr/~patte
6 years, 6 months