由买买提看人间百态

topics

全部话题 - 话题: append
1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
r*****y
发帖数: 199
1
来自主题: Statistics版 - 一个SAS Macro和Append的问题,救助!
简单来说,我要每次simulation生成一个dataset A,对A做一些分析,一共
simulate100000次,因为每次生成的A太大,所以不方便直接生成一个含有100000个A叠
加起来的dataset。具体code如下:
%MACRO DOIT(N);
%DO sim=1 %TO &N;
...这里generate A(每次seed=sim);
ods output ParameterEstimates=B;
proc phreg data=A;
...
proc append base=B_all data=B;
run;
%END;
%MEND DOIT;
就是不知道为什么append不起来我要的data,有没有熟悉macro和append的高手指点一
下,另外如果append的base是空白,就想把每个macro循环生成的B 放到一个新的
dataset里面,有没有更好更简单的方法呢?
r*****y
发帖数: 199
2
来自主题: Statistics版 - 一个SAS Macro和Append的问题,救助!
具体问题是append可以,但是只能append一个循环的结果,貌似每次的结果没有output
到dataset里面,我希望的是一次循环出来的summary成为append的dataset的一条
observation记录。
w********n
发帖数: 6
3
in GUI, a Form SearchForm for searching, TextField input for input key word.
but after search once, when go back search again, it throws
java.lang.IllegalStateException, it can't append form. why? The 1st round is
ok, but never can run the 2nd time.
searchForm.append(input);
g***y
发帖数: 11
4
来自主题: Unix版 - question about appending file
I know it is easy to append to end of file, just cat file1 file2>file3.
Actually, I want to append one file into another file in given position (in
bytes). How can I do it?
Thanks.
c**t
发帖数: 2744
5
来自主题: Unix版 - question about appending file
man split

I know it is easy to append to end of file, just cat file1 file2>file3.
Actually, I want to append one file into another file in given position (in
bytes). How can I do it?
Thanks.
m***b
发帖数: 11
6
我以前(< R 2.5?)可用pdf("myplot.pdf",append=T) 将多个图输出到同一个PDF文件 (
用loop). 但R 2.7.1好象没有'append' argument了.如何实现这样的操作? 单个输出再
merge PDF文件的问题是: 每个图的尺寸应小与每页的尺寸.用mfrow=c(n,1)的问题是:
太多图(300), 不知怎样设置window大小, 总是说超限. 谢谢.
m***p
发帖数: 86
7
append就是加到末尾, insert是加到中间, delete是任何位置的删除
linkedlist + hashtable 或者 array + hashtable?
已跪, 请问具体如何实现?
u***************r
发帖数: 11227
8
来自主题: Java版 - How to append something on a file?
I hope I have understood the problem right -- read the Javadoc for
FileOutputStream's constructor:
public FileOutputStream(String name,
boolean append)
throws FileNotFoundException
Creates an output file stream to write to the file with the specified name. If the second argument is true, then bytes will be written to the end of the file rather than the beginning. A new FileDescriptor object is created to represent this file
connection.
D*******y
发帖数: 366
9
非常感谢你的帮助!
我在做一个市场买卖双方的模拟。
这个软件的输出部分需要输出每周的历史数据。这样每周的市场和每个交易者的价格,
数量需要输出到不同的文件中。里面含有int, double,char 数据类型。
一下是我学习的一个简单输出代码。能够运行,但是输出文件显示不出来。
package ts;
import java.io.*;
import ts.AppendToFile;
public class Append {
/**
* @param args
*/
public static void main(String[] args) {
String fileName="D:/output/out1.txt";
// TODO Auto-generated method stub
AppendToFile[] file=new AppendToFile[4];

file[1]=new AppendToFile(1);

//Sys
b****t
发帖数: 114
10
Hi all,
I want to append new column data to a data file. The data has been formated
in a tabbed way (very clean data without any missing/empty cells). This is
usefull when I run my c/c++ code and save data each time as one or more
columns. Ideally, it will be done within c/c++ code with fstream, but it is
ok to use stript split single (or 2 column) column data into multiple
columns.
e.g.
file1:
1 2 3
2 3 4
5 6 7
l**********n
发帖数: 5272
11
In unix I can use something like cat file1 >> file2.
In windows, is there any command to append the content of file1 to file2 ?
Thanks a lot.
A*******s
发帖数: 3942
12
来自主题: Statistics版 - 一个SAS Macro和Append的问题,救助!
不知道你具体出的问题是啥
我有限的经验是
1. proc append不需要base dataset事先存在。如果不存在的话会自动创建一个。
2. 最好事先定义好base dataset的变量格式和长度,然后用force option。
w*****r
发帖数: 92
13
来自主题: Statistics版 - How to append data sets in SAS?
There are 5 data sets in total. Each set has one observation and 3 variables
(different variable names and attributes).
How to append or row bind all the data sets together?
Tried several ways, PROC DATASETS with FORCE causes missing data; PROC IML
cannot read in multiple tables, have to add one at a time.
t********5
发帖数: 274
14
来自主题: DotNet版 - 求救一个小问题
我也认为是button的事件里写的
可是我找不到那个button相关的任何代码
是flash,整个页面主要都是flash的,我以前没接触过flash方面的编程,不知道您有
没有什么猜想,我顺着路子去找一找
table.aspx页面,就是有聊天窗口,有send按钮的这个页面
<%@ Page Title="" Language="VB" MasterPageFile="~/Shared/xxxx.master"
AutoEventWireup="false"
CodeFile="table.aspx.vb" Inherits="VNT_table" %>
"Server">

阅读全帖
D*****d
发帖数: 1307
15
来自主题: Joke版 - 学术版求教一下
I wrote some java code, might be ugly, but it works...
package Testing;
public class TestReplaceWithQuotes {
public static String replaceInsideQuotes(String source, char quote,
String target, String replacement){
StringBuilder regex = new StringBuilder();
StringBuilder replace = new StringBuilder();

String quoteChar = Character.isDigit(quote) || Character.
isAlphabetic(quote) ? String.valueOf(quote) : ("\" + quote);
String nonQuoteChar = "[^" + quoteCh... 阅读全帖

发帖数: 1
16
11 月13日 终于找到另一股在我家害我的势力
昨天,这些人折腾了一天,白天,晚上皮啦啦,也不知道谁把谁杀了,谁把谁带走了。
反正我先生和孩子被绑架了,就不知道是不是已经遇害了。我本来是打算睡觉的,但他
们头上,地下装电磁波攻击器,让我几乎窒息。虽然我没倒下,但其实他们在我身上扎
的毒针已经蔓延,我能感觉到我的呼吸有窒息的感觉。我想我对他们已经非常仁慈了,
但他们不依不饶地攻击我,欲置我于死地,让我非常生气,特别是肆意伤害我家里的人
,绑架我先生和孩子,而且有许许多多无辜的生命毁于他们之手,有必要把他们曝光。
当然我还没分析这里边是那几个人具体攻击我,伤害我的,但他们显然都是一伙的。鉴
于他们伤害我的头部,胸部 和胃部,我就把这几部分的医生都曝光,受害者慢慢去调
查,追查他们吧。
Cleveland Clinic, Website: my.clevelandclinic.org
Call 855. REFER. 123 or 855.733.3712
Lung Cancer
Results: 57 Doctors
PREV123NEXT
Results per page:
Dav... 阅读全帖
c********t
发帖数: 5706
17
Leetcode Integer to Roma
看完题,读了一下wiki,好像不那么复杂,行云流水写下如下code,竟然很少有的bug
free,沾沾自喜。查查别人的解法,有人说写成我这样会被面试官直接送回家。
帮我看看,至于吗?有啥问题?
public String intToRoman(int num) {
// Start typing your Java solution below
// DO NOT write main() function
StringBuilder sb = new StringBuilder();
while (num > 0) {
if (num >= 1000) {
sb.append('M');
num -= 1000;
} else if (num >= 900) {
sb.append("CM");
num -= 900;
} else if (num >= 500) {
sb.a... 阅读全帖
p*****2
发帖数: 21240
18
来自主题: JobHunting版 - 罗马数字转换成十进制
import java.io.*;
import java.util.*;
public class Roman
{
public static void main(String[] args)
{
new Roman().run();
}
PrintWriter out = null;
void run()
{
Scanner in = new Scanner(System.in);
out = new PrintWriter(System.out);
String s = in.next();
out.println(romanToInt(s));
out.close();
}
public String intToRoman(int num)
{
StringBuffer sb = new StringBuffer();
sb.append(Convert(num, 1000, ne... 阅读全帖
t***q
发帖数: 418
19
【 以下文字转载自 Programming 讨论区 】
发信人: treeq (treeq), 信区: Programming
标 题: 如何用python web.py web service 做 multiple parameters 的 call?
发信站: BBS 未名空间站 (Sun Mar 22 23:14:33 2015, 美东)
大家好。我的那个web service 做成了。用了python 的 web.py.
install web.py
cd webpy
编辑python web service.
#!/usr/bin/env python
import web
import csv
import difflib
import re
import operator
import Levenshtein
urls = ('/title_matching2','title_matching2')
app = web.application(urls,globals())
class title_matching2:
def __init__(self):
... 阅读全帖
t***q
发帖数: 418
20
【 以下文字转载自 Programming 讨论区 】
发信人: treeq (treeq), 信区: Programming
标 题: 如何用python web.py web service 做 multiple parameters 的 call?
发信站: BBS 未名空间站 (Sun Mar 22 23:14:33 2015, 美东)
大家好。我的那个web service 做成了。用了python 的 web.py.
install web.py
cd webpy
编辑python web service.
#!/usr/bin/env python
import web
import csv
import difflib
import re
import operator
import Levenshtein
urls = ('/title_matching2','title_matching2')
app = web.application(urls,globals())
class title_matching2:
def __init__(self):
... 阅读全帖
f*******8
发帖数: 3612
21
这是一个将RFC 文件转换成 kindle格式的程序,
来自:
https://github.com/pingwin/RFC-2-Kindle
我是windows上的python 2.71, 运行完全仿照该网站的要求
结果出来是找不到font MONOSPACE, 不知道MONOspace是不是个字体库或别的什么。
running output:
D:\>rfctxt2kindlehtml.py -i rfc791.txt -o rfc791.html && ./ki
ndlegen rfc791.html
Unable to find font: /usr/share/cups/fonts/Monospace
Convert IETF RFC TXT file to HTML for kindlegen
-h --help This message
-v verbosity
-i --input input file
-o --output output file
-f --font font file to use for monospace ... 阅读全帖
t***q
发帖数: 418
22
大家好。我的那个web service 做成了。用了python 的 web.py.
install web.py
cd webpy
编辑python web service.
#!/usr/bin/env python
import web
import csv
import difflib
import re
import operator
import Levenshtein
urls = ('/title_matching2','title_matching2')
app = web.application(urls,globals())
class title_matching2:
def __init__(self):
self.hello = "hello world"
def GET(self):
getInput = web.input(name="World")
b=[]
with open("Book1.txt","rb") as k:
for row in k:
... 阅读全帖
g*******n
发帖数: 214
23
来自主题: JobHunting版 - G电面一题
如果不用recursion的话代码太长是不是面试的时候不能用?
public ArrayList numString2Char(String num) {
//map to store all the previous possibilities
HashMap> map = new HashMap ArrayList>();
int[] numbers = new int[num.length()];
for (int i = 0; i < num.length(); i++) {
numbers[i] = Integer.parseInt(num.charAt(i) + "");
}
if(numbers[0]==0) return null;
ArrayList tempList;
... 阅读全帖
r******g
发帖数: 138
24
来自主题: JobHunting版 - G家面经(已被HC挂,求分析)
对第四轮

public static String getDecimal(int a, int b){
if(a == 0)
return "0.0";
if(b == 0)
return "";

StringBuilder res = new StringBuilder();
res.append(a/b);
res.append(".");
int c = a;
HashMap mod = new HashMap();
ArrayList decimals = new ArrayList();

int index=0;
while(c%b !=0 && !mod.containsKey(c%b)){
... 阅读全帖
p**o
发帖数: 3409
25
来自主题: Programming版 - 简易计算器优先计算级别怎么算?

You may define the precedence levels for operators. E.g.,
precedence = {
'(': 0, ')': 0,
'+': 1, '-': 1,
'*': 2, '/': 2, '//': 2, '%': 2,
'^': 3, '**': 3,
}
operators = set(precedence.iterkeys())
right_associative_ops = {'^', '**',}
def infix_to_postlist (infix):
""" Simplified Shunting-yard algorithm. E.g.,
30 + 4 * 2 / ( 1 - 5 ) ^ 2 ^ 3
<==> 30 + ((4 * 2) / ((1 - 5) ^ (2 ^ 3)))
<==> 30 4 2 * 1 5 - 2 3 ^ ^ / +
"""
postlist = []
opstack = ... 阅读全帖
t********5
发帖数: 522
26
来自主题: JobHunting版 - 关于python interview
代码很乱 凑合看=。=
"""
# 11.33
class Node(object):
def __init__(self, value = None, next = None):
self.value = value
self.next = next

class LinkedList(object):
def __init__(self):
self.head = None
self.size = 0

def __repr__(self):
result = []
tmp = self.head
while tmp is not None:
result.append(tmp.value)
tmp = tmp.next

return str(result)

def append(self, value):
node = Node(value)
if self.head is None:
self.head = node
... 阅读全帖
a**s
发帖数: 9606
27
来自主题: Tennis版 - VirtualDub视频编辑简单步骤
def ReadVDScript(strJsFile):
lstSubs=[]
lstVideoFile=[]
strOutFile = ""
fpJs=open(strJsFile, 'r')
strScript=fpJs.read()
fpJs.close()

# Get videos source(s)
# VirtualDub.Open("2012.12.08.vs.Tim.avi","",0);
# VirtualDub.append("2.MOV")
n1 = strScript.find('.Open') + 5
if n1>4:
n1 = strScript.find('"', n1) + 1
lstVideoFile.append(strScript[n1:strScript.find('"', n1)])
... 阅读全帖
a**s
发帖数: 9606
28
来自主题: Tennis版 - VirtualDub视频编辑简单步骤
def ReadVDScript(strJsFile):
lstSubs=[]
lstVideoFile=[]
strOutFile = ""
fpJs=open(strJsFile, 'r')
strScript=fpJs.read()
fpJs.close()

# Get videos source(s)
# VirtualDub.Open("2012.12.08.vs.Tim.avi","",0);
# VirtualDub.append("2.MOV")
n1 = strScript.find('.Open') + 5
if n1>4:
n1 = strScript.find('"', n1) + 1
lstVideoFile.append(strScript[n1:strScript.find('"', n1)])
... 阅读全帖
d****g
发帖数: 7460
29
来自主题: Java版 - 我自己编了个Java面试题
Here is my implementation. google了很久,本以为是个很基本的use case,但最后没
有找到好办法。写出来也不算太麻烦。没有考虑general的solution,也没有考虑CDData
和comment.对我们这个app应该足够了。
public static String removeNameSPace(String input1) {
String ret = null;
int strStart = 0;
boolean finished = false;
if ( input1 != null ){
StringBuffer sb = new StringBuffer(input1.length());
while (!finished){

int start = input1.indexOf('<', strStart);
int end = input1.indexOf('>', strStart);
if ( start != -1 && end != -1)... 阅读全帖
p****u
发帖数: 2422
30
来自主题: Linux版 - 请教个简单命令问题
from Advanced Bash-Scripting Guide:
http://www.tldp.org/LDP/abs/html/io-redirection.html
Chapter 20. I/O Redirection
Table of Contents
20.1. Using exec
20.2. Redirecting Code Blocks
20.3. Applications
There are always three default files [1] open, stdin (the keyboard), stdout
(the screen), and stderr (error messages output to the screen). These, and a
ny other open files, can be redirected. Redirection simply means capturing o
utput from a file, command, program, script, or even code block withi... 阅读全帖
r****m
发帖数: 70
31
来自主题: JobHunting版 - Text Justification
先计算可以放的最大单词数,然后在单词中插入空格输出行
public class AdjustText {
static List justifyText(String[] words, int L) {
List result = new ArrayList();

int i = 0;
while (i < words.length) {
List lineWords = new ArrayList();
int curLen = 0;
do {
lineWords.add(words[i]);
curLen += words[i].length() + 1;
i++;
} while (i阅读全帖
n**********s
发帖数: 9
32
来自主题: JobHunting版 - text justification 有人ac吗
看看你漏了什么
public class Solution {
public ArrayList fullJustify(String[] words, int L) {
ArrayList result=new ArrayList();
ArrayList currentLine=new ArrayList();
int i=0;
while(i currentLine=new ArrayList();
int len=0;
int wordLength=0;
int wordCount=0;
do {
len+=words[i].length()+1;
wordLength+=words[i].lengt... 阅读全帖
w****e
发帖数: 3827
33
来自主题: JobHunting版 - G的一道Onesite题
如果是压缩的话,压完了长度要比原长度小,所以出现一两次的就不数个数了。
抛个砖,求轻拍
public static String encode(String s) {
StringBuilder sb = new StringBuilder();
int i = 0;
while (i < s.length()) {
int count = 1;
while (i < s.length() - 1 && s.charAt(i) == s.charAt(i + 1)) {
i++;
count++;
}
if (count == 2) {
sb.append(s.charAt(i));
sb.append(s.charAt(i));
i++;
} else if (count > 2) {
sb.append(count);
... 阅读全帖
z*****1
发帖数: 1
34
用的dfs 写起来也没有那么复杂
String getCurString(String pat, int patIndex)
{
char curChar = pat.charAt(patIndex);
boolean positive = pat.charAt(patIndex + 1) == '+';
StringBuilder sb = new StringBuilder();
if (positive)
{
sb.append(curChar);
sb.append(curChar);
}
else
{
sb.append(curChar);
sb.append(curChar);
sb.append(curChar);
sb.append(curChar);
}

return sb.toString();
}

public int dfs(String txt... 阅读全帖

发帖数: 1
35
仅此而已,no trick ,
public String lc301(String input) {
char[]inputt = input.toCharArray();
StringBuilder s = new StringBuilder();
StringBuilder res = new StringBuilder();
int open = 0;
for (char i : inputt) {
if (i =='(') {
open++;
s.append(i);

}else if (i ==')') {
if(open >0) {
s.append(i);
open--;
}
}el... 阅读全帖
x******3
发帖数: 245
36
来自主题: JobHunting版 - 请教一道 Google 面试题
I used a DP method and get the same result with your sample outputs.
My approach is to assume the last Ctrl-C is at position j,
then everything after the last Ctrl-C should be Ctrl-V.
I also think the operation right before Ctrl-C should be Ctrl-A.
So j can be varied to pick the maximum.
python code here, it prints out the solution key sequence
#!/usr/bin/env python

... 阅读全帖
l**h
发帖数: 893
37
来自主题: JobHunting版 - G 家电面面经
/**
* 比如输入1,3 输出0.(3)
* 输入1,2 输出0.5(0)
* 输入1,700, 输出 0.00(142857)
* 暂不考虑输入为负数
*/
public class Division {
public static String getQuotientInString(int i, int j) {
StringBuffer quotient = new StringBuffer();
quotient.append(i/j);
quotient.append(".");
int modular = i%j * 10;
while(modular/j == 0) {
quotient.append("0");
modular = modular * 10;
}

int a[] = new int[10];
Arrays.fill(a, 0);
... 阅读全帖
W********e
发帖数: 45
38
【leetcode restore IP address】这题,思路和算法我都写出来了,不过有个地方觉
得很奇怪,小问题 ,可是我没想明白,请指教!
问题就是为什么要用tmp来代替ans这个参数?在下面的code里我有coment
class Solution {
public:
vector restoreIpAddresses(string s) {
vector result;
string ans;
dfs(s,&result,ans,4);
return result;

}
void dfs(string s,vector*result, string ans,int tokenLeft)
{
int i,sectionValue=0;
if(s.length()==0 && tokenLeft==0)
{
result->push_back(an... 阅读全帖
W***o
发帖数: 6519
39
这个是我CrimeTypeKey的class,生成composite key object:
public class CrimeTypeKey implements Writable, WritableComparable<
CrimeTypeKey>
{
private Text key = new Text();
private IntWritable year = new IntWritable();

public CrimeTypeKey() { }

public CrimeTypeKey(String k, int y)
{
key.set(k);
year.set(y);
}

public static CrimeTypeKey read(DataInput in) throws IOException
{
CrimeTypeKey keytp = new CrimeTypeKey();
keytp.readFields(... 阅读全帖
p****o
发帖数: 46
40
来自主题: JobHunting版 - 问一个面试题
ok, I only had a glimpse on a.append(0), and quickly skip it... :-), have
not written python for quite some time.
then I think it is correct. but personally, I feel it is tricky to append "0
" at the end of input, and also the input has to change. Another
controversial case is the empty input, you will output "out".
Well, maybe the reviewer did not see that "append", or did not think too
much. or there is still something wrong we have not checked out.
Your code is not far from not modifying inpu... 阅读全帖
i*****h
发帖数: 1534
41
lc原题啊,给你贴上来了。
public String fractionToDecimal(int numerator, int denominator) {
StringBuilder sb=new StringBuilder();
if(denominator==0) return "";
if(numerator>0&&denominator<0 || numerator<0&&denominator>0) sb.
append("-");
long num=Math.abs((long)numerator), den=Math.abs((long)denominator);
sb.append(num/den);
long remainder=num%den;
if(remainder==0) return sb.toString();
sb.append(".");
Map hashMap=new Hash... 阅读全帖
k****r
发帖数: 807
42
来自主题: JobHunting版 - Google 电面
是这样的solution吗?
其中returnPosition的function应该不难写,但面试会要求写吗?
应该像上面的牛人说的,建个char-》position的表格最好了,不然每次还要算。
结果应该不唯一,估计面试follow up需要decode。
public class remoteControl {
String[] dic = {"abcde", "fghij", "klmno","pqrst", "uvwxy", "z"};
public String remoteControl(String name) {
int x = 0;
int y = 0;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < name.length(); i++) {
Point curr = returnPosition(name.charAt(i), dic);
for (int j = y... 阅读全帖
F*****o
发帖数: 32
43
来自主题: JobHunting版 - G家最新电面
class TreeNode:
def __init__(self,x):
self.child=[]
self.val=x
class Solution:
def strToTree(self,s):
if len(s)==0: return None
stack=[]
for i in range(len(s)):
if s[i]=='(': stack.append(s[i])
elif s[i].isalpha():
stack.append(TreeNode(s[i])) #push to stack except ')'
else:
t,temp=stack.pop(),[]
while t!='(':
temp.append(t)
t... 阅读全帖
l**h
发帖数: 893
44
来自主题: JobHunting版 - 请教个面试题
写了个java的:
String toCsv(String str) throws Exception {
boolean insideQuote = false;
Stack stack = new Stack();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
if (c == '[') {
stack.push(c);
} else if (c == ']') {
if (stack.isEmpty() || stack.peek() != '[') {
throw new Exception("Found unmatched ]");... 阅读全帖
h*****0
发帖数: 4889
45
有几个地方可以优化。
1. 用StringBuilder, 用法跟StringBuffer一样,但速度更快。
2. sb.append("(" + list.get(j) + "),");
要改成:
sb.append("(");
sb.append(list.get(j));
sb.append("),");
这样可以减少内存消耗。
3. 最后,如果还是会out of memory,那就试着不要先读文件存入list中,而是直接读
一行append一行。
4. 最最后,如果还是不行,你分析一下。默认内存(堆)只有64M,是不是不够?如果
不够,运行程序时java命令加入参数指定更大的内存(堆)。
f****g
发帖数: 313
46
来自主题: JobHunting版 - 讨论一道面试题
We have two schedules S1&S2:
S1 = { , , ... }
S2 = { , , ... }
Assumptions:
1. S1&S2 are sorted by the starting time.
2. There are no conflicts in S1 and S2 itself.
Problem:
We try to find all the conflicts between these two schedules.
the basic idea is to merge sort to find the conflicts. the running time is
O(n).
My code in python: (code is kind of messy)
def merge(a,b):
i, j = 0, 0
unconflict = []
conflict = []
while( i < len(a... 阅读全帖
r*******n
发帖数: 3020
47
来自主题: JobHunting版 - List Flattening from book
我的递归解法,大家看看对吗?
Node flat_list_head[N]; // N is the largest level.
void flattenList(Node *head, int level)
{
if (head->next){
insert_node_front_flat_list_head(head, level);

// Go next
head = head->next;
flattenList(head, level);
}

if (head->child){
insert_node_front_flat_list_head(head, level+1);
// Go child
head = head->child;
flattenList(head, level+1);
}
}
void ... 阅读全帖
k*****y
发帖数: 744
48
来自主题: JobHunting版 - facebook一题
Python写了一个,练练手
L = ['fooo', 'barr', 'wing', 'ding', 'wing']
S = 'lingmindraboofooowingdingbarrwingmonkeypoundcake'
# L1 stores distinct stings in L
# multiples counts the corresponding multiples
L1 = []
multiples = []
for str in L:
if str not in L1:
L1.append(str)
multiples.append(L.count(str))
# k is the lenght of each substring
k = len(L[0])
match = [0]*len(S)
checklist = []
for i in range(0, len(L1)):
mul = multiples[i]
list_pos = []
# find all possible positio... 阅读全帖
k*****y
发帖数: 744
49
来自主题: JobHunting版 - facebook一题
Python写了一个,练练手
L = ['fooo', 'barr', 'wing', 'ding', 'wing']
S = 'lingmindraboofooowingdingbarrwingmonkeypoundcake'
# L1 stores distinct stings in L
# multiples counts the corresponding multiples
L1 = []
multiples = []
for str in L:
if str not in L1:
L1.append(str)
multiples.append(L.count(str))
# k is the lenght of each substring
k = len(L[0])
match = [0]*len(S)
checklist = []
for i in range(0, len(L1)):
mul = multiples[i]
list_pos = []
# find all possible positio... 阅读全帖
y*****z
发帖数: 9
50
来自主题: JobHunting版 - 报个offer@FG,回报版面
这个是概率题。。
先生成 4个bit的 二进制 true代表1,false代表0
这样我们能生成0-15的 等概率的 distribution
然后 [0,15] 当中 选[0,10] -->[0,2](true), [3,9](false)
public class Solution {
/**
* @param args
*/

public void doit(){
int iterate = 10000000;
boolean valve = true;
StringBuilder s = new StringBuilder();
while (valve) {
StringBuilder str = new StringBuilder();
for (int i = 0; i < 4; i++) {
if (Math.random() < 0.5) str.append('1');
... 阅读全帖
1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)