Skip to content

Instantly share code, notes, and snippets.

View dscataglini's full-sized avatar

Diego Scataglini dscataglini

View GitHub Profile
@dscataglini
dscataglini / justing_myer.rb
Created February 7, 2022 21:50
fizz buzz using Noise class
class Noise
def consider(number)
return 'fizzbuzz' if number % 15 == 0
return 'fizz' if number % 3 == 0
return 'buzz' if number % 5 == 0
number
end
end
noise = Noise.new
Task
You will be given an array of numbers. You have to sort the odd numbers in ascending order while leaving the even numbers at their original positions.
Examples
[7, 1] => [1, 7]
[5, 8, 6, 3, 4] => [3, 8, 6, 5, 4]
[9, 8, 7, 6, 5, 4, 3, 2, 1, 0] => [1, 8, 3, 6, 5, 4, 7, 2, 9, 0]
[Sample Input]
A 4
B 3
X 5
[Sample output]
AAAA
BBB AAAA BBB
CC BBB AAAA BBB CC
D CC BBB AAAA BBB CC D
Your task is to make a function that can take any non-negative integer as an argument and return it with its digits in descending order.
Essentially, rearrange the digits to create the highest possible number.
Examples:
Input: 42145 Output: 54421
Input: 145263 Output: 654321
Input: 123456789 Output: 987654321
Sample Data:
//randomly generate 1 to 20 numbers with values between 0 and 1000.
2 4 6 8 10 12 14
1 2 3 4 5 6 7 8 9
2 10 20 21 23 24 40 55 60 61
Sample Output:
//perhaps print out your randomly generated array one here so we can compare odds and evens
Odds - []
class BitmapEditor
VALID_SIZE_RANGE = (1..250)
DEFAULT_COLOR = 'O'
def clear(c = cols, r = rows)
return unless VALID_SIZE_RANGE === r &&
VALID_SIZE_RANGE === c
@bitmap = Array.new(r) { Array.new(c) { DEFAULT_COLOR }}
end
@dscataglini
dscataglini / tinder-api-documentation.md
Created October 7, 2015 17:43 — forked from rtt/tinder-api-documentation.md
Tinder API Documentation

Tinder API documentation

http://rsty.org/

I've sniffed most of the Tinder API to see how it works. You can use this to create bots (etc) very trivially. Some example python bot code is here -> https://gist.github.com/rtt/5a2e0cfa638c938cca59 (horribly quick and dirty, you've been warned!)

Note: this was written in April/May 2014 and the API may have changed since

API Details

/* Generated by Opal 0.8.0.beta1 */
(function(Opal) {
Opal.dynamic_require_severity = "error";
function $rb_plus(lhs, rhs) {
return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs);
}
function $rb_times(lhs, rhs) {
return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs * rhs : lhs['$*'](rhs);
}
function $rb_minus(lhs, rhs) {
<html>
<head>
<style>
#container li{ font: 12pt/14pt Times; color: blue; }
ul.list li.item { font-size: 14pt; font-weight: bold; font-family: Verdana; }
</style>
</head>
<body>
<div id="container">
<ul class="list">
@dscataglini
dscataglini / pairs
Created December 19, 2013 16:04
Finding Pairs Given N integers, count the total pairs of integers that have a difference of K. Sample Input #00: k = 2 n = 1 5 3 4 2 Sample Output #00: 3 Sample Input #01: k = 1 n = 363374326 364147530 61825163 1073065718 1281246024 1399469912 428047635 491595254 879792181 1069262793 Sample Output #01: 0
require 'test/unit'
# Head ends here
def pairs( a,k)
#a is an array containing numbers and k is the difference.
end
class PairTest < Test::Unit::TestCase
def test_small_occurances
assert_equal 3, pairs([1, 5, 3, 4, 2], 2)