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
| #Tomado de https://stackoverflow.com/questions/8653516/python-list-of-dictionaries-search | |
| dicts = [ | |
| { "name": "Tom", "age": 10 }, | |
| { "name": "Mark", "age": 5 }, | |
| { "name": "Pam", "age": 7 }, | |
| { "name": "Dick", "age": 12 } | |
| ] | |
| next(item for item in dicts if item["name"] == "Pam") | |
| # {'age': 7, 'name': 'Pam'} |
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
| package main | |
| import ( | |
| "fmt" | |
| "strings" | |
| ) | |
| var morseCodes = map[string]string{ | |
| ".-": "A", | |
| "-...": "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 characters
| sudo npm update -g |
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
| package main | |
| import ( | |
| "fmt" | |
| "strings" | |
| ) | |
| func Pyramid(size int) { | |
| for index := 0; index < size; index++ { | |
| fmt.Println(strings.Repeat("*", index)) |
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
| package main | |
| import ( | |
| "fmt" | |
| ) | |
| func Solution(str string) (pairs []string) { | |
| pair := "" | |
| for _, value := range str { | |
| pair += string(value) |
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
| package kata | |
| func QuarterOf(month int) int { | |
| switch month{ | |
| case 1, 2, 3: | |
| return 1 | |
| case 4, 5, 6: | |
| return 2 | |
| case 7, 8, 9: | |
| return 3 |
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 quarter_of(month): | |
| first_quarter = [1, 2, 3] | |
| second_quarter = [4, 5, 6] | |
| third_quarter = [7, 8, 9] | |
| if month in first_quarter: | |
| return 1 | |
| elif month in second_quarter: | |
| return 2 | |
| elif month in third_quarter: |
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
| package kata | |
| import "strings" | |
| func Accum(s string) (result string) { | |
| for i:=0; i<len(s); i++{ | |
| result = result + strings.ToUpper(string(s[i])) | |
| for j:=0; j<i; j++{ | |
| result = result + strings.ToLower(string(s[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
| package main | |
| import "fmt" | |
| func RowSumOddNumbers(n int) int { | |
| return n * n * n | |
| } | |
| func main (){ | |
| fmt.Println(RowSumOddNumbers(13)) // 2197 |
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
| package main | |
| import "fmt" | |
| func SquaresInRect(lng int, wdth int) (result []int) { | |
| if lng == wdth { | |
| return nil | |
| } | |
| for wdth != lng { | |
| if wdth > lng { |