Skip to content

Instantly share code, notes, and snippets.

View pbassut's full-sized avatar

Patrick Bassut pbassut

View GitHub Profile
def is_pandigital(num):
num = str(num)
beg = set(num[0:len(num)])
end = set(num[-len(num):])
if beg != end:
return False
return beg == set(map(str, range(1, len(num) + 1)))
def find_sumpairs(n, numbers):
# This assumes we can't count on the fact that the array will be sorted
# So, sort it to make sure. Not that this could be skipped and save an O(n log n)
best_case = sorted(numbers, reverse=True)
if (n / 2) > best_case[0]:
# if in a descending sorted array the left-most element
# is less than a half the number we're looking for,
# we can guarantee that the next number won't add up to n.
# So skip here
return False
@pbassut
pbassut / gist:7b3614d2d1d15afc8ee9
Last active September 16, 2015 14:07
Exercise 1
def count(numbers):
result = []
for index, each in enumerate(numbers):
cpy = list(numbers)
del cpy[index]
result.append(reduce(lambda x, y: x * y, cpy))
return result
const int greenLEDPin = 9;
const int redLEDPin = 11;
const int blueLEDPin = 10;
void changeLED(int r, int g, int b) {
analogWrite(greenLEDPin, r);
analogWrite(redLEDPin, g);
analogWrite(blueLEDPin, b);
}
#include <iostream>
#include <sstream>
#include <algorithm>
using namespace std;
bool isTheGreatest(int x, int y){
static int greastest = 0;
if(x * y > greastest){
greastest = x * y;
https://gist.github.com/pbassut/d7f483399d3a9df1f394#include <stdio.h>
#include <stdlib.h>
bool dividerBy(char *number, int divider);
int main(){
int flag = 0;
char year[1000];
bool leap, huluculu, bulukulu;
#include <stdio.h>
#include <stdlib.h>
bool dividerBy(char *number, int divider);
int main(){
int flag = 0;
char year[1000];
bool leap, huluculu, bulukulu;
(
"<NSLayoutConstraint:0x7fdc79679380 H:[UIButton:0x7fdc796797b0(63)]>",
"<NSLayoutConstraint:0x7fdc79688fd0 H:[UIView:0x7fdc79688df0(1)]>",
"<NSLayoutConstraint:0x7fdc7967ab20 H:[UIButton:0x7fdc7967a950(140)]>",
"<NSLayoutConstraint:0x7fdc79689530 H:[UIView:0x7fdc79689450(1)]>",
"<NSLayoutConstraint:0x7fdc7967afe0 H:[UIButton:0x7fdc7967ada0(75)]>",
"<NSLayoutConstraint:0x7fdc79689b50 H:|-(8)-[UIButton:0x7fdc796797b0] (Names: '|':UIView:0x7fdc79688b70 )>",
"<NSLayoutConstraint:0x7fdc79689c40 H:[UIView:0x7fdc79688780]-(236)-| (Names: '|':UIView:0x7fdc79688b70 )>",
"<NSLayoutConstraint:0x7fdc79689c90 UIView:0x7fdc79688780.trailing == UIView:0x7fdc79688df0.trailing + 2>",
"<NSLayoutConstraint:0x7fdc79689d80 H:[UIButton:0x7fdc796797b0]-(8)-[UIView:0x7fdc79688c50]>",
2015-02-28 04:30:32.863 InRadar[8673:613] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSLayoutConstraint:0x7fca2a51ee10 H:[UIButton:0x7fca2a51fa50(63)]>",
"<NSLayoutConstraint:0x7fca2a531550 H:[UIView:0x7fca2a531370(1)]>",
"<NSLayoutConstraint:0x7fca2a520e40 H:[UIButton:0x7fca2a520c70(140)]>",
"<NSLayoutConstraint:0x7fca2a531ab0 H:[UIView:0x7fca2a5319d0(1)]>",
"<NSLayoutConstraint:0x7fca2a5212a0 H:[UIButton:0x7fca2a521080(75)]>",
"<NSLayoutConstraint:0x7fca2a532120 H:|-(8)-[UIButton:0x7fca2a51fa50] (Names: '|':UIView:0x7fca2a5310f0 )>",
<script>
$("#my_upload_form").bind("submit", function() {
var ext = $('#my_file_field').val().split('.').pop().toLowerCase();
if($.inArray(ext, ['gif','png','jpg','jpeg']) == -1) {
alert('invalid extension!');
}
});
</script>