This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.swift | |
// Destini | |
// | |
// Created by Philipp Muellauer on 01/09/2015. | |
// Copyright (c) 2015 London App Brewery. All rights reserved. | |
// | |
import UIKit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@IBAction func notePressed(_ sender: UIButton) { | |
playSound("note" + String(sender.tag)) | |
} | |
func playSound(_ fileName: String) { | |
let soundURL = Bundle.main.url(forResource: fileName, withExtension: "wav") | |
do { | |
try audioPlayer = AVAudioPlayer(contentsOf: soundURL!) | |
} | |
catch { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
pub fn factorial(n: u32) u32 { | |
var result: u32 = 1; | |
var i: u32 = 1; | |
while (i <= n): (i += 1) | |
result *= i; | |
return result; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
values = [] | |
for i in range(5): | |
values.append(int(input("Enter a number: "))) | |
average = sum(values) / len(values) | |
if average <= 50: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
def print_english_version_of_number(integer): | |
ones_values = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine"] | |
teens_values = ["eleven", "twelve", "thirteen", "fourteen", "fifeteen", "sixteen", "seventeen", "eighteen", "nineteen"] | |
tens_values = ["ten", "twenty", "thirty", "forty", "fifety", "sixty", "seventy", "eighty", "ninety"] | |
integer_hundreds_value = integer // 100 | |
integer %= 100 | |
integer_tens_value = integer // 10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::cmp::Ordering; | |
#[allow(dead_code)] | |
fn binary_search<T: std::cmp::Ord>(n: T, array: &[T]) -> Option<usize> { | |
if !array.is_empty() { | |
let mut lower_bound = 0; | |
let mut upper_bound = array.len() - 1; | |
let mut midway_point; | |
while lower_bound <= upper_bound { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A hacky way to get a string from a float in C++ | |
#include <iostream> | |
#include <math.h> | |
std::string float_to_string(const double& number, int precision) | |
{ | |
int adjustment_int = pow(10, precision); | |
int intermediate_value = number * adjustment_int; | |
double truncated_float = intermediate_value / (double) adjustment_int; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// main.cpp | |
// CHOC_test | |
// | |
// Created by Joseph Lyons on 7/9/20. | |
// Copyright © 2020 Joseph Lyons. All rights reserved. | |
// | |
// Find the choc_FloatToString.h at: | |
// https://github.com/julianstorer/choc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Only prints odd numbers whose individual digits are odd and are not repeated | |
def meets_criteria(number): | |
if number % 2 == 0: | |
return False | |
digits = [] | |
while number > 0: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
def print_square_wave(character, length, period): | |
for i in range(0, period): | |
for _ in range(0, length - 1): | |
print(character) | |
for _ in range(0, length): | |
print(character + " ", end="") |
OlderNewer