Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System to collect contributions from other people #1

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
### Contributing to 1brc-perl

1) Fork the project.
2) Create a branch from master.
3) Create a new folder in the Submissions folder with a name for your new example (e.g. BRC_<github_id>)
4) Develop and test your script (appropriately named e.g. BRC_<github_id>_<strategy>.pl) to work on the test file. This should be executable using
`perl <path_to_script_folder>/BRC_<github_id>_<strategy>.pl test.txt` when run in the same folder as the test file. multiple strategies can be submitted.
5) Add a ReadMe.md file that describes the technique/modules used, and optionally the performance you obtained with specs of your hardware
6) Push this branch to your GitHub project.
7) Do a Pull Request on GitHub once you arre happy with your submission
28 changes: 28 additions & 0 deletions Submissions/BRC_saiftynet/BRC_saiftynet_basic.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use strict;use warnings;
my $data={}; # hash for collecting data
while(<>){
my ($city,$temp)=split(';'); # get city and temperature
$temp=~s/\.//; # remove decimal point
use integer; # speeds up by 10%
if ($data->{$city}){
my $cd=$data->{$city}; # create a local copy to speed up access for calculations
if ($temp>$cd->{max}){ # max
$cd->{max}=$temp;
}
elsif ($temp<$cd->{min}){ # min
$cd->{min}=$temp;
}
$cd->{mean}=($cd->{number}*$cd->{mean}+$temp)/($cd->{number}+1); # mean
$cd->{number}++; # count
}
else {
$data->{$city}={max=>$temp,min=>$temp,mean=>$temp,number=>1} # initialise city
}
}

print"{";
for (sort keys %$data){ # print results
my $cd=$data->{$_};
print $_,";",$cd->{min}/10,"/",($cd->{mean}+5)/10,"/",$cd->{max}/10,", ";
}
print"}\n\n";
3 changes: 3 additions & 0 deletions Submissions/BRC_saiftynet/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Saiftynet attempts

Basic. The template for future versions no modules uses a hash rather an array. Removes decimal point and uses `integer`.
3 changes: 3 additions & 0 deletions Submissions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Submissions

Each folder in this folder contains a submission (or set of submissions) along with a description of how these submissons tackle the task