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 create_phone_number(n): | |
| f = "".join(map(str, n[0:3]) ) | |
| s = "".join(map(str, n[3:6]) ) | |
| t = "".join(map(str, n[6:10]) ) | |
| return "("+f+") "+ s +"-"+t | |
| ######## Refactored ##### | |
| def create_phone_number(n): |
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 count_sheeps(arrayOfSheeps): | |
| return arrayOfSheeps.count(True) |
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
| require 'active_support/all' | |
| def song_decoder(song) | |
| song.gsub(/WUB/, " ").squish! | |
| end |
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 song_decoder(song): | |
| return " ".join(song.replace("WUB", " ").split()) |
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 no_space(x): | |
| return x.replace(' ' ,'') |
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 isValidWalk(walk) | |
| walk.count == 10 && walk.count('n') == walk.count('s') && walk.count('e') == walk.count('w') | |
| end |
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(string): | |
| return string[::-1] |
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
| defmodule Codewars.Zoo do | |
| def monkey_count(n) do | |
| Enum.to_list(1..n) | |
| end | |
| end |
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 longest_consec(strarr, k): | |
| n = len(strarr) | |
| if n == 0 or k > n or k <= 0: | |
| return '' | |
| return sorted([''.join(strarr[i:i+k]) for i in range(0, n-k+1)], key=len, reverse=True)[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 characters
| defmodule Longestconsec do | |
| def longest_consec(strarr, k) | |
| when length(strarr) == 0 | |
| when k > length(strarr) | |
| when k <= 0, | |
| do: "" | |
| def longest_consec(strarr, k) do | |
| Enum.chunk_every(strarr, k, 1) |