This file contains 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
ls, out = [line.strip() for line in open('input')], '' | |
for t in xrange(1, int(ls[0]) + 1): | |
st, n = ls[t].split(' ') | |
n, k, l, p, r = int(n), len(st), 0, 1, '' | |
while n >= p: | |
n -= p | |
p *= k | |
l += 1 | |
for i in range(l): | |
r += st[n % k] |
This file contains 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
#include <map> | |
#include <set> | |
#include <list> | |
#include <cmath> | |
#include <ctime> | |
#include <deque> | |
#include <queue> | |
#include <stack> | |
#include <bitset> | |
#include <cstdio> |
This file contains 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
lines, w, out, l, c = [line.strip() for line in open('basketball_game.txt')], ' ', '', 1, 0 | |
while l < lines.__len__(): | |
s = lines[l].split(w) | |
tp, rt, ts = int(s[0]), int(s[1]), int(s[2]) | |
tmp = lines[slice(l + 1, l + tp + 1)] | |
pl = [{'name': i.split(w)[0], 'shot': i.split(w)[1], 'height': i.split(w)[2]} for i in tmp] | |
srtd = sorted(pl, key=lambda k: (k['shot'], k['height']), reverse=True) | |
t1, t2 = srtd[0:][::2], srtd[1:][::2] | |
nt1 = t1[-rt % len(t1):] + t1[:-rt % len(t1)] | |
nt2 = t2[-rt % len(t2):] + t2[:-rt % len(t2)] |
This file contains 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
#ifdef DEBUG | |
#define DLog(...) NSLog(__VA_ARGS__) | |
#else | |
#define DLog(...) /* */ | |
#endif | |
#define ALog(...) NSLog(__VA_ARGS__) | |
#ifdef DEBUG | |
#define DLog(format, ...) NSLog((@"%s [Line %d] " format), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); |
This file contains 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
#ifdef VERBOSE_DEBUG_LOGGING | |
# define NSLog(fmt, ...) NSLog((@"%s(%d) " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); | |
#else | |
# define NSLog(...) | |
#endif |
This file contains 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
- (UIImage *)blurryImage:(UIImage *)image withBlurLevel:(CGFloat)blur { | |
if (blur < 0.f || blur > 1.f) { | |
blur = 0.5f; | |
} | |
int boxSize = (int)(blur * 100); | |
boxSize = boxSize - (boxSize % 2) + 1; | |
CGImageRef img = image.CGImage; | |
vImage_Buffer inBuffer, outBuffer; |
This file contains 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
- (UIImage *)blendOverlay:(UIImage *)topImage withBaseImage:(UIImage *)baseImage toSize:(CGFloat)imageSize | |
{ | |
UIGraphicsBeginImageContext(CGSizeMake(imageSize, imageSize)); | |
[baseImage drawInRect:CGRectMake(0.0, 0.0, imageSize, imageSize)]; | |
[topImage drawInRect:CGRectMake(0.0, 0.0, imageSize, imageSize) blendMode:kCGBlendModeNormal alpha:0.5]; | |
UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
return image; | |
} |
This file contains 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
-(UIImage *) negativeImage | |
{ | |
UIGraphicsBeginImageContext(self.size); | |
CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeCopy); | |
[self drawInRect:CGRectMake(0, 0, self.size.width, self.size.height)]; | |
CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeDifference); | |
CGContextSetFillColorWithColor(UIGraphicsGetCurrentContext(),[UIColor whiteColor].CGColor); | |
CGContextFillRect(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, self.size.width, self.size.height)); | |
UIImage *negativeImage = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); |
This file contains 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
module Paperclip | |
class Blur < Processor | |
def initialize file, options = {}, attachment = nil | |
super | |
@format = File.extname(@file.path) | |
@basename = File.basename(@file.path, @format) | |
end |
This file contains 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
package com.chroman.test; | |
import android.app.DatePickerDialog; | |
import android.content.Context; | |
import android.widget.DatePicker; | |
/** | |
* Created by chroman on 09/10/13. | |
*/ | |