开发工具分享
  • 首页
  • 计算科学
  • 文化旅游
  • 项目和网站
    • OSSEZ 计算技术
    • USRealEstate 社区
    • 地区文化
    • CWIKI.US
    • BUG.OSSEZ.COM
    • RSS.OSSEZ.COM
CWIKIUS.CN
一个有独立思考和温度的清新站
  1. Home
  2. Computer Science
  3. This article

对一门不是非常熟悉的语言是怎么面试的

2023年10月07日 424Browse 0Like 0Comments

公司是一个基础通讯类的公司,需要的职位是一个高级系统和软件工程师。

职位要求,是一个完全不怎么大众的语言:Elixir。

没听过,这就对了,这是一个函数式的语言,可以认为是 Erlang 的升级版本,Erlang 多用在交换机设备上的开发语言,这个语言其实还是比较小众的。

RabbitMQ 就是 Erlang 开发的,虽然 Erlang 在整个项目中的比例并不是很高。

 

2023-10-06_15-30-51

 

职位需求

这个职位的需求就是使用 Elixir 语言来处理 HTTP 的 API。

这个 API 主要是用户电子邮件相关的内容,我不知道为什么他们选择 Elixir,可能主要还是比较好和现有的系统保持一致吧。

面试

整个面试的时间是 1 个小时。

在这一个小时中主要聊了下对 HTTP 的请求,API 的调用是不是熟悉。不管用的是什么语言,只要你写过 API,这部分还是比较容易说清楚的。

下一步就是在线的 Coding 了,这个在线的代码也是非常简单的,唯一麻烦的地方是 Elixir,因为从来没有接触过这个语言,突然在平台上要用 Elixir 这个语言还是有点懵逼的。

好在示例程序什么都比较简单,就是对照下 API 的调用文档,利用模拟的环境写几个 API 接口。

只要有示例程序,要写其他的还是很简单就完成了,因为对 API 的写法,不管什么语言都差不多。

好在他们提供了一个 API 的示例程序。

在这部,都已经顺利完成了所有的代码,也正确没有问题。

随后他们就提出是不是给我一个回家做的题目,要求是完成这个题目,然后尽快提交给他们。

回家做题

对于给出的题目,稍后我在下面的文章中给出。

如果你是使用其他的比较高级的语言,这个应该没有什么问题,可以说是非常简单的。

但是 Elixir 是一个函数式的语言,同时循环是不可变的,在这里哪怕是一个循环都要折腾半天。

本着,既然我答应你回家试试了,那么我就抱着一定要做出来的想法来做的,也在规定的时间把代码提交了。

结果

大概 1 周后,收到了他们比较客气的拒绝信。

理由是找到了更加合适的人了。

点评

找到更加合适的人,这个不足为奇。因为 Elixir 这个语言实在是非常小众的语言,有比较大的学习曲线。

不是说,你今天开始看文档,明天就能全部看明白的那种。

这个语言没有好的集成 IDE 开发环境,代码写起来不是那么友好,高级语言非常容易实现的东西,Elixir 需要比较多的步骤才能完成。

其实,对公司本身来说,这次面试并没有什么负面评价。主要原因是,在投简历的时候没有仔细看看需要的语言,主要是看了 API 编程能力。

通常来说,这个都不是什么问题。

唯一感觉有点不好的是,公司方面对面试者的反馈比较差。在我提交代码到对方邮箱后,没有任何邮件说邮件已经收到了。完全不知道邮件是不是已经发送过去了或者他们在进行评估什么的。

一般来说,2 到 3 天没有消息的话,感觉都不会非常靠谱,所以也没有抱有太大希望。

只是希望的是,他们应该可以通过更好的沟通让整个流程更加好,可惜他们没有做到,有点把面试当儿戏的意思。

题目和解答

Program 1

Using input_data1.txt, complete the code in file program1.exs

You can install Elixir on a machine you work on, or you can
use Try It Online or something similar.
tio has an input section where you can paste in the input data.

input_data1.txt (3.6 KB)

源代码如下:

defmodule M do
  def read do
    IO.read(:stdio,:all)
  end

  def input_to_list( input ) do
    # turn single string into a list of input values
    String.split(input)
  end

  def calculate([head | tail], acc) do
    calculate( tail, head + acc )
  end
  
  # finish
  def calculate( [], acc ) do
	acc
  end
end


IO.inspect M.read() |> M.input_to_list |> M.calculate(0)

Program 2

Extending the technique of Program 1, write a program that
given 3 lists, selects the greatest even value at each iteration and
adds it to an accumulator. For example:

[ 5, 8, 9, 2, 4, 7 ]
[ 9, 1, 6, 7, 9, 6 ]
[ 4, 4, 8, 6, 2, 4 ]

sums the list:

[ 4, 8, 8, 6, 4, 6 ]

and a sum of 36

The lists to use are:

[184, 89, 960, 133, 239, 413, 425, 355, 636, 519, 430, 562, 296, 175, 471, 260, 279, 934, 667, 804, 954, 274, 833, 428, 912, 789, 76, 805, 522, 692, 139, 598, 943, 309, 954, 265, 958, 559, 722, 910, 388, 996, 716, 706, 291, 236, 593, 154, 103, 8, 319, 722, 863, 493, 384, 206, 696, 563, 276, 422, 642, 163, 926, 823, 608, 193, 713, 119, 141, 297, 99, 321, 976, 972, 46, 34, 719, 186, 446, 563, 139, 887, 729, 319, 679, 734, 565, 531, 210, 275, 113, 409, 384, 872, 442, 364, 757, 44, 332, 802, 389, 626, 15, 376, 143, 450, 362, 31, 847, 935, 103, 856, 700, 78, 904, 697, 453, 995, 420, 426, 1000, 264, 88, 384, 323, 322, 289, 383, 916, 460, 350, 29, 384, 421, 869, 462, 156, 362, 162, 757, 31, 450, 85, 850, 344, 864]
[112, 348, 854, 848, 27, 435, 103, 625, 477, 203, 513, 736, 638, 229, 517, 580, 476, 692, 124, 136, 257, 785, 415, 5, 332, 366, 124, 108, 864, 362, 272, 331, 20, 612, 532, 18, 487, 524, 266, 973, 642, 46, 174, 256, 37, 416, 424, 749, 532, 922, 279, 537, 268, 148, 981, 141, 334, 603, 570, 400, 4, 24, 789, 416, 475, 442, 485, 636, 151, 736, 162, 528, 52, 804, 793, 183, 734, 365, 595, 922, 187, 48, 365, 164, 47, 467, 63, 325, 250, 980, 970, 853, 716, 639, 382, 482, 241, 377, 753, 689, 108, 240, 261, 48, 478, 922, 648, 468, 33, 71, 670, 421, 727, 780, 873, 648, 416, 661, 655, 202, 745, 177, 264, 175, 284, 49, 333, 727, 668, 323, 593, 408, 693, 98, 332, 148, 634, 739, 703, 157, 359, 346, 90]
[915, 576, 254, 844, 744, 656, 149, 46, 883, 902, 636, 545, 978, 972, 572, 686, 927, 781, 463, 384, 450, 690, 322, 454, 686, 309, 56, 152, 622, 94, 579, 395, 964, 787, 886, 336, 606, 286, 880, 248, 337, 425, 590, 342, 980, 731, 541, 941, 788, 481, 753, 912, 100, 306, 414, 736, 360, 454, 52, 984, 420, 750, 839, 173, 450, 260, 189, 929, 659, 349, 664, 989, 219, 62, 566, 346, 150, 446, 838, 880, 644, 898, 662, 610, 688, 225, 519, 655, 489, 63, 492, 916, 762, 990, 273, 241, 925, 259, 138, 929, 769, 991, 981, 298, 437, 120, 627, 636, 107, 505, 80, 781, 13, 924, 901, 905, 507, 559, 48, 778, 444, 65, 312, 287, 804, 960, 573, 533, 52, 763, 188, 379, 709, 820, 334, 519, 992, 218, 550, 253, 812, 83, 620, 539, 404, 317, 966, 657, 630]

源代码如下:

defmodule M do
  def read do
    IO.read(:stdio,:all)
  end

  def input_to_list( input ) do
    # turn single string into a list of input values
    inputList = String.split(input, "\n")
    [head | tail] =inputList 
    list_1_str = head 
    [head | tail] = tail
    list_2_str = head 
    [head | tail] = tail
    list_3_str = head 

	#pattern = :binary.compile_pattern([" ", ", "])
	#IO.inspect(String.split("[1,2 3,4]", pattern))

	list_1_str = String.replace(list_1_str ,"[", "")
	list_1_str = String.replace(list_1_str ,"]", "")
	list_1_str = String.replace(list_1_str ," ", "")
	list_1 = String.split(list_1_str,[" ", ","])

	list_2_str = String.replace(list_2_str ,"[", "")
	list_2_str = String.replace(list_2_str ,"]", "")
	list_2_str = String.replace(list_2_str ," ", "")
	list_2 = String.split(list_2_str ,[" ", ","])

	list_3_str = String.replace(list_3_str ,"[", "")
	list_3_str = String.replace(list_3_str ,"]", "")
	list_3_str = String.replace(list_3_str ," ", "")
	list_3 = String.split(list_3_str ,[" ", ","])


	length_list = [0]
        length_list  = [length(list_1) | length_list ]
	length_list  = [length(list_2) | length_list ]
	length_list  = [length(list_3) | length_list ]
 	length_max = Enum.max(length_list )


	IO.inspect(length_max )

	list_1 = list_1
		|> append_if(length_max > length(list_1),"0")
	list_2 = list_2
		|> append_if(length_max > length(list_2),"0")
	list_3 = list_3
		|> append_if(length_max > length(list_3),"0")

#	IO.inspect(list_1)
#	IO.inspect(list_2)
#	IO.inspect(list_3)


	lx =[list_1 | []]
	lx =[list_2 | lx]
	lx =[list_3 | lx]
	

	lx_1 = Enum.zip(lx)


	l = Enum.map(lx_1 , fn n ->
	 max_even(Tuple.to_list(n))
	end)

	IO.inspect(l)

  end


defp append_if(list, condition, item) do
  if condition, do: list ++ [item], else: list
end



  def max_even(list) do
   evenList = 	list
	|> Enum.map(&String.to_integer/1)
	|> Enum.filter(&rem(&1, 2) == 0)

   if Enum.empty?(evenList ) do
	0
   else 
	evenList 
	|> IO.inspect
	|> Enum.reduce(&max/2)
	|> IO.inspect
   end
  end



  def calculate([head | tail], acc) do

#IO.inspect(acc)
#IO.inspect(tail)
    calculate(tail, head + acc)
  end
  
  # finish
  def calculate( [], acc ), do: acc
end




#IO.puts M.calculate(["1", "2", "3"], 0)

IO.inspect M.read() |> M.input_to_list |> M.calculate(0)

如觉得代码比较难读的话,可以直接下载我们的附件,在附件中有题目说明,测试数据和源代码。

 

Snag_14e674c

上图是网站上的运行结果。

 

https://www.isharkfly.com/t/topic/15035

Tags: None
Last updated:2023年10月07日

HoneyMoose

有温度的人文和独立的思考

Like
< Previous
Next >

Comments

Cancel reply

Archives
  • May 2026
  • April 2026
  • March 2026
  • February 2026
  • January 2026
  • December 2025
  • November 2025
  • October 2025
  • September 2025
  • August 2025
  • July 2025
  • June 2025
  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • July 2024
  • June 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • July 2019
  • June 2019
  • May 2019
  • April 2019
  • March 2019
  • February 2019
  • January 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • June 2018
  • May 2018
  • April 2018
  • March 2018
Categories
  • Computer Science (2,362)
    • Confluence (663)
    • Gradle (12)
  • U.S. (482)
  • 文化旅游 (145)

COPYRIGHT © 2020 CWIKIUS. ALL RIGHTS RESERVED.

THEME KRATOS MADE BY VTROIS

湘ICP备2020018253号-1