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 characters
| SELECT strftime('%Y-W%V', current_timestamp, '-3 days', 'weekday 4') as period; |
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 characters
| #!/bin/python3 | |
| import math | |
| import os | |
| import random | |
| import re | |
| import sys | |
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 characters
| """ | |
| Don't Get Volunteered! | |
| ====================== | |
| As a henchman on Commander Lambda's space station, you're expected to be resourceful, smart, and a quick thinker. It's not easy building a doomsday device and ordering the bunnies around at the same time, after all! In order to make sure that everyone is sufficiently quick-witted, Commander Lambda has installed new flooring outside the henchman dormitories. It looks like a chessboard, and every morning and evening you have to solve a new movement puzzle in order to cross the floor. That would be fine if you got to be the rook or the queen, but instead, you have to be the knight. Worse, if you take too much time solving the puzzle, you get "volunteered" as a test subject for the LAMBCHOP doomsday device! | |
| To help yourself get to and from your bunk every day, write a function called solution(src, dest) which takes in two parameters: the source square, on which you start, and the destination square, which is where you need to land to solve the puzzle. The funct |
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 characters
| def solution(s): | |
| acc = s[0] | |
| while len(acc) < len(s): | |
| while len(s) % len(acc) != 0: | |
| acc = s[:len(acc)+1] | |
| steps = len(s) // len(acc) | |
| for i in range(1, steps): | |
| if s[i * len(acc):(i + 1) * len(acc)] != acc: | |
| acc = s[:(i * len(acc))+1] | |
| break |
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 characters
| /* | |
| Given a binary string str, the task is to print the numbers of steps required to convert it to one by the following operations: | |
| If ‘S’ is odd add 1 to it. | |
| If ‘S’ is even divide it by 2. | |
| */ | |
| package main | |
| func main() { |
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 characters
| func argSetter(index int, newVal interface{}) func(args mock.Arguments) { | |
| return func(args mock.Arguments) { | |
| // get dest arg | |
| dest := args.Get(index) | |
| // inspect | |
| ptr := reflect.ValueOf(dest) | |
| // dereference | |
| val := ptr.Elem() |
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 characters
| // an in-place solution of Squares of a Sorted Array problem | |
| // https://leetcode.com/problems/squares-of-a-sorted-array/ | |
| func sortedSquares(A []int) []int { | |
| // [-3,-2,0, 1, 2] | |
| size := len(A) | |
| for i := 0; i < size; i++ { | |
| A[i] *= A[i] |
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 characters
| vowels = set('aıoueəiöüAIOUEƏİÖÜ') | |
| def songify(line): | |
| i = next(i for i in range(len(line)) if line[i] in vowels) | |
| syllable = line[:i+1] | |
| prefix = '-'.join([syllable] * 3) | |
| return prefix + ' ' + line | |
| lyrics = """ | |
| Nəşəni çəkdim |
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 characters
| // JoinURLs joins base URL and paths safely | |
| // No worries for extra or missing slashes | |
| func JoinURLs(baseURL string, paths ...string) string { | |
| if len(paths) == 0 { | |
| return baseURL | |
| } | |
| joint := strings.TrimRight(baseURL, "/") | |
| for _, path := range paths { | |
| joint += "/" + strings.TrimLeft(path, "/") |
NewerOlder