Skip to content

Instantly share code, notes, and snippets.

View syntacticsugar's full-sized avatar
🎯
Focusing

RomyRomy syntacticsugar

🎯
Focusing
View GitHub Profile
@syntacticsugar
syntacticsugar / Detect_Pangram.rb
Created April 9, 2020 03:37
A pangram is a sentence that contains every single letter of the alphabet at least once. For example, the sentence "The quick brown fox jumps over the lazy dog" is a pangram, because it uses the letters A-Z at least once (case is irrelevant). Given a string, detect whether or not it is a pangram. Return True if it is, False if not. Ignore number…
#https://www.codewars.com/kata/545cedaa9943f7fe7b000048/train/ruby
def panagram? str
chars_only = ->(string) {string.split('').map(&:downcase).uniq.select{ |c| c =~ /[[:alpha:]]/ }}
chars_only[str].size.eql? 26
end
def panagram?(string)
('a'..'z').all? { |x| string.downcase.include? (x) }
end
@syntacticsugar
syntacticsugar / give_me_a_diamond.rb
Created March 18, 2020 03:14
"Give me a Diamond"
=begin
https://www.codewars.com/kata/5503013e34137eeeaa001648/train/ruby
Give me a Diamond
Jamie is a programmer, and James' girlfriend. She likes diamonds, and wants a diamond string from James. Since James doesn't know how to make this happen, he needs your help.
Task
You need to return a string that looks like a diamond shape when printed on the screen, using asterisk (*) characters. Trailing spaces should be removed, and every line must be terminated with a newline character (\n).
Return null/nil/None/... if the input is an even number or negative, as it is not possible to print a diamond of even or negative size.
@syntacticsugar
syntacticsugar / consonant_value_add.js
Created March 11, 2020 21:48
Codewars Javascript:
/*
Given a lowercase string that has alphabetic characters only and no spaces, return the highest value of consonant substrings. Consonants are any letters of the alpahabet except "aeiou".
We shall assign the following values: a = 1, b = 2, c = 3, .... z = 26.
For example, for the word "zodiacs", let's cross out the vowels. We get: "z o d ia cs"
-- The consonant substrings are: "z", "d" and "cs" and the values are z = 26, d = 4 and cs = 3 + 19 = 22. The highest is 26.
solve("zodiacs") = 26
@syntacticsugar
syntacticsugar / consonant_value_add.js
Created March 11, 2020 21:48
Codewars Javascript
/*
Given a lowercase string that has alphabetic characters only and no spaces, return the highest value of consonant substrings. Consonants are any letters of the alpahabet except "aeiou".
We shall assign the following values: a = 1, b = 2, c = 3, .... z = 26.
For example, for the word "zodiacs", let's cross out the vowels. We get: "z o d ia cs"
-- The consonant substrings are: "z", "d" and "cs" and the values are z = 26, d = 4 and cs = 3 + 19 = 22. The highest is 26.
solve("zodiacs") = 26
@syntacticsugar
syntacticsugar / matchingPairs.py
Last active May 11, 2019 18:03
For an array of socks, return the total number of matching pairs. (integer represents a unique color)
n = 7
arr = [ 1,2,1,2,1,3,2 ]
def matchingPairs(qty,socks):
pairs = 0
counts = {}
for s in socks:
if s in counts:
counts[s] += 1
@syntacticsugar
syntacticsugar / marvelous_monadic_mischief.elm
Created April 4, 2019 15:40
wherein i learn about my first monad.
module Main exposing (main)
import Browser
import Html exposing (Html, button, div, text)
import Html.Events exposing (onClick)
type alias Model =
{ count : Int }
@syntacticsugar
syntacticsugar / intersectionOfPlaces.rb
Created March 18, 2019 21:29
Locations. Traveling Salesman problem ? Create a function that returns an array of arrays where the inner arrays are the groups
# sometimes, we get data that is not fully populated
# eg Boston <> New York appears, and so does New York <> Boston,
# but Berlin <> Munich appears, though not Munich <> Berlin
locations = {
'new york' => [ 'boston', 'philly' ],
'boston' => [ 'new york' ],
'philly' => [ 'new york' ],
'paris' => [ 'amsterdam', 'berlin' ],
'berlin' => [ 'paris', 'munich' ],
'amsterdam' => [],
@syntacticsugar
syntacticsugar / .vimrc
Created December 5, 2018 16:15
.vimrc
"this is the .vimrc for the mac terminal...
" important, let mapleader has to go first here..
"Sun Mar 3 19:30:06 2013
" execute pathogen#infect()
"set nowrap
let mapleader=","
"Thu Feb 18 16:31:32 EST 2016
@syntacticsugar
syntacticsugar / gist:2011138b1b2a8411d8911853603f8d52
Created March 7, 2017 17:02 — forked from sapegin/gist:1735915
CSS vendor prefixes for Stylus
// © 2011 Artem Sapegin http://sapegin.ru
// Simple CSS3 properties with vendor prefixes
box-sizing()
-moz-box-sizing arguments
box-sizing arguments
box-shadow()
-webkit-box-shadow arguments
@syntacticsugar
syntacticsugar / MultiSelect.jsx
Created March 1, 2017 22:32 — forked from kkoch986/MultiSelect.jsx
A MultiSelect prototype for Material UI (v.0.14.4)
/**
* Material UI multi select
*
* Use with:
* <MultiSelect fullWidth={true} value={this.state.values} onChange={(e,v) => this.setState({values: v})}>
* <ListItem primaryText={"Option 1"} value={1} />
* <ListItem primaryText={"Option 2"} value={2} />
* <ListItem primaryText={"Option 3"} value={3} />
* <ListItem primaryText={"Option 4"} value={4} />
* </MultiSelect>