This file contains hidden or 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
class Descriptor: | |
def __get__(self, instance, *args): | |
return getattr(instance, self.attribute_name, 'None') | |
def __set__(self, instance, value): | |
setattr(instance, self.attribute_name, value) | |
def __delete__(self, instance): | |
delattr(instance, self.attribute_name) | |
def __set_name__(self, owner, name): | |
self.attribute_name = name + "_hidden_part" |
This file contains hidden or 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
class Desc: | |
def __set_name__(self, owner, name): | |
self.field_name = name | |
def __get__(self, instance, *args): | |
if self.field_name in instance.__dict__.keys(): | |
return instance.__dict__[self.field_name] | |
else: | |
return "NoneDescriptor" | |
def __set__(self, instance, value, *args): | |
instance.__dict__[self.field_name] = value |
This file contains hidden or 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
class Desc: | |
def __set_name__(self, owner, name): | |
self.field_name = name | |
def __get__(self, instance, *args): | |
if self.field_name in instance.__dict__.keys(): | |
return instance.__dict__[self.field_name] | |
else: | |
return "NoneDescriptor" | |
def __set__(self, instance, value, *args): | |
instance.__dict__[self.field_name] = value |
This file contains hidden or 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
from inspect import getmembers, isroutine | |
class Descriptor: | |
def __init__(self, value): | |
self.value = value | |
def __get__(self, instance, owner): | |
print("get") |
This file contains hidden or 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
/* | |
* MinIO Go Library for Amazon S3 Compatible Cloud Storage | |
* Copyright 2015-2017 MinIO, Inc. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* |
This file contains hidden or 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
fn main() { | |
} | |
/// Find a duplicate in array in O(N), with in-place modifications. | |
/// Iterate over the first N items. On meeting a value {v}, try to insert it | |
/// to index {v}, but before that, check if {input[v] == v} - if yes, return {v} as | |
/// the answer. | |
/// Finally, if nothing was found, then by birthday paradox, the last element repeats | |
/// some other element in the array. | |
fn solve(mut input: Vec<i32>) -> i32 { |
This file contains hidden or 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
struct Node { | |
left: Option<Box<Node>>, | |
right: Option<Box<Node>>, | |
value: i32, | |
l_size: usize, | |
r_size: usize, | |
reps: usize, | |
} | |
struct Tree { |