This file contains 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 characters
fn main() { | |
println!("{}", number_of_ones(14)); | |
} | |
/// Given an integer n, count the total number of 1 digits appearing in all non-negative integers less than or equal to n. | |
/// | |
/// Example: | |
/// | |
/// ```bash | |
/// > numberOfOnes(14) |
This file contains 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 characters
use std::iter::repeat; | |
fn main() { | |
println!("{}", long_string(String::from("hello world"), 3)); | |
println!("{}", long_string(String::from("lol"), 10)); | |
} | |
/// Create a loooong teeeext generator that takes in a string and an integer `n`, | |
/// and multiplies the vowels in the string by `n`. | |
/// |
This file contains 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 characters
package main | |
import ( | |
"database/sql" | |
"fmt" | |
"log" | |
"os" | |
_ "github.com/mattn/go-sqlite3" | |
) |
This file contains 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 characters
fn main() { | |
println!( | |
"{:?}", | |
elements_in_container(String::from("|**|*|*|"), 0, 5) | |
); | |
println!( | |
"{:?}", | |
elements_in_container(String::from("|**|*|*|"), 0, 6) | |
); | |
println!( |
This file contains 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 characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
var ( | |
input = []string{"01h00m", "08h15m", "11h30m", "13h45m", "14h10m", "20h05m"} | |
) |
This file contains 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 characters
# echo -n '1,9,87,3,10,4,20,2,45' | tr ',' '\n' | sort -g | tr '\n' ' ' | awk -f longest-seq.awk | |
BEGIN {getline; | |
i = 2 | |
j = 1 | |
while (i < NF) { | |
if ($(i) - $(j) != i - j) { | |
j++ | |
} | |
i++ | |
} |
This file contains 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 characters
package main | |
import ( | |
"fmt" | |
"strings" | |
) | |
type Key struct { | |
val rune | |
left, right, up, down *Key |
This file contains 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 characters
package main | |
import ( | |
"fmt" | |
"io" | |
"log" | |
"net/http" | |
"net/url" | |
"github.com/klauspost/compress/gzhttp" |
This file contains 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 characters
#!/bin/bash | |
TZ=$(awk -F ',' "NR>1 && tolower(\$0) ~ /$1/ {print \$2}" people.csv) date \ | |
"+%H:%M" |
This file contains 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 characters
package main | |
import ( | |
"fmt" | |
"go/ast" | |
"go/parser" | |
"go/token" | |
"log" | |
"os" | |
) |