即日起一周内,不问出身,不看简历,用Nodejs代码挑战全世界最难面试的公司,成为世界顶级大牛的同事!

即日起一周内,不问出身,不看简历,用Nodejs代码挑战全世界最难面试的公司,成为世界顶级大牛的同事!

找工作=简历+面试 ?No ! 拉勾网携手ThoughtWorks 招代码奇才,不看简历,代码说话。无需干爹,不必爸爸是李刚,you can you up.

从看到消息这一秒开始——你就可以潜心写代码,Java ,C++ , C# , Ruby ,Javascript , Python都可以,鼓励使用单元测试,展示你出色的面向对象能力。

5月4日上午9:00前把作品传回来给我们; 5月4日——7日,我们会夜以继日推敲你的代码; 5月8日——9日,通过代码测试的你,会接到我们温柔的电话; 5月10日——11日,来ThoughtWorks感受一天独特面试。(包括逻辑笔试、结对编程、技术对话)

ThoughtWorks被评为全球最难面试科技公司,就算没吃到猪肉,你也将成为一个见过猪跑的人! “世之奇伟、瑰怪、非常之观,常在于险远,而人之所罕至焉,故非有志者不能至也”,国际环境,风口行业,神一样的队友,不看简历,代码说话。程序猿们!爆发吧!扬眉吐气、验明正身的时刻到了!

查阅题目、上传作品戳这里:http://www.lagou.com/subject/s_thoughtworks.html?joinName=shouye


22 回复

即日起一周内,不问出身,不看简历,用Node.js代码挑战全世界最难面试的公司,成为世界顶级大牛的同事!

找工作 = 简历 + 面试 ? No!

拉勾网携手ThoughtWorks招代码奇才,不看简历,代码说话。无需干爹,不必爸爸是李刚,you can you up.

如何参与?

从看到消息这一刻开始——你就可以潜心写代码,无论你是Java、C++、C#、Ruby、JavaScript还是Python高手,我们都欢迎。鼓励使用单元测试,展示你出色的面向对象能力。

时间安排:

  • 5月4日上午9:00前:将你的作品提交给我们。
  • 5月4日至7日:我们将夜以继日地推敲你的代码。
  • 5月8日至9日:通过代码测试的你,会接到我们温柔的电话。
  • 5月10日至11日:来ThoughtWorks感受一天独特面试(包括逻辑笔试、结对编程、技术对话)。

ThoughtWorks被评为全球最难面试科技公司,就算没吃到猪肉,你也将成为一个见过猪跑的人!

“世之奇伟、瑰怪、非常之观,常在于险远,而人之所罕至焉,故非有志者不能至也。”国际环境,风口行业,神一样的队友,不看简历,代码说话。程序猿们!爆发吧!扬眉吐气、验明正身的时刻到了!

示例代码

为了帮助你更好地准备这次挑战,以下是一个简单的Node.js示例代码,展示了如何实现一个基本的HTTP服务器,并使用单元测试验证其功能。

// server.js
const http = require('http');

const hostname = '127.0.0.1';
const port = 3000;

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World\n');
});

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});

使用Mocha进行单元测试

首先安装Mocha:

npm install --save-dev mocha

然后创建一个测试文件test/server.test.js

// test/server.test.js
const request = require('supertest');
const server = require('../server');

describe('Server', () => {
  it('should return 200 status code', async () => {
    const response = await request(server).get('/');
    expect(response.status).toBe(200);
  });

  it('should return "Hello World"', async () => {
    const response = await request(server).get('/');
    expect(response.text).toBe('Hello World\n');
  });
});

运行测试:

npx mocha test/

查阅题目、上传作品

点击这里:提交作品


通过这些示例代码,你可以了解如何构建一个简单的HTTP服务器并编写单元测试来验证其功能。希望你能在这个挑战中脱颖而出,成为ThoughtWorks的一员!


ThoughtWorks!

是!我!们!

现在招人面试也开始搞噱头了哈

function tw(x, y, z){
  for(var i = 1; i <= 100; i++){
    if(~(i + '').indexOf(x)){
      console.log('Fizz');
    }else{ 
      var temp  = ((i % x) ? '' : 'Fizz') + ((i % y) ? '' : 'Buzz') + ((i % z) ? '' : 'Whizz');
      (temp) ? console.log(temp) : console.log(i); 
    }
  }
}

这个能算10行以内么?

这道是在考大家显示器有多宽吗?。。。。。。。。。

赞!这才是招聘程序员的正道!

快点来提交你的代码作业~

楼主的语气好像有点传销的风格,哈哈,就和那个电视广告一样,不然楼主先给我来一段, ####12行之内并且只用一个变量的9*9乘法表打印的代码,不限语言!有本事挑战吗? 按照你的说话风格就是,对!!你听得没错就是12行,不要40行,也不要30行,只要12行!!12行啊!!!

弱弱地谷歌了一把这个公司
for(var i = 1; i <=9; i++){
    var a1 = ((i - 8) <= 0) ? '' : ((i - 8) + '*' + i + '=' + (i - 8) * i + ' ');
    var a2 = ((i - 7) <= 0) ? '' : ((i - 7) + '*' + i + '=' + (i - 7) * i + ' ');
    var a3 = ((i - 6) <= 0) ? '' : ((i - 6) + '*' + i + '=' + (i - 6) * i + ' ');
    var a4 = ((i - 5) <= 0) ? '' : ((i - 5) + '*' + i + '=' + (i - 5) * i + ' ');
    var a5 = ((i - 4) <= 0) ? '' : ((i - 4) + '*' + i + '=' + (i - 4) * i + ' ');
    var a6 = ((i - 3) <= 0) ? '' : ((i - 3) + '*' + i + '=' + (i - 3) * i + ' ');
    var a7 = ((i - 2) <= 0) ? '' : ((i - 2) + '*' + i + '=' + (i - 2) * i + ' ');
    var a8 = ((i - 1) <= 0) ? '' : ((i - 1) + '*' + i + '=' + (i - 1) * i + ' ');
    var a9 = i + '*' + i + '=' + i * i + ' ';
    console.log(a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9);
  }

为了能写清楚点,我把9个变量分开写了,其实只要三行就够了。这个算不算?

其实,这不是LZ说话的风格呀!

这是活动的文案来着~~~

真的很像电视广告噗

我也经常google我们公司,看看有没有人吐槽什么的~~~你看到了什么呀~

s = [] do { s[s.length] = []; do { s[s.length - 1].push(’’ + s.length + ’ x ’ + (s[s.length - 1].length + 1) + ’ = ’ + s.length * (s[s.length - 1].length + 1)); } while (s[s.length - 1].length < s.length); s[s.length - 1] = s[s.length - 1].join(’ ') } while (s.length < 9)

console.log(s.join(’\n’))

========================================

1 x 1 = 1 2 x 1 = 2 2 x 2 = 4 3 x 1 = 3 3 x 2 = 6 3 x 3 = 9 4 x 1 = 4 4 x 2 = 8 4 x 3 = 12 4 x 4 = 16 5 x 1 = 5 5 x 2 = 10 5 x 3 = 15 5 x 4 = 20 5 x 5 = 25 6 x 1 = 6 6 x 2 = 12 6 x 3 = 18 6 x 4 = 24 6 x 5 = 30 6 x 6 = 36 7 x 1 = 7 7 x 2 = 14 7 x 3 = 21 7 x 4 = 28 7 x 5 = 35 7 x 6 = 42 7 x 7 = 49 8 x 1 = 8 8 x 2 = 16 8 x 3 = 24 8 x 4 = 32 8 x 5 = 40 8 x 6 = 48 8 x 7 = 56 8 x 8 = 64 9 x 1 = 9 9 x 2 = 18 9 x 3 = 27 9 x 4 = 36 9 x 5 = 45 9 x 6 = 54 9 x 7 = 63 9 x 8 = 72 9 x 9 = 81

Process finished with exit code 0 是要这样的结果吗?


###C#解决方案,全文20行,实现方法不超过10行,无if,else,while条件语句。


using System;
using System.Linq;

namespace FizzBuzzWhizz { class Program { static void Main(string[] args) { Output(Console.ReadLine()); Console.ReadLine(); } static void Output(string recive) { int[] Input = recive.Split(’,’).Select(i => Convert.ToInt32(i)).ToArray(); for (int i = 0; i <= 100; i++) { Console.WriteLine(i.ToString().Contains(Input[0].ToString()) ? “Fizz” : (0 != i % Input[0] && 0 != i % Input[1] && 0 != i % Input[2]) ? i.ToString() : (0 == i % Input[0] ? “Fizz” : “”) + (0 == i % Input[1] ? “Buzz” : “”) + (0 == i % Input[2] ? “Whizz” : “”)); } } } }

三目已经算条件了。。。

php 实现 <?php class FizzBuzzWhizz{ private $_special=array(); private $_words=array(); public function __construct(array $special,array $words){ if(in_array(0,$special)){ exit(‘特殊数中不能含有0’); } if(count($special)!=count($words)){ exit(‘特殊数和替代词不对称’); } $this->_special=$special; $this->_words=$words; } public function run($num){ $output=’’; for($i=1;$i<=$num;$i++){ $output.=$this->_calculate($i); } echo $output; exit(); } private function _calculate($number){ $str=’’; if(strpos($number,$this->_special[0]) > 0){ return $this->_words[0]."\r\n"; } foreach($this->_special as $k=>$v){ if($number%$v === 0){ $str.=$this->_words[$k]; } } return $str==’’?$number."\r\n": $str."\r\n"; } }

$special=array(3,5,7); $words=array(‘Fizz’,‘Buzz’,‘Whizz’); $obj=new FizzBuzzWhizz($special,$words); $obj->run(100);

$special=array(3,5,7,9); $words=array(‘Fizz’,‘Buzz’,‘Whizz’,‘haha’); $obj=new FizzBuzzWhizz($special,$words); $obj->run(200); 特殊数可以是任意个,数值范围任意(1~xxx) 计算的函数应该进一步独立(偷个懒),以便修改和替换

(function xx(a) { if (a -1 > 0) xx(a-1); for (var i=1;i<=a;++i) { process.stdout.write ("" + i + “x” + a + “=” + i*a + " "); } process.stdout.write(’\n’); })(9);

!function (p, m, i, c, l) {
  while (i++ < c) {
    l(((i + '').indexOf(p[0]) + 1) ? m[0] : (p.map(function (n, j) {
      return i % n ? '' : m[j]
    }).join('') || i))
  }
}([ 3, 5, 7 ], [ 'Fizz', 'Buzz', 'Whizz' ], 0, 100, console.log)

在Terminal下運行 seq 9 | sed 'H;g' | awk -v RS='' '{for(i=1;i<=NF;i++)printf("%dx%d=%d%s", i, NR, i*NR, i==NR?"\n":"\t")}'

coffee一行也行 <code> ((one, two, three) -> console.log [1…100].map (number) -> “#{one}” in “#{number}” and ‘Fizz’ or ([one, two, three].map (item, i) => if number % item is 0 then [‘Fizz’, ‘Buzz’, ‘Whizz’][i] else ‘’).join(’’) or number)(3, 5, 7) </code>

针对这个题目,你需要准备一段高质量的Node.js代码,用于展示你的编程能力和面向对象的设计能力。以下是一个简单的示例,展示如何创建一个HTTP服务器,并提供一些基本的REST API功能。这不仅能够展示你的Node.js技能,还体现了你对于模块化和测试驱动开发的理解。

示例代码

首先,安装必要的依赖:

npm install express body-parser

然后,创建一个简单的Express应用:

const express = require('express');
const bodyParser = require('body-parser');

// 初始化Express应用
const app = express();
app.use(bodyParser.json());

// 定义数据模型
class Todo {
    constructor(id, task) {
        this.id = id;
        this.task = task;
    }
}

let todos = [];

// 创建一个新的任务
app.post('/todos', (req, res) => {
    const { task } = req.body;
    const todo = new Todo(todos.length + 1, task);
    todos.push(todo);
    res.status(201).json(todo);
});

// 获取所有任务
app.get('/todos', (req, res) => {
    res.json(todos);
});

// 更新任务
app.put('/todos/:id', (req, res) => {
    const { id } = req.params;
    const { task } = req.body;

    const todoIndex = todos.findIndex(todo => todo.id == id);
    if (todoIndex === -1) {
        return res.status(404).send({ message: "Todo not found" });
    }

    todos[todoIndex].task = task;
    res.json(todos[todoIndex]);
});

// 删除任务
app.delete('/todos/:id', (req, res) => {
    const { id } = req.params;
    todos = todos.filter(todo => todo.id !== parseInt(id));
    res.send({ message: "Todo deleted successfully" });
});

// 启动服务器
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => console.log(`Server running on port ${PORT}`));

解释

  1. 模块化:通过引入expressbody-parser模块,代码结构清晰。
  2. RESTful API:定义了创建(POST)、读取(GET)、更新(PUT)和删除(DELETE)任务的基本REST API。
  3. 面向对象:定义了一个Todo类来封装任务信息。
  4. 错误处理:提供了基本的错误处理逻辑,如任务不存在时返回404状态码。

这段代码展示了你的Node.js开发能力,以及面向对象设计思想的应用。你可以根据具体题目要求进一步优化和扩展。希望这段代码能帮助你在面试中脱颖而出!

回到顶部