2021届秋招提前批——携程数据分析笔试

1.给出你10个点(xi,yi),先找出xi+yi最大的那一组temp,然后在从剩下的九组中找到离temp最近的点temp1,紧接着再从剩下的8个点钟找到离temp1最近的点temp2*。

import numpy as np

s='31.816767,119.98048|30.90029,120.09334|30.057623,120.59004|32.048153,118.79044|31.236351,121.48024|30.752031,120.76203|31.581388,120.30619|30.279995,120.16161|31.657412,119.0347|31.305141,120.59173'
line=s.split('|')
aa=[]
b=[]
#先找出最大的点temp
for i in range(len(line)):
    line[i]=line[i].split(',')
    aa.append(list(map(float,line[i])))
    b.append(sum(list(map(float,line[i]))))
index=b.index(max(b))
temp=aa[index]
# 存储整理后的结果
aa1=[]
aa1.append(temp)
aa.remove(temp)
ll=len(aa)
#来回调用bijiao函数,找出temp1,temp2....
for i in range(ll):
    ss= bijiao(aa,temp)
    index=ss.index(min(ss))
    temp=aa[index]
    aa1.append(temp)
    aa.remove(temp)
print(aa1)
# 从数组中找出离给定点最近的点
def bijiao(aa,temp):
    ss=[]
    for i in range(len(aa)):
        s=(aa[i][0]-temp[0])*(aa[i][0]-temp[0])+(aa[i][1]-temp[1])*(aa[i][1]-temp[1])
        ss.append(np.sqrt(s))
    return ss

在这里插入图片描述
2.找出浏览过商品但是没买的用户ID,商品ID,商品名称

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值