Definition
flatten = lambda x: sum(x, [])
Example usage
>>> flatten([[1,2],[3,4]])
[1, 2, 3, 4]
// Prompt: | |
// Write a node backend which accepts a .zip file from the JavaScript function in the following backticks: | |
// (the code in backticks ``` was here: https://gist.github.com/classmember/72ab335223722623af9ed5346e5ed6eb ) | |
const express = require('express'); | |
const multer = require('multer'); | |
const fs = require('fs'); | |
const app = express(); |
// Prompt: | |
// Write a frontend JavaScript function to upload a .zip file from a chrome extension in a browser to a node backend using express. The code must publish to a POST endpoint over HTTPS. | |
// Response: | |
// Note: This code assumes the use of jQuery for the AJAX request | |
function uploadZipFile(file) { | |
let formData = new FormData(); | |
formData.append('file', file); | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Detecting Key Input</title> | |
<!-- http://www.openjs.com/scripts/events/keyboard_shortcuts/shortcut.js --> | |
<script src="shortcut.js"></script> |
vector<string> split(const string &str) { | |
vector<string> tokens; | |
string::size_type start = 0; | |
string::size_type end = 0; | |
while ((end = str.find(" ", start)) != string::npos) { | |
tokens.push_back(str.substr(start, end - start)); | |
start = end + 1; |
/** | |
* phoneBook.cpp: | |
* Hashmaps in C++ - Kolby Heacock | |
* | |
* build: | |
* clang++ -std=c++2a test.cpp -o phonebook | |
* | |
* run: | |
* ./phonebook < input | |
* |
// fraction.cpp, Kolby Heacock | |
// Description: A simple fraction class. | |
#include <iostream> | |
#include <cmath> | |
using namespace std; | |
// Fraction | |
// takes two integers as parameters during construction |
<!DOCTYPE html> | |
<html> | |
<head> | |
<script type="text/javascript" src="https://unpkg.com/vue@next"></script> | |
<script type="text/javascript" src="https://unpkg.com/marked@0.3.6"></script> | |
<script type="text/javascript" src="https://unpkg.com/lodash@4.16.0"></script> | |
<title> Markdown </title> | |
<style> | |
html, |
;; roll-20-sided-dice.clj | |
;; return a function that rolls a 20 sided dice | |
(def roll-20-sided-dice | |
(fn [] (inc (int (rand 19))))) | |
;; call function to roll 20 sided dice | |
(roll-20-sided-dice) |
""" | |
Random number guessing game | |
""" | |
import sys | |
from random import randrange | |
from math import ceil, floor | |
class NumberGuessingGame: |
Definition
flatten = lambda x: sum(x, [])
Example usage
>>> flatten([[1,2],[3,4]])
[1, 2, 3, 4]