View codechallenge.go
package main
import "log"
func main() {
numbers := []int{23, 2, 4, 7, 2, 11}
find := 20 // should return true
// numbers := []int{1, 3, 5, 23, 2}
// find := 8 // should return true
//numbers := []int{1, 3, 5, 23, 2}
View round.go
package main
import (
"log"
"math"
)
func Round(val float64, roundOn float64, places int ) (newVal float64) {
var round float64
pow := math.Pow(10, float64(places))
View FinderExample.Go
package main
import (
"reflect"
"log"
)
type Part struct {
Id int
UPC string
View sortBasedOnStructsProperty.go
package main
import (
"fmt"
"sort"
)
type Person struct {
Name string
Weight int
View CSVwriterExample
import (
"../../web"
"bytes"
"encoding/csv"
}
func GenerateCSV(ctx *web.Context, args ...string) {
record := []string{"test1", "test2", "test3"} // just some test data to use for the wr.Writer() method below.
View FindRanges.cs
public List<Range> findRanges(List<int> numbers) {
List<Range> ranges = new List<Range>(); // create a list of ranges that will eventually be populated.
numbers = numbers.OrderBy(x=>x).ToList<int>(); // order the list of numbers coming in.
int min = numbers.Min(); // get the smallest number
int max = numbers.Max(); // get the largest number
List<int> missingNumbers = new List<int>(); // create an empty list of missing numbers
int i = min; // create a counter for stepping through all the numbers starting with the smallest number
while (i < max) { // step through each possible number from min to max.
if (!numbers.Contains(i)) { // if the number doesnt exist from our list, its a missing number
// found a gap in the number (missing number)
View Happpi_Getting_Started.php
<?php
require_once('libraries/happpi/LoadAll.php'); // points to the LoadAll.php file for loading the library.
?>
<!doctype html>
<html>
<head>
</head>
<body>
View Happpi_Getting_Started.php
<?php
require_once('libraries/happpi/LoadAll.php'); // points to the LoadAll.php file for loading the library.
?>
<!doctype html>
<html>
<head>
</head>
<body>
View example output
<Root xmlns="http://www.adventure-works.com">
<Child3>1</Child3>
<Child3>2</Child3>
<Child3>3</Child3>
<Child4>4</Child4>
<Child5>5</Child5>
<Child5>6</Child5>
</Root>