Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

RomyRomy syntacticsugar

🎯
Focusing
View GitHub Profile
@syntacticsugar
syntacticsugar / Detect_Pangram.rb
Created Apr 9, 2020
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…
View Detect_Pangram.rb
#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
View give_me_a_diamond.rb
=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.
View consonant_value_add.js
/*
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
View consonant_value_add.js
/*
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
For an array of socks, return the total number of matching pairs. (integer represents a unique color)
View matchingPairs.py
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 Apr 4, 2019
wherein i learn about my first monad.
View marvelous_monadic_mischief.elm
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 Mar 18, 2019
Locations. Traveling Salesman problem ? Create a function that returns an array of arrays where the inner arrays are the groups
View intersectionOfPlaces.rb
# 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' => [],
View .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
View gist:2011138b1b2a8411d8911853603f8d52
// © 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 Mar 1, 2017 — forked from kkoch986/MultiSelect.jsx
A MultiSelect prototype for Material UI (v.0.14.4)
View MultiSelect.jsx
/**
* 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>
You can’t perform that action at this time.