для save_contact не потрібно вказувати id в INSERT
https://stackoverflow.com/questions/934 … sqlite-row
for k, contact in enumerate(contact_list):
тут логічніше вивести id як на мене, тоді з видаленням простіше
Ви не увійшли. Будь ласка, увійдіть або зареєструйтесь.
Ласкаво просимо вас на україномовний форум з програмування, веб-дизайну, SEO та всього пов'язаного з інтернетом та комп'ютерами.
Будемо вдячні, якщо ви поділитись посиланням на Replace.org.ua на інших ресурсах.
Для того щоб створювати теми та надсилати повідомлення вам потрібно Зареєструватись.
Український форум програмістів → Повідомлення користувача Voron
для save_contact не потрібно вказувати id в INSERT
https://stackoverflow.com/questions/934 … sqlite-row
for k, contact in enumerate(contact_list):
тут логічніше вивести id як на мене, тоді з видаленням простіше
Немає респонсиву для меню (лінки випадають з шапки)
Сторінки jobs, articles, contact немають респонсиву
Меню може бути погано видно (чорний на сірому)
Немає empty тексту або нереалізована сторінка blade_blanks
Немає метатегу description, немає метатегів og:title, og:description
Немає favicon
я можу перекласти кілька задач
google запустив сервіс з продажу доменних імен - http://domains.google.com/
Доброго дня. Пропоную вашій увазі програму яку я написав для масового редагування світлин.
Програма дає змогу змінити розширення та орієнтацію для всіх світлин у вказаній папці. Програма не замінює оригінальні файли, а сторює нову папку з відредагованими світлинами.
Використані бібліотеки: gtk, gobject, threading, os, shutil, PIL та інші
Програма тестувалася на Linux Mint 15
Інтерфейс:
Програма може бути цікава також тим хто цікавиться ООП, редагуванням фото за допоможою Python, ниттєвим програмуванням, використанням gtk для графічного ітенфейса.
Іконка додаються, лінк на відео з роботою програми - https://dl.dropboxusercontent.com/u/620 … 0%3A57.mkv
Код:
#!/usr/bin/env python
# This Python file uses the following encoding: utf-8
import gtk
import gobject
import threading
import os
import shutil
from time import time
from PIL import Image
resolution = 1600
orientacion = 0
class MainWin:
def destroy(self, widget, data=None):
print "{0:.3f}".format(time()-start_time), ":", "destroy signal occurred"
gtk.main_quit()
def change_resolution(self, widget):
global resolution
resolution = int(self.combo1.get_active_text());
def change_orientacion(self, widget):
global orientacion
orientacion = int(self.combo2.get_active_text());
def on_folder_clicked(self, widget):
dialog = gtk.FileChooserDialog("Please choose a folder",
None,
gtk.FILE_CHOOSER_ACTION_OPEN,
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
gtk.STOCK_OPEN, gtk.RESPONSE_OK))
dialog.set_default_size(800, 400)
dialog.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
response = dialog.run()
if response == gtk.RESPONSE_OK:
folder = dialog.get_filename()
print "{0:.3f}".format(time()-start_time), "Select clicked"
print "{0:.3f}".format(time()-start_time), ":", "Folder selected: " + folder
os.chdir(folder)
dialog.destroy()
directory = folder + '/new'
if not os.path.exists(directory):
os.makedirs(directory)
print "{0:.3f}".format(time()-start_time), ":", "Create folder: " + directory
thread = threading.Thread(target=self.processing_images, args=(os.listdir("."), directory,))
thread.setDaemon(True)
thread.start()
elif response == gtk.RESPONSE_CANCEL:
print "{0:.3f}".format(time()-start_time), ":", "Cancel clicked"
def processing_images(self, filess, directory):
i = 0
for files in filess:
if files.endswith(".jpg") or files.endswith(".JPG"):
try:
img = Image.open(files)
ratio = 1.0*img.size[0]/img.size[1]
if ratio >= 1:
img = img.resize((resolution,int(resolution/ratio)), Image.ANTIALIAS)
else:
img = img.resize((int(resolution*ratio),resolution), Image.ANTIALIAS)
img = img.rotate(orientacion, expand=True)
img.save(directory + '/' + files)
i += 1
gobject.idle_add(self.set_progress_bar_fraction, i, len(filess)-1)
print "{0:.3f}".format(time()-start_time), 'resize', files, 'to', resolution, 'and rotate to', orientacion
except Exception,e:
print "{0:.3f}".format(time()-start_time), ":", str(e), 'with file:', files
def set_progress_bar_fraction(self, i, n):
self.progressbar.set_text(str(i) + ' from ' + str(n))
self.progressbar.set_fraction(1.0*i/n)
def __init__(self):
global start_time
gtk.gdk.threads_init()
start_time = time()
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_title('Photo processing')
self.window.set_size_request(270,80)
self.window.set_border_width(10)
color = gtk.gdk.color_parse('#777')
self.window.modify_bg(gtk.STATE_NORMAL, color)
try:
self.window.set_icon_from_file("test.png")
except Exception,e:
print "{0:.3f}".format(time()-start_time), ":", str(e)
self.window.connect("destroy", self.destroy)
self.b_open = gtk.Button("Select folder")
self.b_open.connect("clicked", self.on_folder_clicked)
self.combo1 = gtk.combo_box_new_text()
self.combo1.append_text("800")
self.combo1.append_text("1024")
self.combo1.append_text("1600")
self.combo1.append_text("2400")
self.combo1.set_active(2)
self.combo1.set_size_request(40,30)
self.combo1.connect('changed', self.change_resolution)
self.combo2 = gtk.combo_box_new_text()
self.combo2.append_text("0")
self.combo2.append_text("90")
self.combo2.append_text("180")
self.combo2.append_text("270")
self.combo2.set_active(0)
self.combo2.set_size_request(40,30)
self.combo2.connect('changed', self.change_orientacion)
self.progressbar = gtk.ProgressBar(adjustment=None)
self.vbox = gtk.VBox(spacing=6)
self.hbox = gtk.HBox()
self.hbox.pack_start(self.combo1)
self.hbox.pack_start(self.combo2)
self.hbox.pack_start(self.b_open)
self.vbox.pack_start(self.hbox, False)
self.vbox.pack_start(self.progressbar, False)
self.window.add(self.vbox)
self.window.show_all()
def main(self):
gtk.main()
if __name__ == "__main__":
MainWin().main()
Якщо вас цікавлять нетипові задачі з програмування математичного спрямування спробуйте Projecteuler - http://projecteuler.net/
Тут є переклад задач на російську - http://euler.jakumo.org/
Папірці можливо не потрібні, але знання...
Кілька днів тому закінчив курс з Пітону, наразі можу писати прості програми, хоча раніше пітону не знав.
Зараз проходжу курс Startup Engineering на coursera.org - розповідають про віртуальні виділені сервери Amazon, про github.com , http://heroku.com/ а також про node.js
Ще на курсері зараз йдуть курси з криптографії та дискретної оптимізації.
У першій задачі наскільки зрозумів потрібно рахувати через трикутник Паскаля - http://uk.wikipedia.org/wiki/Трикутник_Паскаля
Dead Pixels 45 points
John's friend Peter purchases a new high resolution monitor with dimension W * H where W is the number of pixels in each row (i.e. width) and H is the number of pixels in each column (i.e. height).
However, there are N dead pixels on the monitor. The i-th dead pixel is located at (x[і], y[і]). (0, 0) is the top-left pixel and (W - 1, H - 1) is the bottom-right pixel. The locations of the dead pixels could be generated by 6 given integers X, Y, a, b, c and d by the following rules. If 2 pixels are at the same location, they are considered the same. It is possible that there are less than N distinct dead pixels.
x[0] = X
y[0] = Y
x[і] = (x[i - 1] * a + y[i - 1] * b + 1) % W (for 0 < i < N)
y[і] = (x[i - 1] * c + y[i - 1] * d + 1) % H (for 0 < i < N)
Peter connects his monitor to his computer and opens an image with dimension P (width) * Q (height). How many unique positions can the image be placed so that it can be displayed perfectly (i.e. all pixels of the picture are shown on the monitor)? The image cannot be rotated.
Input
The first line contains an integer T, which is the number of test cases. Then T test cases follow. Each test case contains 11 integers W, H, P, Q, N, X, Y, a, b, c, d.
Output
For each of the test cases numbered in order from 1 to T, output "Case #", followed by the case number (with 1 being the first test case), followed by ": ", followed by an integer which is the number of different possible positions for the poster.
Constraints
1 ≤ T ≤ 20
1 ≤ W, H ≤ 40 000
1 ≤ P ≤ W
1 ≤ Q ≤ H
1 ≤ N ≤ min(1 000 000, W * H)
1 ≤ a, b, c, d ≤ 100
0 ≤ X < W
0 ≤ Y < H
Example input
5
4 4 2 2 1 0 2 1 2 3 4
4 4 1 1 3 1 1 2 2 2 2
6 10 3 2 2 0 0 5 4 3 2
16 18 5 1 5 10 8 21 27 29 87
14 15 12 4 4 3 5 84 74 53 68
Example output
Case #1: 7
Case #2: 15
Case #3: 32
Case #4: 197
Case #5: 16
Security 35 points
You are designing a new encryption system that works in the following way:
For server-client communication you need a key k, composed of m sections, each of length l, and the key consists only of lowercase characters in the set {a, b, c, d, e, f}. The server has a key k1 and the client has a key k2 where:
k1 = f(k). f is a function that receives a key and replace some random letters by ? indicating that those characters can be any lowercase letter of the set described before.
k2 = f(g(k)). g is a function that takes a key and produces a random permutation of its m sections. And f is the function defined above.
For example: let m = 3, l = 2
f('abacbc') = '?ba??c'
g('abacbc') = 'acbcab' (each section was moved one place to the left).
Your task is given k1 and k2, find key k. If there are several solutions, print the lexicographically smallest key. And if there is no solution at all, print "IMPOSSIBLE" (without the quotes).
Input description:
The first line has a single integer T, which corresponds to the number of test cases. T test cases follows: the first line of the test case corresponds to the integer m, the second line contains the string k1 and the third line contains the string k2.
Constraints:
T <= 20
0 < |k1| <= 100
0 < m <= 50
|k2| = |k1|
It is guaranteed that m is always a divisor of |k1|
k1 and k2 consist of {a, b, c, d, e, f, ?}
Output description:
For test case i, numbered from 1 to T, output "Case #i: ", followed by the lexicographically smallest key or "IMPOSSIBLE".
Example input
5
2
abcd
c?ab
3
ab?c?c
ac?c??
3
ab?c?c
aabbdd
2
aa
bb
2
abcd
cdab
Example output
Case #1: abcd
Case #2: abacac
Case #3: IMPOSSIBLE
Case #4: IMPOSSIBLE
Case #5: abcd
Card Game (20 points)
John is playing a game with his friends. The game's rules are as follows: There is deck of N cards from which each person is dealt a hand of K cards. Each card has an integer value representing its strength. A hand's strength is determined by the value of the highest card in the hand. The person with the strongest hand wins the round. Bets are placed before each player reveals the strength of their hand.
John needs your help to decide when to bet. He decides he wants to bet when the strength of his hand is higher than the average hand strength. Hence John wants to calculate the average strength of ALL possible sets of hands. John is very good at division, but he needs your help in calculating the sum of the strengths of all possible hands.
Problem
You are given an array a with N ≤ 10 000 different integer numbers and a number, K, where 1 ≤ K ≤ N. For all possible subsets of a of size K find the sum of their maximal elements modulo 1 000 000 007.
Input
The first line contains the number of test cases T, where 1 ≤ T ≤ 25
Each case begins with a line containing integers N and K. The next line contains N space-separated numbers 0 ≤ a [і] ≤ 2 000 000 000, which describe the array a.
Output
For test case i, numbered from 1 to T, output "Case #i: ", followed by a single integer, the sum of maximal elements for all subsets of size K modulo 1 000 000 007.
Example
For a = [3, 6, 2, 8] and N = 4 and K = 3, the maximal numbers among all triples are 6, 8, 8, 8 and the sum is 30.
Example input
5
4 3
3 6 2 8
5 2
10 20 30 40 50
6 4
0 1 2 3 5 8
2 2
1069 1122
10 5
10386 10257 10432 10087 10381 10035 10167 10206 10347 10088
Example output
Case #1: 30
Case #2: 400
Case #3: 103
Case #4: 1122
Case #5: 2621483
Я у себе примонтував папку з локальними сайтами з розділу з Ubuntu на розділ з Mint. Прописав в fstab
/media/L/opt/lampp/htdocs /opt/lampp/htdocs none defaults,bind 0 0
(перед цим примонтував розділ L)
i am sick today (:"()"
Незбалансований, але лише тому що " - недопустимі.
Як на мене zenity досить зручно і просто.
Використав в одному скрипті, який інформує мене про зміну певного файлу.
У другому завданні мене смущають 3-й, 4-й приклади
Yes - тому що:
- A message with balanced parentheses followed by another message with balanced parentheses.
- An open parenthesis '(', followed by a message with balanced parentheses, followed by a close parenthesis ')'.
i am sick today - збалансовано - збалансовано
P.S. Загалом я пройшов у наступний тур які відбудеться цими вихідними.
У першому завданні на:
Я відповів:
Для другого завдання потрібна рекурсія.
Моє рішення на Delphi (Lazarus):
Скрін вікна програми:
P.S. Для мене зручніше скопіпастити вміст вхідного і вихідного файлів, ніж працювати з файлами на пряму - так простіше контролювати роботу програми.
Задача №3
Find the Min (45 points)
After sending smileys, John decided to play with arrays. Did you know that hackers enjoy playing with arrays? John has a zero-based index array, m, which contains n non-negative integers. However, only the first k values of the array are known to him, and he wants to figure out the rest.
John knows the following: for each index i, where k <= i < n, m[і] is the minimum non-negative integer which is *not* contained in the previous *k* values of m.
For example, if k = 3, n = 4 and the known values of m are [2, 3, 0], he can figure out that m[3] = 1.
John is very busy making the world more open and connected, as such, he doesn't have time to figure out the rest of the array. It is your task to help him.
Given the first k values of m, calculate the nth value of this array. (i.e. m[n - 1]).
Because the values of n and k can be very large, we use a pseudo-random number generator to calculate the first k values of m. Given positive integers a, b, c and r, the known values of m can be calculated as follows:
m[0] = a
m[і] = (b * m[i - 1] + c) % r, 0 < i < k
Input
The first line contains an integer T (T <= 20), the number of test cases.
This is followed by T test cases, consisting of 2 lines each.
The first line of each test case contains 2 space separated integers, n, k (1 <= k <= 105, k < n <= 109).
The second line of each test case contains 4 space separated integers a, b, c, r (0 <= a, b, c <= 109, 1 <= r <= 109).
Output
For each test case, output a single line containing the case number and the nth element of m.
Example input
5
97 39
34 37 656 97
186 75
68 16 539 186
137 49
48 17 461 137
98 59
6 30 524 98
46 18
7 11 9 46
Example output
Case #1: 8
Case #2: 38
Case #3: 41
Case #4: 40
Case #5: 12