Revisions
-
dbohdan revised this gist
Mar 9, 2018 . 1 changed file with 16 additions and 16 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,30 +7,30 @@ sqlite3 db :memory: db eval {CREATE TABLE grades(name TEXT PRIMARY KEY, grade TEXT)} foreach {name grade} [::fileutil::cat grades.txt] { if {![regexp {[A-F][+-]?} $grade]} { puts "Can't parse pair '$name $grade'" exit 1 } db eval {INSERT INTO grades VALUES ($name, $grade)} } puts "Zsófia's grade: [db eval {SELECT grade FROM grades WHERE name='Zsófia'}]" puts "List of students with a failing grade:" puts " [join [ db eval {SELECT name FROM grades WHERE grade >= 'E' ORDER BY grade} ] {, }]" set grades [db eval { SELECT DISTINCT trim(grade, '+-') FROM grades ORDER BY grade }] puts "Distribution of grades by letter:" foreach grade $grades { puts -nonewline " $grade: " set count [db eval { SELECT count(name) FROM grades WHERE trim(grade, '+-')=$grade }] puts -nonewline "$count student" if {$count > 1} { puts -nonewline s } puts {} } -
dbohdan revised this gist
Jan 1, 2015 . 2 changed files with 8 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,10 +16,10 @@ foreach {name grade} [::fileutil::cat grades.txt] { puts "Zsófia's grade: [db eval {SELECT grade FROM grades WHERE name="Zsófia"}]" puts "List of students with a failing grade:" puts " [join [ db eval {SELECT name FROM grades WHERE grade >= "E" ORDER BY grade} ] ", "]" set grades [db eval { SELECT DISTINCT trim(grade, "+-") FROM grades ORDER BY grade This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,8 @@ Zsófia's grade: B+ List of students with a failing grade: João, Emma Distribution of grades by letter: A: 2 students B: 5 students D: 1 student F: 2 students -
dbohdan revised this gist
Jan 1, 2015 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ Zsófia's grade: B+ List of students with a failing grade: João, Emma Distribution of grades by letter: A: 2 students B: 5 students D: 1 student F: 2 students -
dbohdan revised this gist
Dec 11, 2014 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,8 +6,6 @@ package require fileutil sqlite3 db :memory: db eval {CREATE TABLE grades(name TEXT PRIMARY KEY, grade TEXT)} foreach {name grade} [::fileutil::cat grades.txt] { if {![regexp {[A-F][+-]?} $grade]} { puts "Can't parse pair '$name $grade'" -
dbohdan revised this gist
Dec 11, 2014 . 4 changed files with 38 additions and 57 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,15 +0,0 @@ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,27 +0,0 @@ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ #!/usr/bin/env tclsh package require sqlite3 package require fileutil sqlite3 db :memory: db eval {CREATE TABLE grades(name TEXT PRIMARY KEY, grade TEXT)} db function gradeToNumber {} foreach {name grade} [::fileutil::cat grades.txt] { if {![regexp {[A-F][+-]?} $grade]} { puts "Can't parse pair '$name $grade'" exit 1 } db eval {INSERT INTO grades VALUES ($name, $grade)} } puts "Zsófia's grade: [db eval {SELECT grade FROM grades WHERE name="Zsófia"}]" puts "List of students with a failing grade:"; puts [join [ db eval {SELECT name FROM grades WHERE grade >= "E" ORDER BY grade} ] ", "] set grades [db eval { SELECT DISTINCT trim(grade, "+-") FROM grades ORDER BY grade }] puts "Distribution of grades by letter:" foreach grade $grades { puts -nonewline " $grade: " set count [db eval { SELECT count(name) FROM grades WHERE trim(grade, "+-")=$grade }] puts -nonewline "$count student" if {$count > 1} { puts -nonewline "s" } puts "" } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,15 +0,0 @@ -
dbohdan revised this gist
Dec 11, 2014 . No changes.There are no files selected for viewing
-
smls revised this gist
Dec 5, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ my %grade = "grades.txt".IO.lines.map: { say "Zsófia's grade: %grade<Zsófia>"; say "List of students with a failing grade:"; say " " ~ %grade.grep(*.value ge "E")».key.join(', '); say "Distribution of grades by letter:"; say " $(.key): $(+.value) student$("s" if .value != 1)" -
smls created this gist
Dec 5, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ #!/usr/bin/env perl6 my %grade = "grades.txt".IO.lines.map: { m:s/^ (\w+) (<[A..F]><[+-]>?) $/ or die "Can't parse line '$_'"; ~$0 => ~$1 }; say "Zsófia's grade: %grade<Zsófia>"; say "List of students with a failing grade:"; say " " ~ %grade.grep(*.value ge "E")».key.join(', '); say "Distribution of grades by letter:"; say " {.key}: {+.value} student{"s" if .value != 1}" for %grade.classify(*.value.comb[0]).sort(*.key); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ #!/usr/bin/env perl use warnings; use strict; use feature 'say'; use utf8; binmode STDOUT, ":utf8"; open my $fh, '<:utf8', "grades.txt" or die "Failed to open file: $!"; my %grade; while (<$fh>) { m/^ (\w+) \s+ ([A-F][+-]?) $/x or die "Can't parse line '$_'"; $grade{$1} = $2; }; say "Zsófia's grade: $grade{Zsófia}"; say "List of students with a failing grade:"; say " " . join ", ", grep { $grade{$_} ge "E" } keys %grade; say "Distribution of grades by letter:"; my %freq; $freq{substr $grade{$_}, 0, 1}++ for keys %grade; say " $_: $freq{$_} student".($freq{$_} != 1 ? "s" : "") for sort keys %freq; This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ Peter B Celine A- Zsófia B+ João F Maryam B+ 秀英 B- Finn D+ Aarav A Emma F Omar B This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ #!/usr/bin/env perl6 my %grade = "grades.txt".IO.lines.map: { m:s/^ (\w+) (<[A..F]><[+-]>?) $/ or die "Can't parse line '$_'"; ~$0 => ~$1 }; say "Zsófia's grade: %grade<Zsófia>"; say "List of students with a failing grade:"; say " " ~ %grade.grep(*.value ge "E")>>.key.join(', '); say "Distribution of grades by letter:"; say " $(.key): $(+.value) student$("s" if .value != 1)" for %grade.classify(*.value.comb[0]).sort(*.key);