Below are several programming problems. Try and solve them without Googling the answers.
Create a function(s) that takes an integer and returns its factorial.
Example: Takes 3, returns (1 * 2 * 3) or 6
| public class Bootstrapper : DefaultNancyBootstrapper | |
| { | |
| protected override void RequestStartup(TinyIoCContainer requestContainer, IPipelines pipelines, NancyContext context) | |
| { | |
| pipelines.OnError += (ctx, ex) => | |
| { | |
| return ErrorResponse.FromException(ex); | |
| }; | |
| base.RequestStartup(requestContainer, pipelines, context); |
| Public Class Thread | |
| Public Posts as List(of Post) | |
| Property Subject as String | |
| Property Status as int | |
| Property Product as String | |
| Property Priority as int | |
| Property CallType as int | |
| Property AssignedToUser as User |
| public class Platform | |
| { | |
| public string Name { get; set; } | |
| public string Server { get; set; } | |
| public int Port { get; set; } | |
| public string Username { get; set } | |
| public string Password { get; set; } | |
| } |
| Imports System.Reflection | |
| Imports System.CodeDom.Compiler | |
| Imports IBE.Scripting | |
| Module Module1 | |
| Sub Main() | |
| Dim vbScript = <a> |
| function FizzBuzz(i, end) { | |
| if (i > end) return; | |
| if (i % 3) { | |
| console.log('fizz') | |
| } | |
| if (i % 5) { | |
| console.log('buzz') | |
| } |
| module Diamond = { | |
| let inc_char c => char_of_int (int_of_char c + 1); | |
| let rec range_rec l a b => a == b ? l @ [a] : range_rec (l @ [a]) (inc_char a) b; | |
| let range a b => range_rec [] a b; | |
| let rec replicate a s i => i < 1 ? a : replicate (a ^ s) s (i - 1); | |
| let addSpaces i => replicate "" " " i; | |
| let line p j c => { | |
| let cs = Char.escaped c; | |
| addSpaces p ^ cs ^ (j < 1 ? "" : addSpaces j ^ cs) | |
| }; |
| /*output is a concatenated string for testing, but feel free to reformat as needed*/ | |
| /*campaignID:experimentId:variationId:audienceId:"audience conditions"*/ | |
| /*e.g. 7807482864:7807902575:7806347946:6536242902:"and,or,or,{"value":"iphone","type":"device","name":null,"match":null}",7807482864:7807902575:7806347946:9436482444:"and,or,or,{"value":"00:00_23:59_friday","type":"time_and_day","name":null,"match":null}"*/ | |
| /*this code only includes audiences for which the visitor actually qualified*/ | |
| var state = window.optimizely.get && window.optimizely.get('state'); | |
| var data = window.optimizely.get && window.optimizely.get('data'); | |
| (function getCurrentActiveAll(e) { | |
| if ('undefined' !== typeof window.optimizely) { |
| //# Dispatch Event | |
| // An event is sent when something happens - the user clicks a button, or a websocket receives a new message. | |
| // The UI can dispatch | |
| // Event has: name and data | |
| function onButtonClick() { | |
| let queryText = document.getElementById('queryText').value | |
| console.log('queryText', queryText) | |
| dispatchEvent({ name: 'START_SEARCH' , payload: queryText }); |
| function parseQueryString(queryString) { | |
| Array.prototype.fapply = function(fn) { return fn(this); }; | |
| return (queryString[0] === '?' ? queryString.substr(1) : '') | |
| .split('&') | |
| .fapply(i => (i.length && !i[0]) ? [] : i) | |
| .map(i => i.length ? i.split('=') : []) | |
| .reduce((a, i) => { | |
| a[i[0]] = i[1]; | |
| return a; | |
| }, {}); |